/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * Sets the globals. * @param message the message * @param operation the operation * @param runtime the runtime engine * @param singleton singleton */ public static void setGlobals(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime, boolean singleton) { Globals globals = runtime.getSessionGlobals(); if (globals != null) { Map<String, Object> globalsMap = new HashMap<String, Object>(); globalsMap.put(GLOBALS, new ConcurrentHashMap<String, Object>()); Map<String, Object> expressionMap = getMap(message, operation.getGlobalExpressionMappings(), null); if (expressionMap != null) { globalsMap.putAll(expressionMap); } for (Entry<String, Object> globalsEntry : globalsMap.entrySet()) { if (!singleton) { globals.set(globalsEntry.getKey(), globalsEntry.getValue()); } else { if (globals.get(globalsEntry.getKey()) == null || (globalsEntry.getValue() != null && (globalsEntry .getValue() instanceof Map && !((Map) globalsEntry .getValue()).isEmpty()))) { globals.set(globalsEntry.getKey(), globalsEntry.getValue()); } } } } }
/** * Sets the globals. * @param message the message * @param operation the operation * @param runtime the runtime engine * @param singleton singleton */ public static void setGlobals(Message message, KnowledgeOperation operation, KnowledgeRuntimeEngine runtime, boolean singleton) { Globals globals = runtime.getSessionGlobals(); if (globals != null) { Map<String, Object> globalsMap = new HashMap<String, Object>(); globalsMap.put(GLOBALS, new ConcurrentHashMap<String, Object>()); Map<String, Object> expressionMap = getMap(message, operation.getGlobalExpressionMappings(), null); if (expressionMap != null) { globalsMap.putAll(expressionMap); } for (Entry<String, Object> globalsEntry : globalsMap.entrySet()) { if (!singleton) { globals.set(globalsEntry.getKey(), globalsEntry.getValue()); } else { if (globals.get(globalsEntry.getKey()) == null || (globalsEntry.getValue() != null && (globalsEntry .getValue() instanceof Map && !((Map) globalsEntry .getValue()).isEmpty()))) { globals.set(globalsEntry.getKey(), globalsEntry.getValue()); } } } } }