Search in sources :

Example 1 with EventCRFDAO

use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.

the class ImportSpringJob method executeInternalInTransaction.

protected void executeInternalInTransaction(JobExecutionContext context) {
    locale = new Locale("en-US");
    ResourceBundleProvider.updateLocale(locale);
    respage = ResourceBundleProvider.getPageMessagesBundle();
    resword = ResourceBundleProvider.getWordsBundle();
    triggerService = new TriggerService();
    JobDataMap dataMap = context.getMergedJobDataMap();
    SimpleTrigger trigger = (SimpleTrigger) context.getTrigger();
    TriggerBean triggerBean = new TriggerBean();
    triggerBean.setFullName(trigger.getName());
    String contactEmail = dataMap.getString(EMAIL);
    logger.debug("=== starting to run trigger " + trigger.getName() + " ===");
    try {
        ApplicationContext appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
        dataSource = (DataSource) appContext.getBean("dataSource");
        mailSender = (OpenClinicaMailSender) appContext.getBean("openClinicaMailSender");
        RuleSetServiceInterface ruleSetService = (RuleSetServiceInterface) appContext.getBean("ruleSetService");
        itemDataDao = new ItemDataDAO(dataSource);
        eventCrfDao = new EventCRFDAO(dataSource);
        auditEventDAO = new AuditEventDAO(dataSource);
        int userId = dataMap.getInt(USER_ID);
        UserAccountDAO userAccountDAO = new UserAccountDAO(dataSource);
        UserAccountBean ub = (UserAccountBean) userAccountDAO.findByPK(userId);
        triggerBean.setUserAccount(ub);
        String directory = dataMap.getString(DIRECTORY);
        String studyName = dataMap.getString(STUDY_NAME);
        String studyOid = dataMap.getString(STUDY_OID);
        String localeStr = dataMap.getString(ExampleSpringJob.LOCALE);
        if (localeStr != null) {
            locale = new Locale(localeStr);
            ResourceBundleProvider.updateLocale(locale);
            respage = ResourceBundleProvider.getPageMessagesBundle();
            resword = ResourceBundleProvider.getWordsBundle();
        }
        StudyDAO studyDAO = new StudyDAO(dataSource);
        StudyBean studyBean;
        if (studyOid != null) {
            studyBean = studyDAO.findByOid(studyOid);
        } else {
            studyBean = (StudyBean) studyDAO.findByName(studyName);
        }
        // might also need study id here for the data service?
        File fileDirectory = new File(SQLInitServlet.getField("filePath") + DIR_PATH + File.separator);
        // File fileDirectory = new File(IMPORT_DIR);
        if ("".equals(directory)) {
        // avoid NPEs
        // do nothing here?
        } else {
            // there is a separator at the end of IMPORT_DIR already...
            // fileDirectory = new File(IMPORT_DIR + directory +
            // File.separator);
            fileDirectory = new File(SQLInitServlet.getField("filePath") + DIR_PATH + File.separator + directory + File.separator);
        }
        if (!fileDirectory.isDirectory()) {
            fileDirectory.mkdirs();
        }
        // this is necessary the first time this is run, tbh
        // File destDirectory = new File(IMPORT_DIR_2);
        File destDirectory = new File(SQLInitServlet.getField("filePath") + DEST_DIR + File.separator);
        if (!destDirectory.isDirectory()) {
            destDirectory.mkdirs();
        }
        // look at directory, if there are new files, move them over and
        // read them
        // File fileDirectory = new File(directory);
        String[] files = fileDirectory.list();
        logger.debug("found " + files.length + " files under directory " + SQLInitServlet.getField("filePath") + DIR_PATH + File.separator + directory);
        File[] target = new File[files.length];
        File[] destination = new File[files.length];
        for (int i = 0; i < files.length; i++) {
            // hmm
            if (!new File(fileDirectory + File.separator + files[i]).isDirectory()) {
                File f = new File(fileDirectory + File.separator + files[i]);
                if (f == null || f.getName() == null) {
                    logger.debug("found a null file");
                } else if (f.getName().indexOf(".xml") < 0 && f.getName().indexOf(".XML") < 0) {
                    logger.debug("does not seem to be an xml file");
                // we need a place holder to avoid 'gaps' in the file
                // list
                } else {
                    logger.debug("adding: " + f.getName());
                    // new File(IMPORT_DIR +
                    target[i] = f;
                    // directory +
                    // File.separator + files[i]);
                    // destination[i] = new File(IMPORT_DIR_2 + files[i]);
                    destination[i] = new File(SQLInitServlet.getField("filePath") + DEST_DIR + File.separator + files[i]);
                }
            }
        }
        if (target.length > 0 && destination.length > 0) {
            cutAndPaste(target, destination);
            // @pgawade 28-June-2012: Fix for issue #13964 - Remove the null
            // elements from destination array of files
            // which might be created because of presense of sub-directories
            // or non-xml files under scheduled_data_import directory
            // which are non-usable files for import.
            destination = removeNullElements(destination);
            // do everything else here with 'destination'
            ArrayList<String> auditMessages = processData(destination, dataSource, respage, resword, ub, studyBean, destDirectory, triggerBean, ruleSetService);
            auditEventDAO.createRowForExtractDataJobSuccess(triggerBean, auditMessages.get(1));
            try {
                if (contactEmail != null && !"".equals(contactEmail)) {
                    mailSender.sendEmail(contactEmail, respage.getString("job_ran_for") + " " + triggerBean.getFullName(), generateMsg(auditMessages.get(0), contactEmail), true);
                    logger.debug("email body: " + auditMessages.get(1));
                }
            } catch (OpenClinicaSystemException e) {
                // Do nothing
                logger.error("=== throw an ocse === " + e.getMessage());
                e.printStackTrace();
            }
        } else {
            logger.debug("no real files found");
            auditEventDAO.createRowForExtractDataJobSuccess(triggerBean, respage.getString("job_ran_but_no_files"));
        // no email here, tbh
        }
    // use the business logic to go through each one and import that
    // data
    // check to see if they were imported before?
    // using the four methods:
    // importCRFDataServce.validateStudyMetadata,
    // service.lookupValidationErrors, service.fetchEventCRFBeans(?),
    // and
    // service.generateSummaryStatsBean(for the email we send out later)
    } catch (Exception e) {
        // more detailed reporting here
        logger.error("found a fail exception: " + e.getMessage());
        e.printStackTrace();
        auditEventDAO.createRowForExtractDataJobFailure(triggerBean, e.getMessage());
        try {
            mailSender.sendEmail(contactEmail, respage.getString("job_failure_for") + " " + triggerBean.getFullName(), e.getMessage(), true);
        } catch (OpenClinicaSystemException ose) {
            // Do nothing
            logger.error("=== throw an ocse: " + ose.getMessage());
        }
    }
}
Also used : Locale(java.util.Locale) JobDataMap(org.quartz.JobDataMap) TriggerBean(org.akaza.openclinica.bean.admin.TriggerBean) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) AuditEventDAO(org.akaza.openclinica.dao.admin.AuditEventDAO) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) OpenClinicaException(org.akaza.openclinica.exception.OpenClinicaException) JobExecutionException(org.quartz.JobExecutionException) OpenClinicaSystemException(org.akaza.openclinica.exception.OpenClinicaSystemException) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException) RuleSetServiceInterface(org.akaza.openclinica.service.rule.RuleSetServiceInterface) ApplicationContext(org.springframework.context.ApplicationContext) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) SimpleTrigger(org.quartz.SimpleTrigger) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) File(java.io.File) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 2 with EventCRFDAO

