Search in sources :

Example 1 with ShowActionBean

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

the class ImportDataRuleRunner method runRules.

@Transactional
private MessageContainer runRules(StudyBean currentStudy, UserAccountBean ub, HashMap<String, String> variableAndValue, HashMap<String, ArrayList<RuleActionContainer>> toBeExecuted) {
    //Copied from DataEntryRuleRunner runRules
    MessageContainer messageContainer = new MessageContainer();
    for (Map.Entry<String, ArrayList<RuleActionContainer>> entry : toBeExecuted.entrySet()) {
        // Sort the list of actions
        Collections.sort(entry.getValue(), new RuleActionContainerComparator());
        for (RuleActionContainer ruleActionContainer : entry.getValue()) {
            logger.info("START Expression is : {} , RuleAction : {} ", new Object[] { ruleActionContainer.getExpressionBean().getValue(), ruleActionContainer.getRuleAction().toString() });
            ruleActionContainer.getRuleSetBean().setTarget(ruleActionContainer.getExpressionBean());
            ruleActionContainer.getRuleAction().setCuratedMessage(curateMessage(ruleActionContainer.getRuleAction(), ruleActionContainer.getRuleAction().getRuleSetRule()));
            ActionProcessor ap = ActionProcessorFacade.getActionProcessor(ruleActionContainer.getRuleAction().getActionType(), ds, getMailSender(), dynamicsMetadataService, ruleActionContainer.getRuleSetBean(), getRuleActionRunLogDao(), ruleActionContainer.getRuleAction().getRuleSetRule());
            ItemDataBean itemData = getExpressionService().getItemDataBeanFromDb(ruleActionContainer.getRuleSetBean().getTarget().getValue());
            RuleActionBean rab = ap.execute(RuleRunnerMode.IMPORT_DATA, ExecutionMode.SAVE, ruleActionContainer.getRuleAction(), itemData, DiscrepancyNoteBean.ITEM_DATA, currentStudy, ub, prepareEmailContents(ruleActionContainer.getRuleSetBean(), ruleActionContainer.getRuleAction().getRuleSetRule(), currentStudy, ruleActionContainer.getRuleAction()));
            if (rab != null) {
                if (rab instanceof ShowActionBean) {
                    messageContainer.add(getExpressionService().getGroupOidOrdinal(ruleActionContainer.getRuleSetBean().getTarget().getValue()), rab);
                } else {
                    messageContainer.add(getExpressionService().getGroupOrdninalConcatWithItemOid(ruleActionContainer.getRuleSetBean().getTarget().getValue()), ruleActionContainer.getRuleAction());
                }
            }
            logger.info("END Expression is : {} , RuleAction : {} ", new Object[] { ruleActionContainer.getExpressionBean().getValue(), ruleActionContainer.getRuleAction().toString() });
        }
    }
    return messageContainer;
}
Also used : ShowActionBean(org.akaza.openclinica.domain.rule.action.ShowActionBean) RuleActionBean(org.akaza.openclinica.domain.rule.action.RuleActionBean) ItemDataBean(org.akaza.openclinica.bean.submit.ItemDataBean) ArrayList(java.util.ArrayList) ActionProcessor(org.akaza.openclinica.domain.rule.action.ActionProcessor) HashMap(java.util.HashMap) Map(java.util.Map) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with ShowActionBean

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

the class MessageContainer method add.

