use of org.akaza.openclinica.web.pform.dto.UserControl in project OpenClinica by OpenClinica.
the class OpenRosaXmlGenerator method getGroupInfo.
/**
* @param itemGroupBean
* @param crfVersion
* @param section
* @param factory
* @param bindList
* @return
* @throws Exception
*/
private HashMap<String, Object> getGroupInfo(ItemGroupBean itemGroupBean, CRFVersionBean crfVersion, SectionBean section, WidgetFactory factory, ArrayList<Bind> bindList) throws Exception {
boolean expressionEvaluate = true;
igmdao = new ItemGroupMetadataDAO(dataSource);
List<ItemGroupMetadataBean> itemGroupMetadata = igmdao.findMetaByGroupAndSection(itemGroupBean.getId(), crfVersion.getId(), section.getId());
HashMap<String, Object> map = new HashMap<String, Object>();
Group group = new Group();
Repeat repeat = new Repeat();
group.setUsercontrol(new ArrayList<UserControl>());
repeat.setUsercontrol(new ArrayList<UserControl>());
Label groupHeader = new Label();
groupHeader.setLabel(itemGroupMetadata.get(0).getHeader());
boolean isGroupRepeating = getItemGroupMetadata(itemGroupBean, crfVersion, section).isRepeatingGroup();
String nodeset = "/" + crfVersion.getOid() + "/" + itemGroupBean.getOid();
// repeat.setJrNoAddRemove("true()");
repeat.setJrCount(nodeset);
group.setRef(nodeset);
repeat.setNodeset(nodeset);
String groupExpression = null;
ExpressionExpressionEvaluate eev = getSkipPattern(null, itemGroupBean);
groupExpression = eev.getExpression();
expressionEvaluate = eev.isExpressionEvaluate();
if (groupExpression != null)
groupExpression = getFullExpressionToParse(groupExpression, crfVersion, expressionEvaluate);
setGroupWidget(section, crfVersion, groupExpression, bindList, factory, itemGroupBean, group, repeat, isGroupRepeating, groupHeader);
map.put("group", group);
map.put("repeat", repeat);
map.put("isGroupRepeating", isGroupRepeating);
return map;
}
use of org.akaza.openclinica.web.pform.dto.UserControl in project OpenClinica by OpenClinica.
the class OpenRosaXmlGenerator method mapBeansToDTO.
/**
* @param html
* @param crf
* @param crfVersion
* @param crfSections
* @return
* @throws Exception
*/
private Integer mapBeansToDTO(Html html, CRFBean crf, CRFVersionBean crfVersion, ArrayList<SectionBean> crfSections) throws Exception {
boolean expressionEvaluate = true;
int sectionCount = 0;
ItemFormMetadataBean itemFormMetadataBean = null;
Body body = html.getBody();
ArrayList<Group> allSections = new ArrayList<Group>();
ArrayList<Bind> bindList = new ArrayList<Bind>();
WidgetFactory factory = new WidgetFactory(crfVersion);
html.getHead().setTitle(crf.getName());
for (SectionBean section : crfSections) {
ArrayList<Group> groups = new ArrayList<Group>();
Group singleSection = new Group();
singleSection.setUsercontrol(new ArrayList<UserControl>());
String ref = "/" + crfVersion.getOid() + "/" + "SECTION_" + section.getLabel().replaceAll("\\W", "_");
singleSection.setRef(ref);
String sectionExpression = null;
igdao = new ItemGroupDAO(dataSource);
ArrayList<ItemGroupBean> groupBeans = (ArrayList<ItemGroupBean>) igdao.findGroupBySectionId(section.getId());
int count = 0;
if (groupBeans.size() > 0) {
for (ItemGroupBean groupBean : groupBeans) {
ExpressionExpressionEvaluate eev = getSkipPattern(null, groupBean);
String expr = eev.getExpression();
expressionEvaluate = eev.isExpressionEvaluate();
if (expr != null) {
if (sectionExpression != null) {
sectionExpression = sectionExpression + " and " + expr;
count++;
} else {
sectionExpression = expr;
count++;
}
}
}
if (sectionExpression != null && groupBeans.size() == count) {
sectionExpression = getFullExpressionToParse(sectionExpression, crfVersion, expressionEvaluate);
} else {
sectionExpression = null;
}
setSectionWidget(section, crfVersion, sectionExpression, bindList, factory, singleSection);
HashMap<String, Object> groupMap = null;
boolean isGroupRepeating = false;
Group group = null;
Repeat repeat = null;
idao = new ItemDAO(dataSource);
ArrayList<ItemBean> items = (ArrayList<ItemBean>) idao.findAllBySectionIdOrderedByItemFormMetadataOrdinal(section.getId());
Integer itemGroupId = 0;
for (ItemBean item : items) {
ItemGroupBean itemGroupBean = getItemGroupBeanByItemId(item.getId());
if (itemGroupId != itemGroupBean.getId()) {
groupMap = getGroupInfo(itemGroupBean, crfVersion, section, factory, bindList);
isGroupRepeating = (Boolean) groupMap.get("isGroupRepeating");
group = (Group) groupMap.get("group");
repeat = (Repeat) groupMap.get("repeat");
}
itemFormMetadataBean = getItemFormMetadata(item, crfVersion);
int responseTypeId = itemFormMetadataBean.getResponseSet().getResponseTypeId();
boolean isItemRequired = itemFormMetadataBean.isRequired();
String responseLayout = itemFormMetadataBean.getResponseLayout();
String itemExpression = null;
ExpressionExpressionEvaluate eev = getSkipPattern(item, itemGroupBean);
itemExpression = eev.getExpression();
expressionEvaluate = eev.isExpressionEvaluate();
if (itemExpression != null)
itemExpression = getFullExpressionToParse(itemExpression, crfVersion, expressionEvaluate);
// Add the Item Header
setHeaderWidget(item, itemFormMetadataBean, itemGroupBean, bindList, factory, isGroupRepeating, repeat, group, itemExpression);
// Add the Item SubHeader
setSubHeaderWidget(item, itemFormMetadataBean, itemGroupBean, bindList, factory, isGroupRepeating, repeat, group, itemExpression);
// Add the Item itself
setItemWidget(item, responseTypeId, itemFormMetadataBean, itemGroupBean, bindList, factory, isGroupRepeating, repeat, group, isItemRequired, responseLayout, itemExpression);
if (itemGroupId != itemGroupBean.getId()) {
groups.add(group);
itemGroupId = itemGroupBean.getId();
}
}
// end of item loop
singleSection.setGroup(groups);
allSections.add(singleSection);
}
// end of groups per section if exist
sectionCount = allSections.size();
}
// end of section loop
body.setGroup(allSections);
html.getHead().getModel().setBind(bindList);
return sectionCount;
}
Aggregations