use of org.akaza.openclinica.bean.core.DataEntryStage in project OpenClinica by OpenClinica.
the class DataImportService method validateData.
/**
* Import Data, the logic which imports the data for our data service. Note that we will return three strings string
* 0: status, either 'success', 'fail', or 'warn'. string 1: the message string which will be returned in our soap
* response string 2: the audit message, currently not used but will be saved in the event of a success.
*
* import consist from 3 steps 1) parse xml and extract data 2) validation 3) data submission
*
* @author thickerson
* @param dataSource
* @param resources
* @param studyBean
* @param userBean
* @param xml
* @return
* @throws Exception
*
* /* VALIDATE data on all levels
*
* msg - contains status messages
* @return list of errors
*/
public List<String> validateData(ODMContainer odmContainer, DataSource dataSource, CoreResources resources, StudyBean studyBean, UserAccountBean userBean, List<DisplayItemBeanWrapper> displayItemBeanWrappers, HashMap<Integer, String> importedCRFStatuses) {
ResourceBundle respage = ResourceBundleProvider.getPageMessagesBundle();
setRespage(respage);
TriggerService triggerService = new TriggerService();
StringBuffer auditMsg = new StringBuffer();
List<String> errors = new ArrayList<String>();
// htaycher: return back later?
auditMsg.append(respage.getString("passed_study_check") + " ");
auditMsg.append(respage.getString("passed_oid_metadata_check") + " ");
// validation errors, the same as in the ImportCRFDataServlet. DRY?
Boolean eventCRFStatusesValid = getImportCRFDataService(dataSource).eventCRFStatusesValid(odmContainer, userBean);
List<EventCRFBean> eventCRFBeans = getImportCRFDataService(dataSource).fetchEventCRFBeans(odmContainer, userBean);
// The following line updates a map that is used for setting the EventCRF status post import
getImportCRFDataService(dataSource).fetchEventCRFStatuses(odmContainer, importedCRFStatuses);
ArrayList<Integer> permittedEventCRFIds = new ArrayList<Integer>();
// -- does the event already exist? if not, fail
if (eventCRFBeans == null) {
errors.add(respage.getString("the_event_crf_not_correct_status"));
return errors;
} else if (eventCRFBeans.isEmpty() && !eventCRFStatusesValid) {
errors.add(respage.getString("the_event_crf_not_correct_status"));
return errors;
} else if (eventCRFBeans.isEmpty()) {
errors.add(respage.getString("no_event_crfs_matching_the_xml_metadata"));
return errors;
}
logger.debug("found a list of eventCRFBeans: " + eventCRFBeans.toString());
for (EventCRFBean eventCRFBean : eventCRFBeans) {
DataEntryStage dataEntryStage = eventCRFBean.getStage();
Status eventCRFStatus = eventCRFBean.getStatus();
logger.debug("Event CRF Bean: id " + eventCRFBean.getId() + ", data entry stage " + dataEntryStage.getName() + ", status " + eventCRFStatus.getName());
if (eventCRFStatus.equals(Status.AVAILABLE) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) || dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) || dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
permittedEventCRFIds.add(new Integer(eventCRFBean.getId()));
} else {
errors.add(respage.getString("your_listed_crf_in_the_file") + " " + eventCRFBean.getEventName());
continue;
}
}
if (eventCRFBeans.size() >= permittedEventCRFIds.size()) {
auditMsg.append(respage.getString("passed_event_crf_status_check") + " ");
} else {
auditMsg.append(respage.getString("the_event_crf_not_correct_status") + " ");
}
// List<DisplayItemBeanWrapper> displayItemBeanWrappers = new ArrayList<DisplayItemBeanWrapper>();
HashMap<String, String> totalValidationErrors = new HashMap<String, String>();
HashMap<String, String> hardValidationErrors = new HashMap<String, String>();
try {
List<DisplayItemBeanWrapper> tempDisplayItemBeanWrappers = new ArrayList<DisplayItemBeanWrapper>();
// htaycher: this should be rewritten with validator not to use request to store data
MockHttpServletRequest request = new MockHttpServletRequest();
request.addPreferredLocale(getLocale());
tempDisplayItemBeanWrappers = getImportCRFDataService(dataSource).lookupValidationErrors(request, odmContainer, userBean, totalValidationErrors, hardValidationErrors, permittedEventCRFIds);
displayItemBeanWrappers.addAll(tempDisplayItemBeanWrappers);
logger.debug("size of total validation errors: " + (totalValidationErrors.size() + hardValidationErrors.size()));
ArrayList<SubjectDataBean> subjectData = odmContainer.getCrfDataPostImportContainer().getSubjectData();
if (!hardValidationErrors.isEmpty()) {
// check here where to get group repeat key
errors.add(triggerService.generateHardValidationErrorMessage(subjectData, hardValidationErrors, "1"));
}
if (!totalValidationErrors.isEmpty()) {
errors.add(triggerService.generateHardValidationErrorMessage(subjectData, totalValidationErrors, "1"));
}
} catch (NullPointerException npe1) {
// what if you have 2 event crfs but the third is a fake?
npe1.printStackTrace();
errors.add(respage.getString("an_error_was_thrown_while_validation_errors"));
logger.debug("=== threw the null pointer, import === " + npe1.getMessage());
} catch (OpenClinicaException oce1) {
errors.add(oce1.getOpenClinicaMessage());
logger.debug("=== threw the openclinica message, import === " + oce1.getOpenClinicaMessage());
}
auditMsg.append(respage.getString("passing_crf_edit_checks") + " ");
return errors;
}
use of org.akaza.openclinica.bean.core.DataEntryStage in project OpenClinica by OpenClinica.
the class ImportCRFDataService method lookupValidationErrors.
public List<DisplayItemBeanWrapper> lookupValidationErrors(HttpServletRequest request, ODMContainer odmContainer, UserAccountBean ub, HashMap<String, String> totalValidationErrors, HashMap<String, String> hardValidationErrors, ArrayList<Integer> permittedEventCRFIds) throws OpenClinicaException {
DisplayItemBeanWrapper displayItemBeanWrapper = null;
HashMap validationErrors = new HashMap();
List<DisplayItemBeanWrapper> wrappers = new ArrayList<DisplayItemBeanWrapper>();
ImportHelper importHelper = new ImportHelper();
FormDiscrepancyNotes discNotes = new FormDiscrepancyNotes();
DiscrepancyValidator discValidator = new DiscrepancyValidator(request, discNotes);
// create a second Validator, this one for hard edit checks
HashMap<String, String> hardValidator = new HashMap<String, String>();
StudyEventDAO studyEventDAO = new StudyEventDAO(ds);
StudyDAO studyDAO = new StudyDAO(ds);
StudyBean studyBean = studyDAO.findByOid(odmContainer.getCrfDataPostImportContainer().getStudyOID());
StudySubjectDAO studySubjectDAO = new StudySubjectDAO(ds);
StudyEventDefinitionDAO sedDao = new StudyEventDefinitionDAO(ds);
HashMap<String, ItemDataBean> blankCheck = new HashMap<String, ItemDataBean>();
String hardValidatorErrorMsgs = "";
ArrayList<SubjectDataBean> subjectDataBeans = odmContainer.getCrfDataPostImportContainer().getSubjectData();
int totalEventCRFCount = 0;
int totalItemDataBeanCount = 0;
for (SubjectDataBean subjectDataBean : subjectDataBeans) {
ArrayList<DisplayItemBean> displayItemBeans = new ArrayList<DisplayItemBean>();
logger.debug("iterating through subject data beans: found " + subjectDataBean.getSubjectOID());
ArrayList<StudyEventDataBean> studyEventDataBeans = subjectDataBean.getStudyEventData();
totalEventCRFCount += studyEventDataBeans.size();
StudySubjectBean studySubjectBean = studySubjectDAO.findByOidAndStudy(subjectDataBean.getSubjectOID(), studyBean.getId());
for (StudyEventDataBean studyEventDataBean : studyEventDataBeans) {
int parentStudyId = studyBean.getParentStudyId();
StudyEventDefinitionBean sedBean = sedDao.findByOidAndStudy(studyEventDataBean.getStudyEventOID(), studyBean.getId(), parentStudyId);
ArrayList<FormDataBean> formDataBeans = studyEventDataBean.getFormData();
logger.debug("iterating through study event data beans: found " + studyEventDataBean.getStudyEventOID());
int ordinal = 1;
try {
ordinal = new Integer(studyEventDataBean.getStudyEventRepeatKey()).intValue();
} catch (Exception e) {
// trying to catch NPEs, because tags can be without the
// repeat key
}
StudyEventBean studyEvent = (StudyEventBean) studyEventDAO.findByStudySubjectIdAndDefinitionIdAndOrdinal(studySubjectBean.getId(), sedBean.getId(), ordinal);
displayItemBeans = new ArrayList<DisplayItemBean>();
for (FormDataBean formDataBean : formDataBeans) {
Map<String, Integer> groupMaxOrdinals = new HashMap<String, Integer>();
displayItemBeanWrapper = null;
CRFVersionDAO crfVersionDAO = new CRFVersionDAO(ds);
EventCRFDAO eventCRFDAO = new EventCRFDAO(ds);
ArrayList<CRFVersionBean> crfVersionBeans = crfVersionDAO.findAllByOid(formDataBean.getFormOID());
ArrayList<ImportItemGroupDataBean> itemGroupDataBeans = formDataBean.getItemGroupData();
if ((crfVersionBeans == null) || (crfVersionBeans.size() == 0)) {
MessageFormat mf = new MessageFormat("");
mf.applyPattern(respage.getString("your_crf_version_oid_did_not_generate"));
Object[] arguments = { formDataBean.getFormOID() };
throw new OpenClinicaException(mf.format(arguments), "");
}
CRFVersionBean crfVersion = crfVersionBeans.get(0);
// if you have a mispelled form oid you get an error here
// need to error out gracefully and post an error
logger.debug("iterating through form beans: found " + crfVersion.getOid());
// may be the point where we cut off item groups etc and
// instead work on sections
EventCRFBean eventCRFBean = eventCRFDAO.findByEventCrfVersion(studyEvent, crfVersion);
EventDefinitionCRFDAO eventDefinitionCRFDAO = new EventDefinitionCRFDAO(ds);
EventDefinitionCRFBean eventDefinitionCRF = eventDefinitionCRFDAO.findByStudyEventIdAndCRFVersionId(studyBean, studyEvent.getId(), crfVersion.getId());
if (eventCRFBean != null) {
if (permittedEventCRFIds.contains(new Integer(eventCRFBean.getId()))) {
for (ImportItemGroupDataBean itemGroupDataBean : itemGroupDataBeans) {
groupMaxOrdinals.put(itemGroupDataBean.getItemGroupOID(), 1);
}
// correctness, tbh
for (ImportItemGroupDataBean itemGroupDataBean : itemGroupDataBeans) {
ArrayList<ItemBean> blankCheckItems = new ArrayList<ItemBean>();
ArrayList<ImportItemDataBean> itemDataBeans = itemGroupDataBean.getItemData();
logger.debug("iterating through group beans: " + itemGroupDataBean.getItemGroupOID());
// put a checker in here
ItemGroupDAO itemGroupDAO = new ItemGroupDAO(ds);
ItemGroupBean testBean = itemGroupDAO.findByOid(itemGroupDataBean.getItemGroupOID());
if (testBean == null) {
// TODO i18n of message
MessageFormat mf = new MessageFormat("");
mf.applyPattern(respage.getString("your_item_group_oid_for_form_oid"));
Object[] arguments = { itemGroupDataBean.getItemGroupOID(), formDataBean.getFormOID() };
throw new OpenClinicaException(mf.format(arguments), "");
}
totalItemDataBeanCount += itemDataBeans.size();
for (ImportItemDataBean importItemDataBean : itemDataBeans) {
logger.debug(" iterating through item data beans: " + importItemDataBean.getItemOID());
ItemDAO itemDAO = new ItemDAO(ds);
ItemFormMetadataDAO itemFormMetadataDAO = new ItemFormMetadataDAO(ds);
List<ItemBean> itemBeans = itemDAO.findByOid(importItemDataBean.getItemOID());
if (!itemBeans.isEmpty()) {
ItemBean itemBean = itemBeans.get(0);
logger.debug(" found " + itemBean.getName());
// throw a null pointer? hopefully not if its been checked...
DisplayItemBean displayItemBean = new DisplayItemBean();
displayItemBean.setItem(itemBean);
ArrayList<ItemFormMetadataBean> metadataBeans = itemFormMetadataDAO.findAllByItemId(itemBean.getId());
logger.debug(" found metadata item beans: " + metadataBeans.size());
int groupOrdinal = 1;
if (itemGroupDataBean.getItemGroupRepeatKey() != null) {
try {
groupOrdinal = new Integer(itemGroupDataBean.getItemGroupRepeatKey()).intValue();
if (groupOrdinal > groupMaxOrdinals.get(itemGroupDataBean.getItemGroupOID())) {
groupMaxOrdinals.put(itemGroupDataBean.getItemGroupOID(), groupOrdinal);
}
} catch (Exception e) {
// do nothing here currently, we are
// looking for a number format
// exception
// from the above.
logger.debug("found npe for group ordinals, line 344!");
}
}
ItemDataBean itemDataBean = createItemDataBean(itemBean, eventCRFBean, importItemDataBean.getValue(), ub, groupOrdinal);
blankCheckItems.add(itemBean);
String newKey = groupOrdinal + "_" + itemGroupDataBean.getItemGroupOID() + "_" + itemBean.getOid() + "_" + subjectDataBean.getSubjectOID();
blankCheck.put(newKey, itemDataBean);
logger.info("adding " + newKey + " to blank checks");
if (!metadataBeans.isEmpty()) {
ItemFormMetadataBean metadataBean = metadataBeans.get(0);
// also possible nullpointer
displayItemBean.setData(itemDataBean);
displayItemBean.setMetadata(metadataBean);
displayItemBean.setEventDefinitionCRF(eventDefinitionCRF);
String eventCRFRepeatKey = studyEventDataBean.getStudyEventRepeatKey();
// if you do indeed leave off this in the XML it will pass but return 'null'
// tbh
attachValidator(displayItemBean, importHelper, discValidator, hardValidator, request, eventCRFRepeatKey, studySubjectBean.getOid());
displayItemBeans.add(displayItemBean);
} else {
MessageFormat mf = new MessageFormat("");
mf.applyPattern(respage.getString("no_metadata_could_be_found"));
Object[] arguments = { importItemDataBean.getItemOID() };
throw new OpenClinicaException(mf.format(arguments), "");
}
} else {
// report the error there
MessageFormat mf = new MessageFormat("");
mf.applyPattern(respage.getString("no_item_could_be_found"));
Object[] arguments = { importItemDataBean.getItemOID() };
throw new OpenClinicaException(mf.format(arguments), "");
}
}
// end item data beans
logger.debug(".. found blank check: " + blankCheck.toString());
for (int i = 1; i <= groupMaxOrdinals.get(itemGroupDataBean.getItemGroupOID()); i++) {
for (ItemBean itemBean : blankCheckItems) {
String newKey = i + "_" + itemGroupDataBean.getItemGroupOID() + "_" + itemBean.getOid() + "_" + subjectDataBean.getSubjectOID();
if (blankCheck.get(newKey) == null) {
// if it already exists, Do Not Add It.
ItemDataBean itemDataCheck = getItemDataDao().findByItemIdAndEventCRFIdAndOrdinal(itemBean.getId(), eventCRFBean.getId(), i);
logger.debug("found item data bean id: " + itemDataCheck.getId() + " for ordinal " + i);
if (itemDataCheck.getId() == 0) {
ItemDataBean blank = createItemDataBean(itemBean, eventCRFBean, "", ub, i);
DisplayItemBean displayItemBean = new DisplayItemBean();
displayItemBean.setItem(itemBean);
displayItemBean.setData(blank);
// displayItemBean.setMetadata(metadataBean);
// set event def crf?
displayItemBean.setEventDefinitionCRF(eventDefinitionCRF);
String eventCRFRepeatKey = studyEventDataBean.getStudyEventRepeatKey();
// if you do indeed leave off this in the XML it will pass but return
// 'null'
// tbh
displayItemBeans.add(displayItemBean);
logger.debug("... adding display item bean");
}
}
logger.debug("found a blank at " + i + ", adding " + blankCheckItems.size() + " blank items");
}
}
// << tbh #5548
blankCheckItems = new ArrayList<ItemBean>();
}
// end item group data beans
}
// matches if on permittedCRFIDs
CRFDAO crfDAO = new CRFDAO(ds);
CRFBean crfBean = crfDAO.findByVersionId(crfVersion.getCrfId());
// seems like an extravagance, but is not contained in crf
// version or event crf bean
validationErrors = discValidator.validate();
// totalValidationErrors.addAll(validationErrors);
for (Object errorKey : validationErrors.keySet()) {
// JN: to avoid duplicate errors
if (!totalValidationErrors.containsKey(errorKey.toString()))
totalValidationErrors.put(errorKey.toString(), validationErrors.get(errorKey).toString());
// assuming that this will be put back in to the core
// method's hashmap, updating statically, tbh 06/2008
logger.debug("+++ adding " + errorKey.toString());
}
logger.debug("-- hard validation checks: --");
for (Object errorKey : hardValidator.keySet()) {
logger.debug(errorKey.toString() + " -- " + hardValidator.get(errorKey));
hardValidationErrors.put(errorKey.toString(), hardValidator.get(errorKey));
// updating here 'statically' tbh 06/2008
hardValidatorErrorMsgs += hardValidator.get(errorKey) + "<br/><br/>";
}
String studyEventId = studyEvent.getId() + "";
String crfVersionId = crfVersion.getId() + "";
logger.debug("creation of wrapper: original count of display item beans " + displayItemBeans.size() + ", count of item data beans " + totalItemDataBeanCount + " count of validation errors " + validationErrors.size() + " count of study subjects " + subjectDataBeans.size() + " count of event crfs " + totalEventCRFCount + " count of hard error checks " + hardValidator.size());
// check if we need to overwrite
DataEntryStage dataEntryStage = eventCRFBean.getStage();
Status eventCRFStatus = eventCRFBean.getStatus();
boolean overwrite = false;
// //JN: Commenting out the following 2 lines, coz the prompt should come in the cases on
if (// eventCRFStatus.equals(Status.UNAVAILABLE) ||
dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY) || dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
overwrite = true;
}
// << tbh, adding extra statuses to prevent appending, 06/2009
// SummaryStatsBean ssBean = new SummaryStatsBean();
// ssBean.setDiscNoteCount(totalValidationErrors);
// ssBean.setEventCrfCount(totalEventCRFCount);
// ssBean.setStudySubjectCount(subjectDataBeans.size());
// // add other stats here, tbh
// not working here, need to do it in a different method,
// tbh
// summary stats added tbh 05/2008
// JN: Changed from validationErrors to totalValidationErrors to create discrepancy notes for
// all
// the
displayItemBeanWrapper = new DisplayItemBeanWrapper(displayItemBeans, true, overwrite, validationErrors, studyEventId, crfVersionId, studyEventDataBean.getStudyEventOID(), studySubjectBean.getLabel(), eventCRFBean.getCreatedDate(), crfBean.getName(), crfVersion.getName(), studySubjectBean.getOid(), studyEventDataBean.getStudyEventRepeatKey());
// JN: Commenting out the following code, since we shouldn't re-initialize at this point, as
// validationErrors would get overwritten and the
// older errors will be overriden. Moving it after the form.
// Removing the comments for now, since it seems to be creating duplicate Discrepancy Notes.
validationErrors = new HashMap();
discValidator = new DiscrepancyValidator(request, discNotes);
// reset to allow for new errors...
}
}
// discValidator = new DiscrepancyValidator(request, discNotes);
if (displayItemBeanWrapper != null && displayItemBeans.size() > 0)
wrappers.add(displayItemBeanWrapper);
}
// after study events
// remove repeats here? remove them below by only forwarding the
// first
// each wrapper represents an Event CRF and a Form, but we don't
// have all events for all forms
// need to not add a wrapper for every event + form combination,
// but instead for every event + form combination which is present
// look at the hack below and see what happens
}
// thrown, tbh 06/2008
if (!hardValidator.isEmpty()) {
// throw new OpenClinicaException(hardValidatorErrorMsgs, "");
}
return wrappers;
}
use of org.akaza.openclinica.bean.core.DataEntryStage in project OpenClinica by OpenClinica.
the class DoubleDataEntryServlet method mayProceed.
/*
* (non-Javadoc)
*
* @see org.akaza.openclinica.control.core.SecureController#mayProceed()
*/
@Override
protected void mayProceed(HttpServletRequest request, HttpServletResponse response) throws InsufficientPermissionException {
checkStudyLocked(Page.LIST_STUDY_SUBJECTS, respage.getString("current_study_locked"), request, response);
checkStudyFrozen(Page.LIST_STUDY_SUBJECTS, respage.getString("current_study_frozen"), request, response);
UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
StudyUserRoleBean currentRole = (StudyUserRoleBean) request.getSession().getAttribute("userRole");
HttpSession session = request.getSession();
locale = LocaleResolver.getLocale(request);
// < respage =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.page_messages",
// locale);
// < restext =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.notes",locale);
// <
// resexception=ResourceBundle.getBundle(
// "org.akaza.openclinica.i18n.exceptions",locale);
// < resword =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.words",locale);
getInputBeans(request);
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
FormProcessor fp = new FormProcessor(request);
SectionBean sb = (SectionBean) request.getAttribute(SECTION_BEAN);
// BWP 12/2/07>> The following COUNT_VALIDATE session attribute is not
// accessible,
// for unknown reasons (threading problems?), when
// double-data entry displays error messages; it's value is always 0; so
// I have to create my
// own session variable here to keep track of DDE stages
// We'll go by the SectionBean's ordinal first
int tabNumber = 1;
if (sb != null) {
tabNumber = sb.getOrdinal();
}
// if tabNumber still isn't valid, check the "tab" parameter
if (tabNumber < 1) {
if (fp == null) {
fp = new FormProcessor(request);
}
String tab = fp.getString("tab");
if (tab == null || tab.length() < 1) {
tabNumber = 1;
} else {
tabNumber = fp.getInt("tab");
}
}
SectionDAO sectionDao = new SectionDAO(getDataSource());
int crfVersionId = ecb.getCRFVersionId();
int eventCRFId = ecb.getId();
ArrayList sections = sectionDao.findAllByCRFVersionId(crfVersionId);
int sectionSize = sections.size();
HttpSession mySession = request.getSession();
DoubleDataProgress doubleDataProgress = (DoubleDataProgress) mySession.getAttribute(DDE_PROGESS);
if (doubleDataProgress == null || doubleDataProgress.getEventCRFId() != eventCRFId) {
doubleDataProgress = new DoubleDataProgress(sectionSize, eventCRFId);
mySession.setAttribute(DDE_PROGESS, doubleDataProgress);
}
boolean hasVisitedSection = doubleDataProgress.getSectionVisited(tabNumber, eventCRFId);
// setting up one-time validation here
// admit that it's an odd place to put it, but where else?
// placing it in dataentryservlet is creating too many counts
int keyId = ecb.getId();
Integer count = (Integer) session.getAttribute(COUNT_VALIDATE + keyId);
if (count != null) {
count++;
session.setAttribute(COUNT_VALIDATE + keyId, count);
LOGGER.info("^^^just set count to session: " + count);
} else {
count = 0;
session.setAttribute(COUNT_VALIDATE + keyId, count);
LOGGER.info("***count not found, set to session: " + count);
}
DataEntryStage stage = ecb.getStage();
if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) && !hasVisitedSection) {
// if the user has not entered this section yet in Double Data
// Entry, then
// set a flag that default values should be shown in the form
request.setAttribute(DDE_ENTERED, true);
}
// Now update the session attribute
doubleDataProgress.setSectionVisited(eventCRFId, tabNumber, true);
mySession.setAttribute("doubleDataProgress", doubleDataProgress);
// StudyEventStatus status =
Role r = currentRole.getRole();
session.setAttribute("mayProcessUploading", "true");
return;
}
use of org.akaza.openclinica.bean.core.DataEntryStage in project OpenClinica by OpenClinica.
the class DataEntryServlet method markCRFComplete.
/**
* The following methods are for 'mark CRF complete'
* @param request TODO
*
* @return
*/
protected boolean markCRFComplete(HttpServletRequest request) throws Exception {
locale = LocaleResolver.getLocale(request);
HttpSession session = request.getSession();
UserAccountBean ub = (UserAccountBean) request.getSession().getAttribute(USER_BEAN_NAME);
EventCRFBean ecb = (EventCRFBean) request.getAttribute(INPUT_EVENT_CRF);
EventDefinitionCRFBean edcb = (EventDefinitionCRFBean) request.getAttribute(EVENT_DEF_CRF_BEAN);
EventCRFDAO ecdao = new EventCRFDAO(getDataSource());
ItemDataDAO iddao = new ItemDataDAO(getDataSource(), locale);
// < respage =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.page_messages",
// locale);
// < restext =
// ResourceBundle.getBundle("org.akaza.openclinica.i18n.notes",locale);
// <
// resexception=ResourceBundle.getBundle(
// "org.akaza.openclinica.i18n.exceptions",locale);
getEventCRFBean(request);
getEventDefinitionCRFBean(request);
DataEntryStage stage = ecb.getStage();
// request.setAttribute(TableOfContentsServlet.INPUT_EVENT_CRF_BEAN,
// ecb);
// request.setAttribute(INPUT_EVENT_CRF_ID, new Integer(ecb.getId()));
LOGGER.trace("inout_event_crf_id:" + ecb.getId());
if (stage.equals(DataEntryStage.UNCOMPLETED) || stage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) || stage.equals(DataEntryStage.LOCKED)) {
addPageMessage(respage.getString("not_mark_CRF_complete1"), request);
return false;
}
if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) || stage.equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
if (!edcb.isDoubleEntry()) {
addPageMessage(respage.getString("not_mark_CRF_complete2"), request);
return false;
}
}
if (isEachRequiredFieldFillout(request) == false) {
addPageMessage(respage.getString("not_mark_CRF_complete4"), request);
return false;
}
/*
* if (ecb.getInterviewerName().trim().equals("")) { throw new InconsistentStateException(errorPage, "You may not mark this Event CRF complete, because
* the interviewer name is blank."); }
*/
Status newStatus = ecb.getStatus();
boolean ide = true;
if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY) && edcb.isDoubleEntry()) {
newStatus = Status.PENDING;
ecb.setUpdaterId(ub.getId());
ecb.setUpdater(ub);
ecb.setUpdatedDate(new Date());
ecb.setDateCompleted(new Date());
} else if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY) && !edcb.isDoubleEntry()) {
newStatus = Status.UNAVAILABLE;
ecb.setUpdaterId(ub.getId());
ecb.setUpdater(ub);
ecb.setUpdatedDate(new Date());
ecb.setDateCompleted(new Date());
ecb.setDateValidateCompleted(new Date());
} else if (stage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) && edcb.isDoubleEntry()) {
newStatus = Status.UNAVAILABLE;
ecb.setUpdaterId(ub.getId());
ecb.setUpdater(ub);
ecb.setUpdatedDate(new Date());
ecb.setDateCompleted(new Date());
ecb.setDateValidateCompleted(new Date());
ide = false;
} else if (stage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) || stage.equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
newStatus = Status.UNAVAILABLE;
ecb.setDateValidateCompleted(new Date());
ecb.setUpdaterId(ub.getId());
ecb.setUpdater(ub);
ide = false;
}
// create them
if (!isEachSectionReviewedOnce(request)) {
boolean canSave = saveItemsToMarkComplete(newStatus, request);
if (canSave == false) {
addPageMessage(respage.getString("not_mark_CRF_complete3"), request);
return false;
}
}
ecb.setStatus(newStatus);
/*
* Marking the data entry as signed if the corresponding EventDefinitionCRF is being enabled for electronic signature.
*/
if (edcb.isElectronicSignature()) {
ecb.setElectronicSignatureStatus(true);
}
ecb = (EventCRFBean) ecdao.update(ecb);
// note the below statement only updates the DATES, not the STATUS
ecdao.markComplete(ecb, ide);
// update all the items' status to complete
iddao.updateStatusByEventCRF(ecb, newStatus);
// change status for study event
StudyEventDAO sedao = new StudyEventDAO(getDataSource());
StudyEventBean seb = (StudyEventBean) sedao.findByPK(ecb.getStudyEventId());
seb.setUpdatedDate(new Date());
seb.setUpdater(ub);
EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(getDataSource());
ArrayList allCRFs = ecdao.findAllByStudyEventAndStatus(seb, Status.UNAVAILABLE);
StudyBean study = (StudyBean) session.getAttribute("study");
ArrayList allEDCs = (ArrayList) edcdao.findAllActiveByEventDefinitionId(study, seb.getStudyEventDefinitionId());
CRFVersionDAO crfversionDao = new CRFVersionDAO(getDataSource());
boolean eventCompleted = true;
boolean allRequired = true;
//JN Adding another flag
boolean allCrfsCompleted = false;
int allEDCsize = allEDCs.size();
ArrayList nonRequiredCrfIds = new ArrayList();
ArrayList requiredCrfIds = new ArrayList();
if (allCRFs.size() == allEDCs.size()) {
// was
//JN: all crfs are completed and then set the subject event status as complete
seb.setSubjectEventStatus(SubjectEventStatus.COMPLETED);
}
seb = (StudyEventBean) sedao.update(seb);
request.setAttribute(INPUT_EVENT_CRF, ecb);
request.setAttribute(EVENT_DEF_CRF_BEAN, edcb);
return true;
}
use of org.akaza.openclinica.bean.core.DataEntryStage in project OpenClinica by OpenClinica.
the class ImportSpringJob method processData.
/*
* processData, a method which should take in all XML files, check to see if they were imported previously, ? insert
* them into the database if not, and return a message which will go to audit and to the end user.
*/
private ArrayList<String> processData(File[] dest, DataSource dataSource, ResourceBundle respage, ResourceBundle resword, UserAccountBean ub, StudyBean studyBean, File destDirectory, TriggerBean triggerBean, RuleSetServiceInterface ruleSetService) throws Exception {
StringBuffer msg = new StringBuffer();
StringBuffer auditMsg = new StringBuffer();
Mapping myMap = new Mapping();
String propertiesPath = CoreResources.PROPERTIES_DIR;
new File(propertiesPath + File.separator + "ODM1-3-0.xsd");
File xsdFile2 = new File(propertiesPath + File.separator + "ODM1-2-1.xsd");
// @pgawade 18-April-2011 Fix for issue 8394
String ODM_MAPPING_DIR_path = CoreResources.ODM_MAPPING_DIR;
myMap.loadMapping(ODM_MAPPING_DIR_path + File.separator + "cd_odm_mapping.xml");
Unmarshaller um1 = new Unmarshaller(myMap);
ODMContainer odmContainer = new ODMContainer();
// File("log.txt")));
for (File f : dest) {
// >> tbh
boolean fail = false;
// all whitespace, one or more times
String regex = "\\s+";
// replace with underscores
String replacement = "_";
String pattern = "yyyy" + File.separator + "MM" + File.separator + "dd" + File.separator + "HHmmssSSS" + File.separator;
SimpleDateFormat sdfDir = new SimpleDateFormat(pattern);
String generalFileDir = sdfDir.format(new java.util.Date());
File logDestDirectory = new File(destDirectory + File.separator + generalFileDir + f.getName().replaceAll(regex, replacement) + ".log.txt");
if (!logDestDirectory.isDirectory()) {
logger.debug("creating new dir: " + logDestDirectory.getAbsolutePath());
logDestDirectory.mkdirs();
}
File newFile = new File(logDestDirectory, "log.txt");
// FileOutputStream out = new FileOutputStream(new
// File(logDestDirectory, "log.txt"));
// BufferedWriter out = null;
// wrap the below in a try-catch?
BufferedWriter out = new BufferedWriter(new FileWriter(newFile));
// << tbh 06/2010
if (f != null) {
String firstLine = "<P>" + f.getName() + ": ";
msg.append(firstLine);
out.write(firstLine);
auditMsg.append(firstLine);
} else {
msg.append("<P>" + respage.getString("unreadable_file") + ": ");
out.write("<P>" + respage.getString("unreadable_file") + ": ");
auditMsg.append("<P>" + respage.getString("unreadable_file") + ": ");
}
try {
// schemaValidator.validateAgainstSchema(f, xsdFile);
odmContainer = (ODMContainer) um1.unmarshal(new FileReader(f));
logger.debug("Found crf data container for study oid: " + odmContainer.getCrfDataPostImportContainer().getStudyOID());
logger.debug("found length of subject list: " + odmContainer.getCrfDataPostImportContainer().getSubjectData().size());
} catch (Exception me1) {
// fail against one, try another
try {
schemaValidator.validateAgainstSchema(f, xsdFile2);
// for backwards compatibility, we also try to validate vs
// 1.2.1 ODM 06/2008
odmContainer = (ODMContainer) um1.unmarshal(new FileReader(f));
} catch (Exception me2) {
// not sure if we want to report me2
MessageFormat mf = new MessageFormat("");
mf.applyPattern(respage.getString("your_xml_is_not_well_formed"));
Object[] arguments = { me1.getMessage() };
msg.append(mf.format(arguments) + "<br/>");
auditMsg.append(mf.format(arguments) + "<br/>");
// break here with an exception
logger.error("found an error with XML: " + msg.toString());
// continue looping
continue;
}
}
// next: check, then import
List<String> errors = getImportCRFDataService(dataSource).validateStudyMetadata(odmContainer, studyBean.getId());
// the user could be in any study ...
if (errors != null) {
if (errors.size() > 0) {
out.write("<P>Errors:<br/>");
for (String error : errors) {
out.write(error + "<br/>");
}
out.write("</P>");
// fail = true;
// forwardPage(Page.IMPORT_CRF_DATA);
// break here with an exception
// throw new Exception("Your XML in the file " + f.getName()
// + " was well formed, but generated metadata errors: " +
// errors.toString());
// msg.append("Your XML in the file " + f.getName() +
// " was well formed, but generated metadata errors: " +
// errors.toString());
MessageFormat mf = new MessageFormat("");
mf.applyPattern(respage.getString("your_xml_in_the_file"));
Object[] arguments = { f.getName(), errors.size() };
auditMsg.append(mf.format(arguments) + "<br/>");
msg.append(mf.format(arguments) + "<br/>");
auditMsg.append("You can see the log file <a href='" + SQLInitServlet.getField("sysURL.base") + "ViewLogMessage?n=" + generalFileDir + f.getName() + "&tn=" + triggerBean.getName() + "&gn=1'>here</a>.<br/>");
msg.append("You can see the log file <a href='" + SQLInitServlet.getField("sysURL.base") + "ViewLogMessage?n=" + generalFileDir + f.getName() + "&tn=" + triggerBean.getName() + "&gn=1'>here</a>.<br/>");
// auditMsg.append("Your XML in the file " + f.getName() +
// " was well formed, but generated " + errors.size() +
// " metadata errors." + "<br/>");
out.close();
continue;
} else {
msg.append(respage.getString("passed_study_check") + "<br/>");
msg.append(respage.getString("passed_oid_metadata_check") + "<br/>");
auditMsg.append(respage.getString("passed_study_check") + "<br/>");
auditMsg.append(respage.getString("passed_oid_metadata_check") + "<br/>");
}
}
ImportCRFInfoContainer importCrfInfo = new ImportCRFInfoContainer(odmContainer, dataSource);
// validation errors, the same as in the ImportCRFDataServlet. DRY?
List<EventCRFBean> eventCRFBeans = getImportCRFDataService(dataSource).fetchEventCRFBeans(odmContainer, ub);
ArrayList<Integer> permittedEventCRFIds = new ArrayList<Integer>();
Boolean eventCRFStatusesValid = getImportCRFDataService(dataSource).eventCRFStatusesValid(odmContainer, ub);
List<DisplayItemBeanWrapper> displayItemBeanWrappers = new ArrayList<DisplayItemBeanWrapper>();
HashMap<String, String> totalValidationErrors = new HashMap<String, String>();
HashMap<String, String> hardValidationErrors = new HashMap<String, String>();
// The following map is used for setting the EventCRF status post import.
HashMap<Integer, String> importedCRFStatuses = getImportCRFDataService(dataSource).fetchEventCRFStatuses(odmContainer);
// -- does the event already exist? if not, fail
if (eventCRFBeans == null) {
fail = true;
msg.append(respage.getString("no_event_status_matching"));
out.write(respage.getString("no_event_status_matching"));
out.close();
continue;
} else if (!eventCRFBeans.isEmpty()) {
logger.debug("found a list of eventCRFBeans: " + eventCRFBeans.toString());
for (EventCRFBean eventCRFBean : eventCRFBeans) {
DataEntryStage dataEntryStage = eventCRFBean.getStage();
Status eventCRFStatus = eventCRFBean.getStatus();
logger.debug("Event CRF Bean: id " + eventCRFBean.getId() + ", data entry stage " + dataEntryStage.getName() + ", status " + eventCRFStatus.getName());
if (eventCRFStatus.equals(Status.AVAILABLE) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY) || dataEntryStage.equals(DataEntryStage.INITIAL_DATA_ENTRY_COMPLETE) || dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY_COMPLETE) || dataEntryStage.equals(DataEntryStage.DOUBLE_DATA_ENTRY)) {
permittedEventCRFIds.add(new Integer(eventCRFBean.getId()));
} else {
// break out here with an exception
// throw new
// Exception("Your listed Event CRF in the file " +
// f.getName() +
// " does not exist, or has already been locked for import."
// );
MessageFormat mf = new MessageFormat("");
mf.applyPattern(respage.getString("your_listed_crf_in_the_file"));
Object[] arguments = { f.getName() };
msg.append(mf.format(arguments) + "<br/>");
auditMsg.append(mf.format(arguments) + "<br/>");
out.write(mf.format(arguments) + "<br/>");
out.close();
continue;
}
}
if (eventCRFBeans.size() >= permittedEventCRFIds.size()) {
msg.append(respage.getString("passed_event_crf_status_check") + "<br/>");
auditMsg.append(respage.getString("passed_event_crf_status_check") + "<br/>");
} else {
fail = true;
msg.append(respage.getString("the_event_crf_not_correct_status") + "<br/>");
auditMsg.append(respage.getString("the_event_crf_not_correct_status") + "<br/>");
}
// create a 'fake' request to generate the validation errors
// here, tbh 05/2009
MockHttpServletRequest request = new MockHttpServletRequest();
// Locale locale = new Locale("en-US");
request.addPreferredLocale(locale);
try {
List<DisplayItemBeanWrapper> tempDisplayItemBeanWrappers = new ArrayList<DisplayItemBeanWrapper>();
tempDisplayItemBeanWrappers = getImportCRFDataService(dataSource).lookupValidationErrors(request, odmContainer, ub, totalValidationErrors, hardValidationErrors, permittedEventCRFIds);
logger.debug("size of total validation errors: " + totalValidationErrors.size());
displayItemBeanWrappers.addAll(tempDisplayItemBeanWrappers);
} catch (NullPointerException npe1) {
// what if you have 2 event crfs but the third is a fake?
npe1.printStackTrace();
fail = true;
logger.debug("threw a NPE after calling lookup validation errors");
msg.append(respage.getString("an_error_was_thrown_while_validation_errors") + "<br/>");
auditMsg.append(respage.getString("an_error_was_thrown_while_validation_errors") + "<br/>");
out.write(respage.getString("an_error_was_thrown_while_validation_errors") + "<br/>");
logger.debug("=== threw the null pointer, import ===");
} catch (OpenClinicaException oce1) {
fail = true;
logger.error("threw an OCE after calling lookup validation errors " + oce1.getOpenClinicaMessage());
msg.append(oce1.getOpenClinicaMessage() + "<br/>");
// auditMsg.append(oce1.getOpenClinicaMessage() + "<br/>");
out.write(oce1.getOpenClinicaMessage() + "<br/>");
}
} else if (!eventCRFStatusesValid) {
fail = true;
msg.append(respage.getString("the_event_crf_not_correct_status"));
out.write(respage.getString("the_event_crf_not_correct_status"));
out.close();
continue;
} else {
// fail = true;
// break here with an exception
msg.append(respage.getString("no_event_crfs_matching_the_xml_metadata") + "<br/>");
// auditMsg.append(respage.getString("no_event_crfs_matching_the_xml_metadata")
// + "<br/>");
out.write(respage.getString("no_event_crfs_matching_the_xml_metadata") + "<br/>");
// throw new Exception(msg.toString());
out.close();
continue;
}
ArrayList<SubjectDataBean> subjectData = odmContainer.getCrfDataPostImportContainer().getSubjectData();
if (!hardValidationErrors.isEmpty()) {
String messageHardVals = triggerService.generateHardValidationErrorMessage(subjectData, hardValidationErrors, false);
// byte[] messageHardValsBytes = messageHardVals.getBytes();
out.write(messageHardVals);
msg.append(respage.getString("file_generated_hard_validation_error"));
// here we create a file and append the data, tbh 06/2010
fail = true;
} else {
if (!totalValidationErrors.isEmpty()) {
String totalValErrors = triggerService.generateHardValidationErrorMessage(subjectData, totalValidationErrors, false);
out.write(totalValErrors);
// here we also append data to the file, tbh 06/2010
}
String validMsgs = triggerService.generateValidMessage(subjectData, totalValidationErrors);
out.write(validMsgs);
// third place to append data to the file? tbh 06/2010
}
// << tbh 05/2010, bug #5110, leave off the detailed reports
out.close();
if (fail) {
// forwardPage(Page.IMPORT_CRF_DATA);
// break here with an exception
// throw new Exception("Problems encountered with file " +
// f.getName() + ": " + msg.toString());
MessageFormat mf = new MessageFormat("");
mf.applyPattern(respage.getString("problems_encountered_with_file"));
Object[] arguments = { f.getName(), msg.toString() };
msg = new StringBuffer(mf.format(arguments) + "<br/>");
out.close();
auditMsg.append("You can see the log file <a href='" + SQLInitServlet.getField("sysURL.base") + "ViewLogMessage?n=" + generalFileDir + f.getName() + "&tn=" + triggerBean.getName() + "&gn=1'>here</a>.<br/>");
msg.append("You can see the log file <a href='" + SQLInitServlet.getField("sysURL.base") + "ViewLogMessage?n=" + generalFileDir + f.getName() + "&tn=" + triggerBean.getName() + "&gn=1'>here</a>.<br/>");
// ": " + msg.toString() + "<br/>");
continue;
} else {
msg.append(respage.getString("passing_crf_edit_checks") + "<br/>");
auditMsg.append(respage.getString("passing_crf_edit_checks") + "<br/>");
// session.setAttribute("importedData",
// displayItemBeanWrappers);
// session.setAttribute("validationErrors",
// totalValidationErrors);
// session.setAttribute("hardValidationErrors",
// hardValidationErrors);
// above are to be sent to the user, but what kind of message
// can we make of them here?
// if hard validation errors are present, we only generate one
// table
// otherwise, we generate the other two: validation errors and
// valid data
logger.debug("found total validation errors: " + totalValidationErrors.size());
SummaryStatsBean ssBean = getImportCRFDataService(dataSource).generateSummaryStatsBean(odmContainer, displayItemBeanWrappers, importCrfInfo);
// msg.append("===+");
// the above is a special key that we will use to split the
// message into two parts
// a shorter version for the audit and
// a longer version for the email
msg.append(triggerService.generateSummaryStatsMessage(ssBean, respage) + "<br/>");
// session.setAttribute("summaryStats", ssBean);
// will have to set hard edit checks here as well
// session.setAttribute("subjectData",
// ArrayList<SubjectDataBean> subjectData =
// odmContainer.getCrfDataPostImportContainer().getSubjectData();
// forwardPage(Page.VERIFY_IMPORT_SERVLET);
// instead of forwarding, go ahead and save it all, sending a
// message at the end
msg.append(triggerService.generateSkippedCRFMessage(importCrfInfo, resword) + "<br/>");
// setup ruleSets to run if applicable
List<ImportDataRuleRunnerContainer> containers = this.ruleRunSetup(dataSource, studyBean, ub, ruleSetService, odmContainer);
CrfBusinessLogicHelper crfBusinessLogicHelper = new CrfBusinessLogicHelper(dataSource);
for (DisplayItemBeanWrapper wrapper : displayItemBeanWrappers) {
boolean resetSDV = false;
int eventCrfBeanId = -1;
EventCRFBean eventCrfBean = new EventCRFBean();
logger.debug("right before we check to make sure it is savable: " + wrapper.isSavable());
if (wrapper.isSavable()) {
ArrayList<Integer> eventCrfInts = new ArrayList<Integer>();
logger.debug("wrapper problems found : " + wrapper.getValidationErrors().toString());
itemDataDao.setFormatDates(false);
for (DisplayItemBean displayItemBean : wrapper.getDisplayItemBeans()) {
eventCrfBeanId = displayItemBean.getData().getEventCRFId();
eventCrfBean = (EventCRFBean) eventCrfDao.findByPK(eventCrfBeanId);
logger.debug("found value here: " + displayItemBean.getData().getValue());
logger.debug("found status here: " + eventCrfBean.getStatus().getName());
ItemDataBean itemDataBean = new ItemDataBean();
itemDataBean = itemDataDao.findByItemIdAndEventCRFIdAndOrdinal(displayItemBean.getItem().getId(), eventCrfBean.getId(), displayItemBean.getData().getOrdinal());
if (wrapper.isOverwrite() && itemDataBean.getStatus() != null) {
logger.debug("just tried to find item data bean on item name " + displayItemBean.getItem().getName());
if (!itemDataBean.getValue().equals(displayItemBean.getData().getValue()))
resetSDV = true;
itemDataBean.setUpdatedDate(new Date());
itemDataBean.setUpdater(ub);
itemDataBean.setValue(displayItemBean.getData().getValue());
// set status?
itemDataDao.update(itemDataBean);
logger.debug("updated: " + itemDataBean.getItemId());
// need to set pk here in order to create dn
displayItemBean.getData().setId(itemDataBean.getId());
} else {
resetSDV = true;
itemDataDao.create(displayItemBean.getData());
logger.debug("created: " + displayItemBean.getData().getItemId());
ItemDataBean itemDataBean2 = itemDataDao.findByItemIdAndEventCRFIdAndOrdinal(displayItemBean.getItem().getId(), eventCrfBean.getId(), displayItemBean.getData().getOrdinal());
logger.debug("found: id " + itemDataBean2.getId() + " name " + itemDataBean2.getName());
displayItemBean.getData().setId(itemDataBean2.getId());
}
ItemDAO idao = new ItemDAO(dataSource);
ItemBean ibean = (ItemBean) idao.findByPK(displayItemBean.getData().getItemId());
logger.debug("*** checking for validation errors: " + ibean.getName());
String itemOid = displayItemBean.getItem().getOid() + "_" + wrapper.getStudyEventRepeatKey() + "_" + displayItemBean.getData().getOrdinal() + "_" + wrapper.getStudySubjectOid();
if (wrapper.getValidationErrors().containsKey(itemOid)) {
ArrayList messageList = (ArrayList) wrapper.getValidationErrors().get(itemOid);
for (int iter = 0; iter < messageList.size(); iter++) {
String message = (String) messageList.get(iter);
DiscrepancyNoteBean parentDn = createDiscrepancyNote(ibean, message, eventCrfBean, displayItemBean, null, ub, dataSource, studyBean);
createDiscrepancyNote(ibean, message, eventCrfBean, displayItemBean, parentDn.getId(), ub, dataSource, studyBean);
logger.debug("*** created disc note with message: " + message);
// displayItemBean);
}
}
// Update CRF status
if (!eventCrfInts.contains(new Integer(eventCrfBean.getId()))) {
String eventCRFStatus = importedCRFStatuses.get(new Integer(eventCrfBean.getId()));
if (eventCRFStatus != null && eventCRFStatus.equals(DataEntryStage.INITIAL_DATA_ENTRY.getName()) && eventCrfBean.getStatus().isAvailable()) {
crfBusinessLogicHelper.markCRFStarted(eventCrfBean, ub);
} else {
crfBusinessLogicHelper.markCRFComplete(eventCrfBean, ub);
}
logger.debug("*** just updated event crf bean: " + eventCrfBean.getId());
eventCrfInts.add(new Integer(eventCrfBean.getId()));
}
}
itemDataDao.setFormatDates(true);
// Reset the SDV status if item data has been changed or added
if (eventCrfBean != null && resetSDV)
eventCrfDao.setSDVStatus(false, ub.getId(), eventCrfBean.getId());
}
}
// msg.append("===+");
msg.append(respage.getString("data_has_been_successfully_import") + "<br/>");
auditMsg.append(respage.getString("data_has_been_successfully_import") + "<br/>");
// MessageFormat mf = new MessageFormat("");
String linkMessage = respage.getString("you_can_review_the_data") + SQLInitServlet.getField("sysURL.base") + respage.getString("you_can_review_the_data_2") + SQLInitServlet.getField("sysURL.base") + respage.getString("you_can_review_the_data_3") + generalFileDir + f.getName() + "&tn=" + triggerBean.getFullName() + "&gn=1" + respage.getString("you_can_review_the_data_4") + "<br/>";
// mf.applyPattern(respage.getString("you_can_review_the_data"));
// Object[] arguments = {
// SQLInitServlet.getField("sysURL.base"),
// SQLInitServlet.getField("sysURL.base"), f.getName() };
msg.append(linkMessage);
auditMsg.append(linkMessage);
// was here but is now moved up, tbh
// String finalLine =
// "<p>You can review the entered data <a href='" +
// SQLInitServlet.getField("sysURL.base") +
// "ListStudySubjects'>here</a>.";
// >> tbh additional message
// "you can review the validation messages here" <-- where
// 'here' is a link to view an external file
// i.e. /ViewExternal?n=file_name.txt
// << tbh 06/2010
// msg.append(finalLine);
// auditMsg.append(finalLine);
auditMsg.append(this.runRules(studyBean, ub, containers, ruleSetService, ExecutionMode.SAVE));
}
}
// end for loop
// is the writer still not closed? try to close it
ArrayList<String> retList = new ArrayList<String>();
retList.add(msg.toString());
retList.add(auditMsg.toString());
// msg.toString();
return retList;
}
Aggregations