List of usage examples for org.apache.shiro SecurityUtils getSubject
public static Subject getSubject()
From source file:au.org.theark.lims.web.component.barcodelabel.BarcodeLabelContainerPanel.java
License:Open Source License
public BarcodeLabelContainerPanel(String id, WebMarkupContainer arkContextMarkup) { super(id);/*from w ww .j a v a 2 s. c o m*/ this.arkContextMarkup = arkContextMarkup; BarcodeLabel barcodeLabel = new BarcodeLabel(); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null) { Study study = iArkCommonService.getStudy(sessionStudyId); barcodeLabel.setStudy(study); } cpModel = new CompoundPropertyModel<BarcodeLabel>(barcodeLabel); arkCrudContainerVO = new ArkCrudContainerVO(); initialisePanel(); }
From source file:au.org.theark.lims.web.component.barcodelabel.BarcodeLabelContainerPanel.java
License:Open Source License
/** * Returns a list of Studies the user is permitted to access * /*from ww w. j a v a2 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); } catch (EntityNotFoundException e) { log.error(e.getMessage()); } return studyListForUser; }
From source file:au.org.theark.lims.web.component.barcodelabel.form.DetailForm.java
License:Open Source License
/** * Returns study in context// w w w.j ava 2s . co m * * @return */ private List<Study> getStudyListForUser() { List<Study> studyListForUser = new ArrayList<Study>(0); 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); } return studyListForUser; }
From source file:au.org.theark.lims.web.component.barcodelabel.form.SearchForm.java
License:Open Source License
/** * Returns a list of Studies the user is permitted to access * /* w w w. j a va 2s .c o m*/ * @return */ private List<Study> getStudyListForUser() { List<Study> studyListForUser = new ArrayList<Study>(0); 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); } try { Subject currentUser = SecurityUtils.getSubject(); ArkUser arkUser = iArkCommonService.getArkUser(currentUser.getPrincipal().toString()); ArkUserVO arkUserVo = new ArkUserVO(); arkUserVo.setArkUserEntity(arkUser); studyListForUser = iArkCommonService.getArkAuthorisationDao().getStudiesWithRoleForUser(arkUserVo, iArkCommonService.getArkAuthorisationDao().getArkRoleByName("LIMS Administrator")); } catch (EntityNotFoundException e) { log.error(e.getMessage()); } return studyListForUser; }
From source file:au.org.theark.lims.web.component.biocollectioncustomdata.BioCollectionCustomDataContainerPanel.java
License:Open Source License
protected boolean prerenderContextCheck() { // Get the Study, SubjectUID and ArkModule from Context Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Long sessionBioCollectionId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.lims.web.Constants.BIO_COLLECTION); Long sessionArkModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); boolean contextLoaded = false; if ((sessionStudyId != null) && (sessionBioCollectionId != null)) { BioCollection bioCollection = null; ArkModule arkModule = null;//w w w .j a v a2 s. c o m Study study = null; try { study = iArkCommonService.getStudy(sessionStudyId); cpModel.getObject().getBioCollection().setStudy(study); bioCollection = iLimsService.getBioCollection(sessionBioCollectionId); cpModel.getObject().setBioCollection(bioCollection); arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); // cpModel.getObject().setArkModule(arkModule); if (study != null && bioCollection != null && arkModule != null) { contextLoaded = true; //cpModel.getObject().setArkFunction(iArkCommonService.getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_LIMS_COLLECTION)); cpModel.getObject().setArkFunction(iArkCommonService.getArkFunctionByName( au.org.theark.core.Constants.FUNCTION_KEY_VALUE_LIMS_CUSTOM_FIELD)); } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } } return contextLoaded; }
From source file:au.org.theark.lims.web.component.biospecimen.batchaliquot.form.BatchAliquotBiospecimenForm.java
License:Open Source License
private boolean onSave(AjaxRequestTarget target) { List<Biospecimen> biospecimenList = new ArrayList<Biospecimen>(0); if (validatedList()) { if (totalQuantityLessThanParentQuantity()) { // Loop through entire list for (Biospecimen biospecimen : getModelObject().getAliquots()) { biospecimen.setBioCollection(getModelObject().getParentBiospecimen().getBioCollection()); biospecimen.setSampleType(getModelObject().getParentBiospecimen().getSampleType()); biospecimen.setSampleDate(new Date()); biospecimen.setStudy(getModelObject().getParentBiospecimen().getStudy()); biospecimen.setLinkSubjectStudy(getModelObject().getParentBiospecimen().getLinkSubjectStudy()); Set<BioTransaction> bioTransactions = new HashSet<BioTransaction>(0); // Inheriently create a transaction for the initial quantity BioTransaction bioTransaction = new BioTransaction(); bioTransaction.setUnit(biospecimen.getUnit()); //TODO: soon in web form bioTransaction.setBiospecimen(biospecimen); bioTransaction.setTransactionDate(Calendar.getInstance().getTime()); bioTransaction.setQuantity(biospecimen.getQuantity()); bioTransaction/*w ww .j ava 2 s . c o m*/ .setReason(au.org.theark.lims.web.Constants.BIOTRANSACTION_STATUS_INITIAL_QUANTITY); bioTransaction.setRecorder(SecurityUtils.getSubject().getPrincipal().toString()); BioTransactionStatus initialStatus = iLimsService.getBioTransactionStatusByName( au.org.theark.lims.web.Constants.BIOTRANSACTION_STATUS_INITIAL_QUANTITY); bioTransaction.setStatus(initialStatus); //ensure that the initial transaction can be identified bioTransactions.add(bioTransaction); biospecimen.setBioTransactions(bioTransactions); if (biospecimen.getStudy().getAutoGenerateBiospecimenUid()) { biospecimen.setBiospecimenUid( iLimsService.getNextGeneratedBiospecimenUID(biospecimen.getStudy())); } biospecimenList.add(biospecimen); } } StringBuffer message = new StringBuffer(); message.append("Created "); message.append(getModelObject().getNumberToCreate()); message.append(" "); message.append("biospecimen aliquots"); if (!biospecimenList.isEmpty()) { info("Batch aliquots created:"); log.info("Attempting to create " + getModelObject().getAliquots().size() + " biospecimen aliquots"); iLimsService.batchAliquotBiospecimens(biospecimenList); } return true; } else { return false; } }
From source file:au.org.theark.lims.web.component.biospecimen.batchcreate.form.AutoGenBatchCreateBiospecimenForm.java
License:Open Source License
@Override public void onBeforeRender() { // 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 ww w. j a va2s.com 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); } } super.onBeforeRender(); visitChildren(formVisitor); feedbackPanel.clearOriginalDestination(); }
From source file:au.org.theark.lims.web.component.biospecimen.batchcreate.form.ManualBatchCreateBiospecimenForm.java
License:Open Source License
@Override public void onBeforeRender() { // 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 ww w . j a v a2 s .c om*/ 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); } } super.onBeforeRender(); visitChildren(formVisitor); }
From source file:au.org.theark.lims.web.component.biospecimen.BiospecimenContainerPanel.java
License:Open Source License
public BiospecimenContainerPanel(String id, WebMarkupContainer arkContextMarkup, WebMarkupContainer studyNameMarkup, WebMarkupContainer studyLogoMarkup, DefaultTreeModel treeModel) { super(id);/* w w w. j a va2 s .co m*/ this.arkContextMarkup = arkContextMarkup; this.studyNameMarkup = studyNameMarkup; this.studyLogoMarkup = studyLogoMarkup; limsVO.setTreeModel(treeModel); // Get session data (used for subject search) Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(sessionStudyId); limsVO.setStudy(study); cpModel = new CompoundPropertyModel<LimsVO>(limsVO); arkCrudContainerVO = new ArkCrudContainerVO(); initialisePanel(); }
From source file:au.org.theark.lims.web.component.biospecimen.form.BiospecimenListForm.java
License:Open Source License
private void setContextItems(AjaxRequestTarget target, LinkSubjectStudy linkSubjectStudy) { SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID, linkSubjectStudy.getStudy().getId()); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID, linkSubjectStudy.getPerson().getId()); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.PERSON_TYPE, au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_SUBJECT); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.SUBJECTUID, linkSubjectStudy.getSubjectUID()); ContextHelper contextHelper = new ContextHelper(); contextHelper.setStudyContextLabel(target, linkSubjectStudy.getStudy().getName(), arkContextMarkup); contextHelper.setSubjectContextLabel(target, linkSubjectStudy.getSubjectUID(), arkContextMarkup); contextHelper.setSubjectNameContextLabel(target, linkSubjectStudy.getPerson().getFullName(), arkContextMarkup);/* w w w . j a v a 2 s. c o m*/ // Set Study Logo StudyHelper studyHelper = new StudyHelper(); studyHelper.setStudyLogo(linkSubjectStudy.getStudy(), target, studyNameMarkup, studyLogoMarkup, iArkCommonService); }