use of org.akaza.openclinica.bean.submit.FormLayoutBean in project OpenClinica by OpenClinica.
the class EnterDataForStudyEventServlet method getDisplayEventCRFs.
/**
* Each of the event CRFs with its corresponding CRFBean. Then generates a
* list of DisplayEventCRFBeans, one for each event CRF.
*
* @param eventCRFs
* The list of event CRFs for this study event.
* @param eventDefinitionCRFs
* The list of event definition CRFs for this study event.
* @return The list of DisplayEventCRFBeans for this study event.
*/
private ArrayList getDisplayEventCRFs(ArrayList eventCRFs, ArrayList eventDefinitionCRFs, SubjectEventStatus status) {
ArrayList answer = new ArrayList();
HashMap definitionsByCRFId = new HashMap();
int i;
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
definitionsByCRFId.put(new Integer(edc.getCrfId()), edc);
}
CRFDAO cdao = new CRFDAO(sm.getDataSource());
FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
logger.debug("0. found event crf bean: " + ecb.getName());
// populate the event CRF with its crf bean
int crfVersionId = ecb.getFormLayoutId();
CRFBean cb = cdao.findByVersionId(crfVersionId);
logger.debug("1. found crf bean: " + cb.getName());
ecb.setCrf(cb);
FormLayoutBean cvb = (FormLayoutBean) fldao.findByPK(crfVersionId);
logger.debug("2. found crf version bean: " + cvb.getName());
ecb.setFormLayout(cvb);
logger.debug("found subj event status: " + status.getName() + " cb status: " + cb.getStatus().getName() + " cvb status: " + cvb.getStatus().getName());
// below added tbh 092007
boolean invalidate = false;
if (status.isLocked()) {
ecb.setStage(DataEntryStage.LOCKED);
} else if (status.isInvalid()) {
ecb.setStage(DataEntryStage.LOCKED);
// invalidate = true;
} else if (!cb.getStatus().equals(Status.AVAILABLE)) {
logger.debug("got to the CB version of the logic");
ecb.setStage(DataEntryStage.LOCKED);
// invalidate= true;
} else if (!cvb.getStatus().equals(Status.AVAILABLE)) {
logger.debug("got to the CVB version of the logic");
ecb.setStage(DataEntryStage.LOCKED);
// invalidate = true;
}
logger.debug("found ecb stage of " + ecb.getStage().getName());
// above added tbh, 092007-102007
try {
// event crf collection will pull up events that have
// been started, but contain no data
// this creates problems if we remove CRFs from
// event definitions
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) definitionsByCRFId.get(new Integer(cb.getId()));
logger.debug("3. found event def crf bean: " + edcb.getName());
DisplayEventCRFBean dec = new DisplayEventCRFBean();
dec.setFlags(ecb, ub, currentRole, edcb.isDoubleEntry());
ArrayList idata = iddao.findAllByEventCRFId(ecb.getId());
if (!idata.isEmpty()) {
// consider an event crf started only if item data get
// created
answer.add(dec);
}
} catch (NullPointerException npe) {
logger.debug("5. got to NPE on this time around!");
}
}
return answer;
}
use of org.akaza.openclinica.bean.submit.FormLayoutBean in project OpenClinica by OpenClinica.
the class EnterDataForStudyEventServlet method getDisplayEventCRFs.
/**
* Generate a list of DisplayEventCRFBean objects for a study event. Some of
* the DisplayEventCRFBeans will represent uncompleted Event CRFs; others
* will represent Event CRFs which are in initial data entry, have completed
* initial data entry, are in double data entry, or have completed double
* data entry.
*
* The list is sorted using the DisplayEventCRFBean's compareTo method (that
* is, using the event definition crf bean's ordinal value.) Also, the
* setFlags method of each DisplayEventCRFBean object will have been called
* once.
*
* @param studyEvent
* The study event for which we want the Event CRFs.
* @param ecdao
* An EventCRFDAO from which to grab the study event's Event
* CRFs.
* @param edcdao
* An EventDefinitionCRFDAO from which to grab the Event CRF
* Definitions which apply to the study event.
* @return A list of DisplayEventCRFBean objects releated to the study
* event, ordered by the EventDefinitionCRF ordinal property, and
* with flags already set.
*/
public static ArrayList getDisplayEventCRFs(StudyEventBean studyEvent, EventCRFDAO ecdao, EventDefinitionCRFDAO edcdao, FormLayoutDAO fldao, UserAccountBean user, StudyUserRoleBean surb) {
ArrayList answer = new ArrayList();
HashMap indexByCRFId = new HashMap();
ArrayList eventCRFs = ecdao.findAllByStudyEvent(studyEvent);
ArrayList eventDefinitionCRFs = edcdao.findAllByEventDefinitionId(studyEvent.getStudyEventDefinitionId());
// TODO: map this out to another function
ArrayList crfVersions = (ArrayList) fldao.findAll();
HashMap crfIdByCRFVersionId = new HashMap();
for (int i = 0; i < crfVersions.size(); i++) {
FormLayoutBean cvb = (FormLayoutBean) crfVersions.get(i);
crfIdByCRFVersionId.put(new Integer(cvb.getId()), new Integer(cvb.getCrfId()));
}
// put the event definition crfs inside DisplayEventCRFs
for (int i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
DisplayEventCRFBean decb = new DisplayEventCRFBean();
decb.setEventDefinitionCRF(edcb);
answer.add(decb);
indexByCRFId.put(new Integer(edcb.getCrfId()), new Integer(answer.size() - 1));
}
// attach EventCRFs to the DisplayEventCRFs
for (int i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecb = (EventCRFBean) eventCRFs.get(i);
Integer crfVersionId = new Integer(ecb.getFormLayoutId());
if (crfIdByCRFVersionId.containsKey(crfVersionId)) {
Integer crfId = (Integer) crfIdByCRFVersionId.get(crfVersionId);
if (crfId != null && indexByCRFId.containsKey(crfId)) {
Integer indexObj = (Integer) indexByCRFId.get(crfId);
if (indexObj != null) {
int index = indexObj.intValue();
if (index > 0 && index < answer.size()) {
DisplayEventCRFBean decb = (DisplayEventCRFBean) answer.get(index);
decb.setEventCRF(ecb);
answer.set(index, decb);
}
}
}
}
}
for (int i = 0; i < answer.size(); i++) {
DisplayEventCRFBean decb = (DisplayEventCRFBean) answer.get(i);
decb.setFlags(decb.getEventCRF(), user, surb, decb.getEventDefinitionCRF().isDoubleEntry());
answer.set(i, decb);
}
return answer;
}
use of org.akaza.openclinica.bean.submit.FormLayoutBean in project OpenClinica by OpenClinica.
the class ChangeCRFVersionController method chooseCRFVersion.
/*
* Allows user to select new CRF version
*
*/
// @RequestMapping(value="/managestudy/chooseCRFVersion", method = RequestMethod.GET)
@RequestMapping(value = "/managestudy/chooseCRFVersion", method = RequestMethod.GET)
public ModelMap chooseCRFVersion(HttpServletRequest request, HttpServletResponse response, @RequestParam("crfId") int crfId, @RequestParam("crfName") String crfName, @RequestParam("formLayoutId") int formLayoutId, @RequestParam("formLayoutName") String formLayoutName, @RequestParam("studySubjectLabel") String studySubjectLabel, @RequestParam("studySubjectId") int studySubjectId, @RequestParam("eventCRFId") int eventCRFId, @RequestParam("eventDefinitionCRFId") int eventDefinitionCRFId) {
// to be removed for aquamarine
if (!mayProceed(request)) {
try {
response.sendRedirect(request.getContextPath() + "/MainMenu?message=authentication_failed");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
resetPanel(request);
ModelMap gridMap = new ModelMap();
request.setAttribute("eventCRFId", eventCRFId);
request.setAttribute("studySubjectLabel", studySubjectLabel);
request.setAttribute("eventDefinitionCRFId", eventDefinitionCRFId);
request.setAttribute("studySubjectId", studySubjectId);
request.setAttribute("crfId", crfId);
request.setAttribute("crfName", crfName);
request.setAttribute("formLayoutId", formLayoutId);
request.setAttribute("formLayoutName", formLayoutName.trim());
ArrayList<String> pageMessages = initPageMessages(request);
Object errorMessage = request.getParameter("errorMessage");
if (errorMessage != null) {
pageMessages.add((String) errorMessage);
}
// get CRF by ID with all versions
// create List of all versions (label + value)
// set default CRF version label
setupResource(request);
// from event_crf get
StudyBean study = (StudyBean) request.getSession().getAttribute("study");
CRFDAO cdao = new CRFDAO(dataSource);
CRFBean crfBean = (CRFBean) cdao.findByPK(crfId);
FormLayoutDAO formLayoutDao = new FormLayoutDAO(dataSource);
ArrayList<FormLayoutBean> formLayouts = (ArrayList<FormLayoutBean>) formLayoutDao.findAllActiveByCRF(crfId);
StudyEventDefinitionDAO sfed = new StudyEventDefinitionDAO(dataSource);
StudyEventDefinitionBean sedb = sfed.findByEventDefinitionCRFId(eventDefinitionCRFId);
request.setAttribute("eventName", sedb.getName());
EventCRFDAO ecdao = new EventCRFDAO(dataSource);
EventCRFBean ecb = (EventCRFBean) ecdao.findByPK(eventCRFId);
StudyEventDAO sedao = new StudyEventDAO(dataSource);
StudyEventBean seb = (StudyEventBean) sedao.findByPK(ecb.getStudyEventId());
request.setAttribute("eventCreateDate", formatDate(seb.getCreatedDate()));
if (sedb.isRepeating()) {
request.setAttribute("eventOrdinal", seb.getSampleOrdinal());
}
if (study.getParentStudyId() > 0) {
EventDefinitionCRFDAO edfdao = new EventDefinitionCRFDAO(dataSource);
EventDefinitionCRFBean edf = (EventDefinitionCRFBean) edfdao.findByPK(eventDefinitionCRFId);
if (!edf.getSelectedVersionIds().equals("")) {
String[] version_ids = edf.getSelectedVersionIds().split(",");
HashMap<String, String> tmp = new HashMap<String, String>(version_ids.length);
for (String vs : version_ids) {
tmp.put(vs, vs);
}
ArrayList<FormLayoutBean> site_versions = new ArrayList<FormLayoutBean>(formLayouts.size());
for (FormLayoutBean vs : formLayouts) {
if (tmp.get(String.valueOf(vs.getId())) != null) {
site_versions.add(vs);
}
}
formLayouts = site_versions;
}
}
crfBean.setVersions(formLayouts);
gridMap.addAttribute("numberOfVersions", crfBean.getVersions().size() + 1);
gridMap.addAttribute("crfBean", crfBean);
return gridMap;
}
use of org.akaza.openclinica.bean.submit.FormLayoutBean in project OpenClinica by OpenClinica.
the class BatchCRFMigrationController method runPreviewTest.
@SuppressWarnings("unchecked")
public ResponseEntity<HelperObject> runPreviewTest(TransferObject transferObject, HttpServletRequest request) throws Exception {
HelperObject helperObject = new HelperObject();
Locale locale = request.getLocale();
resterms = ResourceBundleProvider.getTermsBundle(locale);
UserAccountBean userAccountBean = getCurrentUser(request);
ReportLog reportLog = new ReportLog();
String studyOid = transferObject.getStudyOID();
String sourceCrfVersion = transferObject.getSourceFormVersion();
String targetCrfVersion = transferObject.getTargetFormVersion();
ArrayList<String> studyEventDefnlist = transferObject.getStudyEventDefs();
ArrayList<String> studyEventDefnlistFiltered = new ArrayList<String>();
ArrayList<String> sitelist = transferObject.getSites();
ArrayList<String> sitelistFiltered = new ArrayList<String>();
FormLayoutBean sourceCrfVersionBean = fldao().findByOid(sourceCrfVersion);
FormLayoutBean targetCrfVersionBean = fldao().findByOid(targetCrfVersion);
StudyBean stBean = sdao().findByOid(studyOid);
if (stBean == null || !stBean.getStatus().isAvailable() || stBean.getParentStudyId() != 0) {
reportLog.getErrors().add(resterms.getString("The_OID_of_the_Target_Study_that_you_provided_is_invalid"));
helperObject.setReportLog(reportLog);
return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
}
StudyUserRoleBean suRole = uadao().findRoleByUserNameAndStudyId(userAccountBean.getName(), stBean.getId());
Role r = suRole.getRole();
if (suRole == null || !(r.equals(Role.STUDYDIRECTOR) || r.equals(Role.COORDINATOR))) {
reportLog.getErrors().add(resterms.getString("You_do_not_have_permission_to_perform_CRF_version_migration_in_this_study"));
helperObject.setReportLog(reportLog);
return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
}
if (sourceCrfVersionBean == null || targetCrfVersionBean == null) {
if (sourceCrfVersion.equals("-1") || targetCrfVersion.equals("-1")) {
reportLog.getErrors().add(resterms.getString("Current_CRF_version_and_New_CRF_version_should_be_selected"));
} else {
reportLog.getErrors().add(resterms.getString("The_OID_of_the_CRF_Version_that_you_provided_is_invalid"));
}
helperObject.setReportLog(reportLog);
return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
}
if (sourceCrfVersionBean.getId() == targetCrfVersionBean.getId()) {
reportLog.getErrors().add(resterms.getString("Current_CRF_version_and_New_CRF_version_can_not_be_same"));
helperObject.setReportLog(reportLog);
return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
}
if (sourceCrfVersionBean.getCrfId() != targetCrfVersionBean.getCrfId() || !sourceCrfVersionBean.getStatus().isAvailable() || !targetCrfVersionBean.getStatus().isAvailable()) {
reportLog.getErrors().add(resterms.getString("The_OID_of_the_CRF_Version_that_you_provided_is_invalid"));
helperObject.setReportLog(reportLog);
return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
}
CRFBean cBean = (CRFBean) cdao().findByPK(sourceCrfVersionBean.getCrfId());
if (sitelist.size() == 0) {
ArrayList<StudyBean> listOfSites = (ArrayList<StudyBean>) sdao().findAllByParent(stBean.getId());
sitelist.add(stBean.getOid());
for (StudyBean s : listOfSites) {
if (s.getStatus().isAvailable()) {
sitelist.add(s.getOid());
}
}
} else {
for (String site : sitelist) {
StudyBean siteBean = sdao().findByOid(site.trim());
if (siteBean == null || getParentStudy(siteBean).getId() != stBean.getId()) {
reportLog.getErrors().add(resterms.getString("The_OID_of_the_Site_that_you_provided_is_invalid"));
helperObject.setReportLog(reportLog);
return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
} else if (siteBean.getStatus().isAvailable()) {
sitelistFiltered.add(site);
}
}
sitelist = sitelistFiltered;
}
if (studyEventDefnlist.size() == 0) {
ArrayList<StudyEventDefinitionBean> listOfDefn = seddao().findAllByStudy(stBean);
for (StudyEventDefinitionBean d : listOfDefn) {
if (d.getStatus().isAvailable()) {
studyEventDefnlist.add(d.getOid());
}
}
} else {
for (String studyEventDefn : studyEventDefnlist) {
StudyEventDefinitionBean sedefnBean = seddao().findByOid(studyEventDefn);
if (sedefnBean == null || sedefnBean.getStudyId() != stBean.getId()) {
reportLog.getErrors().add(resterms.getString("The_OID_of_the_Event_that_you_provided_is_invalid"));
helperObject.setReportLog(reportLog);
return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.NOT_ACCEPTABLE);
} else if (sedefnBean.getStatus().isAvailable()) {
studyEventDefnlistFiltered.add(studyEventDefn);
}
}
studyEventDefnlist = studyEventDefnlistFiltered;
}
int eventCrfCount = ssdao().getTotalEventCrfCountForCrfMigration(sourceCrfVersionBean, targetCrfVersionBean, studyEventDefnlist, sitelist);
reportLog.setEventCrfCount(eventCrfCount);
int subjectCount = ssdao().getTotalCountStudySubjectForCrfMigration(sourceCrfVersionBean, targetCrfVersionBean, studyEventDefnlist, sitelist);
reportLog.setSubjectCount(subjectCount);
List<EventDefinitionCRFBean> crfMigrationDoesNotPerformList = edcdao().findAllCrfMigrationDoesNotPerform(sourceCrfVersionBean, targetCrfVersionBean, studyEventDefnlist, sitelist);
for (EventDefinitionCRFBean crfMigrationDoesNotPerform : crfMigrationDoesNotPerformList) {
StudyEventDefinitionBean seddBean = (StudyEventDefinitionBean) seddao().findByPK(crfMigrationDoesNotPerform.getStudyEventDefinitionId());
StudyBean sssBean = (StudyBean) sdao().findByPK(crfMigrationDoesNotPerform.getStudyId());
reportLog.getCanNotMigrate().add(resterms.getString("CRF_Version_Migration_cannot_be_performed_for") + " " + sssBean.getName() + " " + seddBean.getName() + ". " + resterms.getString("Both_CRF_versions_are_not_available_at_the_Site"));
}
List<EventCRFBean> eventCrfListToMigrate = ecdao().findAllCRFMigrationReportList(sourceCrfVersionBean, targetCrfVersionBean, studyEventDefnlist, sitelist);
helperObject.setReportLog(reportLog);
helperObject.setStBean(stBean);
helperObject.setcBean(cBean);
helperObject.setEventCrfListToMigrate(eventCrfListToMigrate);
helperObject.setSourceCrfVersionBean(sourceCrfVersionBean);
helperObject.setTargetCrfVersionBean(targetCrfVersionBean);
helperObject.setUserAccountBean(userAccountBean);
return new ResponseEntity<HelperObject>(helperObject, org.springframework.http.HttpStatus.OK);
}
use of org.akaza.openclinica.bean.submit.FormLayoutBean in project OpenClinica by OpenClinica.
the class UpdateSubStudyServlet method submitSiteEventDefinitions.
private void submitSiteEventDefinitions(StudyBean site) throws MalformedURLException {
FormProcessor fp = new FormProcessor(request);
Validator v = new Validator(request);
HashMap<String, Boolean> changes = new HashMap<String, Boolean>();
HashMap<String, Boolean> changeStatus = (HashMap<String, Boolean>) session.getAttribute("changed");
ArrayList<StudyEventDefinitionBean> seds = new ArrayList<StudyEventDefinitionBean>();
ArrayList<EventDefinitionCRFBean> defCrfs = new ArrayList<EventDefinitionCRFBean>();
StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
StudyBean parentStudyBean;
if (site.getParentStudyId() == 0) {
parentStudyBean = site;
} else {
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
parentStudyBean = (StudyBean) studyDAO.findByPK(site.getParentStudyId());
}
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList<EventDefinitionCRFBean> eventDefCrfList = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllActiveSitesAndStudiesPerParentStudy(parentStudyBean.getId());
ArrayList<EventDefinitionCRFBean> toBeCreatedEventDefBean = new ArrayList<>();
ArrayList<EventDefinitionCRFBean> toBeUpdatedEventDefBean = new ArrayList<>();
ArrayList<EventDefinitionCRFBean> edcsInSession = new ArrayList<EventDefinitionCRFBean>();
boolean changestate = false;
seds = (ArrayList<StudyEventDefinitionBean>) session.getAttribute("definitions");
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(parentStudyBean.getId(), "participantPortal").getValue();
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
for (StudyEventDefinitionBean sed : seds) {
ArrayList<EventDefinitionCRFBean> edcs = sed.getCrfs();
int start = 0;
for (EventDefinitionCRFBean edcBean : edcs) {
int edcStatusId = edcBean.getStatus().getId();
if (edcStatusId == 5 || edcStatusId == 7) {
} else {
String order = start + "-" + edcBean.getId();
int defaultVersionId = fp.getInt("defaultVersionId" + order);
String requiredCRF = fp.getString("requiredCRF" + order);
String doubleEntry = fp.getString("doubleEntry" + order);
String electronicSignature = fp.getString("electronicSignature" + order);
String hideCRF = fp.getString("hideCRF" + order);
String participantForm = fp.getString("participantForm" + order);
String allowAnonymousSubmission = fp.getString("allowAnonymousSubmission" + order);
String submissionUrl = fp.getString("submissionUrl" + order);
String offline = fp.getString("offline" + order);
int sdvId = fp.getInt("sdvOption" + order);
ArrayList<String> selectedVersionIdList = fp.getStringArray("versionSelection" + order);
int selectedVersionIdListSize = selectedVersionIdList.size();
String selectedVersionIds = "";
if (selectedVersionIdListSize > 0) {
for (String id : selectedVersionIdList) {
selectedVersionIds += id + ",";
}
selectedVersionIds = selectedVersionIds.substring(0, selectedVersionIds.length() - 1);
}
String sdvOption = fp.getString("sdvOption" + order);
boolean changed = false;
if (changeStatus != null && changeStatus.get(sed.getId() + "-" + edcBean.getId()) != null) {
changed = changeStatus.get(sed.getId() + "-" + edcBean.getId());
edcBean.setSubmissionUrl(submissionUrl);
}
boolean isRequired = !StringUtil.isBlank(requiredCRF) && "yes".equalsIgnoreCase(requiredCRF.trim()) ? true : false;
boolean isDouble = !StringUtil.isBlank(doubleEntry) && "yes".equalsIgnoreCase(doubleEntry.trim()) ? true : false;
boolean hasPassword = !StringUtil.isBlank(electronicSignature) && "yes".equalsIgnoreCase(electronicSignature.trim()) ? true : false;
boolean isHide = !StringUtil.isBlank(hideCRF) && "yes".equalsIgnoreCase(hideCRF.trim()) ? true : false;
System.out.println("crf name :" + edcBean.getCrfName());
System.out.println("submissionUrl: " + submissionUrl);
if (edcBean.getParentId() > 0) {
int dbDefaultVersionId = edcBean.getDefaultVersionId();
if (defaultVersionId != dbDefaultVersionId) {
changed = true;
FormLayoutBean defaultVersion = (FormLayoutBean) fldao.findByPK(defaultVersionId);
edcBean.setDefaultVersionId(defaultVersionId);
edcBean.setDefaultVersionName(defaultVersion.getName());
}
if (isRequired != edcBean.isRequiredCRF()) {
changed = true;
edcBean.setRequiredCRF(isRequired);
}
if (isDouble != edcBean.isDoubleEntry()) {
changed = true;
edcBean.setDoubleEntry(isDouble);
}
if (hasPassword != edcBean.isElectronicSignature()) {
changed = true;
edcBean.setElectronicSignature(hasPassword);
}
if (isHide != edcBean.isHideCrf()) {
changed = true;
edcBean.setHideCrf(isHide);
}
if (!submissionUrl.equals(edcBean.getSubmissionUrl())) {
changed = true;
edcBean.setSubmissionUrl(submissionUrl);
}
if (!StringUtil.isBlank(selectedVersionIds) && !selectedVersionIds.equals(edcBean.getSelectedVersionIds())) {
changed = true;
String[] ids = selectedVersionIds.split(",");
ArrayList<Integer> idList = new ArrayList<Integer>();
for (String id : ids) {
idList.add(Integer.valueOf(id));
}
edcBean.setSelectedVersionIdList(idList);
edcBean.setSelectedVersionIds(selectedVersionIds);
}
if (sdvId > 0 && sdvId != edcBean.getSourceDataVerification().getCode()) {
changed = true;
edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
}
if (changed) {
edcBean.setUpdater(ub);
edcBean.setUpdatedDate(new Date());
logger.debug("update for site");
toBeUpdatedEventDefBean.add(edcBean);
// edcdao.update(edcBean);
}
} else {
// only if definition-crf has been modified, will it be
// saved for the site
int defaultId = defaultVersionId > 0 ? defaultVersionId : edcBean.getDefaultVersionId();
int dbDefaultVersionId = edcBean.getDefaultVersionId();
if (defaultId == dbDefaultVersionId) {
if (isRequired == edcBean.isRequiredCRF()) {
if (isDouble == edcBean.isDoubleEntry()) {
if (hasPassword == edcBean.isElectronicSignature()) {
if (isHide == edcBean.isHideCrf()) {
if (submissionUrl.equals("")) {
if (selectedVersionIdListSize > 0) {
if (selectedVersionIdListSize == edcBean.getVersions().size()) {
if (sdvId > 0) {
if (sdvId != edcBean.getSourceDataVerification().getCode()) {
changed = true;
}
}
} else {
changed = true;
}
}
} else {
changed = true;
}
} else {
changed = true;
}
} else {
changed = true;
}
} else {
changed = true;
}
} else {
changed = true;
}
} else {
changed = true;
}
if (changed) {
CRFVersionBean defaultVersion = (CRFVersionBean) cvdao.findByPK(defaultId);
edcBean.setDefaultVersionId(defaultId);
edcBean.setDefaultVersionName(defaultVersion.getName());
edcBean.setRequiredCRF(isRequired);
edcBean.setDoubleEntry(isDouble);
edcBean.setElectronicSignature(hasPassword);
edcBean.setHideCrf(isHide);
edcBean.setSubmissionUrl(submissionUrl);
if (selectedVersionIdListSize > 0 && selectedVersionIdListSize != edcBean.getVersions().size()) {
String[] ids = selectedVersionIds.split(",");
ArrayList<Integer> idList = new ArrayList<Integer>();
for (String id : ids) {
idList.add(Integer.valueOf(id));
}
edcBean.setSelectedVersionIdList(idList);
edcBean.setSelectedVersionIds(selectedVersionIds);
}
if (sdvId > 0 && sdvId != edcBean.getSourceDataVerification().getCode()) {
edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
}
// edcBean.setParentId(edcBean.getId());
edcBean.setStudyId(site.getId());
edcBean.setUpdater(ub);
edcBean.setUpdatedDate(new Date());
logger.debug("create for the site");
toBeCreatedEventDefBean.add(edcBean);
// edcdao.create(edcBean);
}
}
++start;
changes.put(sed.getId() + "-" + edcBean.getId(), changed);
}
edcsInSession.add(edcBean);
}
sed.setPopulated(false);
eventDefCrfList = validateSubmissionUrl(edcsInSession, eventDefCrfList, v, sed);
edcsInSession.clear();
}
errors = v.validate();
if (!errors.isEmpty()) {
logger.info("has errors");
StudyBean study = createStudyBean();
session.setAttribute("newStudy", study);
request.setAttribute("formMessages", errors);
session.setAttribute("changed", changes);
forwardPage(Page.UPDATE_SUB_STUDY);
} else {
for (EventDefinitionCRFBean toBeCreated : toBeCreatedEventDefBean) {
toBeCreated.setParentId(toBeCreated.getId());
edcdao.create(toBeCreated);
}
for (EventDefinitionCRFBean toBeUpdated : toBeUpdatedEventDefBean) {
edcdao.update(toBeUpdated);
}
}
}
Aggregations