use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.

the class SDVUtil method getFilteredItems.

@SuppressWarnings("unchecked")
private Collection<SubjectSDVContainer> getFilteredItems(EventCRFSDVFilter filterSet, EventCRFSDVSort sortSet, int rowStart, int rowEnd, int studyId, HttpServletRequest request) {
    EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
    List<EventCRFBean> eventCRFBeans = new ArrayList<EventCRFBean>();
    /*
         * StudyEventDAO studyEventDAO = new StudyEventDAO(dataSource);
         * 
         * StudyDAO studyDAO = new StudyDAO(dataSource);
         * StudyBean studyBean = (StudyBean) studyDAO.findByPK(studyId);
         * 
         * String label = "";
         * String eventName = "";
         * String eventDate = "";
         * String sdvStatus = "";
         * String crfStatus = "";
         * String studyIdentifier = "";
         * String sdvRequirement = "";
         * SourceDataVerification sourceDataVerification = null;
         * 
         * if (filterSet.getFilter("studySubjectId") != null) {
         * 
         * label = filterSet.getFilter("studySubjectId").getValue().trim();
         * eventCRFBeans = eventCRFDAO.getEventCRFsByStudySubjectLabelLimit(label, studyId, studyId, rowEnd - rowStart,
         * rowStart);
         * 
         * } else if (filterSet.getFilter("eventName") != null) {
         * 
         * eventName = filterSet.getFilter("eventName").getValue().trim();
         * eventCRFBeans = eventCRFDAO.getEventCRFsByEventNameLimit(eventName, rowEnd - rowStart, rowStart);
         * 
         * } else if (filterSet.getFilter("eventDate") != null) {
         * 
         * eventDate = filterSet.getFilter("eventDate").getValue().trim();
         * eventCRFBeans = eventCRFDAO.getEventCRFsByEventDateLimit(studyId, eventDate, rowEnd - rowStart, rowStart);
         * 
         * } else if (filterSet.getFilter("crfStatus") != null) {
         * //
         * //SubjectEventStatus.getSubjectEventStatusIdByName(crfStatus)
         * crfStatus = filterSet.getFilter("crfStatus").getValue().trim();
         * //Get the study event for the event crf
         * eventCRFBeans = eventCRFDAO.getEventCRFsByCRFStatus(studyId, Integer.parseInt(crfStatus), rowEnd - rowStart,
         * rowStart);
         * 
         * } else if (filterSet.getFilter("sdvStatus") != null) {
         * 
         * sdvStatus = filterSet.getFilter("sdvStatus").getValue().trim();
         * eventCRFBeans = eventCRFDAO.getEventCRFsByStudySDV(studyId, ("complete".equalsIgnoreCase(sdvStatus)), rowEnd
         * - rowStart, rowStart);
         * 
         * } else if (filterSet.getFilter("studyIdentifier") != null) {
         * 
         * studyIdentifier = filterSet.getFilter("studyIdentifier").getValue().trim();
         * eventCRFBeans = eventCRFDAO.getEventCRFsByStudyIdentifier(studyId, studyId, studyIdentifier, rowEnd -
         * rowStart, rowStart);
         * 
         * } else if (filterSet.getFilter("sdvRequirementDefinition") != null) {
         * 
         * ArrayList<Integer> reqs = new ArrayList<Integer>();
         * sdvRequirement = filterSet.getFilter("sdvRequirementDefinition").getValue().trim();
         * if (sdvRequirement.contains("&")) {
         * for (String requirement : sdvRequirement.split("&")) {
         * reqs.add(SourceDataVerification.getByI18nDescription(requirement.trim()).getCode());
         * }
         * } else {
         * reqs.add(SourceDataVerification.getByI18nDescription(sdvRequirement.trim()).getCode());
         * }
         * if (reqs.size() > 0) {
         * Integer[] a = { 1 };
         * eventCRFBeans = eventCRFDAO.getEventCRFsBySDVRequirement(studyId, studyId, rowEnd - rowStart, rowStart,
         * reqs.toArray(a));
         * }
         * 
         * } else {
         * eventCRFBeans = eventCRFDAO.getEventCRFsByStudy(studyId, studyId, rowEnd - rowStart, rowStart);
         * 
         * }
         */
    eventCRFBeans = eventCRFDAO.getWithFilterAndSort(studyId, studyId, filterSet, sortSet, rowStart, rowEnd);
    return getSubjectRows(eventCRFBeans, request);
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ArrayList(java.util.ArrayList) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 3 with EventCRFDAO

use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.

the class SubjectIdSDVFactory method getRow.

private SubjectAggregateContainer getRow(StudySubjectBean studySubjectBean) {
    SubjectAggregateContainer row = new SubjectAggregateContainer();
    EventCRFDAO eventCRFDAO = new EventCRFDAO(dataSource);
    StudyDAO studyDAO = new StudyDAO(dataSource);
    StudySubjectDAO studySubjectDAO = new StudySubjectDAO(dataSource);
    StudyGroupDAO studyGroupDAO = new StudyGroupDAO(dataSource);
    row.setStudySubjectId(studySubjectBean.getLabel());
    row.setPersonId(studySubjectBean.getUniqueIdentifier());
    row.setStudySubjectStatus(studySubjectBean.getStatus().getName());
    int numberEventCRFs = eventCRFDAO.countEventCRFsByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
    row.setTotalEventCRF(numberEventCRFs + "");
    StudyBean studyBean = (StudyBean) studyDAO.findByPK(studySubjectBean.getStudyId());
    row.setSiteId(studyBean.getIdentifier());
    List<EventCRFBean> eventCRFBeans = eventCRFDAO.getEventCRFsByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
    HashMap<String, Integer> stats = getEventCRFStats(eventCRFBeans, studySubjectBean);
    // int numberCRFComplete = getNumberCompletedEventCRFs(eventCRFBeans);
    // row.setNumberCRFComplete(numberCRFComplete + "");
    row.setNumberCRFComplete(stats.get("numberOfCompletedEventCRFs") + "");
    row.setNumberOfCRFsSDV(stats.get("numberOfSDVdEventCRFs") + "");
    // row.setNumberOfCRFsSDV(getNumberSDVdEventCRFs(eventCRFBeans) + "");
    // boolean studySubjectSDVd =
    // eventCRFDAO.countEventCRFsByByStudySubjectCompleteOrLockedAndNotSDVd(studySubjectBean.getId()) == 0 &&
    // numberCRFComplete > 0;
    boolean studySubjectSDVd = stats.get("areEventCRFsSDVd") == -1 || stats.get("areEventCRFsSDVd") == 1 ? false : true;
    StringBuilder sdvStatus = new StringBuilder("");
    if (stats.get("shouldDisplaySDVButton") == 0) {
        sdvStatus.append("");
    } else if (studySubjectSDVd) {
        sdvStatus.append("<center><a href='javascript:void(0)' onclick='prompt(document.sdvForm,");
        sdvStatus.append(studySubjectBean.getId());
        sdvStatus.append(")'>");
        sdvStatus.append(getIconForCrfStatusPrefix()).append("DoubleCheck").append(ICON_FORCRFSTATUS_SUFFIX).append("</a></center>");
    } else {
        sdvStatus.append("<center><input style='margin-right: 5px' type='checkbox' ").append("class='sdvCheck'").append(" name='").append("sdvCheck_").append(studySubjectBean.getId()).append("' /></center>");
    }
    row.setSdvStatus(sdvStatus.toString());
    List<StudyGroupBean> studyGroupBeans = studyGroupDAO.getGroupByStudySubject(studySubjectBean.getId(), studySubjectBean.getStudyId(), studySubjectBean.getStudyId());
    if (studyGroupBeans != null && !studyGroupBeans.isEmpty()) {
        row.setGroup(studyGroupBeans.get(0).getName());
    }
    StringBuilder actions = new StringBuilder("<table><tr><td>");
    StringBuilder urlPrefix = new StringBuilder("<a href=\"");
    StringBuilder path = new StringBuilder(contextPath).append("/pages/viewAllSubjectSDVtmp?studyId=").append(studyId).append("&sdv_f_studySubjectId=");
    path.append(studySubjectBean.getLabel());
    urlPrefix.append(path).append("\">");
    actions.append(urlPrefix).append(SDVUtil.VIEW_ICON_HTML).append("</a></td>");
    if (!studySubjectSDVd && stats.get("shouldDisplaySDVButton") == 1) {
        StringBuilder jsCodeString = new StringBuilder("this.form.method='GET'; this.form.action='").append(contextPath).append("/pages/sdvStudySubject").append("';").append("this.form.theStudySubjectId.value='").append(studySubjectBean.getId()).append("';").append("this.form.submit();");
        if (!studyBean.getStatus().isLocked()) {
            actions.append("<td><input type=\"submit\" class=\"button\" value=\"SDV\" name=\"sdvSubmit\" ").append("onclick=\"").append(jsCodeString.toString()).append("\" /></td>");
        }
    } else if (!studySubjectSDVd) {
        actions.append("<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SDV N/A</td>");
    }
    actions.append("</tr></table>");
    row.setActions(actions.toString());
    return row;
}
Also used : StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) StudyGroupDAO(org.akaza.openclinica.dao.managestudy.StudyGroupDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) StudyGroupBean(org.akaza.openclinica.bean.managestudy.StudyGroupBean) SubjectAggregateContainer(org.akaza.openclinica.controller.helper.table.SubjectAggregateContainer) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Example 4 with EventCRFDAO

