List of usage examples for org.apache.shiro SecurityUtils getSubject
public static Subject getSubject()
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.form.DetailForm.java
License:Open Source License
/** * Constructor/*from w ww. j a va 2 s.co m*/ * * @param id * @param cpModel * @param feedBackPanel * @param arkCrudContainerVO */ public DetailForm(String id, CompoundPropertyModel<PhenoDataSetFieldVO> cpModel, FeedbackPanel feedBackPanel, ArkCrudContainerVO arkCrudContainerVO) { super(id, feedBackPanel, cpModel, arkCrudContainerVO); cfGroupDdcListModel = new ListModel<PhenoDataSetGroup>(); refreshEntityFromBackend(); Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); study = cpModel.getObject().getPhenoDataSetField().getStudy(); //arkFunction=iArkCommonService.getArkFunctionByName(au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_FIELD_CATEGORY); }
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.form.DetailForm.java
License:Open Source License
/** * Call this after the constructor is finished in detail panel. *//*from www . j av a 2 s .co m*/ public void initialiseDetailForm() { Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); arkModule = iArkCommonService.getArkModuleById(sessionModuleId); fieldIdTxtFld = new TextField<String>(Constants.FIELDVO_PHENODATASET_ID); fieldNameTxtFld = new TextField<String>(Constants.FIELDVO_PHENODATASET_NAME); fieldNameTxtFld.add(new ArkDefaultFormFocusBehavior()); fieldDescriptionTxtAreaFld = new TextArea<String>(Constants.FIELDVO_PHENODATASET_DESCRIPTION); fieldLabelTxtAreaFld = new TextArea<String>(Constants.FIELDVO_PHENODATASET_FIELD_LABEL); //fieldMissingValueTxtFld = new TextField<String>(Constants.FIELDVO_CUSTOMFIELD_MISSING_VALUE); fieldDisplayRequiredChkBox = new CheckBox(Constants.FIELDVO_PHENODATASET_REQUIRED); fieldAllowMultiselectChkBox = new CheckBox(Constants.FIELDVO_PHENODATASET_ALLOW_MULTIPLE_SELECTION) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return (fieldEncodedValuesTxtFld.getModelObject() != null); } }; fieldMultLineDisplayChkBox = new CheckBox(Constants.FIELDVO_PHENODATASET_MULTILINE_DISPLAY) { private static final long serialVersionUID = 1L; @Override public boolean isEnabled() { return (fieldEncodedValuesTxtFld.getModelObject() == null && (fieldTypeDdc.getModelObject() != null && fieldTypeDdc.getModelObject().getName().equals(Constants.FIELD_TYPE_CHARACTER))); } }; fieldMultLineDisplayChkBox.setEnabled(false); /*if (getModelObject().isUsePhenoDataSetFieldDisplay()) { // TODO: Have not implemented position support right now phenoDataSetDisplayPositionPanel = new EmptyPanel("phenoDataSetFieldDisplayPositionPanel"); } else { phenoDataSetDisplayPositionPanel = new EmptyPanel("phenoDataSetFieldDisplayPositionPanel"); } */ phenoDataSetDisplayPositionPanel = new EmptyPanel("phenoDataSetFieldDisplayPositionPanel"); // Initialise Drop Down Choices initFieldTypeDdc(); initUnitTypeDdc(); // Min and Max Value panels rely on fieldTypeDdc being already established minMaxValueEntryWMC = new WebMarkupContainer("minMaxValueEntryWMC"); minMaxValueEntryWMC.setOutputMarkupPlaceholderTag(true); missingValueEntryWMC = new WebMarkupContainer("missingValueEntryWMC"); missingValueEntryWMC.setOutputMarkupPlaceholderTag(true); defaultValueEntryWMC = new WebMarkupContainer("defaultValueEntryWMC"); defaultValueEntryWMC.setOutputMarkupPlaceholderTag(true); // unitType and encodedValues rely on fieldTypeDdc being already established fieldEncodedValuesTxtFld = new TextArea<String>(Constants.FIELDVO_PHENODATASET_ENCODED_VALUES); fieldEncodedValuesTxtFld.setOutputMarkupId(true); fieldEncodedValuesTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { target.add(fieldAllowMultiselectChkBox); target.add(fieldMultLineDisplayChkBox); } }); updateEncodedValueFld(); updateUnitTypeDdc(); // Have to Edit, before allowing delete deleteButton.setEnabled(false); //defaultValueTextArea = new TextArea<String>(Constants.FIELDVO_PHENODATASET_DEFAULT_VALUE); addDetailFormComponents(); attachValidators(); initMinMaxValuePnls(); historyButtonPanel = new HistoryButtonPanel(this, arkCrudContainerVO.getEditButtonContainer(), arkCrudContainerVO.getDetailPanelFormContainer(), feedBackPanel); }
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.form.SearchForm.java
License:Open Source License
/** * @param id/*from w w w . j av a 2s .c o m*/ */ public SearchForm(String id, CompoundPropertyModel<PhenoDataSetFieldVO> cpModel, FeedbackPanel feedBackPanel, ArkCrudContainerVO arkCrudContainerVO) { super(id, cpModel, feedBackPanel, arkCrudContainerVO); //this.unitTypeDropDownOn = unitTypeDropDownOn; this.cpModel = cpModel; this.feedbackPanel = feedBackPanel; this.arkCrudContainerVO = arkCrudContainerVO; Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); arkModule = iArkCommonService.getArkModuleById(sessionModuleId); //this.subjectCustomField = subjectCustomField; initialiseFieldForm(); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); disableSearchForm(sessionStudyId, "There is no study in context. Please select a study"); }
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.form.SearchForm.java
License:Open Source License
@Override protected void onSearch(AjaxRequestTarget target) { target.add(feedbackPanel);// w w w. jav a 2 s . co m final Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); // Get a list of all Fields for the Study in context Study study = iArkCommonService.getStudy(sessionStudyId); getModelObject().getPhenoDataSetField().setStudy(study); long count = iPhenotypicService.getPhenoFieldCount(getModelObject().getPhenoDataSetField()); if (count <= 0L) { this.info("No records match the specified criteria."); target.add(feedbackPanel); } arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true); target.add(arkCrudContainerVO.getSearchResultPanelContainer()); }
From source file:au.org.theark.phenotypic.web.component.phenodatadictionary.PhenoDataDictionaryContainerPanel.java
License:Open Source License
protected void prerenderContextCheck() { // Get the Study and Module out of context Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Long sessionModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); if ((sessionStudyId != null) && (sessionModuleId != null)) { ArkModule arkModule = null;// w w w. j av a2 s . c o m Study study = null; study = iArkCommonService.getStudy(sessionStudyId); arkModule = iArkCommonService.getArkModuleById(sessionModuleId); if (study != null && arkModule != null) { cpModel.getObject().getPhenoDataSetField().setStudy(study); // TODO: Maybe check that the primary function supplied is of // the same module? } } }
From source file:au.org.theark.phenotypic.web.component.phenodataentry.form.PhenoClinicalDataValueEntryModalDetailForm.java
License:Open Source License
private void initReviewedByDdc() { String sessionUserName = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_USERID); ArkUser arkUser = null;/*from ww w. ja va 2s . com*/ try { arkUser = iArkCommonService.getArkUser(sessionUserName); } catch (EntityNotFoundException e1) { e1.printStackTrace(); } List<ArkUser> arkUserList = new ArrayList<ArkUser>(0); arkUserList = iArkCommonService.getArkUserListByStudy(arkUser, cpModel.getObject().getPhenoDataSetCollection().getLinkSubjectStudy().getStudy()); ChoiceRenderer<ArkUser> choiceRenderer = new ChoiceRenderer<ArkUser>("ldapUserName", "id"); reviewedByDdc = new DropDownChoice<ArkUser>("phenoDataSetCollection.reviewedBy", arkUserList, choiceRenderer); }
From source file:au.org.theark.phenotypic.web.component.phenodataentry.form.PhenoCollectionListForm.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;/*w ww .j a va2 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().getPhenoDataSetGroup().setStudy(study); cpModel.getObject().getPhenoDataSetCollection().setLinkSubjectStudy(linkSubjectStudy); } } super.onBeforeRender(); }
From source file:au.org.theark.phenotypic.web.component.phenodataentry.form.PhenoCollectionListForm.java
License:Open Source License
private void initialiseNewButton() { newButton = new ArkBusyAjaxButton(Constants.NEW) { private static final long serialVersionUID = 1L; @Override/* www. j a v a2s . c o m*/ public boolean isVisible() { boolean isVisible = true; String sessionSubjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); isVisible = (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.NEW) && sessionSubjectUID != null); return isVisible; } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { onNew(target); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { this.error("Unexpected error: Unable to proceed with New"); } }; newButton.setDefaultFormProcessing(false); add(newButton); }
From source file:au.org.theark.phenotypic.web.component.phenodataentry.form.PhenoCollectionListForm.java
License:Open Source License
private void initialiseGetDataButton() { getDataButton = new AjaxButton("getData") { private static final long serialVersionUID = 1L; @Override//from w w w. ja v a2 s.c om public boolean isEnabled() { return (true); } @Override public boolean isVisible() { boolean isVisible = true; String sessionSubjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); isVisible = (ArkPermissionHelper.isActionPermitted(au.org.theark.core.Constants.SEARCH) && sessionSubjectUID != null); return isVisible; } @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { if (phenoDataSetFieldGroupDdc.getValue().isEmpty() || pickedPhenoDataSetCategoryDdc.getValue().isEmpty()) { error("Please select the Dataset and Category first"); } else { LinkSubjectStudy linkSubjectStudy = cpModel.getObject().getPhenoDataSetCollection() .getLinkSubjectStudy(); List<PhenoDataSetGroup> phenoDataSetGroupList = new ArrayList<PhenoDataSetGroup>(0); PhenoDataSetGroup pdsg = iPhenotypicService .getPhenoFieldGroupById(new Long(phenoDataSetFieldGroupDdc.getValue())); phenoDataSetGroupList.add(pdsg); PhenoDataSetCategory phenoDataSetCategory = iPhenotypicService .getPhenoDataSetCategoryById(new Long(pickedPhenoDataSetCategoryDdc.getValue())); List<PhenoDataSetField> phenoSetFields = iPhenotypicService .getPhenoDataSetFieldsLinkedToPhenoDataSetFieldGroupAndPhenoDataSetCategory(pdsg, phenoDataSetCategory); List<String> subjectUids = new ArrayList<String>(0); subjectUids.add(linkSubjectStudy.getSubjectUID()); List<List<String>> dataSet = iPhenotypicService.getPhenoDataAsMatrix( linkSubjectStudy.getStudy(), subjectUids, phenoSetFields, phenoDataSetGroupList, phenoDataSetCategory); phenoDataView = new DataTablePanel("phenoDataView", dataSet); PhenoCollectionListForm.this.addOrReplace(phenoDataView); target.add(phenoDataView); } target.add(feedbackPanel); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { this.error("Unexpected error: Unable to proceed with New"); target.add(feedbackPanel); } }; getDataButton.setDefaultFormProcessing(false); add(getDataButton); }
From source file:au.org.theark.phenotypic.web.component.phenodataentry.PhenoCollectionDataEntryContainerPanel.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); String sessionSubjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); Long sessionArkModuleId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.ARK_MODULE_KEY); boolean contextLoaded = false; if ((sessionStudyId != null) && (sessionSubjectUID != null)) { LinkSubjectStudy linkSubjectStudy = null; ArkModule arkModule = null;//w ww . ja v a2 s . co m Study study = null; try { study = iArkCommonService.getStudy(sessionStudyId); linkSubjectStudy = iArkCommonService.getSubjectByUID(sessionSubjectUID, study); cpModel.getObject().getPhenoDataSetCollection().setLinkSubjectStudy(linkSubjectStudy); arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); if (study != null && linkSubjectStudy != null && arkModule != null) { contextLoaded = true; cpModel.getObject().setArkFunction(iArkCommonService.getArkFunctionByName( au.org.theark.core.Constants.FUNCTION_KEY_VALUE_PHENO_COLLECTION)); } } catch (EntityNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return contextLoaded; }