public void add(String groupOrdinalPLusItemOid, RuleActionBean ruleActionBean) {
    // System.out.println("just added error : " + ruleActionBean.getSummary());
    if (ruleActionBean instanceof ShowActionBean) {
        String groupOidOrdinal = groupOrdinalPLusItemOid;
        List<PropertyBean> properties = ((ShowActionBean) ruleActionBean).getProperties();
        for (PropertyBean propertyBean : properties) {
            String propertyOid = propertyBean.getOid();
            addInternal(propertyOid.contains(".") ? propertyOid : groupOidOrdinal + "." + propertyOid, ruleActionBean.getSummary(), MessageType.WARNING);
        //addInternal(propertyBean.getOid(), ruleActionBean.getSummary(), MessageType.WARNING);
        //System.out.println("just added warning : " + ruleActionBean.getSummary());
        }
    } else {
        addInternal(groupOrdinalPLusItemOid, ruleActionBean.getSummary(), MessageType.ERROR);
    //System.out.println("just added error : " + ruleActionBean.getSummary());
    }
}
Also used : ShowActionBean(org.akaza.openclinica.domain.rule.action.ShowActionBean) PropertyBean(org.akaza.openclinica.domain.rule.action.PropertyBean)

Example 3 with ShowActionBean

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

the class RulesPostImportContainerService method isRuleActionValid.

