use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.
the class ExpressionService method isExpressionValid.
public String isExpressionValid(String oid, RuleSetBean ruleSet) {
StudyEventDefinitionBean studyEventDefinition = getStudyEventDefinitionFromExpression(ruleSet.getTarget().getValue());
String[] theOid = oid.split(ESCAPED_SEPERATOR);
if (theOid.length == 3) {
ItemGroupBean itemGroup = getItemGroupDao().findByOid(theOid[0]);
if (itemGroup != null && itemGroup.getCrfId().equals(ruleSet.getCrfId())) {
ItemBean item = getItemDao().findItemByGroupIdandItemOid(itemGroup.getId(), theOid[1]);
if (item != null) {
return "OK";
}
}
}
if (theOid.length == 2) {
ItemGroupBean itemGroup = getItemGroupDao().findByOid(theOid[0]);
if (itemGroup != null && itemGroup.getCrfId().equals(ruleSet.getCrfId())) {
ItemBean item = getItemDao().findItemByGroupIdandItemOid(itemGroup.getId(), theOid[1]);
if (item != null) {
return "OK";
}
}
}
if (theOid.length == 1) {
ItemGroupBean itemGroup = getItemGroupDao().findByOid(oid);
if (itemGroup != null && itemGroup.getCrfId().equals(ruleSet.getCrfId())) {
return "OK";
}
ItemBean item = getItemDao().findItemByGroupIdandItemOid(getItemGroupExpression(ruleSet.getTarget().getValue()).getId(), oid);
if (item != null) {
return "OK";
}
}
return oid;
}
use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.
the class ExpressionService method constructFullExpressionIfPartialProvided.
public String constructFullExpressionIfPartialProvided(String expression, CRFVersionBean crfVersion, StudyEventDefinitionBean studyEventDefinition) {
String[] splitExpression = expression.split(ESCAPED_SEPERATOR);
String resultingExpression = null;
if (splitExpression.length == 1) {
ItemGroupMetadataBean itemGroupMetadata = (ItemGroupMetadataBean) getItemGroupMetadataDao().findByItemAndCrfVersion(getItemBeanFromExpression(expression).getId(), crfVersion.getId());
ItemGroupBean itemGroup = (ItemGroupBean) getItemGroupDao().findByPK(itemGroupMetadata.getItemGroupId());
resultingExpression = studyEventDefinition.getOid() + SEPERATOR + crfVersion.getOid() + SEPERATOR + itemGroup.getOid() + SEPERATOR + expression;
}
if (splitExpression.length == 2) {
resultingExpression = studyEventDefinition.getOid() + SEPERATOR + crfVersion.getOid() + SEPERATOR + expression;
}
if (splitExpression.length == 3) {
resultingExpression = studyEventDefinition.getOid() + SEPERATOR + expression;
}
return resultingExpression;
}
use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.
the class SpreadSheetItemUtil method verifyParentID.
////////////////////////////////////// verification rules
public void verifyParentID(ArrayList<SpreadSheetItemUtil> row_items, ArrayList<String> ver_errors, HashMap<String, String> htmlErrors, int sheetNumber, ResourceBundle resPageMsg, HashMap<String, ItemGroupBean> itemGroups) {
int row_number = row_items.size();
// BWP>>Prevent parent names that equal the Item names
if (this.getItemName().equalsIgnoreCase(this.getParentItem())) {
this.setParentItem("");
}
if (!this.getParentItem().isEmpty()) {
SpreadSheetItemUtil cur_item = SpreadSheetItemUtil.isItemWithSameParameterExists(CrfTemplateColumnNameEnum.ITEM_NAME, this.getParentItem(), row_items);
// Checking for a valid parent item name
if (cur_item == null) {
ver_errors.add(resPageMsg.getString("parent_id") + row_number + resPageMsg.getString("parent_id_1"));
htmlErrors.put(sheetNumber + "," + row_number + "," + CrfTemplateColumnNameEnum.PARENT_ITEM.getCellNumber(), resPageMsg.getString("INVALID_FIELD"));
}
//prevent more than one level of hierarchy for parent names (new ver)
if (cur_item != null && cur_item.getParentItem() != null && cur_item.getParentItem().length() > 0) {
ver_errors.add(resPageMsg.getString("nested_parent_id") + row_items.size() + resPageMsg.getString("nested_parent_id_1"));
htmlErrors.put(sheetNumber + "," + row_number + "," + CrfTemplateColumnNameEnum.PARENT_ITEM.getCellNumber(), resPageMsg.getString("INVALID_FIELD"));
}
//verify that this is repeating group
if (itemGroups != null && itemGroups.size() > 0) {
ItemGroupBean item_group = itemGroups.get(this.getGroupLabel());
if (item_group != null) {
boolean isRepeatingGroup = item_group.getMeta().isRepeatingGroup();
if (isRepeatingGroup) {
if (this.getParentItem().length() > 0) {
ver_errors.add(resPageMsg.getString("parentId_group") + row_items.size() + resPageMsg.getString("nested_parent_id_1"));
htmlErrors.put(sheetNumber + "," + row_number + "," + CrfTemplateColumnNameEnum.PARENT_ITEM.getCellNumber(), resPageMsg.getString("INVALID_FIELD"));
}
}
}
}
}
}
use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.
the class SpreadSheetItemUtil method verifySectionGroupPlacementForItems.
//TODO if we ever go to normal OO parsing of spreadsheet this method should be moved to
//SpredSheetGroupUtil
//the problem here that Group now can be ungrouped group
public static void verifySectionGroupPlacementForItems(ArrayList<SpreadSheetItemUtil> row_items, ArrayList<String> ver_errors, HashMap<String, String> htmlErrors, int sheetNumber, ResourceBundle resPageMsg, HashMap<String, ItemGroupBean> itemGroups) {
HashMap<String, String> group_section_map = new HashMap<String, String>();
String section_label;
int row_number = 1;
for (SpreadSheetItemUtil cur_item : row_items) {
row_number++;
if (cur_item.getGroupLabel().length() < 1) {
continue;
}
//verify that this is repeating group
ItemGroupBean item_group = itemGroups.get(cur_item.getGroupLabel());
boolean isRepeatingGroup = false;
if (item_group == null) {
//case when item has a group not listed in 'Groups' spreadSheet, error was processed before
} else {
isRepeatingGroup = item_group.getMeta().isRepeatingGroup();
}
if (!isRepeatingGroup) {
continue;
}
section_label = group_section_map.get(cur_item.getGroupLabel());
if (section_label != null) {
//not first item in group
if (!section_label.equals(cur_item.getSectionLabel())) {
//error: items of one group belong to more than one section
ver_errors.add(resPageMsg.getString("group_in_several_sections") + cur_item.getGroupLabel() + "'.");
htmlErrors.put(sheetNumber + "," + (row_number - 1) + "," + CrfTemplateColumnNameEnum.GROUP_LABEL.getCellNumber(), resPageMsg.getString("INVALID_VALUE"));
}
} else {
//first item in group
group_section_map.put(cur_item.getGroupLabel(), cur_item.getSectionLabel());
}
}
}
use of org.akaza.openclinica.bean.submit.ItemGroupBean in project OpenClinica by OpenClinica.
the class BeanFactory method initFormGroupFromMap.
/**
* This method places a group metadata bean into an ItemGroupBean
*
* @param groupLabel
* The String specifying a group label.
* @param groupMap
* The Map containing the data for a group.
* @return ItemGroupBean
*/
private ItemGroupBean initFormGroupFromMap(String groupLabel, Map<Integer, Map<String, String>> groupMap) {
ItemGroupBean formGroupBean = new ItemGroupBean();
ItemGroupMetadataBean igMetaBean = new ItemGroupMetadataBean();
Map<String, String> groupValues;
NumberFormat numFormatter = NumberFormat.getInstance();
numFormatter.setMaximumFractionDigits(0);
String tempValue;
for (Entry<Integer, Map<String, String>> entry : groupMap.entrySet()) {
groupValues = entry.getValue();
if (groupValues.get("group_label").equalsIgnoreCase(groupLabel)) {
formGroupBean.setName(groupLabel);
igMetaBean.setHeader(groupValues.get("group_header"));
//Hamid repeating group or not
if (groupValues.get("repeating_group") != null) {
igMetaBean.setRepeatingGroup(Boolean.parseBoolean(groupValues.get("repeating_group")));
// System.out.println("=============" + groupValues.get("repeating_group"));
}
// YW 10-04-2007 <<
// BWP changed to try/catch block
tempValue = groupValues.get("group_repeat_max");
// exception, but is still unacceptable
if (StringUtil.isBlank(tempValue)) {
tempValue = "0";
} else if ("0.0".equalsIgnoreCase(tempValue)) {
tempValue = "22000";
}
try {
igMetaBean.setRepeatMax(new Integer(numFormatter.format(Double.parseDouble(tempValue))));
} catch (NumberFormatException nfe) {
// BWP >>an arbitrarily large number allows infinite
// repeats; it could also be -1
igMetaBean.setRepeatMax(22000);
}
// YW >>
// YW 10-04-2007 <<
// BWP changed to try/catch block
tempValue = groupValues.get("group_repeat_number");
// exception, but is still unacceptable
if (igMetaBean.isRepeatingGroup() && StringUtil.isBlank(tempValue)) {
tempValue = "1";
} else if (StringUtil.isBlank(tempValue)) {
tempValue = "0";
} else if ("0.0".equalsIgnoreCase(tempValue)) {
tempValue = "1";
}
try {
igMetaBean.setRepeatNum(new Integer(numFormatter.format(Double.parseDouble(tempValue))));
} catch (NumberFormatException nfe) {
// BWP 10-13-07
igMetaBean.setRepeatNum(1);
}
// YW >>
}
}
formGroupBean.setMeta(igMetaBean);
return formGroupBean;
}
Aggregations