use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.

the class DataImportService method submitData.

public ArrayList<String> submitData(ODMContainer odmContainer, DataSource dataSource, StudyBean studyBean, UserAccountBean userBean, List<DisplayItemBeanWrapper> displayItemBeanWrappers, Map<Integer, String> importedCRFStatuses) throws Exception {
    boolean discNotesGenerated = false;
    ItemDataDAO itemDataDao = new ItemDataDAO(dataSource);
    itemDataDao.setFormatDates(false);
    EventCRFDAO eventCrfDao = new EventCRFDAO(dataSource);
    StringBuffer auditMsg = new StringBuffer();
    int eventCrfBeanId = -1;
    EventCRFBean eventCrfBean = null;
    ArrayList<Integer> eventCrfInts;
    ItemDataBean itemDataBean;
    CrfBusinessLogicHelper crfBusinessLogicHelper = new CrfBusinessLogicHelper(dataSource);
    for (DisplayItemBeanWrapper wrapper : displayItemBeanWrappers) {
        boolean resetSDV = false;
        logger.debug("right before we check to make sure it is savable: " + wrapper.isSavable());
        if (wrapper.isSavable()) {
            eventCrfInts = new ArrayList<Integer>();
            logger.debug("wrapper problems found : " + wrapper.getValidationErrors().toString());
            if (wrapper.getDisplayItemBeans() != null && wrapper.getDisplayItemBeans().size() == 0) {
                return getReturnList("fail", "", "No items to submit. Please check your XML.");
            }
            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 = itemDataDao.findByItemIdAndEventCRFIdAndOrdinal(displayItemBean.getItem().getId(), eventCrfBean.getId(), displayItemBean.getData().getOrdinal());
                if (wrapper.isOverwrite() && itemDataBean.getStatus() != null) {
                    if (!itemDataBean.getValue().equals(displayItemBean.getData().getValue()))
                        resetSDV = true;
                    logger.debug("just tried to find item data bean on item name " + displayItemBean.getItem().getName());
                    itemDataBean.setUpdatedDate(new Date());
                    itemDataBean.setUpdater(userBean);
                    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 = itemDataDao.findByItemIdAndEventCRFIdAndOrdinal(displayItemBean.getItem().getId(), eventCrfBean.getId(), displayItemBean.getData().getOrdinal());
                    // logger.debug("found: id " + itemDataBean2.getId() + " name " + itemDataBean2.getName());
                    displayItemBean.getData().setId(itemDataBean.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();
                // wrapper.getValidationErrors().toString());
                if (wrapper.getValidationErrors().containsKey(itemOid)) {
                    ArrayList<String> messageList = (ArrayList<String>) wrapper.getValidationErrors().get(itemOid);
                    for (String message : messageList) {
                        DiscrepancyNoteBean parentDn = createDiscrepancyNote(ibean, message, eventCrfBean, displayItemBean, null, userBean, dataSource, studyBean);
                        createDiscrepancyNote(ibean, message, eventCrfBean, displayItemBean, parentDn.getId(), userBean, dataSource, studyBean);
                        discNotesGenerated = true;
                        logger.debug("*** created disc note with message: " + message);
                        auditMsg.append(wrapper.getStudySubjectOid() + ": " + ibean.getOid() + ": " + message + "---");
                    // split by this ? later, tbh
                    // displayItemBean);
                    }
                }
                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, userBean, true);
                    } else {
                        crfBusinessLogicHelper.markCRFComplete(eventCrfBean, userBean, true);
                    }
                    eventCrfInts.add(new Integer(eventCrfBean.getId()));
                }
            }
            // Reset the SDV status if item data has been changed or added
            if (eventCrfBean != null && resetSDV)
                eventCrfDao.setSDVStatus(false, userBean.getId(), eventCrfBean.getId());
        }
    }
    if (!discNotesGenerated) {
        return getReturnList("success", "", auditMsg.toString());
    } else {
        return getReturnList("warn", "", auditMsg.toString());
    }
}
Also used : DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) ItemBean(org.akaza.openclinica.bean.submit.ItemBean) ItemDAO(org.akaza.openclinica.dao.submit.ItemDAO) ArrayList(java.util.ArrayList) ItemDataDAO(org.akaza.openclinica.dao.submit.ItemDataDAO) Date(java.util.Date) EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) DiscrepancyNoteBean(org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean) DisplayItemBean(org.akaza.openclinica.bean.submit.DisplayItemBean) CrfBusinessLogicHelper(org.akaza.openclinica.web.job.CrfBusinessLogicHelper) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO) DisplayItemBeanWrapper(org.akaza.openclinica.bean.submit.DisplayItemBeanWrapper)

