Search in sources :

Example 6 with NullValue

use of org.akaza.openclinica.bean.core.NullValue in project OpenClinica by OpenClinica.

the class InsertActionValidator method matchValueWithManyOptions.

@SuppressWarnings("unchecked")
private String matchValueWithManyOptions(String value, List<ResponseOptionBean> options) {
    String returnedValue = null;
    String entireOptions = "";
    String[] simValues = value.split(",");
    String simValue = value.replace(",", "");
    simValue = simValue.replace(" ", "");
    boolean checkComplete = true;
    if (!options.isEmpty()) {
        for (ResponseOptionBean responseOptionBean : options) {
            entireOptions += responseOptionBean.getValue();
        }
        // remove spaces, since they are causing problems:
        entireOptions = entireOptions.replace(" ", "");
        ArrayList nullValues = getEventDefinitionCRFBean().getNullValuesList();
        for (Object nullValue : nullValues) {
            NullValue nullValueTerm = (NullValue) nullValue;
            entireOptions += nullValueTerm.getName();
        }
        for (String sim : simValues) {
            sim = sim.replace(" ", "");
            // Pattern.matches(entireOptions,sim);
            checkComplete = entireOptions.contains(sim);
            if (!checkComplete) {
                return returnedValue;
            }
        }
    }
    return value;
}
Also used : NullValue(org.akaza.openclinica.bean.core.NullValue) ArrayList(java.util.ArrayList) ResponseOptionBean(org.akaza.openclinica.bean.submit.ResponseOptionBean)

Example 7 with NullValue

use of org.akaza.openclinica.bean.core.NullValue in project OpenClinica by OpenClinica.

the class ImportCRFDataService method matchValueWithManyOptions.

/*
     * difference from the above is only a 'contains' in the place of an 'equals'. and a few other switches...also need
     * to keep in mind that there are non-null values that need to be taken into account
     */
private String matchValueWithManyOptions(DisplayItemBean displayItemBean, String value, List options) {
    String returnedValue = null;
    // boolean checkComplete = true;
    String entireOptions = "";
    String[] simValues = value.split(",");
    String simValue = value.replace(",", "");
    // also remove all spaces, so they will fit up with the entire set
    // of options
    simValue = simValue.replace(" ", "");
    boolean checkComplete = true;
    if (!options.isEmpty()) {
        for (Object responseOption : options) {
            ResponseOptionBean responseOptionBean = (ResponseOptionBean) responseOption;
            // logger.debug("testing response option bean get value: " + responseOptionBean.getValue());
            // entireOptions += responseOptionBean.getValue() + "{0,1}|";//
            // once, or not at all
            entireOptions += responseOptionBean.getValue();
        // trying smth new, tbh 01/2009
        // logger.debug("checking on this string: " +
        // entireOptions + " versus this value " + simValue);
        // checkComplete = Pattern.matches(entireOptions, simValue); //
        // switch values, tbh
        // if (!checkComplete) {
        // return returnedValue;
        // }
        }
        // remove spaces, since they are causing problems:
        entireOptions = entireOptions.replace(" ", "");
        // following may be superfluous, tbh
        ArrayList nullValues = displayItemBean.getEventDefinitionCRF().getNullValuesList();
        for (Object nullValue : nullValues) {
            NullValue nullValueTerm = (NullValue) nullValue;
            entireOptions += nullValueTerm.getName();
        // logger.debug("found and added " + nullValueTerm.getName());
        }
        for (String sim : simValues) {
            sim = sim.replace(" ", "");
            // logger.debug("checking on this string: " + entireOptions + " versus this value " + sim);
            // Pattern.matches(
            checkComplete = entireOptions.contains(sim);
            // sim);
            if (!checkComplete) {
                return returnedValue;
            }
        }
    }
    return value;
}
Also used : NullValue(org.akaza.openclinica.bean.core.NullValue) ArrayList(java.util.ArrayList) ResponseOptionBean(org.akaza.openclinica.bean.submit.ResponseOptionBean)

Example 8 with NullValue

use of org.akaza.openclinica.bean.core.NullValue in project OpenClinica by OpenClinica.

the class InitUpdateEventDefinitionServlet method processNullValues.

