Search in sources :

Example 6 with ResponseOptionBean

use of org.akaza.openclinica.bean.submit.ResponseOptionBean in project OpenClinica by OpenClinica.

the class DataEntryServlet method addNullValues.

/*
	 *  * @param nullValuesList
	     *            A List of Strings containing "null values" such as "not
	     *            applicable" or NA.
	 */
private void addNullValues(DisplayItemBean displayItemBean, List<String> nullValuesList) {
    // logger = LoggerFactory.getLogger(getClass().getName());
    boolean hasNullValues = nullValuesList != null && !nullValuesList.isEmpty();
    if (!hasNullValues) {
        return;
    }
    String tmpVal = "";
    String responseName = displayItemBean.getMetadata().getResponseSet().getResponseType().getName();
    ;
    List<ResponseOptionBean> respOptions = displayItemBean.getMetadata().getResponseSet().getOptions();
    ResponseOptionBean respBean;
    if (respOptions != null && ("checkbox".equalsIgnoreCase(responseName) || "radio".equalsIgnoreCase(responseName) || "single-select".equalsIgnoreCase(responseName) || "multi-select".equalsIgnoreCase(responseName))) {
        for (String val : nullValuesList) {
            respBean = new ResponseOptionBean();
            // BWP>> set text to the extended version, "not
            // applicable"?
            tmpVal = DataEntryInputGenerator.NULL_VALUES_LONGVERSION.get(val);
            if (tmpVal != null && tmpVal.length() > 0) {
                respBean.setText(tmpVal);
            } else {
                respBean.setText(val);
            }
            respBean.setValue(val);
            displayItemBean.getMetadata().getResponseSet().addOption(respBean);
        //respOptions.add(respBean);
        }
    }
}
Also used : ResponseOptionBean(org.akaza.openclinica.bean.submit.ResponseOptionBean)

Example 7 with ResponseOptionBean

use of org.akaza.openclinica.bean.submit.ResponseOptionBean in project OpenClinica by OpenClinica.

the class DataEntryServlet method ensureSelectedOption.

private void ensureSelectedOption(DisplayItemBean displayItemBean) {
    if (displayItemBean == null || displayItemBean.getData() == null) {
        return;
    }
    ItemDataBean itemDataBean = displayItemBean.getData();
    String dataName = itemDataBean.getName();
    String dataValue = itemDataBean.getValue();
    if ("".equalsIgnoreCase(dataValue)) {
        return;
    }
    List<ResponseOptionBean> responseOptionBeans = new ArrayList<ResponseOptionBean>();
    ResponseSetBean responseSetBean = displayItemBean.getMetadata().getResponseSet();
    if (responseSetBean == null) {
        return;
    }
    responseOptionBeans = responseSetBean.getOptions();
    String tempVal = "";
    for (ResponseOptionBean responseOptionBean : responseOptionBeans) {
        tempVal = responseOptionBean.getValue();
        if (tempVal != null && tempVal.equalsIgnoreCase(dataValue)) {
            responseOptionBean.setSelected(true);
        }
    }
}
Also used : ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) ArrayList(java.util.ArrayList) ResponseSetBean(org.akaza.openclinica.bean.submit.ResponseSetBean) ResponseOptionBean(org.akaza.openclinica.bean.submit.ResponseOptionBean)

Example 8 with ResponseOptionBean

use of org.akaza.openclinica.bean.submit.ResponseOptionBean in project OpenClinica by OpenClinica.

the class CellFactory method createCellContentsForChecks.

public Element[] createCellContentsForChecks(String responseName, DisplayItemBean displayBean, Integer optionsLength, Integer tabIndex, boolean hasDBValues, boolean forPrinting) {
    // In this HTML design, so far, we do not include discrepancy note
    // symbols
    // or icons for horizontal layouts
    Element[] tdElements = new Element[optionsLength];
    Element td;
    List<ResponseOptionBean> list = new ArrayList<ResponseOptionBean>();
    int indx = 0;
    ResponseOptionBean reOptBean;
    for (Iterator iter = displayBean.getMetadata().getResponseSet().getOptions().iterator(); iter.hasNext(); ) {
        reOptBean = (ResponseOptionBean) iter.next();
        list.add(reOptBean);
        td = new Element("td");
        if (responseName.equalsIgnoreCase("checkbox")) {
            td = inputGenerator.createCheckboxTag(td, displayBean.getItem().getId(), list, tabIndex, false, displayBean.getData().getValue(), displayBean.getMetadata().getDefaultValue(), true, hasDBValues);
        } else {
            // Second to last true parameter is for horizontal radios
            td = inputGenerator.createRadioButtonTag(td, displayBean.getItem().getId(), list, tabIndex, false, displayBean.getData().getValue(), displayBean.getMetadata().getDefaultValue(), true, hasDBValues);
        }
        tdElements[indx] = td;
        indx++;
        list.clear();
    }
    return tdElements;
}
Also used : Element(org.jdom.Element) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ResponseOptionBean(org.akaza.openclinica.bean.submit.ResponseOptionBean)

Example 9 with ResponseOptionBean

use of org.akaza.openclinica.bean.submit.ResponseOptionBean in project OpenClinica by OpenClinica.

the class DataEntryDecorator method createCheckboxTag.

