List of usage examples for org.apache.wicket.markup.repeater.data DataView DataView
protected DataView(String id, IDataProvider<T> dataProvider)
From source file:au.org.theark.lims.web.component.barcodelabel.SearchResultsPanel.java
License:Open Source License
public DataView<BarcodeLabel> buildDataView(ArkDataProvider<BarcodeLabel, ILimsAdminService> dataProvider) { DataView<BarcodeLabel> dataView = new DataView<BarcodeLabel>("resultList", dataProvider) { private static final long serialVersionUID = 2981419595326128410L; @Override//from w w w .ja va2 s . co m protected void populateItem(final Item<BarcodeLabel> item) { BarcodeLabel barcodeLabel = item.getModelObject(); item.add(buildLink(barcodeLabel)); if (barcodeLabel.getStudy() != null) { // the ID here must match the ones in mark-up item.add(new Label("study", barcodeLabel.getStudy().getName())); } else { item.add(new Label("study", "")); } if (barcodeLabel.getName() != null) { // the ID here must match the ones in mark-up item.add(new Label("name", barcodeLabel.getName())); } else { item.add(new Label("name", "")); } if (barcodeLabel.getBarcodePrinterName() != null) { // the ID here must match the ones in mark-up item.add(new Label("barcodePrinter", barcodeLabel.getBarcodePrinterName())); } else { item.add(new Label("barcodePrinter", "")); } if (barcodeLabel.getDescription() != null) { // the ID here must match the ones in mark-up item.add(new Label("description", barcodeLabel.getDescription())); } else { item.add(new Label("description", "")); } if (barcodeLabel.getVersion() != null) { item.add(new Label("version", barcodeLabel.getVersion().toString())); } else { item.add(new Label("version", "")); } item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return dataView; }
From source file:au.org.theark.lims.web.component.biospecimen.form.BiospecimenListForm.java
License:Open Source License
/** * //from ww w .j a va 2 s .co m * @param iModel * @return the pageableListView of BioCollection */ public DataView<Biospecimen> buildDataView(ArkDataProvider2<LimsVO, Biospecimen> biospecimenProvider) { DataView<Biospecimen> biospecimenDataView = new DataView<Biospecimen>("biospecimenList", biospecimenProvider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<Biospecimen> item) { item.setOutputMarkupId(true); // DO NOT store the item.getModelObject! Checking it is ok... final Biospecimen biospecimen = item.getModelObject(); WebMarkupContainer rowDetailsWMC = new WebMarkupContainer("rowDetailsWMC", item.getModel()); ArkBusyAjaxLink listDetailsLink = new ArkBusyAjaxLink("listDetailsLink") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>(new LimsVO()); try { Biospecimen biospecimenFromDB = iLimsService.getBiospecimen(biospecimen.getId()); Study study = iArkCommonService.getStudy(biospecimenFromDB.getStudy().getId()); LinkSubjectStudy linkSubjectStudy = iArkCommonService.getSubjectByUID( biospecimenFromDB.getLinkSubjectStudy().getSubjectUID(), study); biospecimenFromDB.setStudy(study); biospecimenFromDB.setLinkSubjectStudy(linkSubjectStudy); setContextItems(target, linkSubjectStudy); newModel.getObject().setLinkSubjectStudy(linkSubjectStudy); newModel.getObject().setBiospecimen(biospecimenFromDB); newModel.getObject().setTreeModel(cpModel.getObject().getTreeModel()); showModalWindow(target, newModel); } catch (EntityNotFoundException e) { log.error(e.getMessage()); } } }; idLblFld = new Label("biospecimen.id", String.valueOf(biospecimen.getId())); nameLblFld = new Label("biospecimen.biospecimenUid", biospecimen.getBiospecimenUid()); listDetailsLink.add(nameLblFld); rowDetailsWMC.add(listDetailsLink); studyLblFld = new Label("biospecimen.study.name", biospecimen.getStudy().getName()); subjectUidLblFld = new Label("biospecimen.linkSubjectStudy.subjectUid", biospecimen.getLinkSubjectStudy().getSubjectUID()); sampleTypeLblFld = new Label("biospecimen.sampleType.name", biospecimen.getSampleType().getName()); collectionLblFld = new Label("biospecimen.bioCollection.biocollectionUid", biospecimen.getBioCollection().getBiocollectionUid()); biospecimen.setQuantity(iLimsService.getQuantityAvailable(biospecimen)); if (biospecimen.getQuantity() == null) { quantityLblFld = new Label("biospecimen.quantity", "0"); } else { quantityLblFld = new Label("biospecimen.quantity", biospecimen.getQuantity().toString()); } if (biospecimen.getUnit() == null) { unitsLblFld = new Label("biospecimen.unit", ""); } else { unitsLblFld = new Label("biospecimen.unit", biospecimen.getUnit().getName()); } try { locationLbl = new Label("biospecimen.location", "view"); locationLink = new ArkBusyAjaxLink("biospecimen.location.link") { /** * */ private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>( new LimsVO()); newModel.getObject().getBiospecimen().setId(biospecimen.getId()); BiospecimenLocationVO biospecimenLocationVo; try { biospecimenLocationVo = iInventoryService.getBiospecimenLocation(biospecimen); newModel.getObject().setBiospecimenLocationVO(biospecimenLocationVo); BioLocationPanel bioLocationPanel = new BioLocationPanel("content", newModel) { /** * */ private static final long serialVersionUID = 1L; @Override public void refreshParentPanel(AjaxRequestTarget target) { } }; bioLocationPanel.getUnallocateButton().setVisible(false); bioLocationPanel.add(new AttributeModifier("class", "detailsPanelBorder")); // Set the modalWindow title and content modalWindow.setTitle("Biospecimen Location Detail"); modalWindow.setContent(bioLocationPanel); modalWindow.show(target); } catch (ArkSystemException e) { log.error(e.getMessage()); } } }; locationLink.add(locationLbl); BiospecimenLocationVO biospecimenLocationVo = iInventoryService .getBiospecimenLocation(biospecimen); if (!biospecimenLocationVo.getIsAllocated()) { locationLink.setVisible(false); } } catch (ArkSystemException e) { log.error(e.getMessage()); } item.add(idLblFld); item.add(rowDetailsWMC); item.add(studyLblFld); item.add(subjectUidLblFld); item.add(sampleTypeLblFld); item.add(collectionLblFld); item.add(quantityLblFld); item.add(unitsLblFld); item.add(locationLink); if (biospecimen.getBarcoded()) { item.addOrReplace( new ContextImage("biospecimen.barcoded", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace( new ContextImage("biospecimen.barcoded", new Model<String>("images/icons/cross.png"))); } item.add(new AjaxButton("batchAliquot") { /** * */ private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.NEW); } protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) { onBatchAliquot(target, item.getModel()); target.add(feedbackPanel); }; protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) { target.add(feedbackPanel); }; public boolean isVisible() { return (item.getModelObject().getQuantity() != null && item.getModelObject().getQuantity() > 0); }; }.setDefaultFormProcessing(false)); item.add(new AjaxButton("allocateUnallocate") { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.EDIT); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { BiospecimenLocationVO biospecimenLocationVo = null; try { biospecimenLocationVo = iInventoryService.getBiospecimenLocation(biospecimen); } catch (ArkSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (biospecimenLocationVo.getIsAllocated()) { //unallocate InvCell invCell = iInventoryService.getInvCellByBiospecimen(biospecimen); invCell.setBiospecimen(null); invCell.setStatus("Empty"); iInventoryService.updateInvCell(invCell); try { cpModel.getObject() .setBiospecimenLocationVO(iInventoryService.getInvCellLocation(invCell)); cpModel.getObject().getBiospecimenLocationVO().setIsAllocated(false); cpModel.getObject().setInvCell(invCell); } catch (ArkSystemException e) { } } else { //cpModel.getObject().setBiospecimen(biospecimen); CompoundPropertyModel<LimsVO> cpm = new CompoundPropertyModel<LimsVO>(new LimsVO()); cpm.getObject().setBiospecimen(biospecimen); modalContentPanel = new BioModalAllocateDetailPanel("content", modalWindow, cpm); // Set the modalWindow title and content modalWindow.setTitle("Biospecimen Allocation"); modalWindow.setContent(modalContentPanel); modalWindow.setWidthUnit("%"); modalWindow.setInitialWidth(70); modalWindow.show(target); //cpModel.getObject().setBiospecimen(new Biospecimen()); modalWindow.repaintComponent(BiospecimenListForm.this); } target.add(BiospecimenListForm.this); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { } }.setDefaultFormProcessing(false)); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return biospecimenDataView; }
From source file:au.org.theark.lims.web.component.biospecimenuidtemplate.SearchResultsPanel.java
License:Open Source License
public DataView<BiospecimenUidTemplate> buildDataView( ArkDataProvider<BiospecimenUidTemplate, ILimsAdminService> dataProvider) { DataView<BiospecimenUidTemplate> dataView = new DataView<BiospecimenUidTemplate>("resultList", dataProvider) {// ww w . j a v a 2s.c om private static final long serialVersionUID = 2981419595326128410L; @Override protected void populateItem(final Item<BiospecimenUidTemplate> item) { BiospecimenUidTemplate biospecimenUidTemplate = item.getModelObject(); item.add(buildLink(biospecimenUidTemplate)); item.add(new Label("study", biospecimenUidTemplate.getStudy().getName())); item.add(new Label("biospecimenUid.template", getBiospecimenUidExample(biospecimenUidTemplate))); item.add(new AttributeModifier("class", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; return dataView; }
From source file:au.org.theark.lims.web.component.biotransaction.BioTransactionListPanel.java
License:Open Source License
/** * // w w w. j a va 2s. c o m * @param iModel * @return the pageableListView of BioCollection */ public DataView<BioTransaction> buildDataView(ArkDataProvider2<LimsVO, BioTransaction> bioTransactionProvider) { final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY); DataView<BioTransaction> bioTransactionDataView = new DataView<BioTransaction>("bioTransactionList", bioTransactionProvider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<BioTransaction> item) { item.setOutputMarkupId(true); // DO NOT store the item.getModelObject! Checking it is ok... final BioTransaction bioTransaction = item.getModelObject(); WebMarkupContainer rowDetailsWMC = new WebMarkupContainer("rowDetailsWMC", item.getModel()); AjaxConfirmLink<BioTransaction> rowDeleteLink = new AjaxConfirmLink<BioTransaction>("rowDeleteLink", new StringResourceModel("bioTransaction.confirmDelete", this, item.getModel()), item.getModel()) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { BioTransaction bioTransaction = getModelObject(); iLimsService.deleteBioTransaction(bioTransaction); // update biospecimen (qty avail) Double qtyAvail = iLimsService.getQuantityAvailable(cpModel.getObject().getBiospecimen()); cpModel.getObject().getBiospecimen().setQuantity(qtyAvail); try { iLimsService.updateBiospecimen(cpModel.getObject()); } catch (ArkSystemException e) { this.error(e.getMessage()); } this.info("Successfully removed the transaction"); target.add(feedbackPanel); target.add(dataViewListWMC); // repaint the list target.add(dataViewListWMC.getParent().getParent()); // repaint the parent form } }; rowDetailsWMC.add(rowDeleteLink); // if ((bioTransaction.getStatus() != null) && (bioTransaction.getStatus().getName().equalsIgnoreCase(Constants.BIOTRANSACTION_STATUS_INITIAL_QUANTITY))) { // // do not allow the initial quantity to be deleted // rowDetailsWMC.setVisible(false); // } idLbl = new Label("bioTransaction.id", bioTransaction.getId().toString()); String dateOfTransaction = ""; if (bioTransaction.getTransactionDate() != null) { dateOfTransaction = simpleDateFormat.format(bioTransaction.getTransactionDate()); } transactionDateLbl = new Label("bioTransaction.transactionDate", dateOfTransaction); if (bioTransaction.getQuantity() == null) { quantityLbl = new Label("bioTransaction.quantity", "0"); } else { quantityLbl = new Label("bioTransaction.quantity", bioTransaction.getQuantity().toString()); } if (bioTransaction.getBiospecimen().getUnit() == null) { unitsLbl = new Label("bioTransaction.biospecimen.unit.name", ""); } else { unitsLbl = new Label("bioTransaction.biospecimen.unit.name", bioTransaction.getBiospecimen().getUnit().getName()); } reasonLbl = new Label("bioTransaction.reason", bioTransaction.getReason()); recorderLbl = new Label("bioTransaction.recorder", bioTransaction.getRecorder()); if (bioTransaction.getStatus() == null) { statusLbl = new Label("bioTransaction.status.name", ""); } else { statusLbl = new Label("bioTransaction.status.name", bioTransaction.getStatus().getName()); } if (bioTransaction.getAccessRequest() == null) { requestLbl = new Label("bioTransaction.accessRequest.id", ""); } else { requestLbl = new Label("bioTransaction.accessRequest.id", bioTransaction.getAccessRequest().getId().toString()); } item.add(idLbl); item.add(transactionDateLbl); if (bioTransaction.getQuantity() > 0) { quantityImage = new ContextImage("bioTransaction.quantityImage", new Model<String>("images/icons/arrow_up.png")); } else { quantityImage = new ContextImage("bioTransaction.quantityImage", new Model<String>("images/icons/arrow_down_red.png")); } item.add(quantityImage); item.add(quantityLbl); item.add(unitsLbl); item.add(reasonLbl); item.add(recorderLbl); item.add(statusLbl); item.add(requestLbl); item.add(rowDetailsWMC); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return bioTransactionDataView; }
From source file:au.org.theark.lims.web.component.global.biospecimen.form.BiospecimenListForm.java
License:Open Source License
/** * //from w w w . j av a2 s . co m * @param iModel * @return the pageableListView of BioCollection */ public DataView<Biospecimen> buildDataView(ArkDataProvider2<LimsVO, Biospecimen> biospecimenProvider) { DataView<Biospecimen> biospecimenDataView = new DataView<Biospecimen>("biospecimenList", biospecimenProvider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<Biospecimen> item) { item.setOutputMarkupId(true); // DO NOT store the item.getModelObject! Checking it is ok... final Biospecimen biospecimen = item.getModelObject(); WebMarkupContainer rowDetailsWMC = new WebMarkupContainer("rowDetailsWMC", item.getModel()); ArkBusyAjaxLink listDetailsLink = new ArkBusyAjaxLink("listDetailsLink") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>(new LimsVO()); try { Biospecimen biospecimenFromDB = iLimsService.getBiospecimen(biospecimen.getId()); Study study = iArkCommonService.getStudy(biospecimenFromDB.getStudy().getId()); LinkSubjectStudy linkSubjectStudy = iArkCommonService.getSubjectByUID( biospecimenFromDB.getLinkSubjectStudy().getSubjectUID(), study); biospecimenFromDB.setStudy(study); biospecimenFromDB.setLinkSubjectStudy(linkSubjectStudy); setContextItems(target, linkSubjectStudy); newModel.getObject().setLinkSubjectStudy(linkSubjectStudy); newModel.getObject().setBiospecimen(biospecimenFromDB); newModel.getObject().setBioCollection(biospecimenFromDB.getBioCollection()); newModel.getObject().setTreeModel(cpModel.getObject().getTreeModel()); showModalWindow(target, newModel); } catch (EntityNotFoundException e) { log.error(e.getMessage()); } } }; idLblFld = new Label("biospecimen.id", String.valueOf(biospecimen.getId())); nameLblFld = new Label("biospecimen.biospecimenUid", biospecimen.getBiospecimenUid()); listDetailsLink.add(nameLblFld); rowDetailsWMC.add(listDetailsLink); studyLblFld = new Label("biospecimen.study.name", biospecimen.getStudy().getName()); subjectUidLblFld = new Label("biospecimen.linkSubjectStudy.subjectUid", biospecimen.getLinkSubjectStudy().getSubjectUID()); sampleTypeLblFld = new Label("biospecimen.sampleType.name", biospecimen.getSampleType().getName()); collectionLblFld = new Label("biospecimen.bioCollection.biocollectionUid", biospecimen.getBioCollection().getBiocollectionUid()); biospecimen.setQuantity(iLimsService.getQuantityAvailable(biospecimen)); if (biospecimen.getQuantity() == null) { quantityLblFld = new Label("biospecimen.quantity", "0"); } else { quantityLblFld = new Label("biospecimen.quantity", biospecimen.getQuantity().toString()); } if (biospecimen.getUnit() == null) { unitsLblFld = new Label("biospecimen.unit", ""); } else { unitsLblFld = new Label("biospecimen.unit", biospecimen.getUnit().getName()); } try { locationLbl = new Label("biospecimen.location", "view"); locationLink = new ArkBusyAjaxLink("biospecimen.location.link") { /** * */ private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>( new LimsVO()); newModel.getObject().getBiospecimen().setId(biospecimen.getId()); BiospecimenLocationVO biospecimenLocationVo; try { biospecimenLocationVo = iInventoryService.getBiospecimenLocation(biospecimen); newModel.getObject().setBiospecimenLocationVO(biospecimenLocationVo); BioLocationPanel bioLocationPanel = new BioLocationPanel("content", newModel) { /** * */ private static final long serialVersionUID = 1L; @Override public void refreshParentPanel(AjaxRequestTarget target) { } }; bioLocationPanel.getUnallocateButton().setVisible(false); bioLocationPanel.add(new AttributeModifier("class", "detailsPanelBorder")); // Set the modalWindow title and content modalWindow.setTitle("Biospecimen Location Detail"); modalWindow.setContent(bioLocationPanel); modalWindow.show(target); } catch (ArkSystemException e) { log.error(e.getMessage()); } } }; locationLink.add(locationLbl); BiospecimenLocationVO biospecimenLocationVo = iInventoryService .getBiospecimenLocation(biospecimen); if (!biospecimenLocationVo.getIsAllocated()) { locationLink.setVisible(false); } } catch (ArkSystemException e) { log.error(e.getMessage()); } item.add(idLblFld); item.add(rowDetailsWMC); item.add(studyLblFld); item.add(subjectUidLblFld); item.add(sampleTypeLblFld); item.add(collectionLblFld); item.add(quantityLblFld); item.add(unitsLblFld); item.add(locationLink); if (biospecimen.getBarcoded()) { item.addOrReplace( new ContextImage("biospecimen.barcoded", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace( new ContextImage("biospecimen.barcoded", new Model<String>("images/icons/cross.png"))); } item.add(new AjaxButton("batchAliquot") { /** * */ private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.NEW); } protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) { onBatchAliquot(target, item.getModel()); target.add(feedbackPanel); }; protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) { target.add(feedbackPanel); }; public boolean isVisible() { return (item.getModelObject().getQuantity() != null && item.getModelObject().getQuantity() > 0); }; }.setDefaultFormProcessing(false)); item.add(new AjaxButton("allocateUnallocate") { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.EDIT); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { BiospecimenLocationVO biospecimenLocationVo = null; try { biospecimenLocationVo = iInventoryService.getBiospecimenLocation(biospecimen); } catch (ArkSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (biospecimenLocationVo.getIsAllocated()) { //unallocate InvCell invCell = iInventoryService.getInvCellByBiospecimen(biospecimen); invCell.setBiospecimen(null); invCell.setStatus("Empty"); iInventoryService.updateInvCell(invCell); try { cpModel.getObject() .setBiospecimenLocationVO(iInventoryService.getInvCellLocation(invCell)); cpModel.getObject().getBiospecimenLocationVO().setIsAllocated(false); cpModel.getObject().setInvCell(invCell); } catch (ArkSystemException e) { } } else { //cpModel.getObject().setBiospecimen(biospecimen); CompoundPropertyModel<LimsVO> cpm = new CompoundPropertyModel<LimsVO>(new LimsVO()); cpm.getObject().setBiospecimen(biospecimen); modalContentPanel = new BioModalAllocateDetailPanel("content", modalWindow, cpm); // Set the modalWindow title and content modalWindow.setTitle("Biospecimen Allocation"); modalWindow.setContent(modalContentPanel); modalWindow.setWidthUnit("%"); modalWindow.setInitialWidth(70); modalWindow.show(target); //cpModel.getObject().setBiospecimen(new Biospecimen()); modalWindow.repaintComponent(BiospecimenListForm.this); } target.add(BiospecimenListForm.this); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { } }.setDefaultFormProcessing(false)); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return biospecimenDataView; }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biocollection.form.BioCollectionListForm.java
License:Open Source License
/** * //from ww w . jav a2 s. co m * @param iModel * @return the pageableListView of BioCollection */ public DataView<BioCollection> buildDataView( ArkDataProvider<BioCollection, ILimsService> bioCollectionProvider) { DataView<BioCollection> bioCollectionDataView = new DataView<BioCollection>("collectionList", bioCollectionProvider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<BioCollection> item) { item.setOutputMarkupId(true); // DO NOT store the item.getModelObject! Checking it is ok... final BioCollection bioCollection = item.getModelObject(); WebMarkupContainer rowDetailsWMC = new WebMarkupContainer("rowDetailsWMC", item.getModel()); ArkBusyAjaxLink listDetailsLink = new ArkBusyAjaxLink("listDetailsLink") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { BioCollection bc = (BioCollection) (getParent().getDefaultModelObject()); CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>(new LimsVO()); newModel.getObject().getBioCollection().setId(bc.getId()); showModalWindow(target, newModel); } }; SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY); idLblFld = new Label("bioCollection.id", String.valueOf(bioCollection.getId())); biocollectionLblFld = new Label("bioCollection.biocollectionUid", bioCollection.getBiocollectionUid()); nameLblFld = new Label("bioCollection.name", bioCollection.getName()); listDetailsLink.add(biocollectionLblFld); rowDetailsWMC.add(listDetailsLink); if (bioCollection.getCollectionDate() != null) { collectionDateLblFld = new Label("bioCollection.collectionDate", simpleDateFormat.format(bioCollection.getCollectionDate())); } else { collectionDateLblFld = new Label("bioCollection.collectionDate", ""); } if (bioCollection.getSurgeryDate() != null) { new Label("bioCollection.surgeryDate", simpleDateFormat.format(bioCollection.getSurgeryDate())); } else { new Label("bioCollection.surgeryDate", ""); } commentsLblFld = new Label("bioCollection.comments", bioCollection.getComments()); item.add(idLblFld); item.add(rowDetailsWMC); item.add(nameLblFld); item.add(collectionDateLblFld); item.add(commentsLblFld); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return bioCollectionDataView; }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenListForm.java
License:Open Source License
/** * //from ww w .j a v a2 s . co m * @param iModel * @return the pageableListView of BioCollection */ public DataView<Biospecimen> buildDataView(ArkDataProvider2<LimsVO, Biospecimen> biospecimenProvider) { DataView<Biospecimen> biospecimenDataView = new DataView<Biospecimen>("biospecimenList", biospecimenProvider) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final Item<Biospecimen> item) { item.setOutputMarkupId(true); // DO NOT store the item.getModelObject! Checking it is ok... final Biospecimen biospecimen = item.getModelObject(); WebMarkupContainer rowDetailsWMC = new WebMarkupContainer("rowDetailsWMC", item.getModel()); ArkBusyAjaxLink listDetailsLink = new ArkBusyAjaxLink("listDetailsLink") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>(new LimsVO()); try { Biospecimen biospecimenFromDB = iLimsService.getBiospecimen(biospecimen.getId()); newModel.getObject().setBiospecimen(biospecimenFromDB); newModel.getObject().setBioCollection(biospecimenFromDB.getBioCollection()); newModel.getObject().setTreeModel(cpModel.getObject().getTreeModel()); showModalWindow(target, newModel); } catch (EntityNotFoundException e) { log.error(e.getMessage()); } } }; idLblFld = new Label("biospecimen.id", String.valueOf(biospecimen.getId())); nameLblFld = new Label("biospecimen.biospecimenUid", biospecimen.getBiospecimenUid()); listDetailsLink.add(nameLblFld); rowDetailsWMC.add(listDetailsLink); studyLblFld = new Label("biospecimen.study.name", biospecimen.getStudy().getName()); sampleTypeLblFld = new Label("biospecimen.sampleType.name", biospecimen.getSampleType().getName()); collectionLblFld = new Label("biospecimen.bioCollection.biocollectionUid", biospecimen.getBioCollection().getBiocollectionUid()); commentsLblFld = new Label("biospecimen.comments", biospecimen.getComments()); biospecimen.setQuantity(iLimsService.getQuantityAvailable(biospecimen)); if (biospecimen.getQuantity() == null) { quantityLblFld = new Label("biospecimen.quantity", "0"); } else { quantityLblFld = new Label("biospecimen.quantity", biospecimen.getQuantity().toString()); } if (biospecimen.getUnit() == null) { unitsLblFld = new Label("biospecimen.unit", ""); } else { unitsLblFld = new Label("biospecimen.unit", biospecimen.getUnit().getName()); } try { locationLbl = new Label("biospecimen.location", "view"); locationLink = new ArkBusyAjaxLink("biospecimen.location.link") { /** * */ private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>( new LimsVO()); newModel.getObject().getBiospecimen().setId(biospecimen.getId()); BiospecimenLocationVO biospecimenLocationVo; try { biospecimenLocationVo = iInventoryService.getBiospecimenLocation(biospecimen); newModel.getObject().setBiospecimenLocationVO(biospecimenLocationVo); newModel.getObject().setTreeModel(cpModel.getObject().getTreeModel()); BioLocationPanel bioLocationPanel = new BioLocationPanel("content", newModel) { /** * */ private static final long serialVersionUID = 1L; @Override public void refreshParentPanel(AjaxRequestTarget target) { } }; bioLocationPanel.getUnallocateButton().setVisible(false); bioLocationPanel.add(new AttributeModifier("class", "detailsPanelBorder")); // Set the modalWindow title and content modalWindow.setTitle("Biospecimen Location Detail"); modalWindow.setContent(bioLocationPanel); modalWindow.show(target); } catch (ArkSystemException e) { log.error(e.getMessage()); } } }; locationLink.add(locationLbl); BiospecimenLocationVO biospecimenLocationVo = iInventoryService .getBiospecimenLocation(biospecimen); if (!biospecimenLocationVo.getIsAllocated()) { locationLink.setVisible(false); } } catch (ArkSystemException e) { log.error(e.getMessage()); } item.add(idLblFld); item.add(rowDetailsWMC); item.add(studyLblFld); item.add(sampleTypeLblFld); item.add(collectionLblFld); //item.add(commentsLblFld); item.add(quantityLblFld); item.add(unitsLblFld); item.add(locationLink); if (biospecimen.getBarcoded()) { item.addOrReplace( new ContextImage("biospecimen.barcoded", new Model<String>("images/icons/tick.png"))); } else { item.addOrReplace( new ContextImage("biospecimen.barcoded", new Model<String>("images/icons/cross.png"))); } item.add(new AjaxButton("batchAliquot") { /** * */ private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.NEW); } protected void onSubmit(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) { onBatchAliquot(target, item.getModel()); target.add(feedbackPanel); }; protected void onError(AjaxRequestTarget target, org.apache.wicket.markup.html.form.Form<?> form) { target.add(feedbackPanel); }; public boolean isVisible() { SecurityManager securityManager = ThreadContext.getSecurityManager(); Subject currentUser = SecurityUtils.getSubject(); boolean canCreate = ArkPermissionHelper.hasNewPermission(securityManager, currentUser); boolean validQuantity = (item.getModelObject().getQuantity() != null && item.getModelObject().getQuantity() > 0); return (canCreate && validQuantity); }; }.setDefaultFormProcessing(false)); item.add(new AjaxButton("allocateUnallocate") { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.EDIT); } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { BiospecimenLocationVO biospecimenLocationVo = null; try { biospecimenLocationVo = iInventoryService.getBiospecimenLocation(biospecimen); } catch (ArkSystemException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (biospecimenLocationVo.getIsAllocated()) { //unallocate InvCell invCell = iInventoryService.getInvCellByBiospecimen(biospecimen); invCell.setBiospecimen(null); invCell.setStatus("Empty"); iInventoryService.updateInvCell(invCell); try { cpModel.getObject() .setBiospecimenLocationVO(iInventoryService.getInvCellLocation(invCell)); cpModel.getObject().getBiospecimenLocationVO().setIsAllocated(false); cpModel.getObject().setInvCell(invCell); } catch (ArkSystemException e) { } } else { //cpModel.getObject().setBiospecimen(biospecimen); CompoundPropertyModel<LimsVO> cpm = new CompoundPropertyModel<LimsVO>(new LimsVO()); cpm.getObject().setBiospecimen(biospecimen); modalContentPanel = new BioModalAllocateDetailPanel("content", modalWindow, cpm); // Set the modalWindow title and content modalWindow.setTitle("Biospecimen Allocation"); modalWindow.setContent(modalContentPanel); modalWindow.setWidthUnit("%"); modalWindow.setInitialWidth(70); modalWindow.show(target); //cpModel.getObject().setBiospecimen(new Biospecimen()); modalWindow.repaintComponent(BiospecimenListForm.this); } target.add(BiospecimenListForm.this); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { } }.setDefaultFormProcessing(false).setOutputMarkupPlaceholderTag(true)); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { private static final long serialVersionUID = 1L; @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return biospecimenDataView; }
From source file:au.org.theark.lims.web.component.subjectlims.subject.SearchResultListPanel.java
License:Open Source License
public DataView<LinkSubjectStudy> buildDataView(ArkDataProvider2<LimsVO, LinkSubjectStudy> subjectProvider) { DataView<LinkSubjectStudy> linkSubjectStudyDataView = new DataView<LinkSubjectStudy>("subjectList", subjectProvider) {/*from w w w . ja va 2 s.com*/ @Override protected void populateItem(final Item<LinkSubjectStudy> item) { LinkSubjectStudy subject = item.getModelObject(); item.add(buildLink(item.getModelObject())); Label studyLbl = new Label("studyLbl", subject.getStudy().getName()); item.add(studyLbl); StringBuffer sb = new StringBuffer(); String firstName = subject.getPerson().getFirstName(); String midName = subject.getPerson().getMiddleName(); String lastName = subject.getPerson().getLastName(); if (firstName != null) { sb.append(subject.getPerson().getFirstName()); sb.append(" "); } if (midName != null) { sb.append(subject.getPerson().getMiddleName()); sb.append(" "); } if (lastName != null) { sb.append(subject.getPerson().getLastName()); } item.add(new Label(Constants.SUBJECT_FULL_NAME, sb.toString())); item.add(new Label("person.genderType.name", subject.getPerson().getGenderType().getName())); SimpleDateFormat simpleDateFormat = new SimpleDateFormat(au.org.theark.core.Constants.DD_MM_YYYY); String dateOfBirth = ""; if (subject != null && subject.getPerson() != null && subject.getPerson().getDateOfBirth() != null) { dateOfBirth = simpleDateFormat.format(subject.getPerson().getDateOfBirth()); item.add(new Label("person.dateOfBirth", dateOfBirth)); } else { item.add(new Label("person.dateOfBirth", "")); } item.add( new Label("person.vitalStatus.statusName", subject.getPerson().getVitalStatus().getName())); if (subject.getConsentStatus() != null) { item.add(new Label("consentStatus.name", subject.getConsentStatus().getName())); } else { item.add(new Label("consentStatus.name", "")); } item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; return linkSubjectStudyDataView; }
From source file:au.org.theark.phenotypic.web.component.phenodatacategory.SearchResultListPanel.java
License:Open Source License
public DataView<PhenoDataSetCategory> buildDataView( ArkDataProvider2<PhenoDataSetCategory, PhenoDataSetCategory> subjectProvider) { DataView<PhenoDataSetCategory> phenoDataSetCategoryDataView = new DataView<PhenoDataSetCategory>( "phenoDataSetCategoryList", subjectProvider) { @Override/*w w w . j av a2 s. c o m*/ protected void populateItem(final Item<PhenoDataSetCategory> item) { PhenoDataSetCategory category = item.getModelObject(); //id if (category.getId() != null) { item.add(new Label(Constants.PHENODATASETCATEGORY_ID, category.getId().toString())); } else { item.add(new Label(Constants.PHENODATASETCATEGORY_ID, "")); } // Component Name Link item.add(buildLinkWMC(item)); // Description if (category.getDescription() != null) { item.add(new Label(Constants.PHENODATASETCATEGORY_DESCRIPTION, category.getDescription())); } else { item.add(new Label(Constants.PHENODATASETCATEGORY_DESCRIPTION, "")); } /* For the alternative stripes */ item.add(new AttributeModifier("class", new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; addToolbars(phenoDataSetCategoryDataView); return phenoDataSetCategoryDataView; }
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.SearchResultListPanel.java
License:Open Source License
public DataView<PhenoDataSetField> buildDataView( ArkDataProvider2<PhenoDataSetField, PhenoDataSetField> subjectProvider) { DataView<PhenoDataSetField> phonoFieldDataView = new DataView<PhenoDataSetField>("phenoDataSetFieldLst", subjectProvider) {/* w ww . ja v a 2 s .c o m*/ @Override protected void populateItem(final Item<PhenoDataSetField> item) { PhenoDataSetField field = item.getModelObject(); if (field.getId() != null) { // Add the id component here item.add(new Label(Constants.PHENODATASET_ID, field.getId().toString())); } else { item.add(new Label(Constants.PHENODATASET_ID, "")); } // Component Name Link item.add(buildLinkWMC(item)); // Field Type if (field.getFieldType() != null) { item.add(new Label(Constants.PHENODATASET_FIELD_TYPE, field.getFieldType().getName())); } else { item.add(new Label(Constants.PHENODATASET_FIELD_TYPE, "")); } // Field Label if (field.getFieldLabel() != null) { item.add(new Label(Constants.PHENODATASET_FIELD_LABEL, field.getFieldLabel())); } else { item.add(new Label(Constants.PHENODATASET_FIELD_LABEL, "")); } if (field.getDefaultValue() != null) { item.add(new Label(Constants.PHENODATASET_DEFAULT_VALUE, field.getDefaultValue())); } else { item.add(new Label(Constants.PHENODATASET_DEFAULT_VALUE, "")); } if (field.getMissingValue() != null) { item.add(new Label(Constants.PHENODATASET_MISSING_VALUE, field.getMissingValue())); } else { item.add(new Label(Constants.PHENODATASET_MISSING_VALUE, "")); } if (field.getRequired() != null && field.getRequired() == true) { item.add(new ContextImage(Constants.PHENODATASET_REQUIRED, new Model<String>("images/icons/tick.png"))); } else { item.add(new ContextImage(Constants.PHENODATASET_REQUIRED, new Model<String>("images/icons/cross.png"))); } /* For the alternative stripes */ item.add(new AttributeModifier("class", new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? "even" : "odd"; } })); } }; addToolbars(phonoFieldDataView); return phonoFieldDataView; }