use of org.akaza.openclinica.domain.xform.dto.UserControl in project OpenClinica by OpenClinica.
the class XformMetaDataService method createGroups.
private void createGroups(XformContainer container, Html html, String submittedXformText, CrfBean crf, CrfVersion version, Section section, UserAccountBean ub, Errors errors) throws Exception {
Integer itemOrdinal = 1;
ArrayList<String> usedGroupOids = new ArrayList<String>();
ArrayList<String> usedItemOids = new ArrayList<String>();
List<Group> htmlGroups = html.getBody().getGroup();
for (Group htmlGroup : htmlGroups) {
XformGroup xformGroup = container.findGroupByRef(htmlGroup.getRef());
ItemGroup itemGroup = itemGroupDao.findByNameCrfId(xformGroup.getGroupName(), crf);
if (itemGroup == null) {
itemGroup = new ItemGroup();
itemGroup.setName(xformGroup.getGroupName());
itemGroup.setCrf(crf);
itemGroup.setStatus(org.akaza.openclinica.domain.Status.AVAILABLE);
itemGroup.setUserAccount(userDao.findById(ub.getId()));
itemGroup.setOcOid(itemGroupDao.getValidOid(new ItemGroup(), crf.getName(), xformGroup.getGroupName(), usedGroupOids));
usedGroupOids.add(itemGroup.getOcOid());
Integer itemGroupId = (Integer) itemGroupDao.save(itemGroup);
itemGroup.setItemGroupId(itemGroupId);
}
List<UserControl> widgets = null;
boolean isRepeating = false;
if (htmlGroup.getRepeat() != null && htmlGroup.getRepeat().getUsercontrol() != null) {
widgets = htmlGroup.getRepeat().getUsercontrol();
isRepeating = true;
} else {
widgets = htmlGroup.getUsercontrol();
}
// Create Item specific DB entries: item, response_set,item_form_metadata,versioning_map,item_group_metadata
for (UserControl widget : widgets) {
// Skip reserved name and read-only items here
XformItem xformItem = container.findItemByGroupAndRef(xformGroup, widget.getRef());
String readonly = html.getHead().getModel().getBindByNodeSet(widget.getRef()).getReadOnly();
if (!xformItem.getItemName().equals("OC.STUDY_SUBJECT_ID") && !xformItem.getItemName().equals("OC.STUDY_SUBJECT_ID_CONFIRM") && (readonly == null || !readonly.trim().equals("true()"))) {
Item item = createItem(html, widget, xformGroup, xformItem, crf, ub, usedItemOids, errors);
if (item != null) {
ResponseType responseType = getResponseType(html, xformItem);
ResponseSet responseSet = responseSetService.getResponseSet(html, submittedXformText, xformItem, version, responseType, item, errors);
createItemFormMetadata(html, xformItem, item, responseSet, section, version, itemOrdinal);
createVersioningMap(version, item);
createItemGroupMetadata(html, item, version, itemGroup, isRepeating, itemOrdinal);
itemOrdinal++;
}
}
}
}
}
use of org.akaza.openclinica.domain.xform.dto.UserControl 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;
}
use of org.akaza.openclinica.domain.xform.dto.UserControl 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;
}
Aggregations