List of usage examples for org.apache.shiro SecurityUtils getSubject
public static Subject getSubject()
From source file:au.org.theark.study.web.component.subject.SearchResultListPanel.java
License:Open Source License
private AjaxLink buildLink(Item<SubjectVO> item, final AbstractDetailModalWindow modalWindow, final List<RelationshipVo> relatives, final FeedbackPanel feedbackPanel) { AjaxLink link = null;/* w ww . j a v a 2 s .c om*/ final SubjectVO subject = item.getModelObject(); if ("Male".equalsIgnoreCase(subject.getLinkSubjectStudy().getPerson().getGenderType().getName())) { subject.setParentType("Father"); } else { subject.setParentType("Mother"); } Boolean inbreedAllowed = (Boolean) SecurityUtils.getSubject().getSession() .getAttribute(Constants.INBREED_ALLOWED); if (BooleanUtils.isTrue(inbreedAllowed)) { final String result = getCircularRelationships(subject, relatives); item.getModelObject().setMessage(result); if (isConsiderParentAge(subject) && result != null) { link = new AjaxConfirmLink(Constants.SUBJECT_UID, new StringResourceModel("pedigree.parent.dob.circular.warning", this, item.getModel()), item.getModel()) { @Override public void onClick(AjaxRequestTarget target) { processParentSelection(subject, modalWindow, relatives, feedbackPanel, target); } }; } else if (isConsiderParentAge(subject)) { link = new AjaxConfirmLink(Constants.SUBJECT_UID, new StringResourceModel("pedigree.parent.dob.warning", this, item.getModel()), item.getModel()) { @Override public void onClick(AjaxRequestTarget target) { processParentSelection(subject, modalWindow, relatives, feedbackPanel, target); } }; } else if (result != null) { link = new AjaxConfirmLink(Constants.SUBJECT_UID, new StringResourceModel("pedigree.parent.circular.warning", this, item.getModel()), item.getModel()) { @Override public void onClick(AjaxRequestTarget target) { processParentSelection(subject, modalWindow, relatives, feedbackPanel, target); } }; } else { link = new ArkBusyAjaxLink(Constants.SUBJECT_UID) { @Override public void onClick(AjaxRequestTarget target) { processParentSelection(subject, modalWindow, relatives, feedbackPanel, target); } }; } } else { if (isConsiderParentAge(subject)) { link = new AjaxConfirmLink(Constants.SUBJECT_UID, new StringResourceModel("pedigree.parent.dob.warning", this, item.getModel()), item.getModel()) { @Override public void onClick(AjaxRequestTarget target) { processParentSelection(subject, modalWindow, relatives, feedbackPanel, target); } }; } else { link = new ArkBusyAjaxLink(Constants.SUBJECT_UID) { @Override public void onClick(AjaxRequestTarget target) { processParentSelection(subject, modalWindow, relatives, feedbackPanel, target); } }; } } Label nameLinkLabel = new Label(Constants.SUBJECT_KEY_LBL, subject.getLinkSubjectStudy().getSubjectUID()); link.add(nameLinkLabel); return link; }
From source file:au.org.theark.study.web.component.subject.SearchResultListPanel.java
License:Open Source License
/** * Create new parent relationship in database for valid relationship. * /* ww w .jav a2 s . c o m*/ * @param subject * @param modalWindow * @param relatives * @param feedbackPanel * @param target */ private void processParentSelection(final SubjectVO subject, final AbstractDetailModalWindow modalWindow, final List<RelationshipVo> relatives, final FeedbackPanel feedbackPanel, AjaxRequestTarget target) { String message; Boolean inbreedAllowed = (Boolean) SecurityUtils.getSubject().getSession() .getAttribute(Constants.INBREED_ALLOWED); if (BooleanUtils.isNotTrue(inbreedAllowed) && (message = getCircularRelationships(subject, relatives)) != null && message.length() > 0) { this.error(message); target.add(feedbackPanel); return; } LinkSubjectPedigree pedigreeRelationship = new LinkSubjectPedigree(); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(sessionStudyId); String subjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); String parentUID = subject.getLinkSubjectStudy().getSubjectUID(); SubjectVO criteriaSubjectVo = new SubjectVO(); criteriaSubjectVo.getLinkSubjectStudy().setStudy(study); criteriaSubjectVo.getLinkSubjectStudy().setSubjectUID(subjectUID); Collection<SubjectVO> subjects = iArkCommonService.getSubject(criteriaSubjectVo); SubjectVO subjectVo = subjects.iterator().next(); pedigreeRelationship.setSubject(subjectVo.getLinkSubjectStudy()); criteriaSubjectVo.getLinkSubjectStudy().setSubjectUID(parentUID); subjects = iArkCommonService.getSubject(criteriaSubjectVo); subjectVo = subjects.iterator().next(); pedigreeRelationship.setRelative(subjectVo.getLinkSubjectStudy()); String gender = subject.getLinkSubjectStudy().getPerson().getGenderType().getName(); List<Relationship> relationships = iArkCommonService.getFamilyRelationships(); for (Relationship relationship : relationships) { if ("Male".equalsIgnoreCase(gender) && "Father".equalsIgnoreCase(relationship.getName())) { pedigreeRelationship.setRelationship(relationship); break; } if ("Female".equalsIgnoreCase(gender) && "Mother".equalsIgnoreCase(relationship.getName())) { pedigreeRelationship.setRelationship(relationship); break; } } iStudyService.create(pedigreeRelationship); modalWindow.close(target); }
From source file:au.org.theark.study.web.component.subject.SearchResultListPanel.java
License:Open Source License
/** * @deprecated//from ww w . j a v a 2 s.c o m * * After select a parent validate the pedigree for circular relationships * and create new parent relationship in database. * * @param subject * @param modalWindow * @param relatives * @param feedbackPanel * @param target * */ private void processParentSelectionOld(final SubjectVO subject, final AbstractDetailModalWindow modalWindow, final List<RelationshipVo> relatives, final FeedbackPanel feedbackPanel, AjaxRequestTarget target, boolean inbreedAllowed) { LinkSubjectPedigree pedigreeRelationship = new LinkSubjectPedigree(); Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(sessionStudyId); String subjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); String parentUID = subject.getLinkSubjectStudy().getSubjectUID(); // Circular validation StringBuilder pedigree = new StringBuilder(); ArrayList<String> dummyParents = new ArrayList<String>(); boolean firstLine = true; List<RelationshipVo> existingRelatives = new ArrayList<RelationshipVo>(); existingRelatives.addAll(relatives); RelationshipVo proband = new RelationshipVo(); proband.setIndividualId(subjectUID); System.out.println("Existing relatives list size: " + existingRelatives.size()); for (RelationshipVo relative : existingRelatives) { System.out.println("Existing relatives UID: " + relative.getIndividualId() + " Father: " + relative.getFatherId() + " Mother:" + relative.getMotherId()); if ("Father".equalsIgnoreCase(relative.getRelationship())) { proband.setFatherId(relative.getIndividualId()); } if ("Mother".equalsIgnoreCase(relative.getRelationship())) { proband.setMotherId(relative.getIndividualId()); } } if (subject.getLinkSubjectStudy().getPerson().getGenderType().getName().startsWith("M")) { proband.setFatherId(parentUID); } else if (subject.getLinkSubjectStudy().getPerson().getGenderType().getName().startsWith("F")) { proband.setMotherId(parentUID); } existingRelatives.add(proband); List<RelationshipVo> newRelatives = iStudyService.generateSubjectPedigreeRelativeList(parentUID, sessionStudyId); RelationshipVo parent = new RelationshipVo(); parent.setIndividualId(parentUID); for (RelationshipVo relative : newRelatives) { if ("Father".equalsIgnoreCase(relative.getRelationship())) { parent.setFatherId(relative.getIndividualId()); } if ("Mother".equalsIgnoreCase(relative.getRelationship())) { parent.setMotherId(relative.getIndividualId()); } } newRelatives.add(parent); for (RelationshipVo relative : newRelatives) { if (!existingRelatives.contains(relative)) { existingRelatives.add(relative); } else { for (RelationshipVo existingRelative : existingRelatives) { if (relative.getIndividualId().equals(existingRelative.getIndividualId())) { if (existingRelative.getFatherId() == null) { existingRelative.setFatherId(relative.getFatherId()); } if (existingRelative.getMotherId() == null) { existingRelative.setMotherId(relative.getMotherId()); } } } } } for (RelationshipVo relative : existingRelatives) { String dummyParent = "D-"; String father = relative.getFatherId(); String mother = relative.getMotherId(); String individual = relative.getIndividualId(); if (father != null) { dummyParent = dummyParent + father; } if (mother != null) { dummyParent = dummyParent + mother; } if (!"D-".equals(dummyParent) && !dummyParents.contains(dummyParent)) { dummyParents.add(dummyParent); if (father != null) { if (firstLine) { pedigree.append(father + " " + dummyParent); firstLine = false; } else { pedigree.append("\n" + father + " " + dummyParent); } } if (mother != null) { if (firstLine) { pedigree.append(mother + " " + dummyParent); firstLine = false; } else { pedigree.append("\n" + mother + " " + dummyParent); } } pedigree.append("\n" + dummyParent + " " + individual); } else if (!"D-".equals(dummyParent)) { if (firstLine) { pedigree.append(dummyParent + " " + individual); firstLine = false; } else { pedigree.append("\n" + dummyParent + " " + individual); } } } // TODO comment this block to disable circular validations for inbred // relatives if (!inbreedAllowed) { Set<String> circularUIDs = PedigreeUploadValidator.getCircularUIDs(pedigree); if (circularUIDs.size() > 0) { this.error("Performing this action will create a circular relationship in the pedigree."); StringBuffer sb = new StringBuffer( "The proposed action will cause a pedigree cycle involving subjects with UID:"); boolean first = true; for (String uid : circularUIDs) { if (first) { sb.append(uid); first = false; } else { sb.append(", " + uid); } } sb.append("."); this.error(sb.toString()); target.add(feedbackPanel); return; } } // Assign new parent relationships SubjectVO criteriaSubjectVo = new SubjectVO(); criteriaSubjectVo.getLinkSubjectStudy().setStudy(study); criteriaSubjectVo.getLinkSubjectStudy().setSubjectUID(subjectUID); Collection<SubjectVO> subjects = iArkCommonService.getSubject(criteriaSubjectVo); SubjectVO subjectVo = subjects.iterator().next(); pedigreeRelationship.setSubject(subjectVo.getLinkSubjectStudy()); criteriaSubjectVo.getLinkSubjectStudy().setSubjectUID(parentUID); subjects = iArkCommonService.getSubject(criteriaSubjectVo); subjectVo = subjects.iterator().next(); pedigreeRelationship.setRelative(subjectVo.getLinkSubjectStudy()); String gender = subject.getLinkSubjectStudy().getPerson().getGenderType().getName(); List<Relationship> relationships = iArkCommonService.getFamilyRelationships(); for (Relationship relationship : relationships) { if ("Male".equalsIgnoreCase(gender) && "Father".equalsIgnoreCase(relationship.getName())) { pedigreeRelationship.setRelationship(relationship); break; } if ("Female".equalsIgnoreCase(gender) && "Mother".equalsIgnoreCase(relationship.getName())) { pedigreeRelationship.setRelationship(relationship); break; } } iStudyService.create(pedigreeRelationship); modalWindow.close(target); }
From source file:au.org.theark.study.web.component.subject.SearchResultListPanel.java
License:Open Source License
/** * Check for circular relationships among the given relative list. * /*from w w w. j av a2 s. c o m*/ * @param subject * @param relatives * @return */ private String getCircularRelationships(final SubjectVO subject, final List<RelationshipVo> relatives) { Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); String subjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); String parentUID = subject.getLinkSubjectStudy().getSubjectUID(); List<RelationshipVo> existingRelatives = new ArrayList<RelationshipVo>(); existingRelatives.addAll(relatives); RelationshipVo proband = new RelationshipVo(); proband.setIndividualId(subjectUID); for (RelationshipVo relative : existingRelatives) { if ("Father".equalsIgnoreCase(relative.getRelationship())) { proband.setFatherId(relative.getIndividualId()); } if ("Mother".equalsIgnoreCase(relative.getRelationship())) { proband.setMotherId(relative.getIndividualId()); } } if (subject.getLinkSubjectStudy().getPerson().getGenderType().getName().startsWith("M")) { proband.setFatherId(parentUID); } else if (subject.getLinkSubjectStudy().getPerson().getGenderType().getName().startsWith("F")) { proband.setMotherId(parentUID); } existingRelatives.add(proband); List<RelationshipVo> newRelatives = iStudyService.generateSubjectPedigreeRelativeList(parentUID, sessionStudyId); RelationshipVo parent = new RelationshipVo(); parent.setIndividualId(parentUID); for (RelationshipVo relative : newRelatives) { if ("Father".equalsIgnoreCase(relative.getRelationship())) { parent.setFatherId(relative.getIndividualId()); } if ("Mother".equalsIgnoreCase(relative.getRelationship())) { parent.setMotherId(relative.getIndividualId()); } } newRelatives.add(parent); for (RelationshipVo relative : newRelatives) { if (!existingRelatives.contains(relative)) { existingRelatives.add(relative); } else { for (RelationshipVo existingRelative : existingRelatives) { if (relative.getIndividualId().equals(existingRelative.getIndividualId())) { if (existingRelative.getFatherId() == null) { existingRelative.setFatherId(relative.getFatherId()); } if (existingRelative.getMotherId() == null) { existingRelative.setMotherId(relative.getMotherId()); } } } } } StringBuilder pedigree = PedigreeUploadValidator.generatePedigreeGraph(existingRelatives); Set<String> circularUIDs = PedigreeUploadValidator.getCircularUIDs(pedigree); if (circularUIDs.size() > 0) { StringBuffer sb = new StringBuffer( "Setting this relationship lead to consanguineous pedigree structure among following subject UIDs:"); boolean first = true; for (String uid : circularUIDs) { if (first) { sb.append(uid); first = false; } else { sb.append(", " + uid); } } sb.append("."); return sb.toString(); } return null; }
From source file:au.org.theark.study.web.component.subject.SubjectContainerPanel.java
License:Open Source License
/** * @param id/* w ww. j a va 2s . c o m*/ * @param studyLogoMarkup * @param studyNameMarkup */ public SubjectContainerPanel(String id, WebMarkupContainer arkContextMarkup, WebMarkupContainer studyNameMarkup, WebMarkupContainer studyLogoMarkup) { super(id); this.arkContextMarkup = arkContextMarkup; this.studyNameMarkup = studyNameMarkup; this.studyLogoMarkup = studyLogoMarkup; /* Initialise the CPM */ cpModel = new CompoundPropertyModel<SubjectVO>(new SubjectVO()); // Restrict to subjects in current study in session sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null) { study = iArkCommonService.getStudy(sessionStudyId); List<Study> studyListForUser = iArkCommonService.getParentAndChildStudies(sessionStudyId); cpModel.getObject().setStudyList(studyListForUser); } containerForm = new ContainerForm("containerForm", cpModel); containerForm.add(initialiseFeedBackPanel()); containerForm.add(initialiseDetailPanel()); containerForm.add(initialiseSearchResults()); containerForm.add(initialiseSearchPanel()); prerenderContextCheck(); add(containerForm); }
From source file:au.org.theark.study.web.component.subject.SubjectContainerPanel.java
License:Open Source License
/** * Re-use in pedigree panel/* w ww . j av a 2s . co m*/ * * @param id * @param studyLogoMarkup * @param studyNameMarkup * @param modalWindow */ public SubjectContainerPanel(String id, WebMarkupContainer arkContextMarkup, WebMarkupContainer studyNameMarkup, WebMarkupContainer studyLogoMarkup, AbstractDetailModalWindow modalWindow, String gender, List<RelationshipVo> relatives) { super(id); this.arkContextMarkup = arkContextMarkup; this.studyNameMarkup = studyNameMarkup; this.studyLogoMarkup = studyLogoMarkup; /* Initialise the CPM */ SubjectVO subjectVO = new SubjectVO(); subjectVO.setEnableNewButton(false); cpModel = new CompoundPropertyModel<SubjectVO>(subjectVO); // Restrict to subjects in current study in session sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null) { study = iArkCommonService.getStudy(sessionStudyId); List<Study> studyListForUser = iArkCommonService.getParentAndChildStudies(sessionStudyId); cpModel.getObject().setStudyList(studyListForUser); } containerForm = new ContainerForm("containerForm", cpModel); containerForm.add(initialiseFeedBackPanel()); containerForm.add(initialiseSearchResults(modalWindow, gender, relatives)); containerForm.add(initialiseSearchPanel()); arkCrudContainerVO.getSearchPanelContainer().get("searchComponentPanel").get("searchForm").get("genderType") .setEnabled(false); arkCrudContainerVO.getSearchPanelContainer().get("searchComponentPanel").get("searchForm").get("study") .setEnabled(false); add(containerForm); }
From source file:au.org.theark.study.web.component.subject.SubjectContainerPanel.java
License:Open Source License
@SuppressWarnings("unchecked") protected void prerenderContextCheck() { // Get the Person in Context and determine the Person Type Long sessionPersonId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID); if ((sessionStudyId != null) && (sessionPersonId != null)) { String sessionPersonType = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.PERSON_TYPE); if (sessionPersonType.equals(au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_SUBJECT)) { Person person;//w w w. j a va2 s . c om boolean contextLoaded = false; try { person = studyService.getPerson(sessionPersonId); SubjectVO subjectVO = new SubjectVO(); subjectVO.getLinkSubjectStudy().setPerson(person); // must // have // Person subjectVO.getLinkSubjectStudy().setStudy(study); // must // have // Study List<SubjectVO> subjectList = (List<SubjectVO>) iArkCommonService.getSubject(subjectVO); subjectList.get(0).setStudyList(cpModel.getObject().getStudyList()); containerForm.setModelObject(subjectList.get(0)); contextLoaded = true; } catch (EntityNotFoundException e) { log.error(e.getMessage()); } catch (ArkSystemException e) { log.error(e.getMessage()); } if (contextLoaded) { // Available/assigned child studies List<Study> availableChildStudies = new ArrayList<Study>(0); List<Study> selectedChildStudies = new ArrayList<Study>(0); if (containerForm.getModelObject().getLinkSubjectStudy().getStudy().getParentStudy() != null) { availableChildStudies = iStudyService.getChildStudyListOfParent( containerForm.getModelObject().getLinkSubjectStudy().getStudy()); selectedChildStudies = iArkCommonService.getAssignedChildStudyListForPerson( containerForm.getModelObject().getLinkSubjectStudy().getStudy(), containerForm.getModelObject().getLinkSubjectStudy().getPerson()); } containerForm.getModelObject().setAvailableChildStudies(availableChildStudies); containerForm.getModelObject().setSelectedChildStudies(selectedChildStudies); // Put into Detail View mode arkCrudContainerVO.getSearchPanelContainer().setVisible(false); arkCrudContainerVO.getSearchResultPanelContainer().setVisible(false); arkCrudContainerVO.getDetailPanelContainer().setVisible(true); arkCrudContainerVO.getDetailPanelFormContainer().setEnabled(false); arkCrudContainerVO.getEditButtonContainer().setVisible(false); } } } }
From source file:au.org.theark.study.web.component.subject.SubjectContainerPanel.java
License:Open Source License
@SuppressWarnings("unchecked") protected WebMarkupContainer initialiseSearchResults(AbstractDetailModalWindow modalWindow, final String gender, final List<RelationshipVo> relatives) { searchResultsPanel = new SearchResultListPanel("searchResults", arkContextMarkup, containerForm, arkCrudContainerVO, studyNameMarkup, studyLogoMarkup); searchResultsPanel.setOutputMarkupId(true); if (sessionStudyId != null) { LinkSubjectStudy linkSubjectStudy = new LinkSubjectStudy(); linkSubjectStudy.setStudy(study); // containerForm.getModelObject().setLinkSubjectStudy(linkSubjectStudy); }/*from w w w . java 2s . c o m*/ // Data providor to paginate resultList subjectProvider = new ArkDataProvider<SubjectVO, IArkCommonService>(iArkCommonService) { private static final long serialVersionUID = 1L; private GenderType genderType; { Collection<GenderType> genderTypes = service.getGenderTypes(); for (GenderType type : genderTypes) { if (gender.equalsIgnoreCase(type.getName())) { this.genderType = type; break; } } } public int size() { String subjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); model.getObject().getRelativeUIDs().add(subjectUID); // TODO comment this block to check inbred relatives Boolean inbreedAllowed = (Boolean) SecurityUtils.getSubject().getSession() .getAttribute(Constants.INBREED_ALLOWED); if (BooleanUtils.isNotTrue(inbreedAllowed)) { for (RelationshipVo relationshipVo : relatives) { model.getObject().getRelativeUIDs().add(relationshipVo.getIndividualId()); } } else { List<RelationshipVo> childRelatives = iStudyService.getSubjectChildren(subjectUID, sessionStudyId); for (RelationshipVo relationshipVo : childRelatives) { model.getObject().getRelativeUIDs().add(relationshipVo.getIndividualId()); } } model.getObject().getLinkSubjectStudy().getPerson().setGenderType(genderType); return (int) service.getStudySubjectCount(model.getObject()); } public Iterator<SubjectVO> iterator(int first, int count) { List<SubjectVO> listSubjects = new ArrayList<SubjectVO>(); if (isActionPermitted()) { model.getObject().getLinkSubjectStudy().getPerson().setGenderType(genderType); String subjectUID = (String) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.SUBJECTUID); model.getObject().getRelativeUIDs().add(subjectUID); // TODO comment this block to check inbred relatives Boolean inbreedAllowed = (Boolean) SecurityUtils.getSubject().getSession() .getAttribute(Constants.INBREED_ALLOWED); if (BooleanUtils.isNotTrue(inbreedAllowed)) { for (RelationshipVo relationshipVo : relatives) { model.getObject().getRelativeUIDs().add(relationshipVo.getIndividualId()); } } else { List<RelationshipVo> childRelatives = iStudyService.getSubjectChildren(subjectUID, sessionStudyId); for (RelationshipVo relationshipVo : childRelatives) { model.getObject().getRelativeUIDs().add(relationshipVo.getIndividualId()); } } listSubjects = iArkCommonService.searchPageableSubjects(model.getObject(), first, count); } return listSubjects.iterator(); } }; subjectProvider.setModel(this.cpModel); dataView = searchResultsPanel.buildDataView(subjectProvider, modalWindow, relatives, feedBackPanel); dataView.setItemsPerPage(iArkCommonService.getRowsPerPage()); AjaxPagingNavigator pageNavigator = new AjaxPagingNavigator("navigator", dataView) { private static final long serialVersionUID = 1L; @Override protected void onAjaxEvent(AjaxRequestTarget target) { target.add(searchResultsPanel); } }; resultsWmc.add(pageNavigator); List<IColumn<SubjectVO>> columns = new ArrayList<IColumn<SubjectVO>>(); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("SubjectUID"), "subjectUID")); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Full Name"), "subjectFullName")); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Preferred Name"), "linkSubjectStudy.person.preferredName")); columns.add(new ExportableDateColumn<SubjectVO>(Model.of("Date Of Birth"), "linkSubjectStudy.person.dateOfBirth", au.org.theark.core.Constants.DD_MM_YYYY)); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Vital Status"), "linkSubjectStudy.person.vitalStatus.name")); columns.add( new ExportableTextColumn<SubjectVO>(Model.of("Gender"), "linkSubjectStudy.person.genderType.name")); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Subject Status"), "linkSubjectStudy.subjectStatus.name")); columns.add(new ExportableTextColumn<SubjectVO>(Model.of("Consent Status"), "linkSubjectStudy.consentStatus.name")); DataTable table = new DataTable("datatable", columns, dataView.getDataProvider(), iArkCommonService.getRowsPerPage()); List<String> headers = new ArrayList<String>(0); headers.add("SubjectUID"); headers.add("Full Name"); headers.add("Preferred Name"); headers.add("Date of Birth"); headers.add("Vital Status"); headers.add("Gender"); headers.add("Subject Status"); headers.add("Consent Status"); String filename = study.getName() + "_subjects"; RepeatingView toolbars = new RepeatingView("toolbars"); ExportToolbar<String> exportToolBar = new ExportToolbar<String>(table, headers, filename); toolbars.add(new Component[] { exportToolBar }); resultsWmc.add(toolbars); resultsWmc.add(dataView); searchResultsPanel.add(resultsWmc); arkCrudContainerVO.getSearchResultPanelContainer().add(searchResultsPanel); return arkCrudContainerVO.getSearchResultPanelContainer(); }
From source file:au.org.theark.study.web.component.subjectcustomdata.SubjectCustomDataContainerPanel.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;//from ww w . j av a 2 s . c om Study study = null; try { study = iArkCommonService.getStudy(sessionStudyId); cpModel.getObject().getLinkSubjectStudy().setStudy(study); linkSubjectStudy = iArkCommonService.getSubjectByUID(sessionSubjectUID, study); cpModel.getObject().setLinkSubjectStudy(linkSubjectStudy); arkModule = iArkCommonService.getArkModuleById(sessionArkModuleId); // cpModel.getObject().setArkModule(arkModule); if (study != null && linkSubjectStudy != null && arkModule != null) { contextLoaded = true; cpModel.getObject().setArkFunction(iArkCommonService.getArkFunctionByName( au.org.theark.core.Constants.FUNCTION_KEY_VALUE_SUBJECT_CUSTOM_FIELD)); customFieldCriteria.setStudy(study); customFieldCriteria.setArkFunction(cpModel.getObject().getArkFunction()); //Get the subject persistance object from the custom field type. customFieldCriteria.setCustomFieldType( iArkCommonService.getCustomFieldTypeByName(au.org.theark.core.Constants.SUBJECT)); } } catch (EntityNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return contextLoaded; }
From source file:au.org.theark.study.web.component.subjectUpload.form.SearchForm.java
License:Open Source License
@Override protected void onSearch(AjaxRequestTarget target) { target.add(feedbackPanel);/* w w w . ja v a2s .com*/ Long studyId = (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(studyId); Upload searchUpload = getModelObject().getUpload(); searchUpload.setStudy(study); java.util.Collection<Upload> uploadCollection = iArkCommonService.searchUploads(searchUpload); if (uploadCollection != null && uploadCollection.size() == 0) { this.info("Uploads with the specified search criteria do not exist in the system."); target.add(feedbackPanel); } getModelObject().setUploadCollection(uploadCollection); listView.removeAll(); arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true);// Make the WebMarkupContainer that houses the search results visible target.add(arkCrudContainerVO.getSearchResultPanelContainer()); }