use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.
the class RuleSetService method filterRuleSetsByHiddenItems.
public List<RuleSetBean> filterRuleSetsByHiddenItems(List<RuleSetBean> ruleSets, EventCRFBean eventCrf, CRFVersionBean crfVersion, List<ItemBean> itemBeansWithSCDShown) {
ArrayList<RuleSetBean> shownRuleSets = new ArrayList<RuleSetBean>();
for (RuleSetBean ruleSetBean : ruleSets) {
logMe("Entering the filterRuleSetsBy HiddenItems? Thread::" + Thread.currentThread() + "eventCrf?" + eventCrf + "crfVersion??" + crfVersion + "ruleSets?" + ruleSets);
ItemBean target = ruleSetBean.getItem();
ItemFormMetadataBean metadataBean = this.getItemFormMetadataDao().findByItemIdAndCRFVersionId(target.getId(), crfVersion.getId());
ItemDataBean itemData = this.getItemDataDao().findByItemIdAndEventCRFId(target.getId(), eventCrf.getId());
DynamicsItemFormMetadataBean dynamicsBean = this.getDynamicsItemFormMetadataDao().findByMetadataBean(metadataBean, eventCrf, itemData);
if (itemBeansWithSCDShown == null)
itemBeansWithSCDShown = new ArrayList<ItemBean>();
if (dynamicsBean == null) {
if (metadataBean.isShowItem() || itemBeansWithSCDShown.contains(target)) {
logger.debug("just added rule set bean");
shownRuleSets.add(ruleSetBean);
}
} else {
if (metadataBean.isShowItem() || dynamicsBean.isShowItem()) {
logger.debug("just added rule set bean 2, with dyn bean");
shownRuleSets.add(ruleSetBean);
}
}
}
return shownRuleSets;
}
use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.
the class RuleSetService method filterRuleSetsByGroupOrdinal.
/*
* (non-Javadoc)
* @see org.akaza.openclinica.service.rule.RuleSetServiceInterface#filterRuleSetsByGroupOrdinal(java.util.List)
*/
public List<RuleSetBean> filterRuleSetsByGroupOrdinal(List<RuleSetBean> ruleSets) {
for (RuleSetBean ruleSetBean : ruleSets) {
List<ExpressionBean> expressionsWithCorrectGroupOrdinal = new ArrayList<ExpressionBean>();
for (ExpressionBean expression : ruleSetBean.getExpressions()) {
String studyEventId = getExpressionService().getStudyEventDefinitionOrdninalCurated(expression.getValue());
String itemOid = getExpressionService().getItemOid(expression.getValue());
String itemGroupOid = getExpressionService().getItemGroupOid(expression.getValue());
String groupOrdinal = getExpressionService().getGroupOrdninalCurated(expression.getValue());
List<ItemDataBean> itemDatas = getItemDataDao().findByStudyEventAndOids(Integer.valueOf(studyEventId), itemOid, itemGroupOid);
logger.debug("studyEventId {} , itemOid {} , itemGroupOid {} , groupOrdinal {} , itemDatas {}", new Object[] { studyEventId, itemOid, itemGroupOid, groupOrdinal, itemDatas.size() });
// case 1 : group ordinal = ""
if (groupOrdinal.equals("") && itemDatas.size() > 0) {
for (int k = 0; k < itemDatas.size(); k++) {
ExpressionBean expBean = new ExpressionBean();
expBean.setValue(getExpressionService().replaceGroupOidOrdinalInExpression(expression.getValue(), k + 1));
expBean.setContext(expression.getContext());
expressionsWithCorrectGroupOrdinal.add(expBean);
}
}
// case 2 : group ordinal = x and itemDatas should be size >= x
if (!groupOrdinal.equals("") && itemDatas.size() >= Integer.valueOf(groupOrdinal)) {
ExpressionBean expBean = new ExpressionBean();
expBean.setValue(getExpressionService().replaceGroupOidOrdinalInExpression(expression.getValue(), null));
expBean.setContext(expression.getContext());
expressionsWithCorrectGroupOrdinal.add(expBean);
}
}
ruleSetBean.setExpressions(expressionsWithCorrectGroupOrdinal);
}
logExpressions(ruleSets);
return ruleSets;
}
use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.
the class ExpressionService method getItemDataBeanFromDb.
public ItemDataBean getItemDataBeanFromDb(String expression) throws OpenClinicaSystemException {
if (isExpressionPartial(expression)) {
throw new OpenClinicaSystemException("getItemDataBeanFromDb:We cannot get the ItemData of a PARTIAL expression : " + expression);
}
String studyEventId = getStudyEventDefinitionOidOrdinalFromExpression(expression);
Integer index = getItemGroupOidOrdinalFromExpression(expression).equals("") ? 0 : Integer.valueOf(getItemGroupOidOrdinalFromExpression(expression)) - 1;
List<ItemDataBean> itemData = getItemDataDao().findByStudyEventAndOids(Integer.valueOf(studyEventId), getItemOidFromExpression(expression), getItemGroupOidFromExpression(expression));
ItemDataBean itemDataBean = itemData.size() > index ? itemData.get(index) : null;
return itemDataBean;
// << tbh 04/28/2010
}
use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.
the class ExpressionService method getValueFromDbb.
public HashMap<String, String> getValueFromDbb(String expression) throws OpenClinicaSystemException {
HashMap<String, String> map = new HashMap<>();
if (isExpressionPartial(expression)) {
throw new OpenClinicaSystemException("getValueFromDb:We cannot get the Value of a PARTIAL expression : " + expression);
}
try {
// Get the studyEventId from RuleSet Target so we can know which
// StudySubject we are dealing with.
String ruleSetExpression = expressionWrapper.getRuleSet().getTarget().getValue();
String ruleSetExpressionStudyEventId = getStudyEventDefinitionOidOrdinalFromExpression(ruleSetExpression);
StudyEventBean studyEvent = (StudyEventBean) getStudyEventDao().findByPK(Integer.valueOf(ruleSetExpressionStudyEventId));
// Prepare Method arguments
String studyEventDefinitionOid = getStudyEventDefinitionOidFromExpression(expression);
String crfOrCrfVersionOid = getCrfOidFromExpression(expression);
String studyEventDefinitionOrdinal = getStudyEventDefinitionOidOrdinalFromExpression(expression);
studyEventDefinitionOrdinal = studyEventDefinitionOrdinal.equals("") ? "1" : studyEventDefinitionOrdinal;
String studySubjectId = String.valueOf(studyEvent.getStudySubjectId());
System.out.println("studySubjectId: " + studySubjectId);
logger.debug("ruleSet studyEventId {} , studyEventDefinitionOid {} , crfOrCrfVersionOid {} , studyEventDefinitionOrdinal {} ,studySubjectId {}", new Object[] { studyEvent.getId(), studyEventDefinitionOid, crfOrCrfVersionOid, studyEventDefinitionOrdinal, studySubjectId });
StudyEventBean studyEventofThisExpression = getStudyEventDao().findAllByStudyEventDefinitionAndCrfOidsAndOrdinal(studyEventDefinitionOid, crfOrCrfVersionOid, studyEventDefinitionOrdinal, studySubjectId);
if (studyEvent.getId() == studyEventofThisExpression.getId())
map.put("match", "true");
logger.debug("studyEvent : {} , itemOid {} , itemGroupOid {}", new Object[] { studyEventofThisExpression.getId(), getItemOidFromExpression(expression), getItemGroupOidFromExpression(expression) });
List<ItemDataBean> itemData = getItemDataDao().findByStudyEventAndOids(Integer.valueOf(studyEventofThisExpression.getId()), getItemOidFromExpression(expression), getItemGroupOidFromExpression(expression));
expression = fixGroupOrdinal(expression, ruleSetExpression, itemData, expressionWrapper.getEventCrf());
Integer index = getItemGroupOidOrdinalFromExpression(expression).equals("") ? 0 : Integer.valueOf(getItemGroupOidOrdinalFromExpression(expression)) - 1;
ItemDataBean itemDataBean = itemData.get(index);
ItemBean itemBean = (ItemBean) getItemDao().findByPK(itemDataBean.getItemId());
String value = itemData.get(index).getValue();
value = ifValueIsDate(itemBean, value);
map.put("value", value);
return map;
} catch (Exception e) {
return map;
}
}
use of org.akaza.openclinica.bean.submit.ItemDataBean in project OpenClinica by OpenClinica.
the class ExpressionService method getValueFromDb.
public String getValueFromDb(String expression, List<ItemDataBean> itemData) throws OpenClinicaSystemException {
if (isExpressionPartial(expression)) {
throw new OpenClinicaSystemException("getValueFromDb:We cannot get the Value of a PARTIAL expression : " + expression);
}
try {
Integer index = getItemGroupOidOrdinalFromExpression(expression).equals("") ? 0 : Integer.valueOf(getItemGroupOidOrdinalFromExpression(expression)) - 1;
ItemDataBean itemDataBean = itemData.get(index);
ItemBean itemBean = (ItemBean) getItemDao().findByPK(itemDataBean.getItemId());
String value = itemData.get(index).getValue();
value = ifValueIsDate(itemBean, value);
return value;
} catch (NullPointerException npe) {
logger.error("NullPointerException was thrown ");
return null;
} catch (IndexOutOfBoundsException ioobe) {
logger.error("IndexOutOfBoundsException was thrown ");
return null;
}
}
Aggregations