private HashMap processNullValues(EventDefinitionCRFBean edc) {
    HashMap flags = new LinkedHashMap();
    // edc.getNullValues();
    String s = "";
    for (int j = 0; j < edc.getNullValuesList().size(); j++) {
        NullValue nv1 = (NullValue) edc.getNullValuesList().get(j);
        s = s + nv1.getName().toUpperCase() + ",";
    }
    // String s = edc.getNullValuesList().toString();
    logger.info("********:" + s);
    if (s != null) {
        for (int i = 1; i <= NullValue.toArrayList().size(); i++) {
            String nv = NullValue.get(i).getName().toUpperCase();
            // if (s.indexOf(nv) >= 0) {
            // indexOf won't save us
            // because NA and NASK will come back both positive, for example
            // rather, we need a regexp here
            Pattern p = Pattern.compile(nv + "\\W");
            // find our word with a non-word character after it (,)
            Matcher m = p.matcher(s);
            if (m.find()) {
                flags.put(nv, "1");
                logger.info("********1:" + nv + " found at " + m.start() + ", " + m.end());
            } else {
                flags.put(nv, "0");
                logger.info("********0:" + nv);
            }
        }
    }
    return flags;
}
Also used : Pattern(java.util.regex.Pattern) NullValue(org.akaza.openclinica.bean.core.NullValue) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Matcher(java.util.regex.Matcher) LinkedHashMap(java.util.LinkedHashMap)

Example 9 with NullValue

use of org.akaza.openclinica.bean.core.NullValue in project OpenClinica by OpenClinica.

the class UpdateEventDefinitionServlet method confirmDefinition.

/**
     * 
     * @throws Exception
     */
