/** * Sets the outputs. * @param message the message * @param operation the operation * @param contextOverrides the context overrides */ public static void setOutputs(Message message, KnowledgeOperation operation, Map<String, Object> contextOverrides) { setOutputsOrFaults(message, operation.getOutputExpressionMappings(), contextOverrides, RESULT); }
/** * Sets the faults. * @param message the message * @param operation the operation * @param contextOverrides the context overrides */ public static void setFaults(Message message, KnowledgeOperation operation, Map<String, Object> contextOverrides) { setOutputsOrFaults(message, operation.getFaultExpressionMappings(), contextOverrides, FAULT); }
/** * Gets an input-only list. * @param message the message * @param operation the operation * @param runtime the runtime engine * @return the input-only list */ public static List<Object> getInputOnlyList(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime) { return getInputList(message, operation.getInputOnlyExpressionMappings(), runtime); }
private int fireAllRules(Message inputMessage, KnowledgeOperation operation) { KnowledgeRuntimeEngine runtime = getSingletonRuntimeEngine(); RulesOperationType operationType = (RulesOperationType) operation .getType(); // sessionIdentifier = runtime.getSessionIdentifier(); setGlobals(inputMessage, operation, runtime, true); KieSession session = runtime.getKieSession(); List<Object> facts = getInputList(inputMessage, operation, runtime); for (Object fact : facts) { session.insert(fact); } if (RulesOperationType.FIRE_ALL_RULES.equals(operationType)) { return session.fireAllRules(); } return 0; }
/** * Gets an input (all) list. * @param message the message * @param operation the operation * @param runtime the runtime engine * @return the input (all) list */ public static List<Object> getInputList(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime) { return getInputList(message, operation.getInputExpressionMappings(), runtime); }
/** * Gets the input. * @param message the message * @param operation the operation * @param runtime the runtime engine * @return the input */ public static Object getInput(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime) { List<Object> list = getList(message, operation.getInputExpressionMappings()); switch (list.size()) { case 0: return filterRemoteDefaultInputContent(message.getContent(), runtime); case 1: return list.get(0); default: return list; } }
/** * Gets an input map. * @param message the message * @param operation the operation * @param runtime the runtime engine * @return the input map */ public static Map<String, Object> getInputMap(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime) { Map<String, Object> map = new HashMap<String, Object>(); List<ExpressionMapping> inputs = operation.getInputExpressionMappings(); if (inputs.size() > 0) { map.putAll(getMap(message, inputs, null)); } else { Object content = filterRemoteDefaultInputContent(message.getContent(), runtime); if (content != null) { map.put(PARAMETER, content); } } return map; }
private static List<Object> getInputList(Message message, List<ExpressionMapping> inputs, KnowledgeRuntimeEngine runtime) { List<Object> list = new ArrayList<Object>(); if (inputs.size() > 0) { list.addAll(getList(message, inputs)); } else { expand(filterRemoteDefaultInputContent(message.getContent(), runtime), list); } return list; }
/** * Gets a list map. * @param message the message * @param expressionMappings the expression mappings * @param expand whether to expand * @param undefinedVariable the undefined variable name * @return the list map */ public static Map<String, List<Object>> getListMap(Message message, List<ExpressionMapping> expressionMappings, boolean expand, String undefinedVariable) { return getListMap(message, expressionMappings, expand, undefinedVariable, null); }
/** * Contains the globals. * * @param message * the message * @param operation * the operation * @param runtime * the runtime engine * @return containsGlobal */ public static boolean containsGlobals(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime) { Map<String, Object> expressionMap = getMap(message, operation.getGlobalExpressionMappings(), null); return expressionMap != null && expressionMap.size() > 0; }
/** * {@inheritDoc} */ @Override public OperationModel setType(KnowledgeOperationType type) { setModelAttribute("type", type != null ? type.name() : null); return this; }
/** * Gets an input (all) list. * @param message the message * @param operation the operation * @param runtime the runtime engine * @return the input (all) list */ public static List<Object> getInputList(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime) { return getInputList(message, operation.getInputExpressionMappings(), runtime); }
/** * Gets the input. * @param message the message * @param operation the operation * @param runtime the runtime engine * @return the input */ public static Object getInput(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime) { List<Object> list = getList(message, operation.getInputExpressionMappings()); switch (list.size()) { case 0: return filterRemoteDefaultInputContent(message.getContent(), runtime); case 1: return list.get(0); default: return list; } }
/** * Gets an input-only list. * @param message the message * @param operation the operation * @param runtime the runtime engine * @return the input-only list */ public static List<Object> getInputOnlyList(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime) { return getInputList(message, operation.getInputOnlyExpressionMappings(), runtime); }
private static List<Object> getInputList(Message message, List<ExpressionMapping> inputs, KnowledgeRuntimeEngine runtime) { List<Object> list = new ArrayList<Object>(); if (inputs.size() > 0) { list.addAll(getList(message, inputs)); } else { expand(filterRemoteDefaultInputContent(message.getContent(), runtime), list); } return list; }
/** * Sets the outputs. * @param message the message * @param operation the operation * @param contextOverrides the context overrides */ public static void setOutputs(Message message, KnowledgeOperation operation, Map<String, Object> contextOverrides) { setOutputsOrFaults(message, operation.getOutputExpressionMappings(), contextOverrides, RESULT); }
/** * Sets the faults. * @param message the message * @param operation the operation * @param contextOverrides the context overrides */ public static void setFaults(Message message, KnowledgeOperation operation, Map<String, Object> contextOverrides) { setOutputsOrFaults(message, operation.getFaultExpressionMappings(), contextOverrides, FAULT); }
/** * Gets a list map. * @param message the message * @param expressionMappings the expression mappings * @param expand whether to expand * @param undefinedVariable the undefined variable name * @return the list map */ public static Map<String, List<Object>> getListMap(Message message, List<ExpressionMapping> expressionMappings, boolean expand, String undefinedVariable) { return getListMap(message, expressionMappings, expand, undefinedVariable, null); }
/** * Contains the globals. * * @param message * the message * @param operation * the operation * @param runtime * the runtime engine * @return containsGlobal */ public static boolean containsGlobals(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime) { Map<String, Object> expressionMap = getMap(message, operation.getGlobalExpressionMappings(), null); return expressionMap != null && expressionMap.size() > 0; }
/** * {@inheritDoc} */ @Override public OperationModel setType(KnowledgeOperationType type) { setModelAttribute("type", type != null ? type.name() : null); return this; }