/** * 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> getList(Message message, List<ExpressionMapping> expressionMappings) { List<Object> list = new ArrayList<Object>(); if (expressionMappings == null || expressionMappings.size() == 0) { expand(message.getContent(), list); } else { Map<String, List<Object>> listMap = getListMap(message, expressionMappings, true, toVariable(message)); for (List<Object> value : listMap.values()) { expand(value, list); } } return list; }
private static Map<String, Object> getMap(Message message, List<ExpressionMapping> expressionMappings, Map<String, Object> contextOverrides) { Map<String, Object> map = new HashMap<String, Object>(); Map<String, List<Object>> listMap = getListMap(message, expressionMappings, false, toVariable(message), contextOverrides); for (Entry<String, List<Object>> entry : listMap.entrySet()) { List<Object> list = entry.getValue(); map.put(entry.getKey(), list != null && list.size() > 0 ? list.get(0) : null); } return map; }
KnowledgeRuntimeEngine runtime = getRuntimeEngine(); setGlobals(inputMessage, operation, runtime, true); Map<String, Object> inputMap = getInputMap(inputMessage, operation, runtime); ProcessInstance processInstance; CorrelationKey correlationKey = getCorrelationKey(exchange, inputMessage); setGlobals(inputMessage, operation, runtime, true); Object eventObject = getInput(inputMessage, operation, runtime); String eventId = operation.getEventId(); if (BPMOperationType.SIGNAL_EVENT.equals(operationType)) { outputContext.setProperty(BPMConstants.PROCESSS_INSTANCE_ID_PROPERTY, processInstanceId); setFaults(outputMessage, operation, expressionVariables); if (outputMessage.getContent() != null) { exchange.sendFault(outputMessage); } else { setOutputs(outputMessage, operation, expressionVariables); exchange.send(outputMessage);
setGlobals(inputMessage, operation, runtime, false); try { KieSession session = runtime.getKieSession(); if (ExchangePattern.IN_ONLY.equals(exchangePattern)) { List<Object> facts = getInputList(inputMessage, operation, runtime); for (Object fact : facts) { session.insert(fact); KieCommands cmds = KieServices.Factory.get().getCommands(); List<Command<?>> batch = new ArrayList<Command<?>>(); Map<String, Object> inouts = getInputOutputMap(inputMessage, operation, runtime); for (Entry<String, Object> inout : inouts.entrySet()) { batch.add(cmds.newInsert(inout.getValue(), inout.getKey())); List<Object> facts = getInputOnlyList(inputMessage, operation, runtime); batch.add(cmds.newInsertElements(facts)); batch.add(cmds.newFireAllRules()); if (KnowledgeOperations.containsGlobals(inputMessage, operation, runtime)) { synchronized (this) { fireAllRules(inputMessage, operation); if (KnowledgeOperations.containsGlobals(inputMessage, operation, runtime)) { synchronized (this) { fireUntilHalt(inputMessage, exchange, operation); setFaults(outputMessage, operation, expressionVariables); if (outputMessage.getContent() != null) { exchange.sendFault(outputMessage);
KnowledgeRuntimeEngine runtime = getSingletonRuntimeEngine(); setGlobals(inputMessage, operation, runtime, true); KieSession session = runtime.getKieSession(); if (_fireUntilHaltThread == null _fireUntilHaltThread = fireUntilHalt.startThread(); final String undefinedVariable = toVariable(exchange); Map<String, List<Object>> inputMap = getListMap( inputMessage, operation.getInputExpressionMappings(), true, List<Object> facts = getInputList(inputMessage, operation, runtime); for (Object fact : facts) {
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; }
Object output = getValue(expressionVariables, defaultReturnVariable); if (output != null) { message.setContent(output); to_em = from_em; Object from_value = run(message, from_em.getFromExpression(), expressionVariables); if (from_value != null) { from_list.add(from_value); } else { from_value = getValue(expressionVariables, from_em.getFrom()); if (from_value != null) { from_list.add(from_value); break; String output_var = toVariable(output); expressionVariables.put(output_var, output); String output_to = to_em.getTo() + " = " + output_var; Expression output_to_expr = ExpressionFactory.INSTANCE.create(output_to, null, to_em.getPropertyResolver()); run(message, output_to_expr, expressionVariables);
/** * 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); }
KnowledgeRuntimeEngine runtime = getRuntimeEngine(); setGlobals(inputMessage, operation, runtime, true); Map<String, Object> inputMap = getInputMap(inputMessage, operation, runtime); ProcessInstance processInstance; CorrelationKey correlationKey = getCorrelationKey(exchange, inputMessage); setGlobals(inputMessage, operation, runtime, true); Object eventObject = getInput(inputMessage, operation, runtime); String eventId = operation.getEventId(); if (BPMOperationType.SIGNAL_EVENT.equals(operationType)) { outputContext.setProperty(BPMConstants.PROCESSS_INSTANCE_ID_PROPERTY, processInstanceId); setFaults(outputMessage, operation, expressionVariables); if (outputMessage.getContent() != null) { exchange.sendFault(outputMessage); } else { setOutputs(outputMessage, operation, expressionVariables); exchange.send(outputMessage);
private static Map<String, Object> getMap(Message message, List<ExpressionMapping> expressionMappings, Map<String, Object> contextOverrides) { Map<String, Object> map = new HashMap<String, Object>(); Map<String, List<Object>> listMap = getListMap(message, expressionMappings, false, toVariable(message), contextOverrides); for (Entry<String, List<Object>> entry : listMap.entrySet()) { List<Object> list = entry.getValue(); map.put(entry.getKey(), list != null && list.size() > 0 ? list.get(0) : null); } return map; }
Object output = getValue(expressionVariables, defaultReturnVariable); if (output != null) { message.setContent(output); to_em = from_em; Object from_value = run(message, from_em.getFromExpression(), expressionVariables); if (from_value != null) { from_list.add(from_value); } else { from_value = getValue(expressionVariables, from_em.getFrom()); if (from_value != null) { from_list.add(from_value); break; String output_var = toVariable(output); expressionVariables.put(output_var, output); String output_to = to_em.getTo() + " = " + output_var; Expression output_to_expr = ExpressionFactory.INSTANCE.create(output_to, null, to_em.getPropertyResolver()); run(message, output_to_expr, expressionVariables);
/** * 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); }
KnowledgeRuntimeEngine runtime = getRuntimeEngine(); setGlobals(inputMessage, operation, runtime, true); Map<String, Object> inputMap = getInputMap(inputMessage, operation, runtime); ProcessInstance processInstance; CorrelationKey correlationKey = getCorrelationKey(exchange, inputMessage); setGlobals(inputMessage, operation, runtime, true); Object eventObject = getInput(inputMessage, operation, runtime); String eventId = operation.getEventId(); if (BPMOperationType.SIGNAL_EVENT.equals(operationType)) { outputContext.setProperty(BPMConstants.PROCESSS_INSTANCE_ID_PROPERTY, processInstanceId); setFaults(outputMessage, operation, expressionVariables); if (outputMessage.getContent() != null) { exchange.sendFault(outputMessage); } else { setOutputs(outputMessage, operation, expressionVariables); exchange.send(outputMessage);
private static List<Object> getList(Message message, List<ExpressionMapping> expressionMappings) { List<Object> list = new ArrayList<Object>(); if (expressionMappings == null || expressionMappings.size() == 0) { expand(message.getContent(), list); } else { Map<String, List<Object>> listMap = getListMap(message, expressionMappings, true, toVariable(message)); for (List<Object> value : listMap.values()) { expand(value, list); } } return list; }
/** * 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 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); }
/** * 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); }