private void confirmDefinition() throws Exception {
    Validator v = new Validator(request);
    FormProcessor fp = new FormProcessor(request);
    StudyEventDefinitionBean sed = (StudyEventDefinitionBean) session.getAttribute("definition");
    StudyParameterValueDAO spvdao = new StudyParameterValueDAO(sm.getDataSource());
    String participateFormStatus = spvdao.findByHandleAndStudy(sed.getStudyId(), "participantPortal").getValue();
    if (participateFormStatus.equals("enabled"))
        baseUrl();
    request.setAttribute("participateFormStatus", participateFormStatus);
    v.addValidation("name", Validator.NO_BLANKS);
    v.addValidation("name", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
    v.addValidation("description", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
    v.addValidation("category", Validator.LENGTH_NUMERIC_COMPARISON, NumericComparisonOperator.LESS_THAN_OR_EQUAL_TO, 2000);
    ArrayList<EventDefinitionCRFBean> edcsInSession = (ArrayList<EventDefinitionCRFBean>) session.getAttribute("eventDefinitionCRFs");
    int parentStudyId = sed.getStudyId();
    EventDefinitionCRFDAO edcdao = new EventDefinitionCRFDAO(sm.getDataSource());
    ArrayList<EventDefinitionCRFBean> eventDefCrfList = (ArrayList<EventDefinitionCRFBean>) edcdao.findAllActiveSitesAndStudiesPerParentStudy(parentStudyId);
    // logger.info("no errors");
    sed.setName(fp.getString("name"));
    sed.setRepeating(fp.getBoolean("repeating"));
    sed.setCategory(fp.getString("category"));
    sed.setDescription(fp.getString("description"));
    sed.setType(fp.getString("type"));
    session.setAttribute("definition", sed);
    FormLayoutDAO fldao = new FormLayoutDAO(sm.getDataSource());
    ArrayList<EventDefinitionCRFBean> edcs = (ArrayList) session.getAttribute("eventDefinitionCRFs");
    for (int i = 0; i < edcs.size(); i++) {
        EventDefinitionCRFBean edcBean = (EventDefinitionCRFBean) edcs.get(i);
        if (!edcBean.getStatus().equals(Status.DELETED) && !edcBean.getStatus().equals(Status.AUTO_DELETED)) {
            // only get inputs from web page if AVAILABLE
            int defaultVersionId = fp.getInt("defaultVersionId" + i);
            edcBean.setDefaultVersionId(defaultVersionId);
            FormLayoutBean defaultVersion = (FormLayoutBean) fldao.findByPK(edcBean.getDefaultVersionId());
            edcBean.setDefaultVersionName(defaultVersion.getName());
            String requiredCRF = fp.getString("requiredCRF" + i);
            String doubleEntry = fp.getString("doubleEntry" + i);
            String decisionCondition = fp.getString("decisionCondition" + i);
            String electronicSignature = fp.getString("electronicSignature" + i);
            String hideCRF = fp.getString("hideCRF" + i);
            int sdvId = fp.getInt("sdvOption" + i);
            String participantForm = fp.getString("participantForm" + i);
            String allowAnonymousSubmission = fp.getString("allowAnonymousSubmission" + i);
            String submissionUrl = fp.getString("submissionUrl" + i);
            String offline = fp.getString("offline" + i);
            System.out.println("submission :" + submissionUrl);
            if (!StringUtil.isBlank(hideCRF) && "yes".equalsIgnoreCase(hideCRF.trim())) {
                edcBean.setHideCrf(true);
            } else {
                edcBean.setHideCrf(false);
            }
            if (!StringUtil.isBlank(requiredCRF) && "yes".equalsIgnoreCase(requiredCRF.trim())) {
                edcBean.setRequiredCRF(true);
            } else {
                edcBean.setRequiredCRF(false);
            }
            if (!StringUtil.isBlank(doubleEntry) && "yes".equalsIgnoreCase(doubleEntry.trim())) {
                edcBean.setDoubleEntry(true);
            } else {
                edcBean.setDoubleEntry(false);
            }
            if (!StringUtil.isBlank(electronicSignature) && "yes".equalsIgnoreCase(electronicSignature.trim())) {
                edcBean.setElectronicSignature(true);
            } else {
                edcBean.setElectronicSignature(false);
            }
            if (!StringUtil.isBlank(decisionCondition) && "yes".equalsIgnoreCase(decisionCondition.trim())) {
                edcBean.setDecisionCondition(true);
            } else {
                edcBean.setDecisionCondition(false);
            }
            if (!StringUtil.isBlank(participantForm) && "yes".equalsIgnoreCase(participantForm.trim())) {
                edcBean.setParticipantForm(true);
            } else {
                edcBean.setParticipantForm(false);
            }
            if (!StringUtils.isBlank(allowAnonymousSubmission) && "yes".equalsIgnoreCase(allowAnonymousSubmission.trim())) {
                edcBean.setAllowAnonymousSubmission(true);
            } else {
                edcBean.setAllowAnonymousSubmission(false);
            }
            edcBean.setSubmissionUrl(submissionUrl.trim());
            if (!StringUtils.isBlank(offline) && "yes".equalsIgnoreCase(offline.trim())) {
                edcBean.setOffline(true);
            } else {
                edcBean.setOffline(false);
            }
            String nullString = "";
            // process null values
            ArrayList nulls = NullValue.toArrayList();
            for (int a = 0; a < nulls.size(); a++) {
                NullValue n = (NullValue) nulls.get(a);
                String myNull = fp.getString(n.getName().toLowerCase() + i);
                if (!StringUtil.isBlank(myNull) && "yes".equalsIgnoreCase(myNull.trim())) {
                    nullString = nullString + n.getName().toUpperCase() + ",";
                }
            }
            if (sdvId > 0 && (edcBean.getSourceDataVerification() == null || sdvId != edcBean.getSourceDataVerification().getCode())) {
                edcBean.setSourceDataVerification(SourceDataVerification.getByCode(sdvId));
            }
            edcBean.setNullValues(nullString);
            logger.info("found null values: " + nullString);
        }
    }
    validateSubmissionUrl(edcsInSession, eventDefCrfList, v);
    errors = v.validate();
    if (!errors.isEmpty()) {
        logger.info("has errors");
        session.setAttribute("eventDefinitionCRFs", edcs);
        request.setAttribute("formMessages", errors);
        forwardPage(Page.UPDATE_EVENT_DEFINITION1);
    }
    session.setAttribute("eventDefinitionCRFs", edcs);
    forwardPage(Page.UPDATE_EVENT_DEFINITION_CONFIRM);
}
Also used : FormProcessor(org.akaza.openclinica.control.form.FormProcessor) ArrayList(java.util.ArrayList) FormLayoutBean(org.akaza.openclinica.bean.submit.FormLayoutBean) StudyEventDefinitionBean(org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean) EventDefinitionCRFDAO(org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO) NullValue(org.akaza.openclinica.bean.core.NullValue) FormLayoutDAO(org.akaza.openclinica.dao.submit.FormLayoutDAO) StudyParameterValueDAO(org.akaza.openclinica.dao.service.StudyParameterValueDAO) EventDefinitionCRFBean(org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean) Validator(org.akaza.openclinica.control.form.Validator)

Aggregations

NullValue (org.akaza.openclinica.bean.core.NullValue)9 ArrayList (java.util.ArrayList)8 EventDefinitionCRFBean (org.akaza.openclinica.bean.managestudy.EventDefinitionCRFBean)4 ResponseOptionBean (org.akaza.openclinica.bean.submit.ResponseOptionBean)3 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)3 EventDefinitionCRFDAO (org.akaza.openclinica.dao.managestudy.EventDefinitionCRFDAO)3 StudyEventDefinitionBean (org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean)2 FormLayoutBean (org.akaza.openclinica.bean.submit.FormLayoutBean)2 Validator (org.akaza.openclinica.control.form.Validator)2 StudyParameterValueDAO (org.akaza.openclinica.dao.service.StudyParameterValueDAO)2 FormLayoutDAO (org.akaza.openclinica.dao.submit.FormLayoutDAO)2 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 ItemDataType (org.akaza.openclinica.bean.core.ItemDataType)1 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)1 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)1 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)1 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)1