Example 5 with EventCRFDAO

use of org.akaza.openclinica.dao.submit.EventCRFDAO in project OpenClinica by OpenClinica.

the class CrfBusinessLogicHelper method areAllCompleted.

protected boolean areAllCompleted(StudyEventBean seBean, StudyBean study) {
    EventDefinitionCRFDAO edcDao = new EventDefinitionCRFDAO(ds);
    EventCRFDAO eventCrfDao = new EventCRFDAO(ds);
    ArrayList allCRFs = eventCrfDao.findAllByStudyEvent(seBean);
    ArrayList allEDCs = (ArrayList) edcDao.findAllActiveByEventDefinitionId(study, seBean.getStudyEventDefinitionId());
    boolean eventCompleted = true;
    logger.info("found all crfs: " + allCRFs.size());
    logger.info("found all edcs: " + allEDCs.size());
    for (int i = 0; i < allCRFs.size(); i++) {
        EventCRFBean ec = (EventCRFBean) allCRFs.get(i);
        // logger.info("found a crf name from event crf bean: " +
        // ec.getCrf().getName());
        logger.info("found a event name from event crf bean: " + ec.getEventName() + " crf version id: " + ec.getCRFVersionId());
        if (!ec.getStatus().equals(Status.UNAVAILABLE) || allCRFs.size() < allEDCs.size()) {
            eventCompleted = false;
            break;
        }
    }
    logger.info("returning for are all completed: " + eventCompleted);
    return eventCompleted;
}
Also used : EventCRFBean(org.akaza.openclinica.bean.submit.EventCRFBean) ArrayList(java.util.ArrayList) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) EventCRFDAO(org.akaza.openclinica.dao.submit.EventCRFDAO)

Aggregations

EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)107 ArrayList (java.util.ArrayList)81 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)77 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)74 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)71 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)57 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)51 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)51 Date (java.util.Date)50 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)50 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)49 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)47 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)46 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)45 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)44 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)41 CRFVersionDAO (org.akaza.openclinica.dao.submit.CRFVersionDAO)40 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)37 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)34 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)28