use of org.akaza.openclinica.bean.submit.FormLayoutBean 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