Search in sources :

Example 31 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class ViewImportJobServlet method processRequest.

@Override
protected void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    // First we must get a reference to a scheduler
    scheduler = getScheduler();
    // then we pull all the triggers that are specifically named
    // IMPORT_TRIGGER.
    Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(GroupMatcher.groupEquals(IMPORT_TRIGGER));
    // the next bit goes out and processes all the triggers
    ArrayList triggerBeans = new ArrayList<TriggerBean>();
    for (TriggerKey triggerKey : triggerKeys) {
        String triggerName = triggerKey.getName();
        Trigger trigger = scheduler.getTrigger(triggerKey);
        logger.debug("found trigger, full name: " + triggerName);
        try {
            logger.debug("prev fire time " + trigger.getPreviousFireTime().toString());
            logger.debug("next fire time " + trigger.getNextFireTime().toString());
            logger.debug("final fire time: " + trigger.getFinalFireTime().toString());
        } catch (NullPointerException npe) {
        // could be nulls in the dates, etc
        }
        TriggerBean triggerBean = new TriggerBean();
        triggerBean.setFullName(triggerName);
        triggerBean.setPreviousDate(trigger.getPreviousFireTime());
        triggerBean.setNextDate(trigger.getNextFireTime());
        if (trigger.getDescription() != null) {
            triggerBean.setDescription(trigger.getDescription());
        }
        // this next bit of code looks at the job data map and pulls out
        // specific items
        JobDataMap dataMap = new JobDataMap();
        if (trigger.getJobDataMap().size() > 0) {
            dataMap = trigger.getJobDataMap();
            triggerBean.setStudyName(dataMap.getString(ExampleSpringJob.STUDY_NAME));
            String oid = dataMap.getString("study_oid");
        }
        // this next bit of code looks to see if the trigger is paused
        logger.debug("Trigger Priority: " + triggerName + " " + trigger.getPriority());
        if (scheduler.getTriggerState(new TriggerKey(triggerName, IMPORT_TRIGGER)) == Trigger.TriggerState.PAUSED) {
            triggerBean.setActive(false);
            logger.debug("setting active to false for trigger: " + triggerName);
        } else {
            triggerBean.setActive(true);
            logger.debug("setting active to TRUE for trigger: " + triggerName);
        }
        triggerBeans.add(triggerBean);
    // our wrapper to show triggers
    }
    // set up the table here and get ready to send to the web page
    ArrayList allRows = TriggerRow.generateRowsFromBeans(triggerBeans);
    EntityBeanTable table = fp.getEntityBeanTable();
    String[] columns = { resword.getString("name"), resword.getString("previous_fire_time"), resword.getString("next_fire_time"), resword.getString("description"), resword.getString("study"), resword.getString("actions") };
    table.setColumns(new ArrayList(Arrays.asList(columns)));
    table.hideColumnLink(3);
    table.hideColumnLink(5);
    table.setQuery("ViewImportJob", new HashMap());
    // table.addLink("", "CreateUserAccount");
    table.setSortingColumnInd(0);
    table.setRows(allRows);
    table.computeDisplay();
    request.setAttribute("table", table);
    forwardPage(Page.VIEW_IMPORT_JOB);
}
Also used : TriggerKey(org.quartz.TriggerKey) TriggerBean(org.akaza.openclinica.bean.admin.TriggerBean) JobDataMap(org.quartz.JobDataMap) Trigger(org.quartz.Trigger) HashMap(java.util.HashMap) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) EntityBeanTable(org.akaza.openclinica.web.bean.EntityBeanTable) ArrayList(java.util.ArrayList)

Example 32 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class ViewLogMessageServlet method processRequest.

