List of usage examples for org.apache.shiro SecurityUtils getSubject
public static Subject getSubject()
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 {//from w ww . j a v a 2 s. c o 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 * /*ww w .java 2s. 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. * //w w w . j av a 2s . c o m * @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.form.ContainerForm.java
License:Open Source License
/** * Returns a list of Studies the user is permitted to access * //from w w w. jav a 2 s . c o m * @return */ public List<Study> getStudyListForUser() { List<Study> studyList = new ArrayList<Study>(0); try { Subject currentUser = SecurityUtils.getSubject(); ArkUser arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString()); ArkUserVO arkUserVo = new ArkUserVO(); arkUserVo.setArkUserEntity(arkUser); Long sessionArkModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); ArkModule arkModule = null; arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); studyList = iArkCommonService.getStudyListForUserAndModule(arkUserVo, arkModule); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null) { studyList = iArkCommonService.getParentAndChildStudies(sessionStudyId); getModelObject().setStudyList(studyList); } getModelObject().setStudyList(studyList); } catch (EntityNotFoundException e) { log.error(e.getMessage()); } return studyList; }
From source file:au.org.theark.lims.web.component.subjectlims.subject.form.ContainerForm.java
License:Open Source License
/** * Returns a list of Studies the user is permitted to access * /* w w w . j av a2s . c o m*/ * @return */ public List<Study> getStudyListForUser() { List<Study> studyList = new ArrayList<Study>(0); try { Subject currentUser = SecurityUtils.getSubject(); ArkUser arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString()); ArkUserVO arkUserVo = new ArkUserVO(); arkUserVo.setArkUserEntity(arkUser); Long sessionArkModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); ArkModule arkModule = null; arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); studyList = iArkCommonService.getStudyListForUserAndModule(arkUserVo, arkModule); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = null; if (sessionStudyId != null) { study = iArkCommonService.getStudy(sessionStudyId); //studyListForUser.add(study); studyList = iArkCommonService.getParentAndChildStudies(sessionStudyId); getModelObject().setStudyList(studyList); } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } return studyList; }
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()); }/*from w ww . ja v a 2 s . c o m*/ } }
From source file:au.org.theark.lims.web.component.subjectlims.subject.form.DetailForm.java
License:Open Source License
/** * Returns a list of Studies the user is permitted to access * //from ww w .jav a 2 s . c o m * @return */ public List<Study> getStudyListForUser() { List<Study> studyList = new ArrayList<Study>(0); try { Subject currentUser = SecurityUtils.getSubject(); ArkUser arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString()); ArkUserVO arkUserVo = new ArkUserVO(); arkUserVo.setArkUserEntity(arkUser); Long sessionArkModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); ArkModule arkModule = null; arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); studyList = iArkCommonService.getStudyListForUserAndModule(arkUserVo, arkModule); } catch (EntityNotFoundException e) { log.error(e.getMessage()); } return studyList; }
From source file:au.org.theark.lims.web.component.subjectlims.subject.form.SearchForm.java
License:Open Source License
/** * Returns a list of Studies the user is permitted to access * /*from ww w .j a v a 2 s. c om*/ * @return */ private List<Study> getStudyListForUser() { List<Study> studyListForUser = new ArrayList<Study>(0); try { Subject currentUser = SecurityUtils.getSubject(); ArkUser arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString()); ArkUserVO arkUserVo = new ArkUserVO(); arkUserVo.setArkUserEntity(arkUser); Long sessionArkModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); ArkModule arkModule = null; //arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); //studyListForUser = iArkCommonService.getStudyListForUserAndModule(arkUserVo, arkModule); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null) { studyListForUser = iArkCommonService.getParentAndChildStudies(sessionStudyId); } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } return studyListForUser; }
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 * //from w ww. ja va2 s . c om * @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(), iArkCommonService); } }; 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 w ww .ja v a2s . 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; }