private void isRuleActionValid(RuleActionBean ruleActionBean, AuditableBeanWrapper<RuleSetBean> ruleSetBeanWrapper, EventDefinitionCRFBean eventDefinitionCRFBean, List<RuleSetBean> eventActionsRuleSetBean) {
    RuleActionRunBean ruleActionRun = ruleActionBean.getRuleActionRun();
    if (ruleActionBean.getActionType().getCode() != 6 && !ruleActionRun.getInitialDataEntry() && !ruleActionRun.getAdministrativeDataEntry() && !ruleActionRun.getBatch() && !ruleActionRun.getDoubleDataEntry() && !ruleActionRun.getImportDataEntry())
        ruleSetBeanWrapper.error(createError("OCRERR_0050"));
    String message = "";
    String emailSubject = "";
    if (ruleActionBean instanceof org.akaza.openclinica.domain.rule.action.NotificationActionBean) {
        message = ((NotificationActionBean) ruleActionBean).getMessage();
        emailSubject = ((NotificationActionBean) ruleActionBean).getSubject();
        if (emailSubject.length() > 330)
            ruleSetBeanWrapper.error(createError("OCRERR_0048"));
        if (message.length() > 2040)
            ruleSetBeanWrapper.error(createError("OCRERR_0049"));
    }
    if (ruleActionBean instanceof org.akaza.openclinica.domain.rule.action.EmailActionBean)
        isUploadedRuleSupportedForEventAction(ruleSetBeanWrapper);
    if (ruleActionBean instanceof DiscrepancyNoteActionBean)
        isUploadedRuleSupportedForEventAction(ruleSetBeanWrapper);
    if (ruleActionBean instanceof ShowActionBean) {
        if (!isUploadedRuleSupportedForEventAction(ruleSetBeanWrapper)) {
            List<PropertyBean> properties = ((ShowActionBean) ruleActionBean).getProperties();
            //if (ruleActionBean.getRuleActionRun().getBatch() == true || ruleActionBean.getRuleActionRun().getImportDataEntry() == true) {
            if (ruleActionBean.getRuleActionRun().getBatch() == true) {
                ruleSetBeanWrapper.error("ShowAction " + ((ShowActionBean) ruleActionBean).toString() + " is not Valid. You cannot have Batch=\"true\". ");
            //+ " is not Valid. You cannot have ImportDataEntry=\"true\" Batch=\"true\". ");
            }
            for (PropertyBean propertyBean : properties) {
                String result = getExpressionService().checkValidityOfItemOrItemGroupOidInCrf(propertyBean.getOid(), ruleSetBeanWrapper.getAuditableBean());
                // String result = getExpressionService().isExpressionValid(oid, ruleSetBeanWrapper.getAuditableBean(), 2) ? "OK" : "";
                if (!result.equals("OK")) {
                    ruleSetBeanWrapper.error("ShowAction OID " + result + " is not Valid. ");
                }
            }
        }
    }
    if (ruleActionBean instanceof HideActionBean) {
        if (!isUploadedRuleSupportedForEventAction(ruleSetBeanWrapper)) {
            List<PropertyBean> properties = ((HideActionBean) ruleActionBean).getProperties();
            //if (ruleActionBean.getRuleActionRun().getBatch() == true || ruleActionBean.getRuleActionRun().getImportDataEntry() == true) {
            if (ruleActionBean.getRuleActionRun().getBatch() == true) {
                ruleSetBeanWrapper.error("HideAction " + ((HideActionBean) ruleActionBean).toString() + " is not Valid. You cannot have Batch=\"true\". ");
            //+ " is not Valid. You cannot have ImportDataEntry=\"true\" Batch=\"true\". ");
            }
            for (PropertyBean propertyBean : properties) {
                String result = getExpressionService().checkValidityOfItemOrItemGroupOidInCrf(propertyBean.getOid(), ruleSetBeanWrapper.getAuditableBean());
                // String result = getExpressionService().isExpressionValid(oid, ruleSetBeanWrapper.getAuditableBean(), 2) ? "OK" : "";
                if (!result.equals("OK")) {
                    ruleSetBeanWrapper.error("HideAction OID " + result + " is not Valid. ");
                }
            }
        }
    }
    if (ruleActionBean instanceof InsertActionBean) {
        if (!isUploadedRuleSupportedForEventAction(ruleSetBeanWrapper)) {
            DataBinder dataBinder = new DataBinder(ruleActionBean);
            Errors errors = dataBinder.getBindingResult();
            InsertActionValidator insertActionValidator = getInsertActionValidator();
            insertActionValidator.setEventDefinitionCRFBean(eventDefinitionCRFBean);
            insertActionValidator.setRuleSetBean(ruleSetBeanWrapper.getAuditableBean());
            insertActionValidator.setExpressionService(expressionService);
            insertActionValidator.validate(ruleActionBean, errors);
            if (errors.hasErrors()) {
                ruleSetBeanWrapper.error("InsertAction is not valid: " + errors.getAllErrors().get(0).getCode());
            }
        }
    }
    if (ruleActionBean instanceof RandomizeActionBean) {
        if (!isUploadedRuleSupportedForEventAction(ruleSetBeanWrapper)) {
            DataBinder dataBinder = new DataBinder(ruleActionBean);
            Errors errors = dataBinder.getBindingResult();
            RandomizeActionValidator randomizeActionValidator = getRandomizeActionValidator();
            randomizeActionValidator.setEventDefinitionCRFBean(eventDefinitionCRFBean);
            randomizeActionValidator.setRuleSetBean(ruleSetBeanWrapper.getAuditableBean());
            randomizeActionValidator.setExpressionService(expressionService);
            randomizeActionValidator.validate(ruleActionBean, errors);
            RandomizeActionBean randomizeActionBean = (RandomizeActionBean) ruleActionBean;
            //        ruleSetBeanWrapper.error(createError("OCRERR_0050"));
            if (randomizeActionBean.getStratificationFactors() != null) {
                for (StratificationFactorBean factor : randomizeActionBean.getStratificationFactors()) {
                    if (factor.getStratificationFactor() != null && factor.getStratificationFactor().getValue() != null && factor.getStratificationFactor().getValue().length() != 0) {
                        String expressionContextName = factor.getStratificationFactor().getContextName();
                        Context context = expressionContextName != null ? Context.getByName(expressionContextName) : Context.OC_RULES_V1;
                        factor.getStratificationFactor().setContext(context);
                        ExpressionBean expBean = factor.getStratificationFactor();
                        String expValue = expBean.getValue();
                        String prefix = "STUDYGROUPCLASSLIST";
                        boolean sgcExist = false;
                        if (expValue.startsWith("SS.")) {
                            String param = expValue.split("\\.", -1)[1].trim();
                            if (param.startsWith(prefix)) {
                                String gcName = param.substring(21, param.indexOf("\"]"));
                                StudyGroupClassDAO studyGroupClassDAO = new StudyGroupClassDAO(ds);
                                ArrayList<StudyGroupClassBean> studyGroupClasses = studyGroupClassDAO.findAllByStudy(currentStudy);
                                for (StudyGroupClassBean studyGroupClass : studyGroupClasses) {
                                    if (studyGroupClass.getName().equalsIgnoreCase(gcName.trim())) {
                                        sgcExist = true;
                                        break;
                                    }
                                }
                            }
                            if (!param.equalsIgnoreCase("BIRTHDATE") && !param.equalsIgnoreCase("SEX") && !sgcExist) {
                                ruleSetBeanWrapper.error(createError("OCRERR_0051", expBean.getValue()));
                            }
                        } else {
                            isStratificationExpressionValid(expBean, ruleSetBeanWrapper);
                        }
                    }
                }
            }
            if (errors.hasErrors())
                ruleSetBeanWrapper.error("Randomize Action is not valid: " + errors.getAllErrors().get(0).getCode());
        }
    }
    if (ruleActionBean instanceof EventActionBean) {
        DataBinder dataBinder = new DataBinder(ruleActionBean);
        Errors errors = dataBinder.getBindingResult();
        eventActionValidator.setRuleSetBeanWrapper(ruleSetBeanWrapper);
        eventActionValidator.setExpressionService(expressionService);
        eventActionValidator.setRespage(respage);
        eventActionValidator.validate(ruleActionBean, errors);
        String currentTarget = null;
        currentTarget = ruleSetBeanWrapper.getAuditableBean().getOriginalTarget().getValue();
        if (currentTarget.contains(".STARTDATE") || currentTarget.contains(".STATUS")) {
            if (ruleActionBean.getActionType().getCode() == 6)
                //Validation , move to Validate Rule page under eventActinValidator
                inValidateInfiniteLoop(ruleActionBean, ruleSetBeanWrapper, eventActionsRuleSetBean);
        } else {
            ruleSetBeanWrapper.error(createError("OCRERR_0044"));
        }
        if (errors.hasErrors()) {
            ruleSetBeanWrapper.error("EventAction is not valid: " + errors.getAllErrors().get(0).getDefaultMessage());
        }
    }
}
Also used : DiscrepancyNoteActionBean(org.akaza.openclinica.domain.rule.action.DiscrepancyNoteActionBean) StudyGroupClassDAO(org.akaza.openclinica.dao.managestudy.StudyGroupClassDAO) EventActionBean(org.akaza.openclinica.domain.rule.action.EventActionBean) RuleActionRunBean(org.akaza.openclinica.domain.rule.action.RuleActionRunBean) StratificationFactorBean(org.akaza.openclinica.domain.rule.action.StratificationFactorBean) RandomizeActionBean(org.akaza.openclinica.domain.rule.action.RandomizeActionBean) StudyGroupClassBean(org.akaza.openclinica.bean.managestudy.StudyGroupClassBean) EmailActionBean(org.akaza.openclinica.bean.rule.action.EmailActionBean) DataBinder(org.springframework.validation.DataBinder) InsertActionValidator(org.akaza.openclinica.validator.rule.action.InsertActionValidator) ShowActionBean(org.akaza.openclinica.domain.rule.action.ShowActionBean) HideActionBean(org.akaza.openclinica.domain.rule.action.HideActionBean) Context(org.akaza.openclinica.domain.rule.expression.Context) RandomizeActionValidator(org.akaza.openclinica.validator.rule.action.RandomizeActionValidator) NotificationActionBean(org.akaza.openclinica.domain.rule.action.NotificationActionBean) InsertActionBean(org.akaza.openclinica.domain.rule.action.InsertActionBean) ExpressionBean(org.akaza.openclinica.domain.rule.expression.ExpressionBean) Errors(org.springframework.validation.Errors) PropertyBean(org.akaza.openclinica.domain.rule.action.PropertyBean)

