public AffectionContainerPanel(String id, WebMarkupContainer arkContextMarkup) { super(id); this.arkContextMarkup = arkContextMarkup; cpModel = new CompoundPropertyModel<AffectionVO>(new AffectionVO()); sessionStudyID = (Long) SecurityUtils.getSubject().getSession().getAttribute(Constants.STUDY_CONTEXT_ID); if (sessionStudyID != null) { study = iArkCommonService.getStudy(sessionStudyID); } Long subjectSessionID = (Long) SecurityUtils.getSubject().getSession().getAttribute(Constants.PERSON_CONTEXT_ID); try { linkSubjectStudy = iArkCommonService.getSubject(subjectSessionID, study); } catch (EntityNotFoundException e) { e.printStackTrace(); } containerForm = new ContainerForm("containerForm", cpModel); containerForm.add(initialiseFeedBackPanel()); containerForm.add(initialiseDetailPanel()); containerForm.add(initialiseSearchResults()); containerForm.add(initialiseSearchPanel()); add(containerForm); }
@Override protected void onSearch(AjaxRequestTarget target) { target.add(feedbackPanel); // Set study in context 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); searchUpload.setArkFunction( iArkCommonService.getArkFunctionByName(Constants.FUNCTION_KEY_VALUE_DATA_DICTIONARY)); Collection<Upload> uploadCollection = iArkCommonService.searchUploads(searchUpload); if (uploadCollection != null && uploadCollection.size() == 0) { this.info("Uploads with the specified criteria does not exist in the system."); target.add(feedbackPanel); } getModelObject().setUploadCollection(uploadCollection); listView.removeAll(); arkCrudContainerVO.getSearchResultPanelContainer().setVisible(true); target.add(arkCrudContainerVO.getSearchResultPanelContainer()); }
/** @param id */ public SubjectSubMenuTab(String id, WebMarkupContainer arkContextMarkup) { super(id); this.arkContextMarkup = arkContextMarkup; new ArrayList<ITab>(); buildTabs(); Long sessionStudyId = (Long) SecurityUtils.getSubject() .getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(sessionStudyId); childStudy = study.getParentStudy() != null && (study != study.getParentStudy()); }
/* * (non-Javadoc) * * @see au.org.theark.core.web.form.AbstractDetailForm#onSave(org.apache.wicket.markup.html.form.Form, org.apache.wicket.ajax.AjaxRequestTarget) */ @Override protected void onSave(Form<CustomFieldGroupVO> containerForm, AjaxRequestTarget target) { if (getModelObject().getCustomFieldGroup().getId() == null) { // Create ArkFunction arkFunction = iArkCommonService.getArkFunctionByName( au.org.theark.core.Constants.FUNCTION_KEY_VALUE_PHENO_COLLECTION); Long studyId = (Long) SecurityUtils.getSubject() .getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(studyId); getModelObject().getCustomFieldGroup().setArkFunction(arkFunction); getModelObject().getCustomFieldGroup().setStudy(study); try { iPhenotypicService.createCustomFieldGroup(getModelObject()); initCustomFieldDataListPanel(); this.info("Data Set has been created successfully."); } catch (EntityExistsException e) { this.error("A Data Set with the same name already exisits. Please choose a unique one."); } catch (ArkSystemException e) { this.error("A System error occured. Please contact Administrator."); } } else { try { iPhenotypicService.updateCustomFieldGroup(getModelObject()); initCustomFieldDataListPanel(); this.info("Data Set has been updated successfully."); } catch (EntityExistsException e) { this.error("A Data Set with the same name already exisits. Please choose a unique one."); e.printStackTrace(); } catch (ArkSystemException e) { this.error("A System error occured. Please contact Administrator."); e.printStackTrace(); } } target.add( arkCrudContainerVO .getWmcForCustomFieldDisplayListPanel()); // Repaint this List of Custom Field Displays onSavePostProcess(target); // Post process }
@SuppressWarnings("unchecked") private void setSelectedCustomFieldsFromFile() { if (fileUploadField.getFileUpload() != null) { ArkFunction arkFunction = iArkCommonService.getArkFunctionByName( au.org.theark.core.Constants.FUNCTION_KEY_VALUE_PHENO_COLLECTION); Long studyId = (Long) SecurityUtils.getSubject() .getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(studyId); ArrayList<CustomField> selectedCustomFields = (ArrayList<CustomField>) iArkCommonService.matchCustomFieldsFromInputFile( fileUploadField.getFileUpload(), study, arkFunction); cpModel.getObject().setSelectedCustomFields(selectedCustomFields); } initCustomFieldPalette(); arkCrudContainerVO.getDetailPanelFormContainer().addOrReplace(customFieldPalette); }
protected boolean prerenderContextCheck() { Long sessionPersonId = (Long) SecurityUtils.getSubject() .getSession() .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID); Long sessionStudyId = (Long) SecurityUtils.getSubject() .getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); boolean contextLoaded = false; 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)) { LinkSubjectStudy lss; try { Study study = iArkCommonService.getStudy(sessionStudyId); lss = iArkCommonService.getSubject(sessionPersonId, study); contextLoaded = true; } catch (EntityNotFoundException e) { log.error(e.getMessage()); } if (contextLoaded) { arkCrudContainerVO.getDetailPanelContainer().setVisible(true); } } } return contextLoaded; }
/* * (non-Javadoc) * * @see au.org.theark.core.web.form.AbstractDetailForm#onSave(org.apache.wicket.markup.html.form.Form, org.apache.wicket.ajax.AjaxRequestTarget) */ @Override protected void onSave(Form<ContactVO> containerForm, AjaxRequestTarget target) { // Persist the phone number to the backend, associate the person in context with the phone // object Long personSessionId = (Long) SecurityUtils.getSubject() .getSession() .getAttribute(au.org.theark.core.Constants.PERSON_CONTEXT_ID); // Get the person and set it on the Phone object. try { boolean saveOk = true; Person person = studyService.getPerson(personSessionId); containerForm.getModelObject().getPhoneVo().getPhone().setPerson(person); /* // Make the area code mandatory only for landline phone (home/work) entries String phType = containerForm.getModelObject().getPhone().getPhoneType().getName().toLowerCase(); if (!phType.equals("mobile")) { // must be landline if (containerForm.getModelObject().getPhone().getAreaCode() == null || containerForm.getModelObject().getPhone().getAreaCode().length() < 1) { this.error("An area code must be entered for landline numbers"); saveOk = false; } } */ if (saveOk) { // Ok to save... String personType = (String) SecurityUtils.getSubject() .getSession() .getAttribute(au.org.theark.core.Constants.PERSON_TYPE); if (personType != null && personType.equalsIgnoreCase( au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_SUBJECT)) { Long studyId = (Long) SecurityUtils.getSubject() .getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); Study study = iArkCommonService.getStudy(studyId); LinkSubjectStudy subjectInContext = iArkCommonService.getSubject( personSessionId, study); // This is fetched basically to display the // info // message along with the Subject UID or Contact ID if (containerForm.getModelObject().getPhoneVo().getPhone().getId() == null) { studyService.create(containerForm.getModelObject().getPhoneVo().getPhone()); this.info( "Phone number was added and linked to Subject UID: " + subjectInContext.getSubjectUID()); } else { studyService.update(containerForm.getModelObject().getPhoneVo().getPhone()); this.info( "Phone number was updated and linked to Subject UID: " + subjectInContext.getSubjectUID()); } } else if (personType != null && personType.equalsIgnoreCase( au.org.theark.core.Constants.PERSON_CONTEXT_TYPE_CONTACT)) { // TODO: Contact Interface implementation } processErrors(target); onSavePostProcess(target); } else { processErrors(target); } } catch (ArkUniqueException aue) { this.error(aue.getMessage()); } catch (EntityNotFoundException e) { this.error("The Subject/Participant is not available in the system anymore"); } catch (ArkSystemException e) { this.error("A System Exception has occured please contact Support."); } }