public Map<String, String> getOutMappings() { Map<String,String> out = new HashMap<String, String>(); for(DataAssociation a : outMapping) { if(a.getSources().size() ==1 && (a.getAssignments() == null || a.getAssignments().size()==0) && a.getTransformation() == null) { out.put(a.getSources().get(0), a.getTarget()); } } return out; }
public void addOutMapping(String parameterName, String variableName, Transformation transformation) { outMapping.add(new DataAssociation(parameterName, variableName, null, transformation)); }
public void validateWorkItemResultVariable(String processName, List<DataAssociation> outputs, WorkItem workItem) { // in case work item results are skip validation as there is no notion of mandatory data outputs if (!variableStrictEnabled || workItem.getResults().isEmpty()) { return; } List<String> outputNames = new ArrayList<String>(); for (DataAssociation association : outputs) { if (association.getSources() != null) { outputNames.add(association.getSources().get(0)); } if (association.getAssignments() != null) { for (Iterator<Assignment> it = association.getAssignments().iterator(); it.hasNext();) { outputNames.add(it.next().getFrom()); } } } for (String outputName : workItem.getResults().keySet()) { if (!outputNames.contains(outputName) && !defaultOutputVariables.contains(outputName)) { throw new IllegalArgumentException("Data output '" + outputName + "' is not defined in process '" + processName + "' for task '" + workItem.getParameter("NodeName") + "'"); } } }
protected Map<String, Object> getSourceParameters(DataAssociation association) { Map<String, Object> parameters = new HashMap<String, Object>(); for (String sourceParam : association.getSources()) { Object parameterValue = null; VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, sourceParam); if (variableScopeInstance != null) { parameterValue = variableScopeInstance.getVariable(sourceParam); } else { try { parameterValue = MVELSafeHelper.getEvaluator().eval(sourceParam, new NodeInstanceResolverFactory(this)); } catch (Throwable t) { logger.warn("Could not find variable scope for variable {}", sourceParam); } } if (parameterValue != null) { parameters.put(association.getTarget(), parameterValue); } } return parameters; }
for (Iterator<org.jbpm.workflow.core.node.DataAssociation> iterator= subProcessNode.getOutAssociations().iterator(); iterator.hasNext(); ) { org.jbpm.workflow.core.node.DataAssociation mapping = iterator.next(); if (mapping.getTransformation() != null) { Transformation transformation = mapping.getTransformation(); DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage()); if (transformer != null) { Object parameterValue = transformer.transform(transformation.getCompiledExpression(), subProcessVariableScopeInstance.getVariables()); VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getTarget()); if (variableScopeInstance != null && parameterValue != null) { variableScopeInstance.setVariable(mapping.getTarget(), parameterValue); } else { logger.warn("Could not find variable scope for variable {}", mapping.getTarget()); logger.warn("Continuing without setting variable."); resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getTarget()); if (variableScopeInstance != null) { Object value = subProcessVariableScopeInstance.getVariable(mapping.getSources().get(0)); if (value == null) { try { value = MVELSafeHelper.getEvaluator().eval(mapping.getSources().get(0), new VariableScopeResolverFactory(subProcessVariableScopeInstance)); } catch (Throwable t) { variableScopeInstance.setVariable(mapping.getTarget(), value); } else { logger.error("Could not find variable scope for variable {}", mapping.getTarget()); logger.error("when trying to complete SubProcess node {}", getSubProcessNode().getName()); logger.error("Continuing without setting variable.");
public void adjustOutMapping(String forEachOutVariable) { Iterator<DataAssociation> it = outMapping.iterator(); while (it.hasNext()) { DataAssociation association = it.next(); if (forEachOutVariable.equals(association.getTarget())) { it.remove(); } } }
@Override public void executeWorkItem(final WorkItem item, final WorkItemManager manager) { final Activity activity = (Activity) getVariable(item, KieActivity.ACTIVITY); final ActivityThread thread = activity.getActivityThread(); final Map<String, Object> results = item.getResults(); final Map<String, String> clientAttributes = thread.getClientAttributes(); for (DataAssociation association : getOutAssociations(item)) { for (String source : association.getSources()) { final String value = clientAttributes.get(source); results.put(source, value); } } manager.completeWorkItem(item.getId(), item.getResults()); }
@Override public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) { super.build(process, processDescr, context, node); WorkflowProcess wfProcess = (WorkflowProcess) process; Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("imports", wfProcess.getImports()); parameters.put("classloader", context.getConfiguration().getClassLoader()); for (DataAssociation dataAssociation: ((SubProcessNode) node).getInAssociations()) { Transformation transformation = dataAssociation.getTransformation(); if (transformation != null) { DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage()); transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters)); } } for (DataAssociation dataAssociation: ((SubProcessNode) node).getOutAssociations()) { Transformation transformation = dataAssociation.getTransformation(); if (transformation != null) { DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage()); transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters)); } } }
protected Map<String, Object> getSourceParameters(DataAssociation association) { Map<String, Object> parameters = new HashMap<String, Object>(); for (String sourceParam : association.getSources()) { Object parameterValue = null; VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, sourceParam); if (variableScopeInstance != null) { parameterValue = variableScopeInstance.getVariable(sourceParam); } else { try { parameterValue = MVELSafeHelper.getEvaluator().eval(sourceParam, new NodeInstanceResolverFactory(this)); } catch (Throwable t) { logger.warn("Could not find variable scope for variable {}", sourceParam); } } if (parameterValue != null) { parameters.put(association.getTarget(), parameterValue); } } return parameters; }
DataAssociation mapping = iterator.next(); Object parameterValue = null; if (mapping.getTransformation() != null) { Transformation transformation = mapping.getTransformation(); DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage()); if (transformer != null) { resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getSources().get(0)); if (variableScopeInstance != null) { parameterValue = variableScopeInstance.getVariable(mapping.getSources().get(0)); } else { try { parameterValue = MVELSafeHelper.getEvaluator().eval(mapping.getSources().get(0), new NodeInstanceResolverFactory(this)); } catch (Throwable t) { parameterValue = VariableUtil.resolveVariable(mapping.getSources().get(0), this); if (parameterValue != null) { parameters.put(mapping.getTarget(), parameterValue); } else { logger.error("Could not find variable scope for variable {}", mapping.getSources().get(0)); logger.error("when trying to execute SubProcess node {}", getSubProcessNode().getName()); logger.error("Continuing without setting parameter."); parameters.put(mapping.getTarget(),parameterValue);
public void adjustOutMapping(String forEachOutVariable) { if (forEachOutVariable == null) { return; } Iterator<DataAssociation> it = outMapping.iterator(); while (it.hasNext()) { DataAssociation association = it.next(); if (forEachOutVariable.equals(association.getTarget())) { it.remove(); } } }
@Override public void executeWorkItem(final WorkItem item, final WorkItemManager manager) { final Activity activity = (Activity) getVariable(item, KieActivity.ACTIVITY); final ActivityThread thread = activity.getActivityThread(); final Map<String, Object> results = item.getResults(); final Map<String, String> clientAttributes = thread.getClientAttributes(); for (DataAssociation association : getOutAssociations(item)) { for (String source : association.getSources()) { final String value = clientAttributes.get(source); results.put(source, value); } } manager.completeWorkItem(item.getId(), item.getResults()); }
public void validateWorkItemResultVariable(String processName, List<DataAssociation> outputs, WorkItem workItem) { // in case work item results are skip validation as there is no notion of mandatory data outputs if (!variableStrictEnabled || workItem.getResults().isEmpty()) { return; } List<String> outputNames = new ArrayList<String>(); for (DataAssociation association : outputs) { if (association.getSources() != null) { outputNames.add(association.getSources().get(0)); } if (association.getAssignments() != null) { for (Iterator<Assignment> it = association.getAssignments().iterator(); it.hasNext();) { outputNames.add(it.next().getFrom()); } } } for (String outputName : workItem.getResults().keySet()) { if (!outputNames.contains(outputName) && !defaultOutputVariables.contains(outputName)) { throw new IllegalArgumentException("Data output '" + outputName + "' is not defined in process '" + processName + "' for task '" + workItem.getParameter("NodeName") + "'"); } } }
@Override public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) { super.build(process, processDescr, context, node); WorkflowProcess wfProcess = (WorkflowProcess) process; Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put("imports", wfProcess.getImports()); parameters.put("classloader", context.getConfiguration().getClassLoader()); for (DataAssociation dataAssociation: ((RuleSetNode) node).getInAssociations()) { Transformation transformation = dataAssociation.getTransformation(); if (transformation != null) { DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage()); transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters)); } } for (DataAssociation dataAssociation: ((RuleSetNode) node).getOutAssociations()) { Transformation transformation = dataAssociation.getTransformation(); if (transformation != null) { DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage()); transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters)); } } }
public Map<String, String> getOutMappings() { Map<String,String> out = new HashMap<String, String>(); for(DataAssociation assoc : outMapping) { if( assoc.getSources().size() == 1 && (assoc.getAssignments() == null || assoc.getAssignments().size() == 0) && assoc.getTransformation() == null ) { out.put(assoc.getSources().get(0), assoc.getTarget()); } } return out; }
protected Map<String, Object> getSourceParameters(DataAssociation association) { Map<String, Object> parameters = new HashMap<String, Object>(); for (String sourceParam : association.getSources()) { Object parameterValue = null; VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, sourceParam); if (variableScopeInstance != null) { parameterValue = variableScopeInstance.getVariable(sourceParam); } else { try { parameterValue = MVELSafeHelper.getEvaluator().eval(sourceParam, new NodeInstanceResolverFactory(this)); } catch (Throwable t) { logger.warn("Could not find variable scope for variable {}", sourceParam); } } if (parameterValue != null) { parameters.put(association.getTarget(), parameterValue); } } return parameters; }
for (Iterator<org.jbpm.workflow.core.node.DataAssociation> iterator= subProcessNode.getOutAssociations().iterator(); iterator.hasNext(); ) { org.jbpm.workflow.core.node.DataAssociation mapping = iterator.next(); if (mapping.getTransformation() != null) { Transformation transformation = mapping.getTransformation(); DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage()); if (transformer != null) { Object parameterValue = transformer.transform(transformation.getCompiledExpression(), subProcessVariableScopeInstance.getVariables()); VariableScopeInstance variableScopeInstance = (VariableScopeInstance) resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getTarget()); if (variableScopeInstance != null && parameterValue != null) { variableScopeInstance.setVariable(mapping.getTarget(), parameterValue); } else { logger.warn("Could not find variable scope for variable {}", mapping.getTarget()); logger.warn("Continuing without setting variable."); resolveContextInstance(VariableScope.VARIABLE_SCOPE, mapping.getTarget()); if (variableScopeInstance != null) { Object value = subProcessVariableScopeInstance.getVariable(mapping.getSources().get(0)); if (value == null) { try { value = MVELSafeHelper.getEvaluator().eval(mapping.getSources().get(0), new VariableScopeResolverFactory(subProcessVariableScopeInstance)); } catch (Throwable t) { variableScopeInstance.setVariable(mapping.getTarget(), value); } else { logger.error("Could not find variable scope for variable {}", mapping.getTarget()); logger.error("when trying to complete SubProcess node {}", getSubProcessNode().getName()); logger.error("Continuing without setting variable.");
faultVariable = trigger.getInAssociations().get(0).getTarget();
public void addInMapping(String parameterName, String variableName) { inMapping.add(new DataAssociation(variableName, parameterName, null, null)); }
final Map<String, Object> results = item.getResults(); for (DataAssociation association : getOutAssociations(item)) { for (String source : association.getSources()) { if (!entity.hasProperty(source)) { continue;