use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class CreateStudyServlet method updateStudy3.
/**
* Updates the study bean with inputs from the third section
*
* @param isInterventional
* if the study type is internventional
*/
private void updateStudy3(boolean isInterventional) {
FormProcessor fp = new FormProcessor(request);
StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
newStudy.setPurpose(fp.getString("purpose"));
if (isInterventional) {
newStudy.setAllocation(fp.getString("allocation"));
newStudy.setMasking(fp.getString("masking"));
newStudy.setControl(fp.getString("control"));
newStudy.setAssignment(fp.getString("assignment"));
newStudy.setEndpoint(fp.getString("endpoint"));
// Handle Interventions-type and name
// repeat 10 times for each pair on the web page
StringBuffer interventions = new StringBuffer();
ArrayList interventionArray = new ArrayList();
for (int i = 0; i < 10; i++) {
String type = fp.getString("interType" + i);
String name = fp.getString("interName" + i);
if (!StringUtil.isBlank(type) && !StringUtil.isBlank(name)) {
InterventionBean ib = new InterventionBean(fp.getString("interType" + i), fp.getString("interName" + i));
interventionArray.add(ib);
interventions.append(ib.toString()).append(",");
}
}
newStudy.setInterventions(interventions.toString());
session.setAttribute("interventionArray", interventionArray);
} else {
// type = observational
newStudy.setDuration(fp.getString("duration"));
newStudy.setSelection(fp.getString("selection"));
newStudy.setTiming(fp.getString("timing"));
}
session.setAttribute("newStudy", newStudy);
}
use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class CreateStudyServlet method confirmStudy3.
/**
* Confirms the third section of study info inputs
*
* @throws Exception
*/
private void confirmStudy3() throws Exception {
Validator v = new Validator(request);
FormProcessor fp = new FormProcessor(request);
v.addValidation("purpose", Validator.NO_BLANKS);
for (int i = 0; i < 10; i++) {
String type = fp.getString("interType" + i);
String name = fp.getString("interName" + i);
if (!StringUtil.isBlank(type) && StringUtil.isBlank(name)) {
v.addValidation("interName", Validator.NO_BLANKS);
request.setAttribute("interventionError", respage.getString("name_cannot_be_blank_if_type"));
break;
}
if (!StringUtil.isBlank(name) && StringUtil.isBlank(type)) {
v.addValidation("interType", Validator.NO_BLANKS);
request.setAttribute("interventionError", respage.getString("name_cannot_be_blank_if_name"));
break;
}
}
errors = v.validate();
boolean isInterventional = true;
if (session.getAttribute("isInterventionalFlag") != null) {
isInterventional = ((Boolean) session.getAttribute("isInterventionalFlag")).booleanValue();
}
updateStudy3(isInterventional);
if (errors.isEmpty()) {
logger.info("no errors");
if (session.getAttribute("interventionArray") == null) {
request.setAttribute("interventions", new ArrayList());
} else {
request.setAttribute("interventions", session.getAttribute("interventionArray"));
}
forwardPage(Page.CREATE_STUDY5);
} else {
logger.info("has validation errors");
request.setAttribute("formMessages", errors);
setMaps(isInterventional);
if (isInterventional) {
forwardPage(Page.CREATE_STUDY3);
} else {
forwardPage(Page.CREATE_STUDY4);
}
}
}
use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class CreateStudyServlet method confirmStudy5.
/**
* Validates the forth section of study and save it into study bean
*
* @param request
* @param response
* @throws Exception
*/
private void confirmStudy5() throws Exception {
FormProcessor fp = new FormProcessor(request);
Validator v = new Validator(request);
if (!StringUtil.isBlank(fp.getString("facConEmail"))) {
v.addValidation("facConEmail", Validator.IS_A_EMAIL);
}
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();
StudyBean newStudy = (StudyBean) session.getAttribute("newStudy");
newStudy.setFacilityCity(fp.getString("facCity"));
newStudy.setFacilityContactDegree(fp.getString("facConDrgree"));
newStudy.setFacilityName(fp.getString("facName"));
newStudy.setFacilityContactEmail(fp.getString("facConEmail"));
newStudy.setFacilityContactPhone(fp.getString("facConPhone"));
newStudy.setFacilityContactName(fp.getString("facConName"));
newStudy.setFacilityCountry(fp.getString("facCountry"));
newStudy.setFacilityContactDegree(fp.getString("facConDegree"));
// newStudy.setFacilityRecruitmentStatus(fp.getString("facRecStatus"));
newStudy.setFacilityState(fp.getString("facState"));
newStudy.setFacilityZip(fp.getString("facZip"));
session.setAttribute("newStudy", newStudy);
if (errors.isEmpty()) {
forwardPage(Page.CREATE_STUDY7);
} else {
request.setAttribute("formMessages", errors);
request.setAttribute("facRecruitStatusMap", facRecruitStatusMap);
forwardPage(Page.CREATE_STUDY6);
}
}
use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class CreateStudyServlet method confirmStudy2.
/**
* Validates the second section of study info inputs
*
* @throws Exception
*/
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("protocolType", Validator.NO_BLANKS);
if (!StringUtil.isBlank(fp.getString(INPUT_VER_DATE))) {
v.addValidation(INPUT_VER_DATE, Validator.IS_A_DATE_WITHOUT_REQUIRED_CHECK);
}
errors = v.validate();
boolean isInterventional = updateStudy2();
session.setAttribute("isInterventionalFlag", new Boolean(isInterventional));
if (errors.isEmpty()) {
logger.info("no errors");
setMaps(isInterventional);
if (isInterventional) {
forwardPage(Page.CREATE_STUDY3);
} else {
forwardPage(Page.CREATE_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", studyPhaseMap);
request.setAttribute("statuses", Status.toActiveArrayList());
// request.setAttribute("studyTypes", StudyType.toArrayList());
forwardPage(Page.CREATE_STUDY2);
}
}
use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.
the class ContactServlet method processRequest.
@Override
public void processRequest() throws Exception {
String action = request.getParameter("action");
if (StringUtil.isBlank(action)) {
if (ub != null && ub.getId() > 0) {
request.setAttribute("name", ub.getName());
request.setAttribute("email", ub.getEmail());
}
forwardPage(Page.CONTACT);
} else {
if ("submit".equalsIgnoreCase(action)) {
Validator v = new Validator(request);
v.addValidation("name", Validator.NO_BLANKS);
v.addValidation("email", Validator.IS_A_EMAIL);
v.addValidation("subject", Validator.NO_BLANKS);
v.addValidation("message", Validator.NO_BLANKS);
errors = v.validate();
FormProcessor fp = new FormProcessor(request);
if (!errors.isEmpty()) {
request.setAttribute("name", fp.getString("name"));
request.setAttribute("email", fp.getString("email"));
request.setAttribute("subject", fp.getString("subject"));
request.setAttribute("message", fp.getString("message"));
request.setAttribute("formMessages", errors);
forwardPage(Page.CONTACT);
} else {
sendEmail();
}
} else {
if (ub != null && ub.getId() > 0) {
request.setAttribute("name", ub.getName());
request.setAttribute("email", ub.getEmail());
}
forwardPage(Page.CONTACT);
}
}
}
Aggregations