Search in sources :

Example 1 with Input

use of org.akaza.openclinica.domain.xform.dto.Input in project OpenClinica by OpenClinica.

the class ResponseSetService method getOptionsText.

private String getOptionsText(Html html, String submittedXformText, XformItem xformItem, ResponseType responseType) throws Exception {
    String optionsText = "";
    List<Group> groups = html.getBody().getGroup();
    for (Group group : groups) {
        List<UserControl> controls = null;
        if (group.getRepeat() != null)
            controls = group.getRepeat().getUsercontrol();
        else
            controls = group.getUsercontrol();
        for (UserControl control : controls) {
            if (control.getRef().equals(xformItem.getItemPath())) {
                List<Item> items = null;
                ItemSet itemSet = null;
                if (control instanceof Input) {
                    return responseType.getName();
                } else if (control instanceof Select) {
                    items = ((Select) control).getItem();
                    itemSet = ((Select) control).getItemSet();
                } else if (control instanceof Select1) {
                    items = ((Select1) control).getItem();
                    itemSet = ((Select1) control).getItemSet();
                } else if (control instanceof Upload && control.getMediatype().equals("image/*")) {
                    return responseType.getName();
                } else {
                    logger.debug("Found Unsupported UserControl (" + control.getClass().getName() + ".  Returning null text.");
                    return null;
                }
                if (itemSet != null)
                    optionsText = getOptionsTextFromItemSet(submittedXformText, itemSet, html);
                else {
                    for (Item option : items) {
                        String label = lookupLabel(html, option.getLabel());
                        label = label.replaceAll(",", "\\\\,");
                        if (optionsText.isEmpty())
                            optionsText = label;
                        else
                            optionsText += "," + label;
                    }
                }
            }
        }
    }
    return optionsText;
}
Also used : UserControl(org.akaza.openclinica.domain.xform.dto.UserControl) Group(org.akaza.openclinica.domain.xform.dto.Group) XformItem(org.akaza.openclinica.domain.xform.XformItem) Item(org.akaza.openclinica.domain.xform.dto.Item) Input(org.akaza.openclinica.domain.xform.dto.Input) ItemSet(org.akaza.openclinica.domain.xform.dto.ItemSet) Select1(org.akaza.openclinica.domain.xform.dto.Select1) Select(org.akaza.openclinica.domain.xform.dto.Select) Upload(org.akaza.openclinica.domain.xform.dto.Upload)

Example 2 with Input

use of org.akaza.openclinica.domain.xform.dto.Input in project OpenClinica by OpenClinica.

the class ResponseSetService method getOptionsValues.

private String getOptionsValues(Html html, String submittedXformText, XformItem xformItem, ResponseType responseType) throws Exception {
    String optionsValues = "";
    List<Group> groups = html.getBody().getGroup();
    for (Group group : groups) {
        List<UserControl> controls = null;
        if (group.getRepeat() != null)
            controls = group.getRepeat().getUsercontrol();
        else
            controls = group.getUsercontrol();
        for (UserControl control : controls) {
            if (control.getRef().equals(xformItem.getItemPath())) {
                List<Item> items = null;
                ItemSet itemSet = null;
                if (control instanceof Input) {
                    return responseType.getName();
                } else if (control instanceof Select) {
                    items = ((Select) control).getItem();
                    itemSet = ((Select) control).getItemSet();
                } else if (control instanceof Select1) {
                    items = ((Select1) control).getItem();
                    itemSet = ((Select1) control).getItemSet();
                } else if (control instanceof Upload && control.getMediatype().equals("image/*")) {
                    return responseType.getName();
                } else {
                    logger.debug("Found Unsupported UserControl (" + control.getClass().getName() + ".  Returning null text.");
                    return null;
                }
                if (itemSet != null)
                    optionsValues = getOptionsValuesFromItemSet(submittedXformText, itemSet, html);
                else {
                    for (Item option : items) {
                        String value = option.getValue();
                        if (optionsValues.isEmpty())
                            optionsValues = value;
                        else
                            optionsValues += "," + value;
                    }
                }
            }
        }
    }
    return optionsValues;
}
Also used : UserControl(org.akaza.openclinica.domain.xform.dto.UserControl) Group(org.akaza.openclinica.domain.xform.dto.Group) XformItem(org.akaza.openclinica.domain.xform.XformItem) Item(org.akaza.openclinica.domain.xform.dto.Item) Input(org.akaza.openclinica.domain.xform.dto.Input) ItemSet(org.akaza.openclinica.domain.xform.dto.ItemSet) Select1(org.akaza.openclinica.domain.xform.dto.Select1) Select(org.akaza.openclinica.domain.xform.dto.Select) Upload(org.akaza.openclinica.domain.xform.dto.Upload)

Aggregations

XformItem (org.akaza.openclinica.domain.xform.XformItem)2 Group (org.akaza.openclinica.domain.xform.dto.Group)2 Input (org.akaza.openclinica.domain.xform.dto.Input)2 Item (org.akaza.openclinica.domain.xform.dto.Item)2 ItemSet (org.akaza.openclinica.domain.xform.dto.ItemSet)2 Select (org.akaza.openclinica.domain.xform.dto.Select)2 Select1 (org.akaza.openclinica.domain.xform.dto.Select1)2 Upload (org.akaza.openclinica.domain.xform.dto.Upload)2 UserControl (org.akaza.openclinica.domain.xform.dto.UserControl)2