use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class InitCreateCRFVersionServlet method processRequest.
@Override
public void processRequest() throws Exception {
resetPanel();
panel.setStudyInfoShown(false);
panel.setOrderedData(true);
setToPanel(resword.getString("create_CRF"), respage.getString("br_create_new_CRF_entering"));
setToPanel(resword.getString("create_CRF_version"), respage.getString("br_create_new_CRF_uploading"));
setToPanel(resword.getString("revise_CRF_version"), respage.getString("br_if_you_owner_CRF_version"));
setToPanel(resword.getString("CRF_spreadsheet_template"), respage.getString("br_download_blank_CRF_spreadsheet_from"));
setToPanel(resword.getString("example_CRF_br_spreadsheets"), respage.getString("br_download_example_CRF_instructions_from"));
String idString = request.getParameter("crfId");
/*
* now that we have automated the choice of crf id, we need to get it from someplace else besides the
* request...this is throwing off the generation of filenames and other processes downstream, tbh 06/2008
*/
String name = request.getParameter("name");
logger.info("*** ^^^ *** crf id:" + idString);
// checks which module the requests are from
String module = request.getParameter(MODULE);
request.setAttribute(MODULE, module);
session.setAttribute("xformEnabled", CoreResources.getField("xform.enabled"));
if (StringUtil.isBlank(idString) || StringUtil.isBlank(name)) {
addPageMessage(respage.getString("please_choose_a_CRF_to_add_new_version_for"));
forwardPage(Page.CRF_LIST);
} else {
// crf id
int crfId = Integer.valueOf(idString.trim()).intValue();
CRFVersionBean version = new CRFVersionBean();
version.setCrfId(crfId);
session.setAttribute("version", version);
request.setAttribute("crfName", name);
request.setAttribute("CrfId", new Integer(crfId));
forwardPage(Page.CREATE_CRF_VERSION);
}
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class RestoreCRFServlet method processRequest.
@Override
public void processRequest() throws Exception {
CRFDAO cdao = new CRFDAO(sm.getDataSource());
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
// checks which module the requests are from
String module = fp.getString(MODULE);
request.setAttribute(MODULE, module);
int crfId = fp.getInt("id", true);
String action = request.getParameter("action");
if (crfId == 0) {
addPageMessage(respage.getString("please_choose_a_CRF_to_restore"));
forwardPage(Page.CRF_LIST_SERVLET);
} else {
CRFBean crf = (CRFBean) cdao.findByPK(crfId);
ArrayList versions = cvdao.findAllByCRFId(crfId);
crf.setVersions(versions);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList edcs = (ArrayList) edcdao.findAllByCRF(crfId);
SectionDAO secdao = new SectionDAO(sm.getDataSource());
EventCRFDAO evdao = new EventCRFDAO(sm.getDataSource());
ArrayList eventCRFs = evdao.findAllByCRF(crfId);
if ("confirm".equalsIgnoreCase(action)) {
request.setAttribute("crfToRestore", crf);
request.setAttribute("eventCRFs", eventCRFs);
forwardPage(Page.RESTORE_CRF);
} else {
logger.info("submit to restore the crf");
crf.setStatus(Status.AVAILABLE);
crf.setUpdater(ub);
crf.setUpdatedDate(new Date());
cdao.update(crf);
for (int i = 0; i < versions.size(); i++) {
CRFVersionBean version = (CRFVersionBean) versions.get(i);
if (version.getStatus().equals(Status.AUTO_DELETED)) {
version.setStatus(Status.AVAILABLE);
version.setUpdater(ub);
version.setUpdatedDate(new Date());
cvdao.update(version);
ArrayList sections = secdao.findAllByCRFVersionId(version.getId());
for (int j = 0; j < sections.size(); j++) {
SectionBean section = (SectionBean) sections.get(j);
if (section.getStatus().equals(Status.AUTO_DELETED)) {
section.setStatus(Status.AVAILABLE);
section.setUpdater(ub);
section.setUpdatedDate(new Date());
secdao.update(section);
}
}
}
}
for (int i = 0; i < edcs.size(); i++) {
EventDefinitionCRFBean edc = (EventDefinitionCRFBean) edcs.get(i);
if (edc.getStatus().equals(Status.AUTO_DELETED)) {
edc.setStatus(Status.AVAILABLE);
edc.setUpdater(ub);
edc.setUpdatedDate(new Date());
edcdao.update(edc);
}
}
ItemDataDAO idao = new ItemDataDAO(sm.getDataSource());
for (int i = 0; i < eventCRFs.size(); i++) {
EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(i);
if (eventCRF.getStatus().equals(Status.AUTO_DELETED)) {
eventCRF.setStatus(Status.AVAILABLE);
eventCRF.setUpdater(ub);
eventCRF.setUpdatedDate(new Date());
evdao.update(eventCRF);
ArrayList items = idao.findAllByEventCRFId(eventCRF.getId());
for (int j = 0; j < items.size(); j++) {
ItemDataBean item = (ItemDataBean) items.get(j);
if (item.getStatus().equals(Status.AUTO_DELETED)) {
item.setStatus(Status.AVAILABLE);
item.setUpdater(ub);
item.setUpdatedDate(new Date());
idao.update(item);
}
}
}
}
addPageMessage(respage.getString("the_CRF") + crf.getName() + " " + respage.getString("has_been_restored_succesfully"));
forwardPage(Page.CRF_LIST_SERVLET);
}
}
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class RestoreCRFVersionServlet method processRequest.
@Override
public void processRequest() throws Exception {
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
FormProcessor fp = new FormProcessor(request);
// checks which module the requests are from
String module = fp.getString(MODULE);
request.setAttribute(MODULE, module);
int versionId = fp.getInt("id", true);
String action = fp.getString("action");
if (versionId == 0) {
addPageMessage(respage.getString("please_choose_a_CRF_version_to_restore"));
forwardPage(Page.CRF_LIST_SERVLET);
} else {
if (StringUtil.isBlank(action)) {
addPageMessage(respage.getString("no_action_specified"));
forwardPage(Page.CRF_LIST_SERVLET);
return;
}
CRFVersionBean version = (CRFVersionBean) cvdao.findByPK(versionId);
SectionDAO secdao = new SectionDAO(sm.getDataSource());
EventCRFDAO evdao = new EventCRFDAO(sm.getDataSource());
// find all event crfs by version id
ArrayList eventCRFs = evdao.findAllByCRFVersion(versionId);
if ("confirm".equalsIgnoreCase(action)) {
request.setAttribute("versionToRestore", version);
request.setAttribute("eventCRFs", eventCRFs);
forwardPage(Page.RESTORE_CRF_VERSION);
} else {
logger.info("submit to restore the crf version");
// version
version.setStatus(Status.AVAILABLE);
version.setUpdater(ub);
version.setUpdatedDate(new Date());
cvdao.update(version);
// all sections
ArrayList sections = secdao.findAllByCRFVersionId(version.getId());
for (int j = 0; j < sections.size(); j++) {
SectionBean section = (SectionBean) sections.get(j);
if (section.getStatus().equals(Status.AUTO_DELETED)) {
section.setStatus(Status.AVAILABLE);
section.setUpdater(ub);
section.setUpdatedDate(new Date());
secdao.update(section);
}
}
// all item data related to event crfs
ItemDataDAO idao = new ItemDataDAO(sm.getDataSource());
for (int i = 0; i < eventCRFs.size(); i++) {
EventCRFBean eventCRF = (EventCRFBean) eventCRFs.get(i);
if (eventCRF.getStatus().equals(Status.AUTO_DELETED)) {
eventCRF.setStatus(Status.AVAILABLE);
eventCRF.setUpdater(ub);
eventCRF.setUpdatedDate(new Date());
evdao.update(eventCRF);
ArrayList items = idao.findAllByEventCRFId(eventCRF.getId());
for (int j = 0; j < items.size(); j++) {
ItemDataBean item = (ItemDataBean) items.get(j);
if (item.getStatus().equals(Status.AUTO_DELETED)) {
item.setStatus(Status.AVAILABLE);
item.setUpdater(ub);
item.setUpdatedDate(new Date());
idao.update(item);
}
}
}
}
addPageMessage(respage.getString("the_CRF_version") + version.getName() + " " + respage.getString("has_been_restored_succesfully"));
forwardPage(Page.CRF_LIST_SERVLET);
}
}
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class DefineStudyEventServlet method confirmWholeDefinition.
/**
* Validates the entire definition
*
* @throws Exception
*/
private void confirmWholeDefinition() throws Exception {
Validator v = new Validator(request);
FormProcessor fp = new FormProcessor(request);
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
ArrayList eventDefinitionCRFs = new ArrayList();
FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
for (int i = 0; i < sed.getCrfs().size(); i++) {
EventDefinitionCRFBean edcBean = new EventDefinitionCRFBean();
int crfId = fp.getInt("crfId" + i);
int defaultVersionId = fp.getInt("defaultVersionId" + i);
edcBean.setCrfId(crfId);
edcBean.setDefaultVersionId(defaultVersionId);
FormLayoutBean defaultVersion = (FormLayoutBean) fldao.findByPK(edcBean.getDefaultVersionId());
edcBean.setDefaultVersionName(defaultVersion.getName());
String crfName = fp.getString("crfName" + i);
edcBean.setCrfName(crfName);
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 participantForm = fp.getString("participantForm" + i);
String allowAnonymousSubmission = fp.getString("allowAnonymousSubmission" + i);
String submissionUrl = fp.getString("submissionUrl" + i);
String offline = fp.getString("offline" + i);
// issue 312 BWP<<
String hiddenCrf = fp.getString("hiddenCrf" + i);
// hideCRF is false by default in the bean
if (!StringUtil.isBlank(hiddenCrf) && "yes".equalsIgnoreCase(hiddenCrf.trim())) {
edcBean.setHideCrf(true);
} else {
edcBean.setHideCrf(false);
}
// >>
String sdvOption = fp.getString("sdvOption" + i);
if (!StringUtils.isBlank(sdvOption)) {
int id = Integer.valueOf(sdvOption);
edcBean.setSourceDataVerification(SourceDataVerification.getByCode(id));
}
if (!StringUtils.isBlank(requiredCRF) && "yes".equalsIgnoreCase(requiredCRF.trim())) {
edcBean.setRequiredCRF(true);
} else {
edcBean.setRequiredCRF(false);
}
if (!StringUtils.isBlank(participantForm) && "yes".equalsIgnoreCase(participantForm.trim())) {
edcBean.setParticipantForm(true);
} else {
edcBean.setParticipantForm(false);
}
// when participant form is not selected, force allow anonymous to be not selected
if (edcBean.isParticipantForm() && !StringUtils.isBlank(allowAnonymousSubmission) && "yes".equalsIgnoreCase(allowAnonymousSubmission.trim())) {
edcBean.setAllowAnonymousSubmission(true);
} else {
edcBean.setAllowAnonymousSubmission(false);
}
if (!StringUtils.isBlank(offline) && "yes".equalsIgnoreCase(offline.trim())) {
edcBean.setOffline(true);
} else {
edcBean.setOffline(false);
}
if (!StringUtils.isBlank(doubleEntry) && "yes".equalsIgnoreCase(doubleEntry.trim())) {
edcBean.setDoubleEntry(true);
} else {
edcBean.setDoubleEntry(false);
}
if (!StringUtils.isBlank(decisionCondition) && "yes".equalsIgnoreCase(decisionCondition.trim())) {
edcBean.setDecisionCondition(true);
} else {
edcBean.setDecisionCondition(false);
}
if (!StringUtils.isBlank(electronicSignature) && "yes".equalsIgnoreCase(electronicSignature.trim())) {
edcBean.setElectronicSignature(true);
} else {
edcBean.setElectronicSignature(false);
}
// also useful to protect from naughty submission not coming from our html form
if (edcBean.isParticipantForm() && edcBean.isAllowAnonymousSubmission()) {
edcBean.setSubmissionUrl(submissionUrl.trim());
}
ArrayList<CRFVersionBean> versions = fldao.findAllByCRFId(crfId);
edcBean.setVersions(versions);
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 (!StringUtils.isBlank(myNull) && "yes".equalsIgnoreCase(myNull.trim())) {
nullString = nullString + n.getName().toUpperCase() + ",";
}
}
edcBean.setNullValues(nullString);
edcBean.setStudyId(ub.getActiveStudyId());
eventDefinitionCRFs.add(edcBean);
}
StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
request.setAttribute("participateFormStatus", participateFormStatus);
if (participateFormStatus.equals("enabled"))
baseUrl();
request.setAttribute("participateFormStatus", participateFormStatus);
request.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
// not used on page
session.setAttribute("edCRFs", eventDefinitionCRFs);
ArrayList<EventDefinitionCRFBean> edcsInSession = (ArrayList<EventDefinitionCRFBean>) session.getAttribute("edCRFs");
int parentStudyId = sed.getStudyId();
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
ArrayList<EventDefinitionCRFBean> eventDefCrfList = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllActiveSitesAndStudiesPerParentStudy(parentStudyId);
if (eventDefCrfList.size() != 0)
validateSubmissionUrl(edcsInSession, eventDefCrfList, v);
errors = v.validate();
if (!errors.isEmpty()) {
ArrayList<String> sdvOptions = new ArrayList<String>();
sdvOptions.add(SourceDataVerification.AllREQUIRED.toString());
sdvOptions.add(SourceDataVerification.PARTIALREQUIRED.toString());
sdvOptions.add(SourceDataVerification.NOTREQUIRED.toString());
sdvOptions.add(SourceDataVerification.NOTAPPLICABLE.toString());
request.setAttribute("sdvOptions", sdvOptions);
logger.info("has errors");
session.setAttribute("eventDefinitionCRFs", eventDefinitionCRFs);
request.setAttribute("formMessages", errors);
forwardPage(Page.DEFINE_STUDY_EVENT4);
}
forwardPage(Page.DEFINE_STUDY_EVENT_CONFIRM);
}
use of org.akaza.openclinica.bean.submit.CRFVersionBean in project OpenClinica by OpenClinica.
the class ListEventDefinitionServlet method processRequest.
/**
* Processes the request
*/
@Override
public void processRequest() throws Exception {
StudyEventDefinitionDAO edao = new StudyEventDefinitionDAO(sm.getDataSource());
UserAccountDAO sdao = new UserAccountDAO(sm.getDataSource());
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
CRFDAO crfDao = new CRFDAO(sm.getDataSource());
CRFVersionDAO crfVersionDao = new CRFVersionDAO(sm.getDataSource());
ArrayList seds = edao.findAllByStudy(currentStudy);
// request.setAttribute("seds", seds);
StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (int i = 0; i < seds.size(); i++) {
StudyEventDefinitionBean sed = (StudyEventDefinitionBean) seds.get(i);
Collection eventDefinitionCRFlist = edcdao.findAllParentsByDefinition(sed.getId());
Map crfWithDefaultVersion = new LinkedHashMap();
for (Iterator it = eventDefinitionCRFlist.iterator(); it.hasNext(); ) {
EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) it.next();
CRFBean crfBean = (CRFBean) crfDao.findByPK(edcBean.getCrfId());
CRFVersionBean crfVersionBean = (CRFVersionBean) crfVersionDao.findByPK(edcBean.getDefaultVersionId());
logger.info("ED[" + sed.getName() + "]crf[" + crfBean.getName() + "]dv[" + crfVersionBean.getName() + "]");
crfWithDefaultVersion.put(crfBean.getName(), crfVersionBean.getName());
}
sed.setCrfsWithDefaultVersion(crfWithDefaultVersion);
logger.info("CRF size [" + sed.getCrfs().size() + "]");
if (sed.getUpdater().getId() == 0) {
sed.setUpdater(sed.getOwner());
sed.setUpdatedDate(sed.getCreatedDate());
}
if (isPopulated(sed, sedao)) {
sed.setPopulated(true);
}
}
FormProcessor fp = new FormProcessor(request);
EntityBeanTable table = fp.getEntityBeanTable();
ArrayList allStudyRows = StudyEventDefinitionRow.generateRowsFromBeans(seds);
String[] columns = { resword.getString("order"), resword.getString("name"), resword.getString("OID"), resword.getString("repeating"), resword.getString("type"), resword.getString("category"), resword.getString("populated"), resword.getString("date_created"), resword.getString("date_updated"), resword.getString("CRFs"), resword.getString("default_version"), resword.getString("actions") };
table.setColumns(new ArrayList(Arrays.asList(columns)));
// >> tbh #4169 09/2009
table.hideColumnLink(2);
table.hideColumnLink(3);
table.hideColumnLink(4);
table.hideColumnLink(6);
table.hideColumnLink(7);
table.hideColumnLink(8);
table.hideColumnLink(9);
// crfs, tbh
table.hideColumnLink(10);
table.hideColumnLink(11);
table.hideColumnLink(12);
// << tbh 09/2009
table.setQuery("ListEventDefinition", new HashMap());
// if (!currentStudy.getStatus().isLocked()) {
// table.addLink(resworkflow.getString(
// "create_a_new_study_event_definition"), "DefineStudyEvent");
// }
table.setRows(allStudyRows);
table.setPaginated(false);
table.computeDisplay();
request.setAttribute("table", table);
request.setAttribute("defSize", new Integer(seds.size()));
if (request.getParameter("read") != null && request.getParameter("read").equals("true")) {
request.setAttribute("readOnly", true);
}
forwardPage(Page.STUDY_EVENT_DEFINITION_LIST);
}
Aggregations