Search in sources :

Example 6 with ShowActionBean

use of org.akaza.openclinica.domain.rule.action.ShowActionBean in project OpenClinica by OpenClinica.

the class RuleSetRuleDao method findByRuleSetStudyIdAndStatusAvail.

/**
     * Use this method carefully as we force an eager fetch. It is also annotated with 
     * Transactional so it can be called from Quartz threads. 
     * @param studyId
     * @return List of RuleSetRuleBeans 
     */
@SuppressWarnings("unchecked")
@Transactional
public ArrayList<RuleSetRuleBean> findByRuleSetStudyIdAndStatusAvail(Integer studyId) {
    String query = "from " + getDomainClassName() + " ruleSetRule  where ruleSetRule.ruleSetBean.studyId = :studyId and status = :status ";
    org.hibernate.Query q = getCurrentSession().createQuery(query);
    q.setInteger("studyId", studyId);
    q.setParameter("status", org.akaza.openclinica.domain.Status.AVAILABLE);
    q.setCacheable(true);
    q.setCacheRegion(getDomainClassName());
    //JN: enabling statistics for hibernate queries etc... to monitor the performance
    Statistics stats = getSessionFactory().getStatistics();
    logger.info("EntityRuleSet" + stats.getEntityInsertCount());
    logger.info(stats.getQueryExecutionMaxTimeQueryString());
    logger.info("hit count" + stats.getSecondLevelCacheHitCount());
    stats.logSummary();
    ArrayList<RuleSetRuleBean> ruleSetRules = (ArrayList<RuleSetRuleBean>) q.list();
    // Forcing eager fetch of actions & their properties
    for (RuleSetRuleBean ruleSetRuleBean : ruleSetRules) {
        for (RuleActionBean action : ruleSetRuleBean.getActions()) {
            if (action instanceof RandomizeActionBean) {
                ((RandomizeActionBean) action).getProperties().size();
            }
            if (action instanceof InsertActionBean) {
                ((InsertActionBean) action).getProperties().size();
            }
            if (action instanceof ShowActionBean) {
                ((ShowActionBean) action).getProperties().size();
            }
            if (action instanceof HideActionBean) {
                ((HideActionBean) action).getProperties().size();
            }
            if (action instanceof EventActionBean) {
                ((EventActionBean) action).getProperties().size();
            }
        }
    }
    return ruleSetRules;
}
Also used : ShowActionBean(org.akaza.openclinica.domain.rule.action.ShowActionBean) HideActionBean(org.akaza.openclinica.domain.rule.action.HideActionBean) RuleActionBean(org.akaza.openclinica.domain.rule.action.RuleActionBean) RuleSetRuleBean(org.akaza.openclinica.domain.rule.RuleSetRuleBean) InsertActionBean(org.akaza.openclinica.domain.rule.action.InsertActionBean) ArrayList(java.util.ArrayList) Statistics(org.hibernate.stat.Statistics) EventActionBean(org.akaza.openclinica.domain.rule.action.EventActionBean) RandomizeActionBean(org.akaza.openclinica.domain.rule.action.RandomizeActionBean) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ShowActionBean (org.akaza.openclinica.domain.rule.action.ShowActionBean)6 ArrayList (java.util.ArrayList)3 RuleSetRuleBean (org.akaza.openclinica.domain.rule.RuleSetRuleBean)3 EventActionBean (org.akaza.openclinica.domain.rule.action.EventActionBean)3 HideActionBean (org.akaza.openclinica.domain.rule.action.HideActionBean)3 InsertActionBean (org.akaza.openclinica.domain.rule.action.InsertActionBean)3 PropertyBean (org.akaza.openclinica.domain.rule.action.PropertyBean)3 RuleActionBean (org.akaza.openclinica.domain.rule.action.RuleActionBean)3 ExpressionBean (org.akaza.openclinica.domain.rule.expression.ExpressionBean)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)2 RuleBean (org.akaza.openclinica.domain.rule.RuleBean)2 RuleSetBean (org.akaza.openclinica.domain.rule.RuleSetBean)2 ActionProcessor (org.akaza.openclinica.domain.rule.action.ActionProcessor)2 DiscrepancyNoteActionBean (org.akaza.openclinica.domain.rule.action.DiscrepancyNoteActionBean)2 NotificationActionBean (org.akaza.openclinica.domain.rule.action.NotificationActionBean)2 RandomizeActionBean (org.akaza.openclinica.domain.rule.action.RandomizeActionBean)2 Iterator (java.util.Iterator)1 List (java.util.List)1