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;
}
Aggregations