use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class DoubleDataEntryServlet method validateDisplayItemGroupBean.
// note that this step sets us up both for
// displaying the data on the form again, in the event of an error
// and sending the data to the database, in the event of no error
//
// we have to do this after adding the validations, so that we don't
// overwrite the value the item data bean had from initial data entry
// before the validator stores it as part of the Matches Initial Data Entry
// Value validation
// dib = loadFormValue(dib);
// return dib;
// }
// should be from the db, we check here for a difference
@Override
protected List<DisplayItemGroupBean> validateDisplayItemGroupBean(DiscrepancyValidator v, DisplayItemGroupBean digb, List<DisplayItemGroupBean> digbs, List<DisplayItemGroupBean> formGroups, HttpServletRequest request, HttpServletResponse response) {
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
HttpSession session = request.getSession();
LOGGER.info("===got this far");
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
int keyId = ecb.getId();
Integer validationCount = (Integer) session.getAttribute(COUNT_VALIDATE + keyId);
formGroups = loadFormValueForItemGroup(digb, digbs, formGroups, edcb.getId(), request);
LOGGER.info("found formgroups size for " + digb.getGroupMetaBean().getName() + ": " + formGroups.size() + " compare to db groups size: " + digbs.size());
String inputName = "";
for (int i = 0; i < formGroups.size(); i++) {
DisplayItemGroupBean displayGroup = formGroups.get(i);
List<DisplayItemBean> items = displayGroup.getItems();
int order = displayGroup.getOrdinal();
if (displayGroup.isAuto() && displayGroup.getFormInputOrdinal() > 0) {
order = displayGroup.getFormInputOrdinal();
}
for (DisplayItemBean displayItem : items) {
if (displayGroup.isAuto()) {
inputName = getGroupItemInputName(displayGroup, order, displayItem);
} else {
inputName = getGroupItemManualInputName(displayGroup, order, displayItem);
}
validateDisplayItemBean(v, displayItem, inputName, request);
}
if (validationCount == null || validationCount.intValue() == 0) {
if (i == 0 && formGroups.size() != digbs.size()) {
v.addValidation(inputName + "group", Validator.DIFFERENT_NUMBER_OF_GROUPS_IN_DDE);
// TODO internationalize this string, tbh
v.setErrorMessage("There are additional values here that were not present in the initial data entry. You have entered a different number of groups" + " for the item groups containing " + inputName);
}
}
}
return formGroups;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class EnterDataForStudyEventServlet method getUncompletedCRFs.
/**
* Finds all the event definitions for which no event CRF exists - which is
* the list of event definitions with uncompleted event CRFs.
*
* @param eventDefinitionCRFs
* All of the event definition CRFs for this study event.
* @param eventCRFs
* All of the event CRFs for this study event.
* @return The list of event definitions for which no event CRF exists.
*/
private ArrayList getUncompletedCRFs(ArrayList eventDefinitionCRFs, ArrayList eventCRFs) {
int i;
HashMap completed = new HashMap();
HashMap startedButIncompleted = new HashMap();
ArrayList answer = new ArrayList();
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
}
CRFVersionDAO cvdao = new CRFVersionDAO(sm.getDataSource());
ItemDataDAO iddao = new ItemDataDAO(sm.getDataSource());
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
int crfId = cvdao.getCRFIdFromCRFVersionId(ecrf.getCRFVersionId());
ArrayList idata = iddao.findAllByEventCRFId(ecrf.getId());
if (!idata.isEmpty()) {
// this crf has data already
completed.put(new Integer(crfId), Boolean.TRUE);
} else {
// event crf got created, but no data entered
startedButIncompleted.put(new Integer(crfId), ecrf);
}
}
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
dedc.setEdc(edcrf);
Boolean b = (Boolean) completed.get(new Integer(edcrf.getCrfId()));
EventCRFBean ev = (EventCRFBean) startedButIncompleted.get(new Integer(edcrf.getCrfId()));
if (b == null || !b.booleanValue()) {
dedc.setEventCRF(ev);
answer.add(dedc);
}
}
return answer;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class ViewStudySubjectServlet method getUncompletedCRFs.
/**
* Finds all the event definitions for which no event CRF exists - which is
* the list of event definitions with uncompleted event CRFs.
*
* @param eventDefinitionCRFs
* All of the event definition CRFs for this study event.
* @param eventCRFs
* All of the event CRFs for this study event.
* @return The list of event definitions for which no event CRF exists.
*/
public static ArrayList getUncompletedCRFs(DataSource ds, ArrayList eventDefinitionCRFs, ArrayList eventCRFs, SubjectEventStatus status) {
int i;
HashMap completed = new HashMap();
HashMap startedButIncompleted = new HashMap();
ArrayList answer = new ArrayList();
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
completed.put(new Integer(edcrf.getCrfId()), Boolean.FALSE);
startedButIncompleted.put(new Integer(edcrf.getCrfId()), new EventCRFBean());
}
CRFVersionDAO cvdao = new CRFVersionDAO(ds);
ItemDataDAO iddao = new ItemDataDAO(ds);
for (i = 0; i < eventCRFs.size(); i++) {
EventCRFBean ecrf = (EventCRFBean) eventCRFs.get(i);
// System.out.println("########event crf id:" + ecrf.getId());
int crfId = cvdao.getCRFIdFromCRFVersionId(ecrf.getCRFVersionId());
ArrayList idata = iddao.findAllByEventCRFId(ecrf.getId());
if (!idata.isEmpty()) {
// this crf has data already
completed.put(new Integer(crfId), Boolean.TRUE);
} else {
// event crf got created, but no data entered
// System.out.println("added one into startedButIncompleted" + ecrf.getId());
startedButIncompleted.put(new Integer(crfId), ecrf);
}
}
// TODO possible relation to 1689 here, tbh
for (i = 0; i < eventDefinitionCRFs.size(); i++) {
DisplayEventDefinitionCRFBean dedc = new DisplayEventDefinitionCRFBean();
EventDefinitionCRFBean edcrf = (EventDefinitionCRFBean) eventDefinitionCRFs.get(i);
// System.out.println("created dedc with edcrf
// "+edcrf.getCrfName()+" default version "+
// edcrf.getDefaultVersionName()+", id
// "+edcrf.getDefaultVersionId());
dedc.setEdc(edcrf);
// below added tbh, 112007 to fix bug 1943
if (status.equals(SubjectEventStatus.LOCKED)) {
dedc.setStatus(Status.LOCKED);
}
Boolean b = (Boolean) completed.get(new Integer(edcrf.getCrfId()));
EventCRFBean ev = (EventCRFBean) startedButIncompleted.get(new Integer(edcrf.getCrfId()));
if (b == null || !b.booleanValue()) {
// System.out.println("entered boolean loop with ev
// "+ev.getId()+" crf version id "+
// ev.getCRFVersionId());
dedc.setEventCRF(ev);
answer.add(dedc);
// System.out.println("just added dedc to answer");
// removed, tbh, since this is proving nothing, 11-2007
/*
* if (dedc.getEdc().getDefaultVersionId() !=
* dedc.getEventCRF().getId()) { System.out.println("ID
* MISMATCH: edc name "+dedc.getEdc().getName()+ ", default
* version id "+dedc.getEdc().getDefaultVersionId()+ " event crf
* id "+dedc.getEventCRF().getId()); }
*/
}
}
// System.out.println("size of answer" + answer.size());
return answer;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class UpdateSubStudyServlet method validateSubmissionUrl.
public ArrayList<EventDefinitionCRFBean> validateSubmissionUrl(ArrayList<EventDefinitionCRFBean> edcsInSession, ArrayList<EventDefinitionCRFBean> eventDefCrfList, Validator v, StudyEventDefinitionBean sed) {
for (int i = 0; i < edcsInSession.size(); i++) {
String order = i + "-" + edcsInSession.get(i).getId();
v.addValidation("submissionUrl" + order, Validator.NO_SPACES_ALLOWED);
EventDefinitionCRFBean sessionBean = null;
boolean isExist = false;
for (EventDefinitionCRFBean eventDef : eventDefCrfList) {
sessionBean = edcsInSession.get(i);
System.out.println("iter: " + eventDef.getId() + "--db: " + eventDef.getSubmissionUrl());
System.out.println("edcsInSession: " + sessionBean.getId() + "--session:" + sessionBean.getSubmissionUrl());
if (sessionBean.getSubmissionUrl().trim().equals("") || sessionBean.getSubmissionUrl().trim() == null) {
break;
} else {
if ((eventDef.getSubmissionUrl().trim().equalsIgnoreCase(sessionBean.getSubmissionUrl().trim()) && (eventDef.getId() != sessionBean.getId())) || (eventDef.getSubmissionUrl().trim().equalsIgnoreCase(sessionBean.getSubmissionUrl().trim()) && (eventDef.getId() == sessionBean.getId()) && eventDef.getId() == 0)) {
v.addValidation("submissionUrl" + order, Validator.SUBMISSION_URL_NOT_UNIQUE);
sed.setPopulated(true);
System.out.println("Duplicate ****************************");
System.out.println();
isExist = true;
break;
} else if (eventDef.getSubmissionUrl().trim().equalsIgnoreCase(sessionBean.getSubmissionUrl().trim()) && (eventDef.getId() == sessionBean.getId())) {
System.out.println("Not Duplicate ***********");
System.out.println();
isExist = true;
break;
}
}
}
if (!isExist) {
eventDefCrfList.add(sessionBean);
}
}
return eventDefCrfList;
}
use of org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean in project OpenClinica by OpenClinica.
the class InitialDataEntryServlet method validateDisplayItemGroupBean.
@Override
protected List<DisplayItemGroupBean> validateDisplayItemGroupBean(DiscrepancyValidator v, DisplayItemGroupBean digb, List<DisplayItemGroupBean> digbs, List<DisplayItemGroupBean> formGroups, HttpServletRequest request, HttpServletResponse response) {
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
formGroups = loadFormValueForItemGroup(digb, digbs, formGroups, edcb.getId(), request);
String inputName = "";
for (int i = 0; i < formGroups.size(); i++) {
DisplayItemGroupBean displayGroup = formGroups.get(i);
List<DisplayItemBean> items = displayGroup.getItems();
int order = displayGroup.getOrdinal();
if (displayGroup.isAuto() && displayGroup.getFormInputOrdinal() > 0) {
order = displayGroup.getFormInputOrdinal();
}
for (DisplayItemBean displayItem : items) {
if (displayGroup.isAuto()) {
inputName = getGroupItemInputName(displayGroup, order, displayItem);
} else {
inputName = getGroupItemManualInputName(displayGroup, order, displayItem);
}
validateDisplayItemBean(v, displayItem, inputName, request);
}
}
return formGroups;
}
Aggregations