Search in sources :

Example 16 with RuleSetBean

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;
}
Also used : RuleSetRuleBean(org.akaza.openclinica.domain.rule.RuleSetRuleBean) CRFVersionBean(org.akaza.openclinica.bean.submit.CRFVersionBean) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean)

Example 17 with 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());
    }
}
Also used : HashMap(java.util.HashMap) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) RuleSetRuleBean(org.akaza.openclinica.domain.rule.RuleSetRuleBean) RuleBean(org.akaza.openclinica.domain.rule.RuleBean) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with RuleSetBean

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);
}
Also used : BeanPropertyRuleRunner(org.akaza.openclinica.logic.rulerunner.BeanPropertyRuleRunner) ParseException(java.text.ParseException) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean)

Example 19 with RuleSetBean

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;
}
Also used : ArrayList(java.util.ArrayList) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean)

Example 20 with RuleSetBean

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;
}
Also used : RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean)

Aggregations

RuleSetBean (org.akaza.openclinica.domain.rule.RuleSetBean)67 ArrayList (java.util.ArrayList)28 RuleSetRuleBean (org.akaza.openclinica.domain.rule.RuleSetRuleBean)26 ExpressionBean (org.akaza.openclinica.domain.rule.expression.ExpressionBean)19 RuleBean (org.akaza.openclinica.domain.rule.RuleBean)15 HashMap (java.util.HashMap)13 ExpressionObjectWrapper (org.akaza.openclinica.domain.rule.expression.ExpressionObjectWrapper)11 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)9 RuleActionBean (org.akaza.openclinica.domain.rule.action.RuleActionBean)9 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)8 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)7 Map (java.util.Map)6 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)6 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)6 OpenClinicaExpressionParser (org.akaza.openclinica.logic.expressionTree.OpenClinicaExpressionParser)6 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)5 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)5 RulesPostImportContainer (org.akaza.openclinica.domain.rule.RulesPostImportContainer)5 RuleActionRunLogBean (org.akaza.openclinica.domain.rule.action.RuleActionRunLogBean)5 Locale (java.util.Locale)4