@Override
protected void processRequest() throws Exception {
    try {
        File destDirectory = new File(ImportSpringJob.IMPORT_DIR_2);
        FormProcessor fp = new FormProcessor(request);
        // all whitespace, one or more times
        String regex = "\\s+";
        // replace with underscores
        String replacement = "_";
        String fileName = fp.getString("n");
        String triggerName = fp.getString("tn");
        String groupName = fp.getString("gn");
        logger.debug("found trigger name " + triggerName + " group name " + groupName);
        File logDestDirectory = new File(destDirectory + File.separator + fileName.replaceAll(regex, replacement) + ".log.txt" + File.separator + "log.txt");
        // StringBuffer sbu = new StringBuffer();
        // BufferedReader r = new BufferedReader(new FileReader(logDestDirectory));
        // char[] buffer = new char[1024];
        // int amount = 0;
        // while ((amount = r.read(buffer, 0, buffer.length)) != -1) {
        // sbu.append(buffer);
        // }
        // r.close();
        String fileContents = readFromFile(logDestDirectory);
        request.setAttribute(this.LOG_MESSAGE, fileContents);
        request.setAttribute(this.FILE_NAME, fileName);
        request.setAttribute(this.TRIGGER_NAME, triggerName);
        request.setAttribute(this.GROUP_NAME, groupName);
        // need to also set the information back to the original view jobs
        // so we have to get back to this type of page:
        // http://localhost:8081/OpenClinica-3.0-SNAPSHOT/ViewSingleJob?tname=test%20job%2001&gname=1
        forwardPage(Page.VIEW_LOG_MESSAGE);
    } catch (Exception e) {
        // TODO Auto-generated catch block
        logger.error("found IO exception: " + e.getMessage());
        addPageMessage(respage.getString("no_have_correct_privilege_current_study") + respage.getString("change_study_contact_sysadmin"));
        // throw new InsufficientPermissionException(Page.MENU, resexception.getString("not_allowed_access_extract_data_servlet"), "1");
        forwardPage(Page.MENU);
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) File(java.io.File) InsufficientPermissionException(org.akaza.openclinica.web.InsufficientPermissionException)

Example 33 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class ViewStudyServlet method processRequest.

@Override
public void processRequest() throws Exception {
    StudyDAO sdao = new StudyDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    int studyId = fp.getInt("id");
    if (studyId == 0) {
        addPageMessage(respage.getString("please_choose_a_study_to_view"));
        forwardPage(Page.STUDY_LIST_SERVLET);
    } else {
        if (currentStudy.getId() != studyId && currentStudy.getParentStudyId() != studyId) {
            checkRoleByUserAndStudy(ub, studyId, 0);
        }
        String viewFullRecords = fp.getString("viewFull");
        StudyBean study = (StudyBean) sdao.findByPK(studyId);
        StudyConfigService scs = new StudyConfigService(sm.getDataSource());
        study = scs.setParametersForStudy(study);
        StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
        String randomizationStatusInOC = spvdao.findByHandleAndStudy(study.getId(), "randomization").getValue();
        String participantStatusInOC = spvdao.findByHandleAndStudy(study.getId(), "participantPortal").getValue();
        if (participantStatusInOC == "")
            participantStatusInOC = "disabled";
        if (randomizationStatusInOC == "")
            randomizationStatusInOC = "disabled";
        RandomizationRegistrar randomizationRegistrar = new RandomizationRegistrar();
        SeRandomizationDTO seRandomizationDTO = randomizationRegistrar.getCachedRandomizationDTOObject(study.getOid(), false);
        if (seRandomizationDTO != null && seRandomizationDTO.getStatus().equalsIgnoreCase("ACTIVE") && randomizationStatusInOC.equalsIgnoreCase("enabled")) {
            study.getStudyParameterConfig().setRandomization("enabled");
        } else {
            study.getStudyParameterConfig().setRandomization("disabled");
        }
        ;
        ParticipantPortalRegistrar participantPortalRegistrar = new ParticipantPortalRegistrar();
        String pStatus = participantPortalRegistrar.getCachedRegistrationStatus(study.getOid(), session);
        if (participantPortalRegistrar != null && pStatus.equalsIgnoreCase("ACTIVE") && participantStatusInOC.equalsIgnoreCase("enabled")) {
            study.getStudyParameterConfig().setParticipantPortal("enabled");
        } else {
            study.getStudyParameterConfig().setParticipantPortal("disabled");
        }
        ;
        request.setAttribute("studyToView", study);
        if ("yes".equalsIgnoreCase(viewFullRecords)) {
            UserAccountDAO udao = new UserAccountDAO(sm.getDataSource());
            StudySubjectDAO ssdao = new StudySubjectDAO(sm.getDataSource());
            ArrayList sites = new ArrayList();
            ArrayList userRoles = new ArrayList();
            ArrayList subjects = new ArrayList();
            if (this.currentStudy.getParentStudyId() > 0 && this.currentRole.getRole().getId() > 3) {
                sites.add(this.currentStudy);
                userRoles = udao.findAllUsersByStudy(currentStudy.getId());
                subjects = ssdao.findAllByStudy(currentStudy);
            } else {
                sites = (ArrayList) sdao.findAllByParent(studyId);
                userRoles = udao.findAllUsersByStudy(studyId);
                subjects = ssdao.findAllByStudy(study);
            }
            // find all subjects in the study, include ones in sites
            StudyEventDefinitionDAO seddao = new StudyEventDefinitionDAO(sm.getDataSource());
            EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
            // StudyEventDAO sedao = new StudyEventDAO(sm.getDataSource());
            //                ArrayList displayStudySubs = new ArrayList();
            //                for (int i = 0; i < subjects.size(); i++) {
            //                    StudySubjectBean studySub = (StudySubjectBean) subjects.get(i);
            //                    // find all events
            //                    ArrayList events = sedao.findAllByStudySubject(studySub);
            //
            //                    // find all eventcrfs for each event
            //                    EventCRFDAO ecdao = new EventCRFDAO(sm.getDataSource());
            //
            //                    DisplayStudySubjectBean dssb = new DisplayStudySubjectBean();
            //                    dssb.setStudyEvents(events);
            //                    dssb.setStudySubject(studySub);
            //                    displayStudySubs.add(dssb);
            //                }
            // find all events in the study, include ones in sites
            ArrayList definitions = seddao.findAllByStudy(study);
            for (int i = 0; i < definitions.size(); i++) {
                StudyEventDefinitionBean def = (StudyEventDefinitionBean) definitions.get(i);
                ArrayList crfs = (ArrayList) edcdao.findAllActiveParentsByEventDefinitionId(def.getId());
                def.setCrfNum(crfs.size());
            }
            String moduleManager = CoreResources.getField("moduleManager");
            request.setAttribute("moduleManager", moduleManager);
            String portalURL = CoreResources.getField("portalURL");
            request.setAttribute("portalURL", portalURL);
            request.setAttribute("config", study);
            request.setAttribute("sitesToView", sites);
            request.setAttribute("siteNum", sites.size() + "");
            request.setAttribute("userRolesToView", userRoles);
            request.setAttribute("userNum", userRoles.size() + "");
            // request.setAttribute("subjectsToView", displayStudySubs);
            // request.setAttribute("subjectNum", subjects.size() + "");
            request.setAttribute("definitionsToView", definitions);
            request.setAttribute("defNum", definitions.size() + "");
            forwardPage(Page.VIEW_FULL_STUDY);
        } else {
            forwardPage(Page.VIEW_STUDY);
        }
    }
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) ArrayList(java.util.ArrayList) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) UserAccountDAO(org.akaza.openclinica.dao.login.UserAccountDAO) StudySubjectDAO(org.akaza.openclinica.dao.managestudy.StudySubjectDAO) StudyConfigService(org.akaza.openclinica.dao.service.StudyConfigService) ParticipantPortalRegistrar(org.akaza.openclinica.service.pmanage.ParticipantPortalRegistrar) StudyEventDefinitionDAO(org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO) RandomizationRegistrar(org.akaza.openclinica.service.pmanage.RandomizationRegistrar) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) SeRandomizationDTO(org.akaza.openclinica.service.pmanage.SeRandomizationDTO) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO)

