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.biospecimen.form.BiospecimenModalDetailForm.java
License:Open Source License
public void initialiseDetailForm() { idTxtFld = new TextField<String>("biospecimen.id"); biospecimenUidTxtFld = new TextField<String>("biospecimen.biospecimenUid"); biospecimenUidTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override/*from w w w . ja va2 s . c o m*/ protected void onUpdate(AjaxRequestTarget target) { // Check BiospecimenUID is unique String biospecimenUid = (getComponent().getDefaultModelObject().toString() != null ? getComponent().getDefaultModelObject().toString() : new String()); Biospecimen biospecimen = iLimsService.getBiospecimenByUid(biospecimenUid, cpModel.getObject().getBiospecimen().getStudy()); if (biospecimen != null && biospecimen.getId() != null) { error("Biospecimen UID must be unique. Please try again."); target.focusComponent(getComponent()); } target.add(feedbackPanel); } }); parentUidTxtFld = new TextField<String>("biospecimen.parentUid"); commentsTxtAreaFld = new TextArea<String>("biospecimen.comments"); sampleDateTxtFld = new DateTextField("biospecimen.sampleDate", au.org.theark.core.Constants.DD_MM_YYYY); useCollectionDate = new AjaxLink<Date>("useCollectionDate") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { BioCollection selectedBioCollection = cpModel.getObject().getBioCollection(); cpModel.getObject().getBiospecimen().setSampleDate(selectedBioCollection.getCollectionDate()); target.add(sampleDateTxtFld); } }; sampleTimeTxtFld = new TimeField("biospecimen.sampleTime") { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { this.getDateTextField().setVisibilityAllowed(false); super.onBeforeRender(); } @Override protected void convertInput() { // Slight change to not default to today's date Date modelObject = (Date) getDefaultModelObject(); getDateTextField().setConvertedInput(modelObject != null ? modelObject : null); super.convertInput(); } }; processedDateTxtFld = new DateTextField("biospecimen.processedDate", au.org.theark.core.Constants.DD_MM_YYYY); processedTimeTxtFld = new TimeField("biospecimen.processedTime") { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { this.getDateTextField().setVisibilityAllowed(false); super.onBeforeRender(); } @Override protected void convertInput() { // Slight change to not default to today's date Date modelObject = (Date) getDefaultModelObject(); getDateTextField().setConvertedInput(modelObject != null ? modelObject : null); super.convertInput(); } }; ArkDatePicker sampleDatePicker = new ArkDatePicker(); sampleDatePicker.bind(sampleDateTxtFld); sampleDateTxtFld.add(sampleDatePicker); ArkDatePicker processedDatePicker = new ArkDatePicker(); processedDatePicker.bind(processedDateTxtFld); processedDateTxtFld.add(processedDatePicker); quantityTxtFld = new TextField<Double>("biospecimen.quantity") { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public <C> IConverter<C> getConverter(Class<C> type) { DoubleConverter doubleConverter = new DoubleConverter(); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumFractionDigits(1); numberFormat.setMaximumFractionDigits(10); doubleConverter.setNumberFormat(getLocale(), numberFormat); return (IConverter<C>) doubleConverter; } }; parentQuantityTxtFld = new TextField<Double>("parentBiospecimen.quantity") { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public <C> IConverter<C> getConverter(Class<C> type) { DoubleConverter doubleConverter = new DoubleConverter(); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumFractionDigits(1); numberFormat.setMaximumFractionDigits(10); doubleConverter.setNumberFormat(getLocale(), numberFormat); return (IConverter<C>) doubleConverter; } }; parentQuantityTxtFld.setVisible(cpModel.getObject().getBiospecimenProcessing() .equalsIgnoreCase(au.org.theark.lims.web.Constants.BIOSPECIMEN_PROCESSING_PROCESSING)); parentQuantityTxtFld.setOutputMarkupId(true); quantityTxtFld.setEnabled(false); bioTransactionQuantityTxtFld = new TextField<Double>("bioTransaction.quantity") { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public <C> IConverter<C> getConverter(Class<C> type) { DoubleConverter doubleConverter = new DoubleConverter(); NumberFormat numberFormat = NumberFormat.getInstance(); numberFormat.setMinimumFractionDigits(1); numberFormat.setMaximumFractionDigits(10); doubleConverter.setNumberFormat(getLocale(), numberFormat); return (IConverter<C>) doubleConverter; } }; bioTransactionQuantityTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(amountLbl); } }); concentrationTxtFld = new TextField<Number>("biospecimen.concentration"); concentrationTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { target.add(amountLbl); } }); amountLbl = new Label("biospecimen.amount", new Model<Number>() { private static final long serialVersionUID = 1L; @Override public Number getObject() { Number concentration = ((concentrationTxtFld.getModelObject() == null) ? 0 : concentrationTxtFld.getModelObject()); Number quantity = null; if (bioTransactionQuantityTxtFld.isVisible()) { quantity = ((bioTransactionQuantityTxtFld.getModelObject() == null) ? 0 : bioTransactionQuantityTxtFld.getModelObject()); } else { quantity = ((quantityTxtFld.getModelObject() == null) ? 0 : quantityTxtFld.getModelObject()); } Number amount = (concentration.doubleValue() * quantity.doubleValue()); return amount; } }); amountLbl.setOutputMarkupPlaceholderTag(true); setQuantityLabel(); initSampleTypeDdc(); initBioCollectionDdc(); initUnitDdc(); initTreatmentTypeDdc(); initGradeDdc(); initStoredInDdc(); initAnticoagDdc(); initStatusDdc(); initQualityDdc(); initBiospecimenProtocol(); purity = new TextField<Number>("biospecimen.purity"); barcodedChkBox = new CheckBox("biospecimen.barcoded"); barcodedChkBox.setVisible(true); barcodedChkBox.setEnabled(false); initialiseBarcodeImage(); initialiseBiospecimenCFDataEntry(); initialiseBioTransactionListPanel(); initialiseBiospecimenLocationPanel(); initialiseBiospecimenButtonsPanel(); initDeleteModelWindow(); attachValidators(); addComponents(); // Focus on Sample Type sampleTypeDdc.add(new ArkDefaultFormFocusBehavior()); }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenModalDetailForm.java
License:Open Source License
@Override protected void onSave(AjaxRequestTarget target) { boolean saveOk = true; org.apache.shiro.subject.Subject currentUser = SecurityUtils.getSubject(); try {// ww w.j a v a 2 s. co m if (cpModel.getObject().getBiospecimen().getId() == null) { // Save/Process/Aliquot if (cpModel.getObject().getBiospecimenProcessing().isEmpty()) { //empty // Normal Save functionality // Initial transaction detail currentUser = SecurityUtils.getSubject(); cpModel.getObject().getBioTransaction().setRecorder(currentUser.getPrincipal().toString()); cpModel.getObject().getBioTransaction().setUnit(cpModel.getObject().getBiospecimen().getUnit()); //TODO: soon in web form iLimsService.createBiospecimen(cpModel.getObject()); // Update location if (cpModel.getObject().getBiospecimenLocationVO().getIsAllocated()) { if (cpModel.getObject().getInvCell() != null && cpModel.getObject().getInvCell().getBiospecimen() != null) { iInventoryService.updateInvCell(cpModel.getObject().getInvCell()); } } this.info("Biospecimen " + cpModel.getObject().getBiospecimen().getBiospecimenUid() + " was created successfully"); setQuantityLabel(); } else if (cpModel.getObject().getBiospecimenProcessing() .equalsIgnoreCase(au.org.theark.lims.web.Constants.BIOSPECIMEN_PROCESSING_PROCESSING)) { // Process the biospecimen try { LimsVO limsVo = cpModel.getObject(); Biospecimen biospecimen = limsVo.getBiospecimen(); Biospecimen parentBiospecimen = iLimsService .getBiospecimen(biospecimen.getParent().getId()); double qtyUsedFromParent = limsVo.getParentBiospecimen().getQuantity(); if (qtyUsedFromParent > parentBiospecimen.getQuantity()) { StringBuffer errorMessage = new StringBuffer(); errorMessage.append("Cannot process more than "); errorMessage.append(parentBiospecimen.getQuantity()); errorMessage.append(parentBiospecimen.getUnit().getName()); errorMessage.append(" of the parent biospecimen"); this.error(errorMessage); saveOk = false; } else { // Process the biospecimen and it's parent iLimsService.createBiospecimen(limsVo); // Add parent transaction LimsVO parentLimsVo = new LimsVO(); parentLimsVo.setBiospecimen(parentBiospecimen); parentLimsVo.getBioTransaction().setId(null); parentLimsVo.getBioTransaction().setUnit(biospecimen.getUnit()); //TODO: soon in web form parentLimsVo.getBioTransaction().setBiospecimen(parentBiospecimen); parentLimsVo.getBioTransaction().setTransactionDate(Calendar.getInstance().getTime()); parentLimsVo.getBioTransaction() .setReason("Processed for: " + biospecimen.getBiospecimenUid()); parentLimsVo.getBioTransaction().setRecorder(currentUser.getPrincipal().toString()); // NOTE: Removing from parent is negative-value transaction parentLimsVo.getBioTransaction().setQuantity(qtyUsedFromParent * -1); BioTransactionStatus bioTransactionStatus = iLimsService .getBioTransactionStatusByName("Processed"); parentLimsVo.getBioTransaction().setStatus(bioTransactionStatus); iLimsService.createBioTransaction(parentLimsVo); this.info("Biospecimen " + cpModel.getObject().getBiospecimen().getBiospecimenUid() + " was created successfully"); setQuantityLabel(); } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } } else if (cpModel.getObject().getBiospecimenProcessing() .equalsIgnoreCase(au.org.theark.lims.web.Constants.BIOSPECIMEN_PROCESSING_ALIQUOTING)) { // Aliquot the biospecimen try { LimsVO limsVo = cpModel.getObject(); Biospecimen biospecimen = limsVo.getBiospecimen(); BioTransaction bioTransaction = limsVo.getBioTransaction(); Biospecimen parentBiospecimen = iLimsService .getBiospecimen(biospecimen.getParent().getId()); if (bioTransaction.getQuantity() > parentBiospecimen.getQuantity()) { StringBuffer errorMessage = new StringBuffer(); errorMessage.append("Cannot aliquot more than "); errorMessage.append(parentBiospecimen.getQuantity()); errorMessage.append(parentBiospecimen.getUnit().getName()); errorMessage.append(" of the parent biospecimen"); this.error(errorMessage); saveOk = false; } else { // Aliquot the biospecimen and it's parent iLimsService.createBiospecimen(limsVo); // Add parent transaction LimsVO parentLimsVo = new LimsVO(); //parentLimsVo.setBiospecimen(parentBiospecimen); parentLimsVo.getBioTransaction().setId(null); parentLimsVo.getBioTransaction().setBiospecimen(parentBiospecimen); parentLimsVo.getBioTransaction().setUnit(biospecimen.getUnit()); //TODO: soon in web form parentLimsVo.getBioTransaction().setTransactionDate(Calendar.getInstance().getTime()); parentLimsVo.getBioTransaction() .setReason("Sub-Aliquot for: " + biospecimen.getBiospecimenUid()); parentLimsVo.getBioTransaction().setRecorder(currentUser.getPrincipal().toString()); // NOTE: Removing from parent is negative-value transaction parentLimsVo.getBioTransaction().setQuantity(bioTransaction.getQuantity() * -1); BioTransactionStatus bioTransactionStatus = iLimsService .getBioTransactionStatusByName("Aliquoted"); parentLimsVo.getBioTransaction().setStatus(bioTransactionStatus); iLimsService.createBioTransaction(parentLimsVo); this.info("Biospecimen " + cpModel.getObject().getBiospecimen().getBiospecimenUid() + " was created successfully"); setQuantityLabel(); } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } } } else { // Update location if (cpModel.getObject().getBiospecimenLocationVO().getIsAllocated()) { if (cpModel.getObject().getInvCell() != null && cpModel.getObject().getInvCell().getBiospecimen() != null) { iInventoryService.updateInvCell(cpModel.getObject().getInvCell()); } } // Update qty avail cpModel.getObject().getBiospecimen() .setQuantity(iLimsService.getQuantityAvailable(cpModel.getObject().getBiospecimen())); // Update biospecimen iLimsService.updateBiospecimen(cpModel.getObject()); this.info("Biospecimen " + cpModel.getObject().getBiospecimen().getBiospecimenUid() + " was updated successfully"); // Hide/show barcode image barcodeImage.setVisible(cpModel.getObject().getBiospecimen().getBarcoded()); target.add(barcodeImage); setQuantityLabel(); } if (saveOk) { // Allow the Biospecimen custom data to be saved any time save is performed if (biospecimenCFDataEntryPanel instanceof BiospecimenCustomDataDataViewPanel) { ((BiospecimenCustomDataDataViewPanel) biospecimenCFDataEntryPanel).saveCustomData(); } // refresh the custom field data entry panel (if necessary) if (initialiseBiospecimenCFDataEntry()) { arkCrudContainerVo.getDetailPanelFormContainer().addOrReplace(biospecimenCFDataEntryPanel); } // refresh the bio transactions (if necessary) if (initialiseBioTransactionListPanel()) { arkCrudContainerVo.getDetailPanelFormContainer().addOrReplace(bioTransactionListPanel); } // refresh the location panel if (initialiseBiospecimenLocationPanel()) { arkCrudContainerVo.getDetailPanelFormContainer().addOrReplace(biospecimenLocationPanel); } // Disable initial transaction details, and hide inital quantity text box bioTransactionDetailWmc.setEnabled(true); bioTransactionQuantityTxtFld.setVisible(false); quantityTxtFld.setVisible(true); // quantityTxtFld.setModelObject(bioTransactionQuantityTxtFld.getModelObject()); target.add(bioTransactionDetailWmc); barcodeImage.setVisible(cpModel.getObject().getBiospecimen().getBarcoded()); target.add(barcodeImage); // Enable/re-enable buttons panel initialiseBiospecimenButtonsPanel(); target.add(biospecimenbuttonsPanel); cpModel.getObject().setBiospecimenProcessing(""); parentQuantityTxtFld.setVisible(false); target.add(parentQuantityTxtFld); onSavePostProcess(target); } } catch (ArkSystemException e) { this.error(e.getMessage()); } processErrors(target); }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenModalDetailForm.java
License:Open Source License
/** * Takes all details of a biospecimen, copies to a new Biospecimen, then allows editing of details before save * /* w ww .j a v a 2 s . com*/ * @param target */ protected void onCloneBiospecimen(AjaxRequestTarget target) { final Biospecimen clonedBiospecimen = cpModel.getObject().getBiospecimen(); final String clonedBiospecimenUid = clonedBiospecimen.getBiospecimenUid(); final Biospecimen biospecimen = new Biospecimen(); try { // Copy parent biospecimen details to new biospecimen PropertyUtils.copyProperties(biospecimen, clonedBiospecimen); // Amend specific fields/detail biospecimen.setId(null); if (biospecimen.getStudy().getAutoGenerateBiospecimenUid()) { biospecimen.setBiospecimenUid(Constants.AUTO_GENERATED); } else { biospecimen.setBiospecimenUid(null); } // Cloning not a child biospecimen // biospecimen.setParent(clonedBiospecimen); // biospecimen.setParentUid(clonedBiospecimen.getBiospecimenUid()); biospecimen.setSampleType(clonedBiospecimen.getSampleType()); biospecimen.setBioCollection(clonedBiospecimen.getBioCollection()); biospecimen.setQuantity(null); biospecimen.setUnit(clonedBiospecimen.getUnit()); biospecimen.setComments("Clone of " + clonedBiospecimenUid); biospecimen.setBarcoded(false); biospecimen.setQuantity(clonedBiospecimen.getQuantity()); biospecimen.setUnit(clonedBiospecimen.getUnit()); biospecimen.setTreatmentType(clonedBiospecimen.getTreatmentType()); biospecimen.setChildren(new ArrayList<Biospecimen>(0)); Study studyFromClone = clonedBiospecimen.getStudy(); // There should be a study and only then do the rest of the code here if (studyFromClone != null) { Study study = iArkCommonService.getStudy(studyFromClone.getId()); biospecimen.setStudy(study); // Reset the biospecimen detail cpModel.getObject().setBiospecimen(biospecimen); // Set the bioTransaction detail org.apache.shiro.subject.Subject currentUser = SecurityUtils.getSubject(); cpModel.getObject().getBioTransaction().setRecorder(currentUser.getPrincipal().toString()); cpModel.getObject().getBioTransaction().setQuantity(null); cpModel.getObject().getBioTransaction().setUnit(biospecimen.getUnit()); enableQuantityTreatment(target); CompoundPropertyModel<BiospecimenCustomDataVO> bioCFDataCpModel = new CompoundPropertyModel<BiospecimenCustomDataVO>( new BiospecimenCustomDataVO()); bioCFDataCpModel.getObject().setBiospecimen(biospecimen); bioCFDataCpModel.getObject().setArkFunction(iArkCommonService .getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_BIOSPECIMEN)); biospecimenCFDataEntryPanel = new BiospecimenCustomDataDataViewPanel("biospecimenCFDataEntryPanel", bioCFDataCpModel).initialisePanel(null); arkCrudContainerVo.getDetailPanelFormContainer().addOrReplace(biospecimenCFDataEntryPanel); // refresh the bioTransaction panel initialiseBioTransactionListPanel(); arkCrudContainerVo.getDetailPanelFormContainer().addOrReplace(bioTransactionListPanel); // refresh the location panel cpModel.getObject().setBiospecimenLocationVO(new BiospecimenLocationVO()); initialiseBiospecimenLocationPanel(); arkCrudContainerVo.getDetailPanelFormContainer().addOrReplace(biospecimenLocationPanel); target.add(biospecimenLocationPanel); // Notify in progress this.info("Cloning biospecimen " + clonedBiospecimenUid + ", please save to confirm"); target.add(feedbackPanel); // hide button panel biospecimenbuttonsPanel.setVisible(false); target.add(biospecimenbuttonsPanel); } else { log.error("Cannot find a study for the cloned biospecimen."); } } catch (IllegalAccessException e) { log.error(e.getMessage()); } catch (InvocationTargetException e) { log.error(e.getMessage()); } catch (NoSuchMethodException e) { log.error(e.getMessage()); } }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenModalDetailForm.java
License:Open Source License
/** * Handle processing or aliquoting of a parent biospecimen. Process essentially changing the type of a parent biospecimen. Aliquot essentially * taking an amount from a parent biospecimen. * /*from www . j ava 2 s .com*/ * @param target * AjxaxRequestTarget * @param processOrAliquot * indication to whether a process or an aliquot * @param comment * comment to add to biospecimen comments */ protected void processOrAliquot(AjaxRequestTarget target, String processOrAliquot, String comment) { final Biospecimen parentBiospecimen = cpModel.getObject().getBiospecimen(); final String parentBiospecimenUid = parentBiospecimen.getBiospecimenUid(); final Biospecimen biospecimen = new Biospecimen(); cpModel.getObject().setParentBiospecimen(parentBiospecimen); try { // Copy parent biospecimen details to new biospecimen PropertyUtils.copyProperties(biospecimen, parentBiospecimen); // Amend specific fields/detail biospecimen.setId(null); if (biospecimen.getStudy().getAutoGenerateBiospecimenUid()) { biospecimen.setBiospecimenUid(Constants.AUTO_GENERATED); } else { biospecimen.setBiospecimenUid(null); } /*** * TRAV TO INVESTIGATE ASAP // Cloning not a child biospecimen // biospecimen.setParent(clonedBiospecimen); // biospecimen.setParentUid(clonedBiospecimen.getBiospecimenUid()); **/ biospecimen.setParent(parentBiospecimen); biospecimen.setParentUid(parentBiospecimen.getBiospecimenUid()); biospecimen.setSampleType(parentBiospecimen.getSampleType()); biospecimen.setBioCollection(parentBiospecimen.getBioCollection()); biospecimen.setQuantity(null); biospecimen.setUnit(parentBiospecimen.getUnit()); biospecimen.setComments(comment + parentBiospecimenUid); biospecimen.setBarcoded(false); biospecimen.setTreatmentType(parentBiospecimen.getTreatmentType()); biospecimen.setChildren(new ArrayList<Biospecimen>(0)); Study studyFromParent = parentBiospecimen.getStudy(); // There should be a study and only then do the rest of the code here if (studyFromParent != null) { Study study = iArkCommonService.getStudy(studyFromParent.getId()); biospecimen.setStudy(study); // Reset the biospecimen detail cpModel.getObject().setBiospecimen(biospecimen); cpModel.getObject().setBiospecimenProcessing(processOrAliquot); // Set the bioTransaction detail org.apache.shiro.subject.Subject currentUser = SecurityUtils.getSubject(); cpModel.getObject().getBioTransaction().setRecorder(currentUser.getPrincipal().toString()); cpModel.getObject().getBioTransaction().setQuantity(null); cpModel.getObject().getBioTransaction().setUnit(biospecimen.getUnit()); //TODO: unit enableQuantityTreatment(target); CompoundPropertyModel<BiospecimenCustomDataVO> bioCFDataCpModel = new CompoundPropertyModel<BiospecimenCustomDataVO>( new BiospecimenCustomDataVO()); bioCFDataCpModel.getObject().setBiospecimen(biospecimen); bioCFDataCpModel.getObject().setArkFunction(iArkCommonService .getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_BIOSPECIMEN)); biospecimenCFDataEntryPanel = new BiospecimenCustomDataDataViewPanel("biospecimenCFDataEntryPanel", bioCFDataCpModel).initialisePanel(null); arkCrudContainerVo.getDetailPanelFormContainer().addOrReplace(biospecimenCFDataEntryPanel); // refresh the bioTransaction panel initialiseBioTransactionListPanel(); arkCrudContainerVo.getDetailPanelFormContainer().addOrReplace(bioTransactionListPanel); // refresh the location panel cpModel.getObject().setBiospecimenLocationVO(new BiospecimenLocationVO()); initialiseBiospecimenLocationPanel(); arkCrudContainerVo.getDetailPanelFormContainer().addOrReplace(biospecimenLocationPanel); target.add(biospecimenLocationPanel); // Notify in progress this.info(processOrAliquot + " biospecimen " + cpModel.getObject().getBiospecimen().getParentUid() + ", please save to confirm"); target.add(feedbackPanel); // hide button panel biospecimenbuttonsPanel.setVisible(false); target.add(biospecimenbuttonsPanel); } else { log.error("Cannot find a study for the parent biospecimen."); } } catch (IllegalAccessException e) { log.error(e.getMessage()); } catch (InvocationTargetException e) { log.error(e.getMessage()); } catch (NoSuchMethodException e) { log.error(e.getMessage()); } }
From source file:au.org.theark.lims.web.component.subjectlims.lims.biospecimen.form.BiospecimenModalDetailForm.java
License:Open Source License
private void initDeleteModelWindow() { answer = new ConfirmationAnswer(false); confirmModal = new ModalWindow("modal"); confirmModal.setCookieName("yesNoPanel"); if (!isNew()) { List<BioTransaction> bioTransactions = iLimsService .getAllBiotransactionForBiospecimen(cpModel.getObject().getBiospecimen()); StringBuffer bioTxID = new StringBuffer(); for (BioTransaction bioTransaction : bioTransactions) { bioTxID.append(bioTransaction.getId()).append(","); }//from w ww.j av a 2 s . c o m bioTxID.deleteCharAt(bioTxID.length() - 1); String modelTextReplce1 = modalText.replaceAll("number", Integer.toString(bioTransactions.size())); String modeltextReplace2 = modelTextReplce1.replaceAll("txs", bioTxID.toString()); confirmModal.setContent( new YesNoPanel(confirmModal.getContentId(), modeltextReplace2, confirmModal, answer)); confirmModal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1L; public void onClose(AjaxRequestTarget target) { if (answer.isAnswer()) { iLimsService.deleteBiospecimen(cpModel.getObject()); getSession().getFeedbackMessages().info(me, "Biospecimen " + cpModel.getObject().getBiospecimen().getBiospecimenUid() + " was deleted successfully"); } else { EditModeButtonsPanel editModeButtonsPanel = ((EditModeButtonsPanel) buttonsPanelWMC .get("buttonsPanel")); editModeButtonsPanel.setDeleteButtonEnabled(true); target.add(editModeButtonsPanel); } target.add(feedbackPanel); } }); } }
From source file:au.org.theark.lims.web.component.subjectlims.lims.LimsContainerPanel.java
License:Open Source License
public void initialisePanel() { containerForm = new ContainerForm("containerForm", cpModel); containerForm.add(initialiseFeedBackPanel()); modalWindow = new AbstractDetailModalWindow("detailModalWindow") { private static final long serialVersionUID = 1L; @Override// w ww .ja v a 2s. c o m protected void onCloseModalWindow(AjaxRequestTarget target) { provider = new BiospecimenTreeProvidor(iArkCommonService, iLimsService, cpModel); state = new ProviderSubset<Object>(provider); ((IDetachable) state).detach(); state = new InverseSet<Object>(new ProviderSubset<Object>(provider)); bioTreePanel = new BiospecimenNestedTreePanel("tree", cpModel, provider, newStateModel(), modalWindow); containerForm.addOrReplace(bioTreePanel); target.add(bioTreePanel); target.add(biocollectionListPanel); target.add(bioSpecimenListPanel); } }; modalWindow.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() { private static final long serialVersionUID = 1L; public void onClose(AjaxRequestTarget target) { provider = new BiospecimenTreeProvidor(iArkCommonService, iLimsService, cpModel); state = new ProviderSubset<Object>(provider); ((IDetachable) state).detach(); state = new InverseSet<Object>(new ProviderSubset<Object>(provider)); bioTreePanel = new BiospecimenNestedTreePanel("tree", cpModel, provider, newStateModel(), modalWindow); containerForm.addOrReplace(bioTreePanel); target.add(bioTreePanel); target.add(biocollectionListPanel); target.add(bioSpecimenListPanel); } }); biocollectionListPanel = new BioCollectionListPanel("biocollectionListPanel", feedbackPanel, cpModel, modalWindow); collectionListPanel = biocollectionListPanel; containerForm.add(collectionListPanel); bioSpecimenListPanel = new BiospecimenListPanel("biospecimenListPanel", feedbackPanel, cpModel, modalWindow); biospecimenListPanel = bioSpecimenListPanel; provider = new BiospecimenTreeProvidor(iArkCommonService, iLimsService, cpModel); state = new ProviderSubset<Object>(provider); ((IDetachable) state).detach(); state = new InverseSet<Object>(new ProviderSubset<Object>(provider)); bioTreePanel = new BiospecimenNestedTreePanel("tree", cpModel, provider, newStateModel(), modalWindow); containerForm.add(bioTreePanel); containerForm.add(modalWindow); containerForm.add(biospecimenListPanel); this.add(containerForm); }
From source file:au.org.theark.lims.web.component.subjectlims.subject.form.DetailForm.java
License:Open Source License
protected void onCancel(AjaxRequestTarget target) { // Set study in context back to limsVo.study Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null) { //Study study = iArkCommonService.getStudy(sessionStudyId); LimsVO limsVo = new LimsVO(); //limsVo.setStudy(study); containerForm.setModelObject(limsVo); // Refresh the contextUpdateTarget (remove) if (containerForm.getContextUpdateLimsWMC() != null) { Panel limsContainerPanel = new EmptyPanel("limsContainerPanel"); limsContainerPanel.setOutputMarkupPlaceholderTag(true); containerForm.getContextUpdateLimsWMC().addOrReplace(limsContainerPanel); target.add(containerForm.getContextUpdateLimsWMC()); }// w w w .j a v a 2 s .c o m } }
From source file:au.org.theark.lims.web.component.subjectlims.subject.form.SearchForm.java
License:Open Source License
protected void onSearch(AjaxRequestTarget target) { target.add(feedbackPanel); List<Study> studyList = new ArrayList<Study>(0); // Restrict search if Study selected in Search form if (cpmModel.getObject().getStudy() != null) { studyList.add(cpmModel.getObject().getStudy()); } else {/*from w w w. j a v a 2 s.c om*/ studyList = cpmModel.getObject().getStudyList(); if (studyList.isEmpty()) { log.error("StudyList is empty, shouldn't happen!"); studyList = getStudyListForUser(); } } int count = iLimsSubjectService.getSubjectCount(cpmModel.getObject(), studyList); if (count == 0) { this.info("There are no subjects with the specified criteria."); target.add(feedbackPanel); } arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true); target.add(arkCrudContainerVO.getSearchResultPanelContainer()); }
From source file:au.org.theark.lims.web.component.subjectlims.subject.SearchResultListPanel.java
License:Open Source License
/** * Builds the link for selection of subject (gets from database to ensure persistence)s * // ww w. j a v a 2s . c o m * @param subject * @return */ private AjaxLink buildLink(final LinkSubjectStudy subject) { ArkBusyAjaxLink link = new ArkBusyAjaxLink("subjectUID") { @Override public void onClick(AjaxRequestTarget target) { LinkSubjectStudy subjectFromBackend = new LinkSubjectStudy(); try { subjectFromBackend = iArkCommonService.getSubjectByUID(subject.getSubjectUID(), subject.getStudy()); } catch (EntityNotFoundException e) { log.error(e.getMessage()); } // Set SubjectUID into context SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.SUBJECTUID, subjectFromBackend.getSubjectUID()); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID, subjectFromBackend.getStudy().getId()); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID, subject.getPerson().getId()); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.PERSON_TYPE, au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_SUBJECT); // Force clearing of Cache to re-load roles for the user for the study arkLdapRealm.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals()); aafRealm.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals()); LimsVO limsVo = new LimsVO(); limsVo.setLinkSubjectStudy(subjectFromBackend); //limsVo.setStudy(subjectFromBackend.getStudy()); containerForm.setModelObject(limsVo); // Set context items ContextHelper contextHelper = new ContextHelper(); //contextHelper.setStudyContextLabel(target, subjectFromBackend.getStudy().getName(), arkContextMarkup); //contextHelper.setSubjectContextLabel(target, subjectFromBackend.getSubjectUID(), arkContextMarkup); // Always disable subjectUID DetailPanel details = (DetailPanel) arkCrudContainerVO.getDetailPanelContainer() .get("detailsPanel"); DetailForm detailsForm = (DetailForm) details.get("detailsForm"); detailsForm.getSubjectUIDTxtFld().setEnabled(false); ArkCRUDHelper.preProcessDetailPanelOnSearchResults(target, arkCrudContainerVO); arkCrudContainerVO.getEditButtonContainer().setVisible(false); // Refresh the contextUpdateTarget (add) if (containerForm.getContextUpdateLimsWMC() != null) { Panel limsContainerPanel = new LimsContainerPanel("limsContainerPanel", arkContextMarkup, containerForm.getModel()); containerForm.getContextUpdateLimsWMC().setVisible(true); containerForm.getContextUpdateLimsWMC().addOrReplace(limsContainerPanel); //details.limsContainerPanel.replaceWith(limsContainerPanel); details.addOrReplace(containerForm.getContextUpdateLimsWMC()); target.add(details); } // Set Study Logo studyHelper = new StudyHelper(); StudyCrudContainerVO studyCrudContainerVO = new StudyCrudContainerVO(); studyCrudContainerVO.setStudyNameMarkup(studyNameMarkup); studyCrudContainerVO.setStudyLogoMarkup(studyLogoMarkup); studyHelper.setStudyLogo(subjectFromBackend.getStudy(), target, studyCrudContainerVO.getStudyNameMarkup(), studyCrudContainerVO.getStudyLogoMarkup()); } }; Label nameLinkLabel = new Label(Constants.SUBJECT_KEY_LBL, subject.getSubjectUID()); link.add(nameLinkLabel); return link; }
From source file:au.org.theark.lims.web.component.subjectlims.subject.SubjectContainerPanel.java
License:Open Source License
protected boolean prerenderContextCheck() { 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); boolean contextLoaded = false; // Force clearing of Cache to re-load roles for the user for the study arkLdapRealm.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals()); aafRealm.clearCachedAuthorizationInfo(SecurityUtils.getSubject().getPrincipals()); Study study = null;/*from www .j a v a2 s . c o m*/ if (sessionStudyId != null) { study = iArkCommonService.getStudy(sessionStudyId); } if ((sessionStudyId != null) && (sessionSubjectUID != null)) { LinkSubjectStudy subjectFromBackend = new LinkSubjectStudy(); try { subjectFromBackend = iArkCommonService.getSubjectByUID(sessionSubjectUID, study); // Set SubjectUID into context SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.SUBJECTUID, subjectFromBackend.getSubjectUID()); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID, subjectFromBackend.getStudy().getId()); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID, subjectFromBackend.getPerson().getId()); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.PERSON_TYPE, au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_SUBJECT); } catch (EntityNotFoundException e) { log.error(e.getMessage()); } if (study != null && subjectFromBackend != null) { // Study and subject in context contextLoaded = true; LimsVO limsVo = new LimsVO(); limsVo.setLinkSubjectStudy(subjectFromBackend); limsVo.setStudy(subjectFromBackend.getStudy()); limsVo.setTreeModel(treeModel); containerForm.setModelObject(limsVo); } if (contextLoaded) { // Put into Detail View mode arkCrudContainerVO.getSearchPanelContainer().setVisible(false); arkCrudContainerVO.getSearchResultPanelContainer().setVisible(false); arkCrudContainerVO.getDetailPanelContainer().setVisible(true); arkCrudContainerVO.getDetailPanelFormContainer().setEnabled(false); //arkCrudContainerVO.getViewButtonContainer().setVisible(true); arkCrudContainerVO.getEditButtonContainer().setVisible(false); if (containerForm.getContextUpdateLimsWMC() != null) { Panel limsContainerPanel = new LimsContainerPanel("limsContainerPanel", arkContextMarkup, containerForm.getModel()); containerForm.getContextUpdateLimsWMC().setVisible(true); detailsPanel.addOrReplace(containerForm.getContextUpdateLimsWMC()); containerForm.getContextUpdateLimsWMC().addOrReplace(limsContainerPanel); AjaxRequestTarget target = AjaxRequestTarget.get(); target.add(detailsPanel); } } } return contextLoaded; }