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);
}
}
}
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);
}
}
}
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;
}
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;
}
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;
}
Aggregations