use of org.akaza.openclinica.control.form.Validator in project OpenClinica by OpenClinica.
the class UpdateStudyServlet method confirmStudy2.
private void confirmStudy2() throws Exception {
Validator v = new Validator(request);
FormProcessor fp = new FormProcessor(request);
v.addValidation(INPUT_START_DATE, Validator.IS_A_DATE);
if (!StringUtil.isBlank(fp.getString(INPUT_END_DATE))) {
v.addValidation(INPUT_END_DATE, Validator.IS_A_DATE);
}
v.addValidation(INPUT_VER_DATE, Validator.IS_A_DATE);
errors = v.validate();
boolean isInterventional = updateStudy2();
if (errors.isEmpty()) {
logger.info("no errors");
ArrayList interventionArray = new ArrayList();
if (isInterventional) {
interventionArray = parseInterventions((StudyBean) session.getAttribute("newStudy"));
setMaps(isInterventional, interventionArray);
forwardPage(Page.UPDATE_STUDY3);
} else {
setMaps(isInterventional, interventionArray);
forwardPage(Page.UPDATE_STUDY4);
}
} else {
logger.info("has validation errors");
try {
local_df.parse(fp.getString(INPUT_START_DATE));
fp.addPresetValue(INPUT_START_DATE, local_df.format(fp.getDate(INPUT_START_DATE)));
} catch (ParseException pe) {
fp.addPresetValue(INPUT_START_DATE, fp.getString(INPUT_START_DATE));
}
try {
local_df.parse(fp.getString(INPUT_VER_DATE));
fp.addPresetValue(INPUT_VER_DATE, local_df.format(fp.getDate(INPUT_VER_DATE)));
} catch (ParseException pe) {
fp.addPresetValue(INPUT_VER_DATE, fp.getString(INPUT_VER_DATE));
}
try {
local_df.parse(fp.getString(INPUT_END_DATE));
fp.addPresetValue(INPUT_END_DATE, local_df.format(fp.getDate(INPUT_END_DATE)));
} catch (ParseException pe) {
fp.addPresetValue(INPUT_END_DATE, fp.getString(INPUT_END_DATE));
}
setPresetValues(fp.getPresetValues());
request.setAttribute("formMessages", errors);
request.setAttribute("studyPhaseMap", CreateStudyServlet.studyPhaseMap);
request.setAttribute("statuses", Status.toActiveArrayList());
forwardPage(Page.UPDATE_STUDY2);
}
}
use of org.akaza.openclinica.control.form.Validator in project OpenClinica by OpenClinica.
the class UpdateStudyServlet method confirmStudy1.
/**
* Validates the first section of study and save it into study bean
*
* @param request
* @param response
* @throws Exception
*/
private void confirmStudy1() throws Exception {
Validator v = new Validator(request);
FormProcessor fp = new FormProcessor(request);
v.addValidation("name", Validator.NO_BLANKS);
v.addValidation("uniqueProId", Validator.NO_BLANKS);
v.addValidation("description", Validator.NO_BLANKS);
v.addValidation("prinInvestigator", Validator.NO_BLANKS);
v.addValidation("sponsor", Validator.NO_BLANKS);
v.addValidation("secondProId", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
v.addValidation("collaborators", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 1000);
v.addValidation("protocolDescription", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 1000);
errors = v.validate();
if (fp.getString("name").trim().length() > 100) {
Validator.addError(errors, "name", resexception.getString("maximum_lenght_name_100"));
}
if (fp.getString("uniqueProId").trim().length() > 30) {
Validator.addError(errors, "uniqueProId", resexception.getString("maximum_lenght_unique_protocol_30"));
}
if (fp.getString("description").trim().length() > 255) {
Validator.addError(errors, "description", resexception.getString("maximum_lenght_brief_summary_255"));
}
if (fp.getString("prinInvestigator").trim().length() > 255) {
Validator.addError(errors, "prinInvestigator", resexception.getString("maximum_lenght_principal_investigator_255"));
}
if (fp.getString("sponsor").trim().length() > 255) {
Validator.addError(errors, "sponsor", resexception.getString("maximum_lenght_sponsor_255"));
}
if (fp.getString("officialTitle").trim().length() > 255) {
Validator.addError(errors, "officialTitle", resexception.getString("maximum_lenght_official_title_255"));
}
session.setAttribute("newStudy", createStudyBean());
if (errors.isEmpty()) {
logger.info("no errors in the first section");
request.setAttribute("studyPhaseMap", CreateStudyServlet.studyPhaseMap);
request.setAttribute("statuses", Status.toActiveArrayList());
StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
fp.addPresetValue(INPUT_START_DATE, local_df.format(newStudy.getDatePlannedStart()));
if (newStudy.getDatePlannedEnd() != null) {
fp.addPresetValue(INPUT_END_DATE, local_df.format(newStudy.getDatePlannedEnd()));
}
fp.addPresetValue(INPUT_VER_DATE, local_df.format(newStudy.getProtocolDateVerification()));
setPresetValues(fp.getPresetValues());
forwardPage(Page.UPDATE_STUDY2);
} else {
logger.info("has validation errors in the first section");
request.setAttribute("formMessages", errors);
forwardPage(Page.UPDATE_STUDY1);
}
}
use of org.akaza.openclinica.control.form.Validator 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);
}
}
}
use of org.akaza.openclinica.control.form.Validator in project OpenClinica by OpenClinica.
the class UpdateSubStudyServlet method confirmStudy.
/**
* Validates the first section of study and save it into study bean * *
*
* @param request
* @param response
* @throws Exception
*/
private void confirmStudy() throws Exception {
Validator v = new Validator(request);
FormProcessor fp = new FormProcessor(request);
v.addValidation("name", Validator.NO_BLANKS);
v.addValidation("uniqueProId", Validator.NO_BLANKS);
// >> tbh
// v.addValidation("description", Validator.NO_BLANKS);
// << tbh, #3943, 07/2009
v.addValidation("prinInvestigator", Validator.NO_BLANKS);
if (!StringUtil.isBlank(fp.getString(INPUT_START_DATE))) {
v.addValidation(INPUT_START_DATE, Validator.IS_A_DATE);
}
if (!StringUtil.isBlank(fp.getString(INPUT_END_DATE))) {
v.addValidation(INPUT_END_DATE, Validator.IS_A_DATE);
}
if (!StringUtil.isBlank(fp.getString(INPUT_VER_DATE))) {
v.addValidation(INPUT_VER_DATE, Validator.IS_A_DATE);
}
if (!StringUtil.isBlank(fp.getString("facConEmail"))) {
v.addValidation("facConEmail", Validator.IS_A_EMAIL);
}
// v.addValidation("statusId", Validator.IS_VALID_TERM);
v.addValidation("secondProId", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
v.addValidation("facName", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
v.addValidation("facCity", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
v.addValidation("facState", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 20);
v.addValidation("facZip", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 64);
v.addValidation("facCountry", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 64);
v.addValidation("facConName", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
v.addValidation("facConDegree", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
v.addValidation("facConPhone", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
v.addValidation("facConEmail", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 255);
errors = v.validate();
// >> tbh
StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
ArrayList<StudyBean> allStudies = (ArrayList<StudyBean>) studyDAO.findAll();
StudyBean oldStudy = (StudyBean) session.getAttribute("newStudy");
for (StudyBean thisBean : allStudies) {
if (fp.getString("uniqueProId").trim().equals(thisBean.getIdentifier()) && !thisBean.getIdentifier().equals(oldStudy.getIdentifier())) {
Validator.addError(errors, "uniqueProId", resexception.getString("unique_protocol_id_existed"));
}
}
// << tbh #3999 08/2009
if (fp.getString("name").trim().length() > 100) {
Validator.addError(errors, "name", resexception.getString("maximum_lenght_name_100"));
}
if (fp.getString("uniqueProId").trim().length() > 30) {
Validator.addError(errors, "uniqueProId", resexception.getString("maximum_lenght_unique_protocol_30"));
}
if (fp.getString("description").trim().length() > 255) {
Validator.addError(errors, "description", resexception.getString("maximum_lenght_brief_summary_255"));
}
if (fp.getString("prinInvestigator").trim().length() > 255) {
Validator.addError(errors, "prinInvestigator", resexception.getString("maximum_lenght_principal_investigator_255"));
}
if (fp.getInt("expectedTotalEnrollment") <= 0) {
Validator.addError(errors, "expectedTotalEnrollment", respage.getString("expected_total_enrollment_must_be_a_positive_number"));
}
if (parentStudy.getStatus().equals(Status.LOCKED)) {
if (fp.getInt("statusId") != Status.LOCKED.getId()) {
Validator.addError(errors, "statusId", respage.getString("study_locked_site_status_locked"));
}
}
// else if (parentStudy.getStatus().equals(Status.FROZEN)) {
// if (fp.getInt("statusId") != Status.AVAILABLE.getId()) {
// Validator.addError(errors, "statusId",
// respage.getString("study_locked_site_status_frozen"));
// }
// }
StudyBean study = createStudyBean();
session.setAttribute("newStudy", study);
if (errors.isEmpty()) {
logger.info("no errors");
// forwardPage(Page.CONFIRM_UPDATE_SUB_STUDY);
submitStudy();
} else {
StudyBean studyCheck = (StudyBean) session.getAttribute("newStudy");
parentStudy = (StudyBean) studyDAO.findByPK(studyCheck.getParentStudyId());
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(parentStudy.getId(), "participantPortal").getValue();
request.setAttribute("participateFormStatus", participateFormStatus);
logger.info("has validation errors");
fp.addPresetValue(INPUT_START_DATE, fp.getString(INPUT_START_DATE));
fp.addPresetValue(INPUT_VER_DATE, fp.getString(INPUT_VER_DATE));
fp.addPresetValue(INPUT_END_DATE, fp.getString(INPUT_END_DATE));
/*
* try {
* local_df.parse(fp.getString(INPUT_START_DATE));
* fp.addPresetValue(INPUT_START_DATE, local_df.format(fp.getDate(INPUT_START_DATE)));
* } catch (ParseException pe) {
* fp.addPresetValue(INPUT_START_DATE, fp.getString(INPUT_START_DATE));
* }
* // tbh 3946 07/2009
* try {
* local_df.parse(fp.getString(INPUT_VER_DATE));
* fp.addPresetValue(INPUT_VER_DATE, local_df.format(fp.getDate(INPUT_VER_DATE)));
* } catch (ParseException pe) {
* fp.addPresetValue(INPUT_VER_DATE, fp.getString(INPUT_VER_DATE));
* }
* // >> tbh
* try {
* local_df.parse(fp.getString(INPUT_END_DATE));
* fp.addPresetValue(INPUT_END_DATE, local_df.format(fp.getDate(INPUT_END_DATE)));
* } catch (ParseException pe) {
* fp.addPresetValue(INPUT_END_DATE, fp.getString(INPUT_END_DATE));
* }
*/
setPresetValues(fp.getPresetValues());
request.setAttribute("formMessages", errors);
request.setAttribute("facRecruitStatusMap", CreateStudyServlet.facRecruitStatusMap);
request.setAttribute("statuses", Status.toStudyUpdateMembersList());
forwardPage(Page.UPDATE_SUB_STUDY);
}
}
use of org.akaza.openclinica.control.form.Validator in project OpenClinica by OpenClinica.
the class UpdateEventDefinitionServlet method confirmDefinition.
/**
*
* @throws Exception
*/
private void confirmDefinition() throws Exception {
Validator v = new Validator(request);
FormProcessor fp = new FormProcessor(request);
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
v.addValidation("name", Validator.NO_BLANKS);
v.addValidation("name", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
v.addValidation("description", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
v.addValidation("category", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
ArrayList<EventDefinitionCRFBean> edcsInSession = (ArrayList<EventDefinitionCRFBean>) session.getAttribute("eventDefinitionCRFs");
int parentStudyId = sed.getStudyId();
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList<EventDefinitionCRFBean> eventDefCrfList = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllActiveSitesAndStudiesPerParentStudy(parentStudyId);
// logger.info("no errors");
sed.setName(fp.getString("name"));
sed.setRepeating(fp.getBoolean("repeating"));
sed.setCategory(fp.getString("category"));
sed.setDescription(fp.getString("description"));
sed.setType(fp.getString("type"));
session.setAttribute("definition", sed);
FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
ArrayList<EventDefinitionCRFBean> edcs = (ArrayList) session.getAttribute("eventDefinitionCRFs");
for (int i = 0; i < edcs.size(); i++) {
EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) edcs.get(i);
if (!edcBean.getStatus().equals(Status.DELETED) && !edcBean.getStatus().equals(Status.AUTO_DELETED)) {
// only get inputs from web page if AVAILABLE
int defaultVersionId = fp.getInt("defaultVersionId" + i);
edcBean.setDefaultVersionId(defaultVersionId);
FormLayoutBean defaultVersion = (FormLayoutBean) fldao.findByPK(edcBean.getDefaultVersionId());
edcBean.setDefaultVersionName(defaultVersion.getName());
String requiredCRF = fp.getString("requiredCRF" + i);
String doubleEntry = fp.getString("doubleEntry" + i);
String decisionCondition = fp.getString("decisionCondition" + i);
String electronicSignature = fp.getString("electronicSignature" + i);
String hideCRF = fp.getString("hideCRF" + i);
int sdvId = fp.getInt("sdvOption" + i);
String participantForm = fp.getString("participantForm" + i);
String allowAnonymousSubmission = fp.getString("allowAnonymousSubmission" + i);
String submissionUrl = fp.getString("submissionUrl" + i);
String offline = fp.getString("offline" + i);
System.out.println("submission :" + submissionUrl);
if (!StringUtil.isBlank(hideCRF) && "yes".equalsIgnoreCase(hideCRF.trim())) {
edcBean.setHideCrf(true);
} else {
edcBean.setHideCrf(false);
}
if (!StringUtil.isBlank(requiredCRF) && "yes".equalsIgnoreCase(requiredCRF.trim())) {
edcBean.setRequiredCRF(true);
} else {
edcBean.setRequiredCRF(false);
}
if (!StringUtil.isBlank(doubleEntry) && "yes".equalsIgnoreCase(doubleEntry.trim())) {
edcBean.setDoubleEntry(true);
} else {
edcBean.setDoubleEntry(false);
}
if (!StringUtil.isBlank(electronicSignature) && "yes".equalsIgnoreCase(electronicSignature.trim())) {
edcBean.setElectronicSignature(true);
} else {
edcBean.setElectronicSignature(false);
}
if (!StringUtil.isBlank(decisionCondition) && "yes".equalsIgnoreCase(decisionCondition.trim())) {
edcBean.setDecisionCondition(true);
} else {
edcBean.setDecisionCondition(false);
}
if (!StringUtil.isBlank(participantForm) && "yes".equalsIgnoreCase(participantForm.trim())) {
edcBean.setParticipantForm(true);
} else {
edcBean.setParticipantForm(false);
}
if (!StringUtils.isBlank(allowAnonymousSubmission) && "yes".equalsIgnoreCase(allowAnonymousSubmission.trim())) {
edcBean.setAllowAnonymousSubmission(true);
} else {
edcBean.setAllowAnonymousSubmission(false);
}
edcBean.setSubmissionUrl(submissionUrl.trim());
if (!StringUtils.isBlank(offline) && "yes".equalsIgnoreCase(offline.trim())) {
edcBean.setOffline(true);
} else {
edcBean.setOffline(false);
}
String nullString = "";
// process null values
ArrayList nulls = NullValue.toArrayList();
for (int a = 0; a < nulls.size(); a++) {
NullValue n = (NullValue) nulls.get(a);
String myNull = fp.getString(n.getName().toLowerCase() + i);
if (!StringUtil.isBlank(myNull) && "yes".equalsIgnoreCase(myNull.trim())) {
nullString = nullString + n.getName().toUpperCase() + ",";
}
}
if (sdvId > 0 && (edcBean.getSourceDataVerification() == null || sdvId != edcBean.getSourceDataVerification().getCode())) {
edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
}
edcBean.setNullValues(nullString);
logger.info("found null values: " + nullString);
}
}
validateSubmissionUrl(edcsInSession, eventDefCrfList, v);
errors = v.validate();
if (!errors.isEmpty()) {
logger.info("has errors");
session.setAttribute("eventDefinitionCRFs", edcs);
request.setAttribute("formMessages", errors);
forwardPage(Page.UPDATE_EVENT_DEFINITION1);
}
session.setAttribute("eventDefinitionCRFs", edcs);
forwardPage(Page.UPDATE_EVENT_DEFINITION_CONFIRM);
}
Aggregations