use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.
the class ItemDataDAO method getEntityFromHashMap.
public Object getEntityFromHashMap(HashMap hm) {
ItemDataBean eb = new ItemDataBean();
this.setEntityAuditInformation(eb, hm);
eb.setId(((Integer) hm.get("item_data_id")).intValue());
eb.setEventCRFId(((Integer) hm.get("event_crf_id")).intValue());
eb.setItemId(((Integer) hm.get("item_id")).intValue());
eb.setValue((String) hm.get("value"));
// fetching out from database
if (formatDates) {
ItemDataType dataType = getDataType(eb.getItemId());
if (dataType.equals(ItemDataType.DATE)) {
eb.setValue(Utils.convertedItemDateValue(eb.getValue(), oc_df_string, local_df_string, locale));
} else if (dataType.equals(ItemDataType.PDATE)) {
eb.setValue(reFormatPDate(eb.getValue()));
}
}
eb.setStatus(Status.get(((Integer) hm.get("status_id")).intValue()));
eb.setOrdinal(((Integer) hm.get("ordinal")).intValue());
eb.setDeleted(((Boolean) hm.get("deleted")).booleanValue());
eb.setOldStatus(Status.get(hm.get("old_status_id") == null ? 1 : ((Integer) hm.get("old_status_id")).intValue()));
return eb;
}
use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.
the class ItemDataDAO method create.
public EntityBean create(EntityBean eb) {
ItemDataBean idb = (ItemDataBean) eb;
// YW 12-06-2007 << convert to oc_date_format_string pattern before
// inserting into database
ItemDataType dataType = getDataType(idb.getItemId());
if (dataType.equals(ItemDataType.DATE)) {
idb.setValue(Utils.convertedItemDateValue(idb.getValue(), local_df_string, oc_df_string, locale));
} else if (dataType.equals(ItemDataType.PDATE)) {
idb.setValue(formatPDate(idb.getValue()));
}
HashMap<Integer, Comparable> variables = new HashMap<Integer, Comparable>();
int id = getNextPK();
variables.put(new Integer(1), new Integer(id));
variables.put(new Integer(2), new Integer(idb.getEventCRFId()));
variables.put(new Integer(3), new Integer(idb.getItemId()));
variables.put(new Integer(4), new Integer(idb.getStatus().getId()));
variables.put(new Integer(5), idb.getValue());
variables.put(new Integer(6), new Integer(idb.getOwnerId()));
variables.put(new Integer(7), new Integer(idb.getOrdinal()));
variables.put(new Integer(8), new Integer(idb.getStatus().getId()));
variables.put(new Integer(9), new Boolean(idb.isDeleted()));
this.execute(digester.getQuery("create"), variables);
if (isQuerySuccessful()) {
idb.setId(id);
}
return idb;
}
use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.
the class ItemDataDAO method findByPK.
public EntityBean findByPK(int ID) {
ItemDataBean eb = new ItemDataBean();
this.setTypesExpected();
HashMap<Integer, Integer> variables = new HashMap<Integer, Integer>();
variables.put(new Integer(1), new Integer(ID));
String sql = digester.getQuery("findByPK");
ArrayList alist = this.select(sql, variables);
Iterator it = alist.iterator();
if (it.hasNext()) {
eb = (ItemDataBean) this.getEntityFromHashMap((HashMap) it.next());
}
return eb;
}
use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.
the class ItemDataDAO method findByItemIdAndEventCRFId.
public ItemDataBean findByItemIdAndEventCRFId(int itemId, int eventCRFId) {
setTypesExpected();
ItemDataBean answer = new ItemDataBean();
HashMap<Integer, Integer> variables = new HashMap<Integer, Integer>();
variables.put(new Integer(1), new Integer(itemId));
variables.put(new Integer(2), new Integer(eventCRFId));
EntityBean eb = this.executeFindByPKQuery("findByItemIdAndEventCRFId", variables);
if (!eb.isActive()) {
return new ItemDataBean();
} else {
return (ItemDataBean) eb;
}
}
use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.
the class ImportDataRuleRunner method runRules.
@Transactional
private MessageContainer runRules(StudyBean currentStudy, UserAccountBean ub, HashMap<String, String> variableAndValue, HashMap<String, ArrayList<RuleActionContainer>> toBeExecuted) {
//Copied from DataEntryRuleRunner runRules
MessageContainer messageContainer = new MessageContainer();
for (Map.Entry<String, ArrayList<RuleActionContainer>> entry : toBeExecuted.entrySet()) {
// Sort the list of actions
Collections.sort(entry.getValue(), new RuleActionContainerComparator());
for (RuleActionContainer ruleActionContainer : entry.getValue()) {
logger.info("START Expression is : {} , RuleAction : {} ", new Object[] { ruleActionContainer.getExpressionBean().getValue(), ruleActionContainer.getRuleAction().toString() });
ruleActionContainer.getRuleSetBean().setTarget(ruleActionContainer.getExpressionBean());
ruleActionContainer.getRuleAction().setCuratedMessage(curateMessage(ruleActionContainer.getRuleAction(), ruleActionContainer.getRuleAction().getRuleSetRule()));
ActionProcessor ap = ActionProcessorFacade.getActionProcessor(ruleActionContainer.getRuleAction().getActionType(), ds, getMailSender(), dynamicsMetadataService, ruleActionContainer.getRuleSetBean(), getRuleActionRunLogDao(), ruleActionContainer.getRuleAction().getRuleSetRule());
ItemDataBean itemData = getExpressionService().getItemDataBeanFromDb(ruleActionContainer.getRuleSetBean().getTarget().getValue());
RuleActionBean rab = ap.execute(RuleRunnerMode.IMPORT_DATA, ExecutionMode.SAVE, ruleActionContainer.getRuleAction(), itemData, DiscrepancyNoteBean.ITEM_DATA, currentStudy, ub, prepareEmailContents(ruleActionContainer.getRuleSetBean(), ruleActionContainer.getRuleAction().getRuleSetRule(), currentStudy, ruleActionContainer.getRuleAction()));
if (rab != null) {
if (rab instanceof ShowActionBean) {
messageContainer.add(getExpressionService().getGroupOidOrdinal(ruleActionContainer.getRuleSetBean().getTarget().getValue()), rab);
} else {
messageContainer.add(getExpressionService().getGroupOrdninalConcatWithItemOid(ruleActionContainer.getRuleSetBean().getTarget().getValue()), ruleActionContainer.getRuleAction());
}
}
logger.info("END Expression is : {} , RuleAction : {} ", new Object[] { ruleActionContainer.getExpressionBean().getValue(), ruleActionContainer.getRuleAction().toString() });
}
}
return messageContainer;
}
Aggregations