Example 4 with ShowActionBean

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

the class RuleController method mapRulesToRulesPostImportContainer.

private RulesPostImportContainer mapRulesToRulesPostImportContainer(org.openclinica.ns.rules.v31.Rules rules) {
    RulesPostImportContainer rpic = new RulesPostImportContainer();
    for (RuleAssignmentType rat : rules.getRuleAssignment()) {
        TargetType targetType = rat.getTarget();
        ExpressionBean targetBean = new ExpressionBean(Context.OC_RULES_V1, targetType.getValue());
        RunOnScheduleType scheduleType = rules.getRuleAssignment().get(0).getRunOnSchedule();
        RuleSetBean ruleSetBean = new RuleSetBean();
        ruleSetBean.setOriginalTarget(targetBean);
        if (scheduleType != null) {
            if (!scheduleType.getTime().equals("")) {
                ruleSetBean.setRunTime(scheduleType.getTime());
            }
        }
        for (RuleRefType rrt : rat.getRuleRef()) {
            RuleSetRuleBean ruleSetRuleBean = new RuleSetRuleBean();
            ruleSetRuleBean.setOid(rrt.getOID());
            for (DiscrepancyNoteActionType discrepancyNoteActionType : rrt.getDiscrepancyNoteAction()) {
                DiscrepancyNoteActionBean action = new DiscrepancyNoteActionBean();
                action.setMessage(discrepancyNoteActionType.getMessage());
                action.setExpressionEvaluatesTo(Boolean.valueOf(discrepancyNoteActionType.getIfExpressionEvaluates()));
                action.getRuleActionRun().setInitialDataEntry(discrepancyNoteActionType.getRun().isInitialDataEntry());
                action.getRuleActionRun().setDoubleDataEntry(discrepancyNoteActionType.getRun().isDoubleDataEntry());
                action.getRuleActionRun().setAdministrativeDataEntry(discrepancyNoteActionType.getRun().isAdministrativeDataEntry());
                action.getRuleActionRun().setImportDataEntry(discrepancyNoteActionType.getRun().isImportDataEntry());
                action.getRuleActionRun().setBatch(discrepancyNoteActionType.getRun().isBatch());
                ruleSetRuleBean.addAction(action);
            }
            for (EmailActionType emailActionType : rrt.getEmailAction()) {
                EmailActionBean action = new EmailActionBean();
                action.setMessage(emailActionType.getMessage());
                action.setTo(emailActionType.getTo());
                action.setExpressionEvaluatesTo(Boolean.valueOf(emailActionType.getIfExpressionEvaluates()));
                action.getRuleActionRun().setInitialDataEntry(emailActionType.getRun().isInitialDataEntry());
                action.getRuleActionRun().setDoubleDataEntry(emailActionType.getRun().isDoubleDataEntry());
                action.getRuleActionRun().setAdministrativeDataEntry(emailActionType.getRun().isAdministrativeDataEntry());
                action.getRuleActionRun().setImportDataEntry(emailActionType.getRun().isImportDataEntry());
                action.getRuleActionRun().setBatch(emailActionType.getRun().isBatch());
                ruleSetRuleBean.addAction(action);
            }
            for (ShowActionType showActionType : rrt.getShowAction()) {
                ShowActionBean action = new ShowActionBean();
                action.setMessage(showActionType.getMessage());
                action.setExpressionEvaluatesTo(Boolean.valueOf(showActionType.getIfExpressionEvaluates()));
                action.getRuleActionRun().setInitialDataEntry(showActionType.getRun().isInitialDataEntry());
                action.getRuleActionRun().setDoubleDataEntry(showActionType.getRun().isDoubleDataEntry());
                action.getRuleActionRun().setAdministrativeDataEntry(showActionType.getRun().isAdministrativeDataEntry());
                action.getRuleActionRun().setImportDataEntry(showActionType.getRun().isImportDataEntry());
                action.getRuleActionRun().setBatch(showActionType.getRun().isBatch());
                for (PropertyType propertyType : showActionType.getDestinationProperty()) {
                    PropertyBean property = new PropertyBean();
                    property.setOid(propertyType.getOID());
                    action.addProperty(property);
                }
                ruleSetRuleBean.addAction(action);
            }
            for (HideActionType hideActionType : rrt.getHideAction()) {
                HideActionBean action = new HideActionBean();
                action.setMessage(hideActionType.getMessage());
                action.setExpressionEvaluatesTo(Boolean.valueOf(hideActionType.getIfExpressionEvaluates()));
                action.getRuleActionRun().setInitialDataEntry(hideActionType.getRun().isInitialDataEntry());
                action.getRuleActionRun().setDoubleDataEntry(hideActionType.getRun().isDoubleDataEntry());
                action.getRuleActionRun().setAdministrativeDataEntry(hideActionType.getRun().isAdministrativeDataEntry());
                action.getRuleActionRun().setImportDataEntry(hideActionType.getRun().isImportDataEntry());
                action.getRuleActionRun().setBatch(hideActionType.getRun().isBatch());
                for (PropertyType propertyType : hideActionType.getDestinationProperty()) {
                    PropertyBean property = new PropertyBean();
                    property.setOid(propertyType.getOID());
                    action.addProperty(property);
                }
                ruleSetRuleBean.addAction(action);
            }
            for (InsertActionType insertActionType : rrt.getInsertAction()) {
                InsertActionBean action = new InsertActionBean();
                action.setExpressionEvaluatesTo(Boolean.valueOf(insertActionType.getIfExpressionEvaluates()));
                action.getRuleActionRun().setInitialDataEntry(insertActionType.getRun().isInitialDataEntry());
                action.getRuleActionRun().setDoubleDataEntry(insertActionType.getRun().isDoubleDataEntry());
                action.getRuleActionRun().setAdministrativeDataEntry(insertActionType.getRun().isAdministrativeDataEntry());
                action.getRuleActionRun().setImportDataEntry(insertActionType.getRun().isImportDataEntry());
                action.getRuleActionRun().setBatch(insertActionType.getRun().isBatch());
                ruleSetRuleBean.addAction(action);
                for (PropertyType propertyType : insertActionType.getDestinationProperty()) {
                    PropertyBean property = new PropertyBean();
                    property.setOid(propertyType.getOID());
                    property.setValue(propertyType.getValue());
                    ExpressionBean expressionBean = new ExpressionBean(Context.OC_RULES_V1, propertyType.getValueExpression().getValue());
                    property.setValueExpression(expressionBean);
                    action.addProperty(property);
                }
                ruleSetRuleBean.addAction(action);
            }
            for (EventActionType eventActionType : rrt.getEventAction()) {
                EventActionBean action = new EventActionBean();
                action.setExpressionEvaluatesTo(Boolean.valueOf(eventActionType.getIfExpressionEvaluates()));
                action.setOc_oid_reference(eventActionType.getOID());
                action.getRuleActionRun().setNot_started(eventActionType.getRunOnStatus().isNotScheduled());
                action.getRuleActionRun().setScheduled(eventActionType.getRunOnStatus().isScheduled());
                action.getRuleActionRun().setData_entry_started(eventActionType.getRunOnStatus().isDataEntryStarted());
                action.getRuleActionRun().setComplete(eventActionType.getRunOnStatus().isCompleted());
                action.getRuleActionRun().setSkipped(eventActionType.getRunOnStatus().isSkipped());
                action.getRuleActionRun().setStopped(eventActionType.getRunOnStatus().isStopped());
                for (EventDestinationType eventDestinationType : eventActionType.getEventDestination()) {
                    EventPropertyBean property = new EventPropertyBean();
                    property.setProperty(eventDestinationType.getProperty());
                    ExpressionBean expressionBean = new ExpressionBean(Context.OC_RULES_V1, eventDestinationType.getValueExpression().getValue());
                    property.setValueExpression(expressionBean);
                    action.addProperty(property);
                }
                ruleSetRuleBean.addAction(action);
            }
            for (NotificationActionType notificationActionType : rrt.getNotificationAction()) {
                NotificationActionBean action = new NotificationActionBean();
                action.setExpressionEvaluatesTo(Boolean.valueOf(notificationActionType.getIfExpressionEvaluates()));
                action.setTo(notificationActionType.getTo());
                action.setSubject(notificationActionType.getSubject());
                action.setMessage(notificationActionType.getMessage());
                ruleSetRuleBean.addAction(action);
            }
            ruleSetBean.addRuleSetRule(ruleSetRuleBean);
        }
        rpic.addRuleSet(ruleSetBean);
    }
    for (RuleDefType rdt : rules.getRuleDef()) {
        RuleBean ruleBean = new RuleBean();
        ExpressionBean ruleExpressionBean = new ExpressionBean(Context.OC_RULES_V1, rdt.getExpression().getValue());
        ruleBean.setExpression(ruleExpressionBean);
        ruleBean.setDescription(rdt.getDescription());
        ruleBean.setName(rdt.getName());
        ruleBean.setOid(rdt.getOID());
        rpic.addRuleDef(ruleBean);
    }
    return rpic;
}
Also used : DiscrepancyNoteActionBean(org.akaza.openclinica.domain.rule.action.DiscrepancyNoteActionBean) EventPropertyBean(org.akaza.openclinica.domain.rule.action.EventPropertyBean) RuleAssignmentType(org.openclinica.ns.rules.v31.RuleAssignmentType) DiscrepancyNoteActionType(org.openclinica.ns.rules.v31.DiscrepancyNoteActionType) PropertyType(org.openclinica.ns.rules.v31.PropertyType) EventActionBean(org.akaza.openclinica.domain.rule.action.EventActionBean) RunOnScheduleType(org.openclinica.ns.rules.v31.RunOnScheduleType) EventActionType(org.openclinica.ns.rules.v31.EventActionType) RuleRefType(org.openclinica.ns.rules.v31.RuleRefType) TargetType(org.openclinica.ns.rules.v31.TargetType) EmailActionBean(org.akaza.openclinica.domain.rule.action.EmailActionBean) EventDestinationType(org.openclinica.ns.rules.v31.EventDestinationType) ShowActionBean(org.akaza.openclinica.domain.rule.action.ShowActionBean) HideActionBean(org.akaza.openclinica.domain.rule.action.HideActionBean) ShowActionType(org.openclinica.ns.rules.v31.ShowActionType) HideActionType(org.openclinica.ns.rules.v31.HideActionType) RuleSetRuleBean(org.akaza.openclinica.domain.rule.RuleSetRuleBean) InsertActionBean(org.akaza.openclinica.domain.rule.action.InsertActionBean) NotificationActionBean(org.akaza.openclinica.domain.rule.action.NotificationActionBean) NotificationActionType(org.openclinica.ns.rules.v31.NotificationActionType) InsertActionType(org.openclinica.ns.rules.v31.InsertActionType) RuleDefType(org.openclinica.ns.rules.v31.RuleDefType) ExpressionBean(org.akaza.openclinica.domain.rule.expression.ExpressionBean) EmailActionType(org.openclinica.ns.rules.v31.EmailActionType) RulesPostImportContainer(org.akaza.openclinica.domain.rule.RulesPostImportContainer) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) PropertyBean(org.akaza.openclinica.domain.rule.action.PropertyBean) EventPropertyBean(org.akaza.openclinica.domain.rule.action.EventPropertyBean) RuleSetRuleBean(org.akaza.openclinica.domain.rule.RuleSetRuleBean) RuleBean(org.akaza.openclinica.domain.rule.RuleBean)

Example 5 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