use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetService method getRuleSetBeanByRuleSetRuleAndSubstituteCrfVersion.
// TODO: look into the commented line make sure logic doesn't break
private RuleSetBean getRuleSetBeanByRuleSetRuleAndSubstituteCrfVersion(String ruleSetRuleId, String crfVersionId, StudyBean currentStudy) {
RuleSetBean ruleSetBean = null;
if (ruleSetRuleId != null && crfVersionId != null && ruleSetRuleId.length() > 0 && crfVersionId.length() > 0) {
RuleSetRuleBean ruleSetRule = getRuleSetRuleDao().findById(Integer.valueOf(ruleSetRuleId));
// ruleSetBean = getRuleSetById(currentStudy, String.valueOf(ruleSetRule.getRuleSetBean().getId()), ruleSetRule.getRuleBean());
ruleSetBean = ruleSetRule.getRuleSetBean();
filterByRules(ruleSetBean, ruleSetRule.getRuleBean().getId());
CRFVersionBean crfVersion = (CRFVersionBean) getCrfVersionDao().findByPK(Integer.valueOf(crfVersionId));
ruleSetBean = replaceCrfOidInTargetExpression(ruleSetBean, crfVersion.getOid());
}
return ruleSetBean;
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetService method saveImportFromDesigner.
@Transactional
public void saveImportFromDesigner(RulesPostImportContainer rulesContainer) {
HashMap<String, RuleBean> ruleBeans = new HashMap<String, RuleBean>();
for (AuditableBeanWrapper<RuleBean> ruleBeanWrapper : rulesContainer.getValidRuleDefs()) {
RuleBean r = getRuleDao().saveOrUpdate(ruleBeanWrapper.getAuditableBean());
ruleBeans.put(r.getOid(), r);
}
for (AuditableBeanWrapper<RuleBean> ruleBeanWrapper : rulesContainer.getDuplicateRuleDefs()) {
RuleBean r = getRuleDao().saveOrUpdate(ruleBeanWrapper.getAuditableBean());
ruleBeans.put(r.getOid(), r);
}
for (AuditableBeanWrapper<RuleSetBean> ruleBeanWrapper : rulesContainer.getValidRuleSetDefs()) {
loadRuleSetRuleWithPersistentRules(ruleBeanWrapper.getAuditableBean());
saveRuleSet(ruleBeanWrapper.getAuditableBean());
}
for (AuditableBeanWrapper<RuleSetBean> ruleBeanWrapper : rulesContainer.getDuplicateRuleSetDefs()) {
loadRuleSetRuleWithPersistentRulesWithHashMap(ruleBeanWrapper.getAuditableBean(), ruleBeans);
replaceRuleSet(ruleBeanWrapper.getAuditableBean());
}
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetService method runRulesInBeanProperty.
public void runRulesInBeanProperty(List<RuleSetBean> ruleSets, Integer userId, StudyEventChangeDetails changeDetails) {
BeanPropertyRuleRunner ruleRunner = new BeanPropertyRuleRunner(dataSource, requestURLMinusServletPath, contextPath, mailSender);
ruleSets = (ArrayList<RuleSetBean>) filterByStatusEqualsAvailable(ruleSets);
ruleSets = (ArrayList<RuleSetBean>) filterRuleSetsByStudyEventOrdinal(ruleSets, null);
try {
ruleSets = (ArrayList<RuleSetBean>) filterRuleSetsByStudySubject(ruleSets);
} catch (NumberFormatException | ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ruleRunner.runRules(ruleSets, dataSource, beanPropertyService, getStudyEventDomainDao(), getStudyEventDefDomainDao(), changeDetails, userId, mailSender);
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetService method filterRuleSetsBySectionAndGroupOrdinal.
/*
* (non-Javadoc)
* @see org.akaza.openclinica.service.rule.RuleSetServiceInterface#filterRuleSetsBySectionAndGroupOrdinal(java.util.List, java.util.HashMap)
*/
public List<RuleSetBean> filterRuleSetsBySectionAndGroupOrdinal(List<RuleSetBean> ruleSets, HashMap<String, Integer> grouped) {
List<RuleSetBean> ruleSetsInThisSection = new ArrayList<RuleSetBean>();
for (RuleSetBean ruleSet : ruleSets) {
String ruleSetTargetValue = getExpressionService().isExpressionPartial(ruleSet.getTarget().getValue()) ? ruleSet.getExpressions().get(0).getValue() : ruleSet.getTarget().getValue();
String expWithGroup = getExpressionService().getGroupOidConcatWithItemOid(ruleSetTargetValue);
String expWithoutGroup = getExpressionService().getItemOid(ruleSetTargetValue);
if (grouped.containsKey(expWithGroup)) {
String ordinal = getExpressionService().getGroupOrdninalCurated(ruleSetTargetValue);
if (ordinal.length() == 0 || grouped.get(expWithGroup) >= Integer.valueOf(ordinal)) {
ruleSetsInThisSection.add(ruleSet);
}
}
if (grouped.containsKey(expWithoutGroup)) {
ruleSetsInThisSection.add(ruleSet);
}
}
logger.info("filterRuleSetsBySectionAndGroupOrdinal : ruleSets affecting the Whole Form : {} , ruleSets affecting this Section {} ", ruleSets.size(), ruleSetsInThisSection.size());
return ruleSetsInThisSection;
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetService method getRuleSetById.
// . TODO: why are we including study but not using it in query
/*
* (non-Javadoc)
* @see org.akaza.openclinica.service.rule.RuleSetServiceInterface#getRuleSetById(org.akaza.openclinica.bean.managestudy.StudyBean, java.lang.String)
*/
public RuleSetBean getRuleSetById(StudyBean study, String id) {
logger.debug(" Study Id {} ", study.getId());
RuleSetBean ruleSetBean = getRuleSetDao().findById(Integer.valueOf(id));
if (ruleSetBean != null) {
getObjects(ruleSetBean);
}
return ruleSetBean;
}
Aggregations