Example 34 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class UpdateJobExportServlet method processRequest.

@Override
protected void processRequest() throws Exception {
    FormProcessor fp = new FormProcessor(request);
    TriggerService triggerService = new TriggerService();
    String action = fp.getString("action");
    String triggerName = fp.getString("tname");
    scheduler = getScheduler();
    ExtractUtils extractUtils = new ExtractUtils();
    Trigger updatingTrigger = scheduler.getTrigger(new TriggerKey(triggerName.trim(), XsltTriggerService.TRIGGER_GROUP_NAME));
    if (StringUtil.isBlank(action)) {
        setUpServlet(updatingTrigger);
        forwardPage(Page.UPDATE_JOB_EXPORT);
    } else if ("confirmall".equalsIgnoreCase(action)) {
        // change and update trigger here
        // validate first
        // then update or send back
        String name = XsltTriggerService.TRIGGER_GROUP_NAME;
        Set<TriggerKey> triggerKeys = scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(name));
        String[] triggerNames = triggerKeys.stream().toArray(String[]::new);
        HashMap errors = validateForm(fp, request, triggerNames, updatingTrigger.getKey().getName());
        if (!errors.isEmpty()) {
            // send back
            addPageMessage("Your modifications caused an error, please see the messages for more information.");
            setUpServlet(updatingTrigger);
            logger.error("errors : " + errors.toString());
            forwardPage(Page.UPDATE_JOB_EXPORT);
        } else {
            // change trigger, update in database
            StudyDAO studyDAO = new StudyDAO(sm.getDataSource());
            StudyBean study = (StudyBean) studyDAO.findByPK(sm.getUserBean().getActiveStudyId());
            DatasetDAO datasetDao = new DatasetDAO(sm.getDataSource());
            CoreResources cr = new CoreResources();
            UserAccountBean userBean = (UserAccountBean) request.getSession().getAttribute("userBean");
            int datasetId = fp.getInt(DATASET_ID);
            String period = fp.getString(PERIOD);
            String email = fp.getString(EMAIL);
            String jobName = fp.getString(JOB_NAME);
            String jobDesc = fp.getString(JOB_DESC);
            Date startDateTime = fp.getDateTime(DATE_START_JOB);
            Integer exportFormatId = fp.getInt(FORMAT_ID);
            ExtractPropertyBean epBean = cr.findExtractPropertyBeanById(exportFormatId, "" + datasetId);
            DatasetBean dsBean = (DatasetBean) datasetDao.findByPK(new Integer(datasetId).intValue());
            String[] files = epBean.getFileName();
            String exportFileName;
            int fileSize = files.length;
            int cnt = 0;
            dsBean.setName(dsBean.getName().replaceAll(" ", "_"));
            String[] exportFiles = epBean.getExportFileName();
            String pattern = "yyyy" + File.separator + "MM" + File.separator + "dd" + File.separator + "HHmmssSSS" + File.separator;
            SimpleDateFormat sdfDir = new SimpleDateFormat(pattern);
            int i = 0;
            String[] temp = new String[exportFiles.length];
            //JN: The following logic is for comma separated variables, to avoid the second file be treated as a old file and deleted.
            String datasetFilePath = SQLInitServlet.getField("filePath") + "datasets";
            while (i < exportFiles.length) {
                temp[i] = extractUtils.resolveVars(exportFiles[i], dsBean, sdfDir, datasetFilePath);
                i++;
            }
            epBean.setDoNotDelFiles(temp);
            epBean.setExportFileName(temp);
            XsltTriggerService xsltService = new XsltTriggerService();
            String generalFileDir = SQLInitServlet.getField("filePath");
            generalFileDir = generalFileDir + "datasets" + File.separator + dsBean.getId() + File.separator + sdfDir.format(new java.util.Date());
            exportFileName = epBean.getExportFileName()[cnt];
            String xsltPath = SQLInitServlet.getField("filePath") + "xslt" + File.separator + files[cnt];
            String endFilePath = epBean.getFileLocation();
            endFilePath = extractUtils.getEndFilePath(endFilePath, dsBean, sdfDir, datasetFilePath);
            //  exportFileName = resolveVars(exportFileName,dsBean,sdfDir);
            if (epBean.getPostProcExportName() != null) {
                String preProcExportPathName = extractUtils.resolveVars(epBean.getPostProcExportName(), dsBean, sdfDir, datasetFilePath);
                epBean.setPostProcExportName(preProcExportPathName);
            }
            if (epBean.getPostProcLocation() != null) {
                String prePocLoc = extractUtils.getEndFilePath(epBean.getPostProcLocation(), dsBean, sdfDir, datasetFilePath);
                epBean.setPostProcLocation(prePocLoc);
            }
            extractUtils.setAllProps(epBean, dsBean, sdfDir, datasetFilePath);
            SimpleTrigger trigger = null;
            trigger = xsltService.generateXsltTrigger(scheduler, xsltPath, // xml_file_path
            generalFileDir, endFilePath + File.separator, exportFileName, dsBean.getId(), epBean, userBean, LocaleResolver.getLocale(request).getLanguage(), cnt, SQLInitServlet.getField("filePath") + "xslt", TRIGGER_GROUP_JOB);
            //Updating the original trigger with user given inputs
            trigger.getTriggerBuilder().withDescription(jobDesc).startAt(startDateTime).forJob(jobName).withSchedule(simpleSchedule().withIntervalInSeconds(new Long(XsltTriggerService.getIntervalTime(period)).intValue()).withRepeatCount(64000).withMisfireHandlingInstructionNextWithExistingCount());
            trigger.getJobDataMap().put(XsltTriggerService.EMAIL, email);
            trigger.getJobDataMap().put(XsltTriggerService.PERIOD, period);
            trigger.getJobDataMap().put(XsltTriggerService.EXPORT_FORMAT, epBean.getFiledescription());
            trigger.getJobDataMap().put(XsltTriggerService.EXPORT_FORMAT_ID, exportFormatId);
            trigger.getJobDataMap().put(XsltTriggerService.JOB_NAME, jobName);
            JobDetailFactoryBean JobDetailFactoryBean = new JobDetailFactoryBean();
            JobDetailFactoryBean.setGroup(xsltService.TRIGGER_GROUP_NAME);
            JobDetailFactoryBean.setName(trigger.getKey().getName());
            JobDetailFactoryBean.setJobClass(org.akaza.openclinica.job.XsltStatefulJob.class);
            JobDetailFactoryBean.setJobDataMap(trigger.getJobDataMap());
            // need durability?
            JobDetailFactoryBean.setDurability(true);
            try {
                // scheduler.unscheduleJob(triggerName, "DEFAULT");
                scheduler.deleteJob(new JobKey(triggerName, XsltTriggerService.TRIGGER_GROUP_NAME));
                Date dataStart = scheduler.scheduleJob(JobDetailFactoryBean.getObject(), trigger);
                // Date dateStart = scheduler.rescheduleJob(triggerName,
                // "DEFAULT", trigger);
                // scheduler.rescheduleJob(triggerName, groupName,
                // newTrigger)
                addPageMessage("Your job has been successfully modified.");
                forwardPage(Page.VIEW_JOB_SERVLET);
            } catch (SchedulerException se) {
                se.printStackTrace();
                // set a message here with the exception message
                setUpServlet(trigger);
                addPageMessage("There was an unspecified error with your creation, please contact an administrator.");
                forwardPage(Page.UPDATE_JOB_EXPORT);
            }
        }
    }
}
Also used : CoreResources(org.akaza.openclinica.dao.core.CoreResources) DatasetBean(org.akaza.openclinica.bean.extract.DatasetBean) ExtractUtils(org.akaza.openclinica.service.extract.ExtractUtils) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) ExtractPropertyBean(org.akaza.openclinica.bean.extract.ExtractPropertyBean) XsltTriggerService(org.akaza.openclinica.service.extract.XsltTriggerService) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) DatasetDAO(org.akaza.openclinica.dao.extract.DatasetDAO) XsltTriggerService(org.akaza.openclinica.service.extract.XsltTriggerService) TriggerService(org.akaza.openclinica.web.job.TriggerService) SimpleDateFormat(java.text.SimpleDateFormat) JobDetailFactoryBean(org.springframework.scheduling.quartz.JobDetailFactoryBean)