public Element createCheckboxTag(Element tdCell, Integer itemId, List options, Integer tabNumber, boolean includeLabel, String dbValue, String defaultValue, boolean isHorizontal, boolean hasSavedData) {
    // The input element
    Element element;
    // the span element that contains the input element
    Element spanElement;
    String[] arrayOfValues = new String[] {};
    int count = 0;
    // Handles lone Strings, or Strings separated by commas
    if (dbValue != null && dbValue.length() > 0) {
        synchronized (inputGenerator) {
            arrayOfValues = inputGenerator.handleSplitString(dbValue);
        }
    } else if (!hasSavedData && defaultValue != null && defaultValue.length() > 0) {
        synchronized (inputGenerator) {
            arrayOfValues = inputGenerator.handleSplitString(defaultValue);
        }
    }
    for (Object responseOptBean : options) {
        spanElement = new Element("span");
        spanElement.setAttribute("style", "float:left;clear:both");
        synchronized (inputGenerator) {
            element = inputGenerator.initializeInputElement("checkbox", itemId, tabNumber);
        }
        spanElement.addContent(element);
        String value = ((ResponseOptionBean) responseOptBean).getValue();
        String forDefVal = ((ResponseOptionBean) responseOptBean).getText();
        element.setAttribute("value", value);
        // It's checked if its value equals the DB value
        if (dbValue != null && dbValue.length() > 0) {
            // && value.equalsIgnoreCase(dbValue)
            for (String string : arrayOfValues) {
                if (value.equalsIgnoreCase(string)) {
                    element.setAttribute("checked", "checked");
                }
            }
        } else if (!hasSavedData && defaultValue != null && defaultValue.length() > 0) {
            // && value.equalsIgnoreCase(dbValue)
            for (String string : arrayOfValues) {
                if (forDefVal.equalsIgnoreCase(string) || value.equalsIgnoreCase(string)) {
                    element.setAttribute("checked", "checked");
                }
            }
        }
        tdCell.addContent(spanElement);
        if (includeLabel) {
            spanElement.addContent(((ResponseOptionBean) responseOptBean).getText());
        }
    }
    return tdCell;
}
Also used : Element(org.jdom.Element) ResponseOptionBean(org.akaza.openclinica.bean.submit.ResponseOptionBean)

Example 10 with ResponseOptionBean

use of org.akaza.openclinica.bean.submit.ResponseOptionBean in project OpenClinica by OpenClinica.

the class DataEntryDecorator method createRadioButtonTag.

public Element createRadioButtonTag(Element tdCell, Integer itemId, List options, Integer tabNumber, boolean includeLabel, String dbValue, String defaultValue, boolean isHorizontal, boolean hasSavedData) {
    // the input element
    Element element;
    // the span element that contains the input element
    Element spanElement;
    // so that the input elements will have unique IDs
    if (itemId == 0) {
        Random rand = new Random();
        itemId = rand.nextInt(10000) + 1;
    }
    // Do not use the default value if there is a valid database value
    boolean hasData = dbValue != null && dbValue.length() > 0;
    for (Object responseOptBean : options) {
        spanElement = new Element("span");
        spanElement.setAttribute("style", "float:left;clear:both");
        synchronized (inputGenerator) {
            element = inputGenerator.initializeInputElement("radio", itemId, tabNumber);
        }
        spanElement.addContent(element);
        String value = ((ResponseOptionBean) responseOptBean).getValue();
        String forDefVal = ((ResponseOptionBean) responseOptBean).getText();
        element.setAttribute("value", value);
        // It's checked if its value equals the DB value
        if (dbValue != null && dbValue.length() > 0 && value.equalsIgnoreCase(dbValue)) {
            element.setAttribute("checked", "checked");
        }
        if (!hasSavedData && defaultValue != null && (forDefVal.equalsIgnoreCase(defaultValue) || value.equalsIgnoreCase(defaultValue))) {
            element.setAttribute("checked", "checked");
        }
        // dealing with IE/repetition model library bug
        if (isHorizontal) {
            element.setAttribute("onclick", "if(detectIEWindows(navigator.userAgent)){this.checked=true; unCheckSiblings(this,'horizontal');}");
        } else {
            element.setAttribute("onclick", "if(detectIEWindows(navigator.userAgent)){this.checked=true; unCheckSiblings(this,'vertical');}");
        }
        tdCell.addContent(spanElement);
        spanElement.addContent(" ");
        if (includeLabel) {
            spanElement.addContent(((ResponseOptionBean) responseOptBean).getText());
        }
    }
    return tdCell;
}
Also used : Random(java.util.Random) Element(org.jdom.Element) ResponseOptionBean(org.akaza.openclinica.bean.submit.ResponseOptionBean)

Aggregations

ResponseOptionBean (org.akaza.openclinica.bean.submit.ResponseOptionBean)31 ArrayList (java.util.ArrayList)20 DisplayItemBean (org.akaza.openclinica.bean.submit.DisplayItemBean)9 Element (org.jdom.Element)8 ItemBean (org.akaza.openclinica.bean.submit.ItemBean)7 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)7 ItemFormMetadataBean (org.akaza.openclinica.bean.submit.ItemFormMetadataBean)7 ItemDataDAO (org.akaza.openclinica.dao.submit.ItemDataDAO)5 HashMap (java.util.HashMap)4 NumberFormat (java.text.NumberFormat)3 Iterator (java.util.Iterator)3 NullValue (org.akaza.openclinica.bean.core.NullValue)3 DisplayItemGroupBean (org.akaza.openclinica.bean.submit.DisplayItemGroupBean)3 DisplayItemWithGroupBean (org.akaza.openclinica.bean.submit.DisplayItemWithGroupBean)3 EventCRFBean (org.akaza.openclinica.bean.submit.EventCRFBean)3 Random (java.util.Random)2 HttpSession (javax.servlet.http.HttpSession)2 DiscrepancyNoteBean (org.akaza.openclinica.bean.managestudy.DiscrepancyNoteBean)2 ResponseSetBean (org.akaza.openclinica.bean.submit.ResponseSetBean)2 DiscrepancyNoteDAO (org.akaza.openclinica.dao.managestudy.DiscrepancyNoteDAO)2