List of usage examples for org.apache.wicket.ajax AjaxRequestTarget add
void add(Component... components);
From source file:au.org.theark.study.web.component.studycomponent.form.SearchForm.java
License:Open Source License
@Override protected void onSearch(AjaxRequestTarget target) { target.add(feedbackPanel); try {// w w w. j a va2 s.com List<StudyComp> resultList = studyService.searchStudyComp(getModelObject().getStudyComponent()); if (resultList != null && resultList.size() == 0) { this.info("Study Component with the specified criteria does not exist in the system."); target.add(feedbackPanel); } getModelObject().setStudyCompList(resultList); listView.removeAll(); arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true); target.add(arkCrudContainerVO.getSearchResultPanelContainer()); } catch (ArkSystemException arkEx) { this.error("A system error has occured. Please try after sometime."); } }
From source file:au.org.theark.study.web.component.subject.form.DetailForm.java
License:Open Source License
@SuppressWarnings("unchecked") public void initialiseDetailForm() { subjectUIDTxtFld = new TextField<String>(Constants.SUBJECT_UID) { private static final long serialVersionUID = 1L; @Override//from ww w .j av a 2 s . c om protected void onBeforeRender() { boolean isNew = isNew(); boolean autoGenerate = containerForm.getModelObject().getLinkSubjectStudy().getStudy() .getAutoGenerateSubjectUid(); if (isNew && !autoGenerate) { setEnabled(true); } else { setEnabled(false); } super.onBeforeRender(); } }; subjectUIDTxtFld.setOutputMarkupId(true); firstNameTxtFld = new TextField<String>(Constants.PERSON_FIRST_NAME); middleNameTxtFld = new TextField<String>(Constants.PERSON_MIDDLE_NAME); lastNameTxtFld = new TextField<String>(Constants.PERSON_LAST_NAME); previousLastNameTxtFld = new TextField<String>(Constants.SUBJECT_PREVIOUS_LAST_NAME) { private static final long serialVersionUID = 1L; @Override protected void onBeforeRender() { if (!isNew()) { String subjectPreviousLastname = iArkCommonService .getPreviousLastname(containerForm.getModelObject().getLinkSubjectStudy().getPerson()); containerForm.getModelObject().setSubjectPreviousLastname(subjectPreviousLastname); } setEnabled(isNew()); super.onBeforeRender(); } }; preferredNameTxtFld = new TextField<String>(Constants.PERSON_PREFERRED_NAME); otherIdWebMarkupContainer = new WebMarkupContainer("otherIDWMC"); otherIdListView = new AbstractListEditor<OtherID>("linkSubjectStudy.person.otherIDs") { private static final long serialVersionUID = 1L; @Override protected void onPopulateItem(ListItem<OtherID> item) { PropertyModel<String> otherIDpropModel = new PropertyModel<String>(item.getModelObject(), "otherID"); PropertyModel<String> otherIDSourcepropModel = new PropertyModel<String>(item.getModelObject(), "otherID_Source"); TextField<String> otherIdTxtFld = new TextField<String>("otherid", otherIDpropModel); otherIdTxtFld.setRequired(true); TextField<String> otherIdSourceTxtFld = new TextField<String>("otherid_source", otherIDSourcepropModel); otherIdSourceTxtFld.setRequired(true); item.add(otherIdTxtFld); item.add(otherIdSourceTxtFld); item.add(new AjaxButton("delete") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { studyService.delete(item.getModelObject()); otherIdListView.getModelObject().remove(item.getIndex()); target.add(otherIdWebMarkupContainer); } @Override protected void onError(AjaxRequestTarget target, Form<?> form) { onSubmit(target, form); } }); item.add(new AttributeModifier(Constants.CLASS, new AbstractReadOnlyModel() { @Override public String getObject() { return (item.getIndex() % 2 == 1) ? Constants.EVEN : Constants.ODD; } })); } }; otherIdWebMarkupContainer.setOutputMarkupId(true); addNewOtherIdBtn = new AjaxButton("newOtherID") { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { OtherID newOtherID = new OtherID(); newOtherID.setPerson(containerForm.getModelObject().getLinkSubjectStudy().getPerson()); otherIdListView.getModelObject().add(newOtherID); target.add(otherIdWebMarkupContainer); super.onSubmit(target, form); } }; addNewOtherIdBtn.setDefaultFormProcessing(false); otherIdWebMarkupContainer.add(otherIdListView); otherIdWebMarkupContainer.add(addNewOtherIdBtn); preferredEmailTxtFld = new TextField<String>(Constants.PERSON_PREFERRED_EMAIL); otherEmailTxtFld = new TextField<String>(Constants.PERSON_OTHER_EMAIL); heardAboutStudyTxtFld = new TextField<String>(Constants.SUBJECT_HEARD_ABOUT_STUDY_FROM); dateOfBirthTxtFld = new DateTextField(Constants.PERSON_DOB, au.org.theark.core.Constants.DD_MM_YYYY); ArkDatePicker dobDatePicker = new ArkDatePicker(); dobDatePicker.bind(dateOfBirthTxtFld); dateOfBirthTxtFld.add(dobDatePicker); currentOrDeathageLable = new Label(Constants.PERSON_CURRENT_OR_DEATH_AGE); currentOrDeathageLable.setOutputMarkupId(true); dateOfBirthTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { //update label at date of birth change. setCurrentOrDeathAgeLabel(); setDeathDetailsContainer(); target.add(wmcDeathDetailsContainer); target.add(currentOrDeathageLable); } }); dateLastKnownAliveTxtFld = new DateTextField("linkSubjectStudy.person.dateLastKnownAlive", au.org.theark.core.Constants.DD_MM_YYYY); ArkDatePicker dateLastKnownAlivePicker = new ArkDatePicker(); dateLastKnownAlivePicker.bind(dateLastKnownAliveTxtFld); dateLastKnownAliveTxtFld.add(dateLastKnownAlivePicker); dateOfDeathTxtFld = new DateTextField(Constants.PERSON_DOD, au.org.theark.core.Constants.DD_MM_YYYY); causeOfDeathTxtFld = new TextField<String>(Constants.PERSON_CAUSE_OF_DEATH); ArkDatePicker dodDatePicker = new ArkDatePicker(); dodDatePicker.bind(dateOfDeathTxtFld); dateOfDeathTxtFld.add(dodDatePicker); dateOfDeathTxtFld.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { //update label at date of text change. setCurrentOrDeathAgeLabel(); setDeathDetailsContainer(); target.add(wmcDeathDetailsContainer); target.add(currentOrDeathageLable); } }); commentTxtAreaFld = new TextArea<String>(Constants.PERSON_COMMENT); wmcDeathDetailsContainer = new WebMarkupContainer("deathDetailsContainer"); wmcDeathDetailsContainer.setOutputMarkupId(true); // Default death details to disabled (enable onChange of vitalStatus) setDeathDetailsContainer(); // Initialise Drop Down Choices // We can also have the reference data populated on Application start // and refer to a static list instead of hitting the database // Title Collection<TitleType> titleTypeList = iArkCommonService.getTitleType(); ChoiceRenderer<TitleType> defaultChoiceRenderer = new ChoiceRenderer<TitleType>(Constants.NAME, Constants.ID); titleTypeDdc = new DropDownChoice<TitleType>(Constants.PERSON_TYTPE_TYPE, (List) titleTypeList, defaultChoiceRenderer); titleTypeDdc.add(new ArkDefaultFormFocusBehavior()); // Preferred Status Collection<EmailStatus> allEmailStatusList = iArkCommonService.getAllEmailStatuses(); ChoiceRenderer<EmailStatus> preferredEmailStatusRenderer = new ChoiceRenderer<EmailStatus>(Constants.NAME, Constants.ID); preferredEmailStatusDdc = new DropDownChoice<EmailStatus>(Constants.PERSON_PREFERRED_EMAIL_STATUS, (List<EmailStatus>) allEmailStatusList, preferredEmailStatusRenderer); // Email Status // Collection<EmailStatus> emailStatusList = iArkCommonService.getEmailStatus(); ChoiceRenderer<EmailStatus> otherEmailStatusRenderer = new ChoiceRenderer<EmailStatus>(Constants.NAME, Constants.ID); otherEmailStatusDdc = new DropDownChoice<EmailStatus>(Constants.PERSON_OTHER_EMAIL_STATUS, (List<EmailStatus>) allEmailStatusList, otherEmailStatusRenderer); // Vital Status Collection<VitalStatus> vitalStatusList = iArkCommonService.getVitalStatus(); ChoiceRenderer<VitalStatus> vitalStatusRenderer = new ChoiceRenderer<VitalStatus>(Constants.NAME, Constants.ID); vitalStatusDdc = new DropDownChoice<VitalStatus>(Constants.PERSON_VITAL_STATUS, (List<VitalStatus>) vitalStatusList, vitalStatusRenderer); vitalStatusDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { //update label at vital status change. setCurrentOrDeathAgeLabel(); setDeathDetailsContainer(); target.add(wmcDeathDetailsContainer); target.add(currentOrDeathageLable); } }); //initialise the current or death label. setCurrentOrDeathAgeLabel(); // Gender Type Collection<GenderType> genderTypeList = iArkCommonService.getGenderTypes(); ChoiceRenderer<GenderType> genderTypeRenderer = new ChoiceRenderer<GenderType>(Constants.NAME, Constants.ID); genderTypeDdc = new DropDownChoice<GenderType>(Constants.PERSON_GENDER_TYPE, (List<GenderType>) genderTypeList, genderTypeRenderer); // Subject Status List<SubjectStatus> subjectStatusList = iArkCommonService.getSubjectStatus(); ChoiceRenderer<SubjectStatus> subjectStatusRenderer = new ChoiceRenderer<SubjectStatus>(Constants.NAME, Constants.SUBJECT_STATUS_ID); subjectStatusDdc = new DropDownChoice<SubjectStatus>(Constants.SUBJECT_STATUS, subjectStatusList, subjectStatusRenderer); subjectStatusDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { if (subjectStatusDdc.getModelObject().getName().equalsIgnoreCase("Archive")) { Biospecimen biospecimenCriteria = new Biospecimen(); biospecimenCriteria.setLinkSubjectStudy(containerForm.getModelObject().getLinkSubjectStudy()); biospecimenCriteria.setStudy(containerForm.getModelObject().getLinkSubjectStudy().getStudy()); // check no biospecimens exist long count = iLimsService.getBiospecimenCount(biospecimenCriteria); if (count > 0) { error("You cannot archive this subject as there are Biospecimens associated "); target.focusComponent(subjectStatusDdc); } } processErrors(target); } }); // Marital Status Collection<MaritalStatus> maritalStatusList = iArkCommonService.getMaritalStatus(); ChoiceRenderer<MaritalStatus> maritalStatusRender = new ChoiceRenderer<MaritalStatus>(Constants.NAME, Constants.ID); maritalStatusDdc = new DropDownChoice<MaritalStatus>(Constants.PERSON_MARITAL_STATUS, (List) maritalStatusList, maritalStatusRender); // Container for preferredEmail (required when Email selected as preferred contact) wmcPreferredEmailContainer = new WebMarkupContainer("preferredEmailContainer"); wmcPreferredEmailContainer.setOutputMarkupPlaceholderTag(true); // Depends on preferredContactMethod setPreferredEmailContainer(); // Person Contact Method List<PersonContactMethod> contactMethodList = iArkCommonService.getPersonContactMethodList(); ChoiceRenderer<PersonContactMethod> contactMethodRender = new ChoiceRenderer<PersonContactMethod>( Constants.NAME, Constants.ID); personContactMethodDdc = new DropDownChoice<PersonContactMethod>(Constants.PERSON_CONTACT_METHOD, (List<PersonContactMethod>) contactMethodList, contactMethodRender); personContactMethodDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { // Check what was selected and then toggle setPreferredEmailContainer(); target.add(wmcPreferredEmailContainer); } }); initConsentFields(); attachValidators(); addDetailFormComponents(); deleteButton.setVisible(false); historyButtonPanel = new HistoryButtonPanel(containerForm, arkCrudContainerVO.getEditButtonContainer(), arkCrudContainerVO.getDetailPanelFormContainer()); }
From source file:au.org.theark.study.web.component.subject.form.DetailForm.java
License:Open Source License
@Override protected void onSave(Form<SubjectVO> containerForm, AjaxRequestTarget target) { target.add(arkCrudContainerVO.getDetailPanelContainer()); Long studyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (studyId == null) { // No study in context this.error("There is no study in Context. Please select a study to manage a subject."); processErrors(target);/*from ww w. j a v a 2s.co m*/ } else { study = iArkCommonService.getStudy(studyId); saveUpdateProcess(containerForm.getModelObject(), target); // String subjectPreviousLastname = iArkCommonService.getPreviousLastname(containerForm.getModelObject().getSubjectStudy().getPerson()); // containerForm.getModelObject().setSubjectPreviousLastname(subjectPreviousLastname); ContextHelper contextHelper = new ContextHelper(); contextHelper.resetContextLabel(target, arkContextMarkupContainer); contextHelper.setStudyContextLabel(target, study.getName(), arkContextMarkupContainer); contextHelper.setSubjectContextLabel(target, containerForm.getModelObject().getLinkSubjectStudy().getSubjectUID(), arkContextMarkupContainer); SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID, containerForm.getModelObject().getLinkSubjectStudy().getPerson().getId()); // We specify the type of person here as Subject SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.PERSON_TYPE, au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_SUBJECT); arkCrudContainerVO.getDetailPanelContainer().setVisible(true); } }
From source file:au.org.theark.study.web.component.subject.form.SearchForm.java
License:Open Source License
@SuppressWarnings("unchecked") private void initStudyDdc() { CompoundPropertyModel<SubjectVO> subjectCpm = cpmModel; PropertyModel<Study> studyPm = new PropertyModel<Study>(subjectCpm, "linkSubjectStudy.study"); ChoiceRenderer choiceRenderer = new ChoiceRenderer(Constants.NAME, Constants.ID); List<Study> studyListForUser = new ArrayList<Study>(0); try {/*ww w. j a va2 s . co m*/ 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); cpmModel.getObject().setStudyList(studyListForUser); } } catch (EntityNotFoundException e) { log.error(e.getMessage()); } ChoiceRenderer<Study> studyRenderer = new ChoiceRenderer<Study>(Constants.NAME, Constants.ID); studyDdc = new DropDownChoice<Study>("study", studyPm, (List<Study>) studyListForUser, studyRenderer); studyDdc.add(new AjaxFormComponentUpdatingBehavior("onchange") { /** * */ private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { SecurityUtils.getSubject().getSession().setAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID, studyDdc.getModelObject().getId()); ContextHelper contextHelper = new ContextHelper(); contextHelper.resetContextLabel(target, arkContextMarkup); contextHelper.setStudyContextLabel(target, studyDdc.getModelObject().getName(), arkContextMarkup); StudyHelper studyHelper = new StudyHelper(); studyHelper.setStudyLogo(studyDdc.getModelObject(), target, studyNameMarkup, studyLogoMarkup); target.add(SearchForm.this); } }); }
From source file:au.org.theark.study.web.component.subject.form.SearchForm.java
License:Open Source License
@SuppressWarnings("unchecked") protected void onNew(AjaxRequestTarget target) { // Disable SubjectUID if auto-generation set Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study studyInContext = iArkCommonService.getStudy(sessionStudyId); if ((studyInContext != null) && (studyInContext.getAutoGenerateSubjectUid())) { TextField<String> subjectUIDTxtFld = (TextField<String>) arkCrudContainerVO .getDetailPanelFormContainer().get(Constants.SUBJECT_UID); getModelObject().getLinkSubjectStudy().setSubjectUID(Constants.SUBJECT_AUTO_GENERATED); subjectUIDTxtFld.setEnabled(false); target.add(subjectUIDTxtFld); } else {/* w w w . jav a 2 s . com*/ TextField<String> subjectUIDTxtFld = (TextField<String>) arkCrudContainerVO .getDetailPanelFormContainer().get(Constants.SUBJECT_UID); subjectUIDTxtFld.setEnabled(true); target.add(subjectUIDTxtFld); } // Available child studies List<Study> availableChildStudies = new ArrayList<Study>(0); if (studyInContext.getParentStudy() != null) { availableChildStudies = iStudyService.getChildStudyListOfParent(studyInContext); } getModelObject().setAvailableChildStudies(availableChildStudies); getModelObject().getLinkSubjectStudy().getPerson().getOtherIDs().clear(); if (!otherIDTxtFld.getValue().isEmpty()) { OtherID searchedOtherID = new OtherID(); searchedOtherID.setOtherID(otherIDTxtFld.getValue()); getModelObject().getLinkSubjectStudy().getPerson().getOtherIDs().add(searchedOtherID); } preProcessDetailPanel(target); }
From source file:au.org.theark.study.web.component.subject.form.SearchForm.java
License:Open Source License
protected void onSearch(AjaxRequestTarget target) { target.add(feedbackPanel); //Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession().getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); //getModelObject().getLinkSubjectStudy().setStudy(iArkCommonService.getStudy(sessionStudyId)); //getModelObject().getLinkSubjectStudy().getStudy(); String otherIDSearch = otherIDTxtFld.getValue(); if (otherIDSearch != null) { OtherID o = new OtherID(); o.setOtherID(otherIDSearch);/*from w w w . j a v a 2 s.co m*/ List<OtherID> otherIDs = new ArrayList<OtherID>(); otherIDs.add(o); cpmModel.getObject().getLinkSubjectStudy().getPerson().getOtherIDs().clear();//setOtherIDs(otherIDs); log.info("onsearch otherids: " + cpmModel.getObject().getLinkSubjectStudy().getPerson().getOtherIDs()); cpmModel.getObject().getLinkSubjectStudy().getPerson().getOtherIDs().add(o); } long count = iArkCommonService.getStudySubjectCount(cpmModel.getObject()); if (count == 0L) { this.info("There are no subjects with the specified criteria."); target.add(feedbackPanel); } arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true); target.add(arkCrudContainerVO.getSearchResultPanelContainer());// For ajax this is required so }
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. * //from www. j ava2s.co 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 w w w . ja va2 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.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 ww .j ava 2 s.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.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()); 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.getUserConfig(au.org.theark.core.Constants.CONFIG_ROWS_PER_PAGE).getIntValue()); 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.form.CustomDataEditorForm.java
License:Open Source License
public void onEditSave(AjaxRequestTarget target, Form<?> form) { List<SubjectCustomFieldData> errorList = studyService .createOrUpdateSubjectCustomFieldData(cpModel.getObject().getCustomFieldDataList()); if (errorList.size() > 0) { for (SubjectCustomFieldData subjectCustomFieldData : errorList) { CustomField cf = subjectCustomFieldData.getCustomFieldDisplay().getCustomField(); String fieldType = cf.getFieldType().getName(); if (fieldType.equals(au.org.theark.core.web.component.customfield.Constants.DATE_FIELD_TYPE_NAME)) { this.error("Unable to save this data: " + cf.getFieldLabel() + " = " + subjectCustomFieldData.getDateDataValue()); } else { this.error("Unable to save this data: " + cf.getFieldLabel() + " = " + subjectCustomFieldData.getTextDataValue()); }//from w w w. j a v a 2 s. co m } } else { this.info("Successfully saved all edits"); } /* * Need to update the dataView, which forces a refresh of the model * objects from backend. This is because deleted fields still remain in * the model, and are stale objects if we try to use them for future * saves. */ target.add(dataViewWMC); target.add(feedbackPanel); }