use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetService method solidifyGroupOrdinalsUsingFormProperties.
/*
* (non-Javadoc)
* @see org.akaza.openclinica.service.rule.RuleSetServiceInterface#solidifyGroupOrdinalsUsingFormProperties(java.util.List, java.util.HashMap)
*/
public List<RuleSetBean> solidifyGroupOrdinalsUsingFormProperties(List<RuleSetBean> ruleSets, HashMap<String, Integer> grouped) {
for (RuleSetBean ruleSet : ruleSets) {
ArrayList<ExpressionBean> expressionsWithCorrectGroupOrdinal = new ArrayList<ExpressionBean>();
for (ExpressionBean expression : ruleSet.getExpressions()) {
logger.debug("solidifyGroupOrdinals: Expression Value : " + expression.getValue());
String groupOIDConcatItemOID = getExpressionService().getGroupOidConcatWithItemOid(expression.getValue());
String itemOID = getExpressionService().getItemOid(expression.getValue());
String groupOrdinal = getExpressionService().getGroupOrdninalCurated(expression.getValue());
if (grouped.containsKey(groupOIDConcatItemOID) && groupOrdinal.equals("")) {
for (int i = 0; i < grouped.get(groupOIDConcatItemOID); i++) {
ExpressionBean expBean = new ExpressionBean();
expBean.setValue(getExpressionService().replaceGroupOidOrdinalInExpression(expression.getValue(), i + 1));
expBean.setContext(expression.getContext());
expressionsWithCorrectGroupOrdinal.add(expBean);
}
} else if (grouped.containsKey(groupOIDConcatItemOID) && !groupOrdinal.equals("")) {
ExpressionBean expBean = new ExpressionBean();
expBean.setValue(expression.getValue());
expBean.setContext(expression.getContext());
expressionsWithCorrectGroupOrdinal.add(expBean);
} else if (grouped.containsKey(itemOID)) {
ExpressionBean expBean = new ExpressionBean();
expBean.setValue(getExpressionService().replaceGroupOidOrdinalInExpression(expression.getValue(), null));
expBean.setContext(expression.getContext());
expressionsWithCorrectGroupOrdinal.add(expBean);
}
}
ruleSet.setExpressions(expressionsWithCorrectGroupOrdinal);
for (ExpressionBean expressionBean : ruleSet.getExpressions()) {
logger.debug("expressionBean value : {} ", expressionBean.getValue());
}
}
return ruleSets;
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetAuditDaoTest method testFindAllByRuleSet.
public void testFindAllByRuleSet() {
//RuleSetDao ruleSetDao = (RuleSetDao) getContext().getBean("ruleSetDao");
// RuleSetAuditDao ruleSetAuditDao = (RuleSetAuditDao) getContext().getBean("ruleSetAuditDao");
RuleSetBean ruleSet = ruleSetDao.findById(-1);
List<RuleSetAuditBean> ruleSetAudits = ruleSetAuditDao.findAllByRuleSet(ruleSet);
assertNotNull("ruleSetAudits is null", ruleSetAudits);
assertEquals("The size of the ruleSetAudits is not 2", new Integer(2), Integer.valueOf(ruleSetAudits.size()));
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetRuleAuditDaoTest method testFindAllByRuleSet.
public void testFindAllByRuleSet() {
// RuleSetDao ruleSetDao = (RuleSetDao) getContext().getBean("ruleSetDao");
// RuleSetRuleAuditDao ruleSetRuleAuditDao = (RuleSetRuleAuditDao) getContext().getBean("ruleSetRuleAuditDao");
RuleSetBean ruleSet = ruleSetDao.findById(-1);
List<RuleSetRuleAuditBean> ruleSetRuleAudits = ruleSetRuleAuditDao.findAllByRuleSet(ruleSet);
assertNotNull("ruleSetAudits is null", ruleSetRuleAudits);
assertEquals("The size of the ruleSetRuleAudits is not 2", new Integer(2), Integer.valueOf(ruleSetRuleAudits.size()));
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetDaoTest method testSaveOrUpdate.
public void testSaveOrUpdate() {
// RuleSetDao ruleSetDao = (RuleSetDao) getContext().getBean("ruleSetDao");
// RuleDao ruleDao = (RuleDao) getContext().getBean("ruleDao");
RuleBean persistantRuleBean = ruleDao.findById(1);
RuleSetBean ruleSetBean = createStubRuleSetBean(persistantRuleBean);
ruleSetBean = ruleSetDao.saveOrUpdate(ruleSetBean);
assertNotNull("Persistant id is null", ruleSetBean.getId());
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetDaoTest method testFindByExpression.
public void testFindByExpression() {
RuleSetBean ruleSet = createStubRuleSetBean();
// RuleSetDao ruleSetDao = (RuleSetDao) getContext().getBean("ruleSetDao");
RuleSetBean persistentRuleSet = ruleSetDao.findByExpression(ruleSet);
assertNotNull("The returned ruleSet was null", persistentRuleSet);
assertEquals("The id of returned object should be -1 ", persistentRuleSet.getId(), new Integer(-1));
}
Aggregations