Example 35 with FormProcessor

use of org.akaza.openclinica.control.form.FormProcessor in project OpenClinica by OpenClinica.

the class UpdateSubjectServlet method processRequest.

@Override
public void processRequest() throws Exception {
    SubjectDAO sdao = new SubjectDAO(sm.getDataSource());
    FormProcessor fp = new FormProcessor(request);
    FormDiscrepancyNotes discNotes = new FormDiscrepancyNotes();
    String fromResolvingNotes = fp.getString("fromResolvingNotes", true);
    if (StringUtils.isBlank(fromResolvingNotes)) {
        session.removeAttribute(ViewNotesServlet.WIN_LOCATION);
        session.removeAttribute(ViewNotesServlet.NOTES_TABLE);
        checkStudyLocked(Page.LIST_SUBJECT_SERVLET, respage.getString("current_study_locked"));
        checkStudyFrozen(Page.LIST_SUBJECT_SERVLET, respage.getString("current_study_frozen"));
    }
    int subjectId = fp.getInt("id", true);
    int studySubId = fp.getInt("studySubId", true);
    if (subjectId == 0) {
        addPageMessage(respage.getString("please_choose_subject_to_edit"));
        forwardPage(Page.LIST_SUBJECT_SERVLET);
    } else {
        String action = fp.getString("action", true);
        if (StringUtils.isBlank("action")) {
            addPageMessage(respage.getString("no_action_specified"));
            forwardPage(Page.LIST_SUBJECT_SERVLET);
            return;
        }
        SubjectBean subject = (SubjectBean) sdao.findByPK(subjectId);
        if (action.equals("show") || action.equals("confirm")) {
            request.setAttribute("studySubId", new Integer(studySubId));
            request.setAttribute("id", new Integer(subjectId));
            request.setAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME, discNotes);
        }
        if ("show".equalsIgnoreCase(action)) {
            //no DOB collected
            request.setAttribute("localBirthDate", "");
            if (!currentStudy.getStudyParameterConfig().getCollectDob().equals("3") && subject.getDateOfBirth() != null) {
                setLocalDOB(subject);
            }
            discNotes = new FormDiscrepancyNotes();
            request.setAttribute("genderDNFlag", "icon_noNote");
            request.setAttribute("birthDNFlag", "icon_noNote");
            request.setAttribute("subjectToUpdate", subject);
            setDNFlag(subjectId);
            forwardPage(Page.UPDATE_SUBJECT);
        } else if ("confirm".equalsIgnoreCase(action)) {
            confirm(subject, subjectId);
        } else {
            String gender = fp.getString("gender");
            subject.setGender(gender.charAt(0));
            if (currentStudy.getStudyParameterConfig().getSubjectPersonIdRequired().equals("required") || currentStudy.getStudyParameterConfig().getSubjectPersonIdRequired().equals("optional")) {
                subject.setUniqueIdentifier(fp.getString("uniqueIdentifier"));
            }
            subject.setUpdater(ub);
            if (!currentStudy.getStudyParameterConfig().getCollectDob().equals("3")) {
                if (currentStudy.getStudyParameterConfig().getCollectDob().equals("2")) {
                    String d_date = fp.getString(DATE_DOB_TO_SAVE);
                    if (!(d_date == null || d_date.trim().length() == 0)) {
                        Date date_new = yformat.parse(fp.getString(DATE_DOB_TO_SAVE));
                        subject.setDateOfBirth(date_new);
                    }
                }
                if (currentStudy.getStudyParameterConfig().getCollectDob().equals("1")) {
                    Date date_new = local_df.parse(fp.getString(DATE_DOB_TO_SAVE));
                    subject.setDateOfBirth(date_new);
                }
            }
            sdao.update(subject);
            // save discrepancy notes into DB
            DiscrepancyNoteDAO dndao = new DiscrepancyNoteDAO(sm.getDataSource());
            FormDiscrepancyNotes fdn = (FormDiscrepancyNotes) session.getAttribute(AddNewSubjectServlet.FORM_DISCREPANCY_NOTES_NAME);
            AddNewSubjectServlet.saveFieldNotes("gender", fdn, dndao, subject.getId(), "subject", currentStudy);
            AddNewSubjectServlet.saveFieldNotes(DATE_DOB, fdn, dndao, subject.getId(), "subject", currentStudy);
            addPageMessage(respage.getString("subject_updated_succcesfully"));
            if (studySubId > 0) {
                request.setAttribute("id", new Integer(studySubId).toString());
                forwardPage(Page.VIEW_STUDY_SUBJECT_SERVLET);
            } else {
                forwardPage(Page.LIST_SUBJECT_SERVLET);
            }
        }
    }
}
Also used : SubjectBean(org.akaza.openclinica.bean.submit.SubjectBean) DiscrepancyNoteDAO(org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO) FormDiscrepancyNotes(org.akaza.openclinica.control.form.FormDiscrepancyNotes) SubjectDAO(org.akaza.openclinica.dao.submit.SubjectDAO) FormProcessor(org.akaza.openclinica.control.form.FormProcessor) Date(java.util.Date)

Aggregations

FormProcessor (org.akaza.openclinica.control.form.FormProcessor)224 ArrayList (java.util.ArrayList)139 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)92 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)73 HashMap (java.util.HashMap)69 Date (java.util.Date)49 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)48 CRFDAO (org.akaza.openclinica.dao.admin.CRFDAO)46 EventCRFDAO (org.akaza.openclinica.dao.submit.EventCRFDAO)46 Validator (org.akaza.openclinica.control.form.Validator)44 StudyEventDefinitionDAO (org.akaza.openclinica.dao.managestudy.StudyEventDefinitionDAO)44 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)42 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)41 StudySubjectDAO (org.akaza.openclinica.dao.managestudy.StudySubjectDAO)41 CRFBean (org.akaza.openclinica.bean.admin.CRFBean)40 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)36 UserAccountDAO (org.akaza.openclinica.dao.login.UserAccountDAO)36 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)35 StudySubjectBean (org.akaza.openclinica.bean.managestudy.StudySubjectBean)35 StudyEventDAO (org.akaza.openclinica.dao.managestudy.StudyEventDAO)35