List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add
void add(Component... components);
From source file:au.org.theark.lims.web.component.subjectlims.lims.biocollection.form.BioCollectionListForm.java
License:Open Source License
protected void onNew(AjaxRequestTarget target) { // refresh the feedback messages target.add(feedbackPanel); // Set new BioCollection into model, then show modalWindow to save CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>(new LimsVO()); Study study = getModelObject().getLinkSubjectStudy().getStudy(); if (study != null && !study.getAutoGenerateBiocollectionUid()) { newModel.getObject().getBioCollection().setBiocollectionUid(""); } else {//from w ww .j a va 2 s . co m newModel.getObject().getBioCollection().setBiocollectionUid(Constants.AUTO_GENERATED); } newModel.getObject().getBioCollection().setLinkSubjectStudy(getModelObject().getLinkSubjectStudy()); newModel.getObject().getBioCollection().setStudy(study); showModalWindow(target, newModel); }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biocollection.form.BioCollectionModalDetailForm.java
License:Open Source License
@Override protected void onClose(AjaxRequestTarget target) { target.add(feedbackPanel); modalWindow.close(target); }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biocollection.form.BioCollectionModalDetailForm.java
License:Open Source License
@Override protected void onDeleteConfirmed(AjaxRequestTarget target, Form<?> form) { BioCollection bioCollection = cpModel.getObject().getBioCollection(); //Ark-1606 bug fix for deleting bio-collection which has already data. if (iLimsService.hasBiocllectionGotCustomFieldData(bioCollection)) { this.error("Biospecimen collection " + bioCollection.getBiocollectionUid() + " can not be deleted because it has biocollection custom field data attached."); target.add(feedbackPanel); }/*from w ww .j a v a 2s . co m*/ if (iLimsService.hasBiospecimens(bioCollection)) { this.error("Biospecimen collection " + bioCollection.getBiocollectionUid() + " can not be deleted because there are biospecimens attached."); target.add(feedbackPanel); } if (!iLimsService.hasBiospecimens(bioCollection) && (!iLimsService.hasBiocllectionGotCustomFieldData(bioCollection))) { iLimsService.deleteBioCollection(cpModel.getObject()); this.info( "Biospecimen collection " + bioCollection.getBiocollectionUid() + " was deleted successfully."); onClose(target); } }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenListForm.java
License:Open Source License
private void initialiseDataView() { dataViewListWMC = new WebMarkupContainer("dataViewListWMC"); dataViewListWMC.setOutputMarkupId(true); // Data provider to paginate resultList biospecimenProvider = new ArkDataProvider2<LimsVO, Biospecimen>() { private static final long serialVersionUID = 1L; public int size() { return (int) iLimsService.getBiospecimenCount(criteriaModel.getObject()); }/* w w w. ja v a 2 s . c o m*/ public Iterator<Biospecimen> iterator(int first, int count) { List<Biospecimen> biospecimenList = new ArrayList<Biospecimen>(); if (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.SEARCH)) { biospecimenList = iLimsService.searchPageableBiospecimens(criteriaModel.getObject(), first, count); } return biospecimenList.iterator(); } }; // Set the criteria into the data provider's model biospecimenProvider.setCriteriaModel(cpModel); dataView = buildDataView(biospecimenProvider); dataView.setItemsPerPage( iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()); AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) { private static final long serialVersionUID = 1L; @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(dataViewListWMC); } }; dataViewListWMC.add(pageNavigator); dataViewListWMC.add(dataView); List<IColumn<Biospecimen>> columns = new ArrayList<IColumn<Biospecimen>>(); columns.add(new ExportableTextColumn<Biospecimen>(Model.of("BiospecimenUID"), "biospecimenUid")); columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Study"), "study.name")); columns.add(new ExportableTextColumn<Biospecimen>(Model.of("SubjectUID"), "linkSubjectStudy.subjectUID")); columns.add(new ExportableTextColumn<Biospecimen>(Model.of("ParentUID"), "ParentUid")); columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Collection"), "bioCollection.name")); columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Sample Type"), "sampleType.name")); columns.add(new ExportableTextColumn<Biospecimen>(Model.of("Quantity"), "quantity")); DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(), iArkCommonService.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()); List<String> headers = new ArrayList<String>(0); headers.add("BiospecimenUID"); headers.add("Study"); headers.add("SubjectUID"); headers.add("ParentUID"); headers.add("Collection"); headers.add("Sample Type"); headers.add("Quantity"); String filename = "biospecimens"; RepeatingView toolbars = new RepeatingView("toolbars"); ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename); toolbars.add(new Component[] { exportToolBar }); dataViewListWMC.add(toolbars); add(dataViewListWMC); }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenListForm.java
License:Open Source License
private void onBatchCreate(AjaxRequestTarget target) { // Needs CREATE permission AND a BioCollection to select from boolean hasBioCollections = false; // Get session data (used for subject search) Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); String sessionSubjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); if ((sessionStudyId != null) && (sessionSubjectUID != null)) { LinkSubjectStudy linkSubjectStudy = null; Study study = null;//from w w w . ja va 2 s .c o m boolean contextLoaded = false; try { study = iArkCommonService.getStudy(sessionStudyId); linkSubjectStudy = iArkCommonService.getSubjectByUID(sessionSubjectUID, study); if (study != null && linkSubjectStudy != null) { contextLoaded = true; } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } if (contextLoaded) { // Successfully loaded from backend cpModel.getObject().setLinkSubjectStudy(linkSubjectStudy); cpModel.getObject().getBiospecimen().setLinkSubjectStudy(linkSubjectStudy); cpModel.getObject().getBiospecimen().setStudy(study); } } hasBioCollections = iLimsService.hasBioCollections(cpModel.getObject().getLinkSubjectStudy()); if (hasBioCollections) { // Set new Biospecimen into model, then show modalWindow to save CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>(new LimsVO()); newModel.getObject().setLinkSubjectStudy(cpModel.getObject().getLinkSubjectStudy()); newModel.getObject().setStudy(cpModel.getObject().getStudy()); newModel.getObject().getBiospecimen().setLinkSubjectStudy(getModelObject().getLinkSubjectStudy()); newModel.getObject().getBiospecimen().setStudy(getModelObject().getLinkSubjectStudy().getStudy()); // Allow for autogen or manual biospecimenUid entry boolean isAutoBiospecimen = getModelObject().getLinkSubjectStudy().getStudy() .getAutoGenerateBiospecimenUid(); if (isAutoBiospecimen) { modalContentPanel = new AutoGenBatchCreateBiospecimenPanel("content", feedbackPanel, newModel, modalWindow); } else { modalContentPanel = new ManualBatchCreateBiospecimenPanel("content", feedbackPanel, newModel, modalWindow); } // Set the modalWindow title and content modalWindow.setTitle("Batch Create Biospecimens"); modalWindow.setContent(modalContentPanel); modalWindow.show(target); } else { this.error("No Biospecimen Collections exist. Please create at least one Collection."); } // refresh the feedback messages target.add(feedbackPanel); }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenListForm.java
License:Open Source License
/** * //from w w w .jav a 2s. c o 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.lims.biospecimen.form.BiospecimenListForm.java
License:Open Source License
protected void onNew(AjaxRequestTarget target) { // Needs CREATE permission AND a BioCollection to select from boolean hasBioCollections = false; // Get session data (used for subject search) Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); String sessionSubjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); if ((sessionStudyId != null) && (sessionSubjectUID != null)) { LinkSubjectStudy linkSubjectStudy = null; Study study = null;/* w ww.ja v a 2 s .c o m*/ boolean contextLoaded = false; try { study = iArkCommonService.getStudy(sessionStudyId); linkSubjectStudy = iArkCommonService.getSubjectByUID(sessionSubjectUID, study); if (study != null && linkSubjectStudy != null) { contextLoaded = true; } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } if (contextLoaded) { // Successfully loaded from backend cpModel.getObject().setLinkSubjectStudy(linkSubjectStudy); cpModel.getObject().getBiospecimen().setLinkSubjectStudy(linkSubjectStudy); cpModel.getObject().getBiospecimen().setStudy(study); } } hasBioCollections = iLimsService.hasBioCollections(cpModel.getObject().getLinkSubjectStudy()); if (hasBioCollections) { // Set new Biospecimen into model, then show modalWindow to save CompoundPropertyModel<LimsVO> newModel = new CompoundPropertyModel<LimsVO>(new LimsVO()); newModel.getObject().setLinkSubjectStudy(cpModel.getObject().getLinkSubjectStudy()); newModel.getObject().setStudy(cpModel.getObject().getStudy()); newModel.getObject().getBiospecimen().setLinkSubjectStudy(getModelObject().getLinkSubjectStudy()); newModel.getObject().getBiospecimen().setStudy(getModelObject().getLinkSubjectStudy().getStudy()); newModel.getObject().setTreeModel(cpModel.getObject().getTreeModel()); //TODO ASAP handle this newModel.getObject().getBiospecimen().setBiospecimenUid(Constants.AUTO_GENERATED); if (getModelObject().getLinkSubjectStudy().getStudy().getAutoGenerateBiospecimenUid()) { newModel.getObject().getBiospecimen().setBiospecimenUid(Constants.AUTO_GENERATED); } else { newModel.getObject().getBiospecimen().setBiospecimenUid(""); } showModalWindow(target, newModel); // listDetailsForm); } else { this.error("No Biospecimen Collections exist. Please create at least one Collection."); } // refresh the feedback messages target.add(feedbackPanel); }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenListForm.java
License:Open Source License
protected void showModalWindow(AjaxRequestTarget target, CompoundPropertyModel<LimsVO> cpModel) { modalContentPanel = new BiospecimenModalDetailPanel("content", modalWindow, cpModel); // Set the modalWindow title and content modalWindow.setTitle("Biospecimen Detail"); modalWindow.setContent(modalContentPanel); modalWindow.show(target);//from w w w . java2 s. com modalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { /** * */ private static final long serialVersionUID = 1L; public void onClose(AjaxRequestTarget target) { // Refresh the list form whenever the modalwindow is closed target.add(BiospecimenListForm.this); } }); }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenModalDetailForm.java
License:Open Source License
/** * Enable quantity/treatment/*from www . ja va 2 s . com*/ */ private void enableQuantityTreatment(AjaxRequestTarget target) { setQuantityLabel(); if (cpModel.getObject().getParentBiospecimen().getQuantity() != null && cpModel.getObject().getParentBiospecimen().getUnit() != null) { String parentQuantityMax = cpModel.getObject().getParentBiospecimen().getQuantity() + cpModel.getObject().getParentBiospecimen().getUnit().getName(); parentQuantityMaxLbl = new Label("parentBiospecimen.quantity.max", "(" + parentQuantityMax + ")"); bioTransactionDetailWmc.addOrReplace(parentQuantityMaxLbl); } parentQuantityTxtFld.setVisible(cpModel.getObject().getBiospecimenProcessing() .equalsIgnoreCase(au.org.theark.lims.web.Constants.BIOSPECIMEN_PROCESSING_PROCESSING)); treatmentTypeDdc.setEnabled(true); bioTransactionDetailWmc.setEnabled(true); target.add(parentQuantityTxtFld); target.add(treatmentTypeDdc); target.add(bioTransactionDetailWmc); }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenModalDetailForm.java
License:Open Source License
private void initialiseBiospecimenButtonsPanel() { biospecimenbuttonsPanel = new BiospecimenButtonsPanel("biospecimenButtonPanel", new PropertyModel<Biospecimen>(cpModel.getObject(), "biospecimen")) { private static final long serialVersionUID = 1L; @Override//from w w w.ja va 2s . c o m public void onAliquot(AjaxRequestTarget target) { processOrAliquot(target, au.org.theark.lims.web.Constants.BIOSPECIMEN_PROCESSING_ALIQUOTING, "Sub-aliquot of: "); // Go straight into edit mode onViewEdit(target, BiospecimenModalDetailForm.this); } @Override public void onClone(AjaxRequestTarget target) { onCloneBiospecimen(target); // Go straight into edit mode onViewEdit(target, BiospecimenModalDetailForm.this); } @Override public void onPrintBarcode(AjaxRequestTarget target) { // Set barcoded flag to true, as barcode has been printed cpModel.getObject().getBiospecimen().setBarcoded(true); // Update/refresh try { iLimsService.updateBiospecimen(cpModel.getObject()); target.add(barcodedChkBox); target.add(barcodeImage); } catch (ArkSystemException e) { this.error(e.getMessage()); } } @Override public void onProcess(AjaxRequestTarget target) { processOrAliquot(target, au.org.theark.lims.web.Constants.BIOSPECIMEN_PROCESSING_PROCESSING, "Processed from: "); // Go straight into edit mode onViewEdit(target, BiospecimenModalDetailForm.this); } @Override public void onPrintStrawBarcode(AjaxRequestTarget target) { // Set barcoded flag to true, as straw barcode has been printed cpModel.getObject().getBiospecimen().setBarcoded(true); // Update/refresh try { iLimsService.updateBiospecimen(cpModel.getObject()); target.add(barcodedChkBox); } catch (ArkSystemException e) { this.error(e.getMessage()); } } }; biospecimenbuttonsPanel.setVisible(getModelObject().getBiospecimen().getId() != null); // Disable Process/Aliquot buttons if new, or quantity available is 0 boolean enabled = true; if (cpModel.getObject().getBiospecimen().getId() == null || (cpModel.getObject().getBiospecimen().getQuantity() != null && cpModel.getObject().getBiospecimen().getQuantity().equals(new Double(0)))) { enabled = false; } biospecimenbuttonsPanel.setProcessButtonEnabled(enabled); biospecimenbuttonsPanel.setAliquotButtonEnabled(enabled); addOrReplace(biospecimenbuttonsPanel); }