use of org.akaza.openclinica.bean.submit.ItemFormMetadataBean in project OpenClinica by OpenClinica.
the class ItemFormMetadataDAO method findByItemIdAndFormLayoutId.
public ItemFormMetadataBean findByItemIdAndFormLayoutId(int itemId, int layoutId) {
this.setTypesExpected();
// TODO note to come back here, tbh
// version name
this.setTypeExpected(28, TypeNames.STRING);
// add more here for display, tbh 082007
// group_label
this.setTypeExpected(29, TypeNames.STRING);
// repeat_max
this.setTypeExpected(30, TypeNames.INT);
// section_name
this.setTypeExpected(31, TypeNames.STRING);
logMe("Current Thread:::" + Thread.currentThread() + "types Expected?");
HashMap<Integer, Object> variables = new HashMap<Integer, Object>();
variables.put(new Integer(1), new Integer(itemId));
variables.put(new Integer(2), new Integer(layoutId));
String sql = digester.getQuery("findByItemIdAndFormLayoutId");
logMe("Thread?" + Thread.currentThread() + "SQL?" + sql + "variables?" + variables);
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
ItemFormMetadataBean ifmb = new ItemFormMetadataBean();
HashMap hm = new HashMap();
if (it.hasNext()) {
hm = (HashMap) it.next();
ifmb = (ItemFormMetadataBean) this.getEntityFromHashMap(hm);
}
// EntityBean eb =
// this.executeFindByPKQuery("findByItemIdAndCRFVersionId", variables);
/*
* if (!ifmb.isActive()) { return new ItemFormMetadataBean(); } else {
*/
// ItemFormMetadataBean ifmb = (ItemFormMetadataBean) eb;
String versionName = (String) hm.get("cvname");
String groupLabel = (String) hm.get("group_label");
String sectionName = (String) hm.get("section_name");
Integer repeatMax = (Integer) hm.get("repeat_max");
int repeatMaxInt = repeatMax != null ? repeatMax.intValue() : 0;
// caught an NPE here, tbh 082007?
// new Integer((Integer)hm.get("repeat_max")).intValue();
ifmb.setCrfVersionName(versionName);
ifmb.setGroupLabel(groupLabel);
// logger.info(">>>added group name: "+groupLabel);
ifmb.setSectionName(sectionName);
// logger.info("<<<added section name: "+sectionName);
ifmb.setRepeatMax(repeatMaxInt);
// return (ItemFormMetadataBean) eb;
return ifmb;
// }
}
use of org.akaza.openclinica.bean.submit.ItemFormMetadataBean in project OpenClinica by OpenClinica.
the class ItemFormMetadataDAO method findByItemIdAndFormLayoutIdNotInIGM.
public ItemFormMetadataBean findByItemIdAndFormLayoutIdNotInIGM(int itemId, int formLayoutId) {
this.setTypesExpected();
HashMap<Integer, Integer> variables = new HashMap<Integer, Integer>();
variables.put(new Integer(1), new Integer(itemId));
variables.put(new Integer(2), new Integer(formLayoutId));
EntityBean eb = this.executeFindByPKQuery("findByItemIdAndFormLayoutIdNotInIGM", variables);
if (!eb.isActive()) {
return new ItemFormMetadataBean();
} else {
return (ItemFormMetadataBean) eb;
}
}
use of org.akaza.openclinica.bean.submit.ItemFormMetadataBean in project OpenClinica by OpenClinica.
the class CreateCRFVersionServlet method isResponseValid.
private ItemBean isResponseValid(HashMap items, CRFVersionBean version) {
ItemDAO idao = new ItemDAO(sm.getDataSource());
ItemFormMetadataDAO metadao = new ItemFormMetadataDAO(sm.getDataSource());
Set names = items.keySet();
Iterator it = names.iterator();
while (it.hasNext()) {
String name = (String) it.next();
ItemBean oldItem = (ItemBean) idao.findByNameAndCRFId(name, version.getCrfId());
ItemBean item = (ItemBean) items.get(name);
if (oldItem.getId() > 0) {
// found same item in DB
ArrayList metas = metadao.findAllByItemId(oldItem.getId());
for (int i = 0; i < metas.size(); i++) {
ItemFormMetadataBean ifmb = (ItemFormMetadataBean) metas.get(i);
ResponseSetBean rsb = ifmb.getResponseSet();
if (hasDifferentOption(rsb, item.getItemMeta().getResponseSet()) != null) {
return item;
}
}
}
}
return null;
}
use of org.akaza.openclinica.bean.submit.ItemFormMetadataBean in project OpenClinica by OpenClinica.
the class BeanFactory method createItemFormMetadataBean.
/*
* Create an ItemFormMetadataBean from the values referred to by a Map.Entry
* object. The Map.Entry contains an integer pointing to a Map of Item
* values from the Sreadsheet template, as in (item_name: Item1, etc...}
*/
public ItemFormMetadataBean createItemFormMetadataBean(Map.Entry<Integer, Map<String, String>> me, String crfName) {
if (me == null)
return new ItemFormMetadataBean();
ItemFormMetadataBean metadataBean = new ItemFormMetadataBean();
// the POI library returns all numbers as doubles (2.0), we round
// off the numbers to 2, for instance
NumberFormat numFormatter = NumberFormat.getInstance();
numFormatter.setMaximumFractionDigits(0);
String itemPageNum;
String columnNum;
String questNum;
metadataBean.setOrdinal(me.getKey());
Map<String, String> map = me.getValue();
// response_layout property for checkboxes and radio buttons
metadataBean.setResponseLayout(map.get("response_layout"));
metadataBean.setDefaultValue(map.get("default_value"));
metadataBean.setParentLabel(map.get("parent_item"));
metadataBean.setLeftItemText(map.get("left_item_text"));
metadataBean.setRightItemText(map.get("right_item_text"));
metadataBean.setHeader(map.get("header"));
metadataBean.setSubHeader(map.get("subheader"));
metadataBean.setGroupLabel(map.get("group_label"));
itemPageNum = map.get("page_number");
try {
itemPageNum = numFormatter.format(Double.parseDouble(itemPageNum));
} catch (NumberFormatException nfe) {
itemPageNum = "";
}
metadataBean.setPageNumberLabel(itemPageNum);
columnNum = map.get("column_number");
try {
columnNum = numFormatter.format(Double.parseDouble(columnNum));
metadataBean.setColumnNumber(Integer.parseInt(columnNum));
} catch (NumberFormatException nfe) {
metadataBean.setColumnNumber(0);
}
questNum = map.get("question_number");
// We support any character in QUESTION_NUMBER field. So there is no need to do this number formatting.
// try {
// questNum = numFormatter.format(Double.parseDouble(questNum));
// } catch (NumberFormatException nfe) {
// questNum = "";
// }
metadataBean.setQuestionNumberLabel(questNum);
String requStr = map.get("required");
requStr = requStr.equalsIgnoreCase("") ? "0" : requStr;
double required;
try {
required = Double.parseDouble(requStr);
} catch (NumberFormatException nfe) {
required = 0;
}
if (required > 0) {
metadataBean.setRequired(true);
}
ResponseSetBean respBean = this.createResponseSetBean(map, crfName);
metadataBean.setResponseSet(respBean);
return metadataBean;
}
use of org.akaza.openclinica.bean.submit.ItemFormMetadataBean in project OpenClinica by OpenClinica.
the class BeanFactory method createMetadataBean.
/**
* Create an ItemFormMetadataBean from the values referred to by a Map
* object. The Map contains the Item values from the Sreadsheet template, as
* in (item_name: Item1, etc...}
*
* @param map
* A Map involving the column names and values Of items.
* @param ordinal
* The ordinal property for the meta data bean.
* @param crfName
* The CRF name.
* @return An ItemFormMetadataBean representing the values from the Map.
*/
public ItemFormMetadataBean createMetadataBean(Map<String, String> map, int ordinal, String crfName) {
if (map == null)
return new ItemFormMetadataBean();
ItemFormMetadataBean metadataBean = new ItemFormMetadataBean();
// the POI library returns all numbers as doubles (2.0), we round
// off the numbers to 2, for instance
NumberFormat numFormatter = NumberFormat.getInstance();
numFormatter.setMaximumFractionDigits(0);
String itemPageNum;
String columnNum;
String questNum;
metadataBean.setOrdinal(ordinal);
metadataBean.setResponseLayout(map.get("response_layout"));
metadataBean.setParentLabel(map.get("parent_item"));
metadataBean.setLeftItemText(map.get("left_item_text"));
metadataBean.setRightItemText(map.get("right_item_text"));
metadataBean.setDefaultValue(map.get("default_value"));
metadataBean.setHeader(map.get("header"));
metadataBean.setSubHeader(map.get("subheader"));
itemPageNum = map.get("page_number");
try {
itemPageNum = numFormatter.format(Double.parseDouble(itemPageNum));
} catch (NumberFormatException nfe) {
itemPageNum = "";
}
metadataBean.setPageNumberLabel(itemPageNum);
columnNum = map.get("column_number");
try {
columnNum = numFormatter.format(Double.parseDouble(columnNum));
metadataBean.setColumnNumber(Integer.parseInt(columnNum));
} catch (NumberFormatException nfe) {
metadataBean.setColumnNumber(0);
}
questNum = map.get("question_number");
try {
questNum = numFormatter.format(Double.parseDouble(questNum));
} catch (NumberFormatException nfe) {
questNum = "";
}
metadataBean.setQuestionNumberLabel(questNum);
String requStr = map.get("required");
requStr = requStr.equalsIgnoreCase("") ? "0" : requStr;
double required;
try {
required = Double.parseDouble(requStr);
} catch (NumberFormatException nfe) {
required = 0;
}
if (required > 0) {
metadataBean.setRequired(true);
}
ResponseSetBean respBean = this.createResponseSetBean(map, crfName);
metadataBean.setResponseSet(respBean);
return metadataBean;
}
Aggregations