未验证 提交 1f83c9f4 编写于 作者: S salaboy 提交者: GitHub

Merge pull request #2374 from Activiti/daisuke-2184-json-el-resolver

Handling expressions for json variables
/* Licensed under the Apache License, Version 2.0 (the "License");
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
......@@ -15,6 +16,7 @@ package org.activiti.engine.impl.el;
import java.beans.FeatureDescriptor;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
import javax.el.CompositeELResolver;
import javax.el.ELContext;
......@@ -22,6 +24,8 @@ import javax.el.ELException;
import javax.el.ELResolver;
import javax.el.PropertyNotWritableException;
import org.activiti.engine.impl.context.Context;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
......@@ -43,16 +47,18 @@ public class JsonNodeELResolver extends ELResolver {
}
/**
* Creates a new BeanELResolver whose read-only status is determined by the given parameter.
* Creates a new BeanELResolver whose read-only status is determined by the
* given parameter.
*/
public JsonNodeELResolver(boolean readOnly) {
this.readOnly = readOnly;
}
/**
* If the base object is not null, returns the most general type that this resolver accepts for
* the property argument. Otherwise, returns null. Assuming the base is not null, this method
* will always return Object.class. This is because any object is accepted as a key and is
* If the base object is not null, returns the most general type that this
* resolver accepts for the property argument. Otherwise, returns null.
* Assuming the base is not null, this method will always return
* Object.class. This is because any object is accepted as a key and is
* coerced into a string.
*
* @param context
......@@ -67,13 +73,15 @@ public class JsonNodeELResolver extends ELResolver {
}
/**
* If the base object is not null, returns an Iterator containing the set of JavaBeans
* properties available on the given object. Otherwise, returns null. The Iterator returned must
* contain zero or more instances of java.beans.FeatureDescriptor. Each info object contains
* information about a property in the bean, as obtained by calling the
* BeanInfo.getPropertyDescriptors method. The FeatureDescriptor is initialized using the same
* fields as are present in the PropertyDescriptor, with the additional required named
* attributes "type" and "resolvableAtDesignTime" set as follows:
* If the base object is not null, returns an Iterator containing the set of
* JavaBeans properties available on the given object. Otherwise, returns
* null. The Iterator returned must contain zero or more instances of
* java.beans.FeatureDescriptor. Each info object contains information about
* a property in the bean, as obtained by calling the
* BeanInfo.getPropertyDescriptors method. The FeatureDescriptor is
* initialized using the same fields as are present in the
* PropertyDescriptor, with the additional required named attributes "type"
* and "resolvableAtDesignTime" set as follows:
* <ul>
* <li>{@link ELResolver#TYPE} - The runtime type of the property, from
* PropertyDescriptor.getPropertyType().</li>
......@@ -84,8 +92,9 @@ public class JsonNodeELResolver extends ELResolver {
* The context of this evaluation.
* @param base
* The bean to analyze.
* @return An Iterator containing zero or more FeatureDescriptor objects, each representing a
* property on this bean, or null if the base object is null.
* @return An Iterator containing zero or more FeatureDescriptor objects,
* each representing a property on this bean, or null if the base
* object is null.
*/
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext context, Object base) {
......@@ -93,9 +102,12 @@ public class JsonNodeELResolver extends ELResolver {
JsonNode node = (JsonNode) base;
final Iterator<String> keys = node.fieldNames();
return new Iterator<FeatureDescriptor>() {
@Override
public boolean hasNext() {
return keys.hasNext();
}
@Override
public FeatureDescriptor next() {
Object key = keys.next();
FeatureDescriptor feature = new FeatureDescriptor();
......@@ -110,6 +122,8 @@ public class JsonNodeELResolver extends ELResolver {
return feature;
}
@Override
public void remove() {
throw new UnsupportedOperationException("cannot remove");
}
......@@ -119,27 +133,30 @@ public class JsonNodeELResolver extends ELResolver {
}
/**
* If the base object is a map, returns the most general acceptable type for a value in this
* map. If the base is a Map, the propertyResolved property of the ELContext object must be set
* to true by this resolver, before returning. If this property is not true after this method is
* called, the caller should ignore the return value. Assuming the base is a Map, this method
* will always return Object.class. This is because Maps accept any object as the value for a
* given key.
* If the base object is a map, returns the most general acceptable type for
* a value in this map. If the base is a Map, the propertyResolved property
* of the ELContext object must be set to true by this resolver, before
* returning. If this property is not true after this method is called, the
* caller should ignore the return value. Assuming the base is a Map, this
* method will always return Object.class. This is because Maps accept any
* object as the value for a given key.
*
* @param context
* The context of this evaluation.
* @param base
* The map to analyze. Only bases of type Map are handled by this resolver.
* The map to analyze. Only bases of type Map are handled by this
* resolver.
* @param property
* The key to return the acceptable type for. Ignored by this resolver.
* @return If the propertyResolved property of ELContext was set to true, then the most general
* acceptable type; otherwise undefined.
* The key to return the acceptable type for. Ignored by this
* resolver.
* @return If the propertyResolved property of ELContext was set to true,
* then the most general acceptable type; otherwise undefined.
* @throws NullPointerException
* if context is null
* @throws ELException
* if an exception was thrown while performing the property or variable resolution.
* The thrown exception must be included as the cause property of this exception, if
* available.
* if an exception was thrown while performing the property or
* variable resolution. The thrown exception must be included as
* the cause property of this exception, if available.
*/
@Override
public Class<?> getType(ELContext context, Object base, Object property) {
......@@ -155,32 +172,38 @@ public class JsonNodeELResolver extends ELResolver {
}
/**
* If the base object is a map, returns the value associated with the given key, as specified by
* the property argument. If the key was not found, null is returned. If the base is a Map, the
* propertyResolved property of the ELContext object must be set to true by this resolver,
* before returning. If this property is not true after this method is called, the caller should
* ignore the return value. Just as in java.util.Map.get(Object), just because null is returned
* doesn't mean there is no mapping for the key; it's also possible that the Map explicitly maps
* the key to null.
* If the base object is a map, returns the value associated with the given
* key, as specified by the property argument. If the key was not found,
* null is returned. If the base is a Map, the propertyResolved property of
* the ELContext object must be set to true by this resolver, before
* returning. If this property is not true after this method is called, the
* caller should ignore the return value. Just as in
* java.util.Map.get(Object), just because null is returned doesn't mean
* there is no mapping for the key; it's also possible that the Map
* explicitly maps the key to null.
*
* @param context
* The context of this evaluation.
* @param base
* The map to analyze. Only bases of type Map are handled by this resolver.
* The map to analyze. Only bases of type Map are handled by this
* resolver.
* @param property
* The key to return the acceptable type for. Ignored by this resolver.
* @return If the propertyResolved property of ELContext was set to true, then the value
* associated with the given key or null if the key was not found. Otherwise, undefined.
* The key to return the acceptable type for. Ignored by this
* resolver.
* @return If the propertyResolved property of ELContext was set to true,
* then the value associated with the given key or null if the key
* was not found. Otherwise, undefined.
* @throws ClassCastException
* if the key is of an inappropriate type for this map (optionally thrown by the
* underlying Map).
* if the key is of an inappropriate type for this map
* (optionally thrown by the underlying Map).
* @throws NullPointerException
* if context is null, or if the key is null and this map does not permit null keys
* (the latter is optionally thrown by the underlying Map).
* if context is null, or if the key is null and this map does
* not permit null keys (the latter is optionally thrown by the
* underlying Map).
* @throws ELException
* if an exception was thrown while performing the property or variable resolution.
* The thrown exception must be included as the cause property of this exception, if
* available.
* if an exception was thrown while performing the property or
* variable resolution. The thrown exception must be included as
* the cause property of this exception, if available.
*/
@Override
public Object getValue(ELContext context, Object base, Object property) {
......@@ -203,9 +226,14 @@ public class JsonNodeELResolver extends ELResolver {
result = resultNode.toString();
}
} else {
if (resultNode.isArray()) {
result = Context.getProcessEngineConfiguration().getObjectMapper().convertValue(resultNode,
List.class);
} else {
result = resultNode;
}
}
context.setPropertyResolved(true);
}
return result;
......@@ -213,30 +241,36 @@ public class JsonNodeELResolver extends ELResolver {
/**
* If the base object is a map, returns whether a call to
* {@link #setValue(ELContext, Object, Object, Object)} will always fail. If the base is a Map,
* the propertyResolved property of the ELContext object must be set to true by this resolver,
* before returning. If this property is not true after this method is called, the caller should
* ignore the return value. If this resolver was constructed in read-only mode, this method will
* always return true. If a Map was created using java.util.Collections.unmodifiableMap(Map),
* this method must return true. Unfortunately, there is no Collections API method to detect
* this. However, an implementation can create a prototype unmodifiable Map and query its
* runtime type to see if it matches the runtime type of the base object as a workaround.
* {@link #setValue(ELContext, Object, Object, Object)} will always fail. If
* the base is a Map, the propertyResolved property of the ELContext object
* must be set to true by this resolver, before returning. If this property
* is not true after this method is called, the caller should ignore the
* return value. If this resolver was constructed in read-only mode, this
* method will always return true. If a Map was created using
* java.util.Collections.unmodifiableMap(Map), this method must return true.
* Unfortunately, there is no Collections API method to detect this.
* However, an implementation can create a prototype unmodifiable Map and
* query its runtime type to see if it matches the runtime type of the base
* object as a workaround.
*
* @param context
* The context of this evaluation.
* @param base
* The map to analyze. Only bases of type Map are handled by this resolver.
* The map to analyze. Only bases of type Map are handled by this
* resolver.
* @param property
* The key to return the acceptable type for. Ignored by this resolver.
* @return If the propertyResolved property of ELContext was set to true, then true if calling
* the setValue method will always fail or false if it is possible that such a call may
* succeed; otherwise undefined.
* The key to return the acceptable type for. Ignored by this
* resolver.
* @return If the propertyResolved property of ELContext was set to true,
* then true if calling the setValue method will always fail or
* false if it is possible that such a call may succeed; otherwise
* undefined.
* @throws NullPointerException
* if context is null.
* @throws ELException
* if an exception was thrown while performing the property or variable resolution.
* The thrown exception must be included as the cause property of this exception, if
* available.
* if an exception was thrown while performing the property or
* variable resolution. The thrown exception must be included as
* the cause property of this exception, if available.
*/
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
......@@ -250,40 +284,45 @@ public class JsonNodeELResolver extends ELResolver {
}
/**
* If the base object is a map, attempts to set the value associated with the given key, as
* specified by the property argument. If the base is a Map, the propertyResolved property of
* the ELContext object must be set to true by this resolver, before returning. If this property
* is not true after this method is called, the caller can safely assume no value was set. If
* this resolver was constructed in read-only mode, this method will always throw
* PropertyNotWritableException. If a Map was created using
* If the base object is a map, attempts to set the value associated with
* the given key, as specified by the property argument. If the base is a
* Map, the propertyResolved property of the ELContext object must be set to
* true by this resolver, before returning. If this property is not true
* after this method is called, the caller can safely assume no value was
* set. If this resolver was constructed in read-only mode, this method will
* always throw PropertyNotWritableException. If a Map was created using
* java.util.Collections.unmodifiableMap(Map), this method must throw
* PropertyNotWritableException. Unfortunately, there is no Collections API method to detect
* this. However, an implementation can create a prototype unmodifiable Map and query its
* runtime type to see if it matches the runtime type of the base object as a workaround.
* PropertyNotWritableException. Unfortunately, there is no Collections API
* method to detect this. However, an implementation can create a prototype
* unmodifiable Map and query its runtime type to see if it matches the
* runtime type of the base object as a workaround.
*
* @param context
* The context of this evaluation.
* @param base
* The map to analyze. Only bases of type Map are handled by this resolver.
* The map to analyze. Only bases of type Map are handled by this
* resolver.
* @param property
* The key to return the acceptable type for. Ignored by this resolver.
* The key to return the acceptable type for. Ignored by this
* resolver.
* @param value
* The value to be associated with the specified key.
* @throws ClassCastException
* if the class of the specified key or value prevents it from being stored in this
* map.
* if the class of the specified key or value prevents it from
* being stored in this map.
* @throws NullPointerException
* if context is null, or if this map does not permit null keys or values, and the
* specified key or value is null.
* if context is null, or if this map does not permit null keys
* or values, and the specified key or value is null.
* @throws IllegalArgumentException
* if some aspect of this key or value prevents it from being stored in this map.
* if some aspect of this key or value prevents it from being
* stored in this map.
* @throws PropertyNotWritableException
* if this resolver was constructed in read-only mode, or if the put operation is
* not supported by the underlying map.
* if this resolver was constructed in read-only mode, or if the
* put operation is not supported by the underlying map.
* @throws ELException
* if an exception was thrown while performing the property or variable resolution.
* The thrown exception must be included as the cause property of this exception, if
* available.
* if an exception was thrown while performing the property or
* variable resolution. The thrown exception must be included as
* the cause property of this exception, if available.
*/
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
......@@ -323,7 +362,8 @@ public class JsonNodeELResolver extends ELResolver {
* @param base
* The bean to analyze.
* @param property
* The name of the property to analyze. Will be coerced to a String.
* The name of the property to analyze. Will be coerced to a
* String.
* @return base != null
*/
private final boolean isResolvable(Object base) {
......
......@@ -14,21 +14,28 @@ package org.activiti.engine.impl.el;
import java.beans.FeatureDescriptor;
import java.util.Iterator;
import java.util.List;
import javax.el.ELContext;
import javax.el.ELResolver;
import org.activiti.engine.delegate.VariableScope;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.identity.Authentication;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.impl.persistence.entity.TaskEntity;
import org.activiti.engine.impl.persistence.entity.VariableInstance;
import com.fasterxml.jackson.databind.JsonNode;
/**
* Implementation of an {@link ELResolver} that resolves expressions with the process variables of a given {@link VariableScope} as context. <br>
* Also exposes the currently logged in username to be used in expressions (if any)
* Implementation of an {@link ELResolver} that resolves expressions with the
* process variables of a given {@link VariableScope} as context. <br>
* Also exposes the currently logged in username to be used in expressions (if
* any)
*
*
*
*/
public class VariableScopeElResolver extends ELResolver {
......@@ -42,12 +49,15 @@ public class VariableScopeElResolver extends ELResolver {
this.variableScope = variableScope;
}
@Override
public Object getValue(ELContext context, Object base, Object property) {
if (base == null) {
String variable = (String) property; // according to javadoc, can only be a String
String variable = (String) property; // according to javadoc, can
// only be a String
if ((EXECUTION_KEY.equals(property) && variableScope instanceof ExecutionEntity) || (TASK_KEY.equals(property) && variableScope instanceof TaskEntity)) {
if ((EXECUTION_KEY.equals(property) && variableScope instanceof ExecutionEntity)
|| (TASK_KEY.equals(property) && variableScope instanceof TaskEntity)) {
context.setPropertyResolved(true);
return variableScope;
} else if (EXECUTION_KEY.equals(property) && variableScope instanceof TaskEntity) {
......@@ -58,8 +68,20 @@ public class VariableScopeElResolver extends ELResolver {
return Authentication.getAuthenticatedUserId();
} else {
if (variableScope.hasVariable(variable)) {
context.setPropertyResolved(true); // if not set, the next elResolver in the CompositeElResolver will be called
return variableScope.getVariable(variable);
context.setPropertyResolved(true); // if not set, the next
// elResolver in the
// CompositeElResolver
// will be called
VariableInstance variableInstance = variableScope.getVariableInstance(variable);
Object value = variableInstance.getValue();
if (("json".equals(variableInstance.getTypeName())
|| "longJson".equals(variableInstance.getTypeName())) && (value instanceof JsonNode)
&& ((JsonNode) value).isArray()) {
return Context.getProcessEngineConfiguration().getObjectMapper().convertValue(value,
List.class);
} else {
return value;
}
}
}
}
......@@ -71,6 +93,7 @@ public class VariableScopeElResolver extends ELResolver {
return null;
}
@Override
public boolean isReadOnly(ELContext context, Object base, Object property) {
if (base == null) {
String variable = (String) property;
......@@ -79,6 +102,7 @@ public class VariableScopeElResolver extends ELResolver {
return true;
}
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
if (base == null) {
String variable = (String) property;
......@@ -88,14 +112,17 @@ public class VariableScopeElResolver extends ELResolver {
}
}
@Override
public Class<?> getCommonPropertyType(ELContext arg0, Object arg1) {
return Object.class;
}
@Override
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext arg0, Object arg1) {
return null;
}
@Override
public Class<?> getType(ELContext arg0, Object arg1, Object arg2) {
return Object.class;
}
......
package org.activiti.engine.test.json;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import org.activiti.engine.history.HistoricTaskInstance;
import org.activiti.engine.impl.test.ResourceActivitiTestCase;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.IdentityLink;
import org.activiti.engine.task.Task;
import org.activiti.engine.test.Deployment;
import org.activiti.examples.variables.SomeSerializable;
public class SerializePOJOJsonTest extends ResourceActivitiTestCase {
public SerializePOJOJsonTest() {
super("org/activiti/standalone/cfg/variable/custom-serialize-variables-activiti.cfg.xml");
}
@Deployment
public void testJsonVarInExpression() throws Exception {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<String, Object>();
map.put("assignee", "salaboy");
map.put("category", "test");
Map<String, Object> mapInMap = new HashMap<String, Object>();
mapInMap.put("user", "salaboy");
map.put("mapInMap", mapInMap);
vars.put("userMap", map);
List<String> list = Arrays.asList("salaboy", "salaboy", "salaboy");
vars.put("userCollection", list);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testJsonVarInExpression", vars);
String taskId = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId();
taskService.complete(taskId);
taskId = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId();
taskService.getIdentityLinksForTask(taskId).stream().forEach(new Consumer<IdentityLink>() {
@Override
public void accept(IdentityLink i) {
if ("candidate".equals(i.getType()) ) {
assertEquals("salaboy", i.getUserId());
}
}
});
taskService.complete(taskId);
HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
assertEquals("salaboy", task.getAssignee());
assertEquals("test", task.getCategory());
}
@Deployment
public void testCollectionJsonVarInExpression() throws Exception {
Map<String, Object> vars = new HashMap<String, Object>();
List<String> list = Arrays.asList("salaboy", "salaboy", "salaboy");
vars.put("userCollection", list);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testCollectionJsonVarInExpression", vars);
String taskId = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId();
taskService.complete(taskId);
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertEquals(3, tasks.size());
tasks.forEach(task -> taskService.complete(task.getId()));
}
@Deployment
public void testCollectionInJsonVarInExpression() throws Exception {
Map<String, Object> vars = new HashMap<String, Object>();
List<String> list = Arrays.asList("salaboy", "salaboy", "salaboy");
Map<String, Object> map = new HashMap<String, Object>();
map.put("userCollection", list);
vars.put("userMap", map);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testCollectionInJsonVarInExpression", vars);
String taskId = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId();
taskService.complete(taskId);
taskService.createTaskQuery().processInstanceId(processInstance.getId()).list().forEach(task -> taskService.complete(task.getId()));
vars = new HashMap<String, Object>();
List<SomeSerializable> beanList = Arrays.asList(new SomeSerializable("salaboy"), new SomeSerializable("salaboy"), new SomeSerializable("salaboy"));
map = new HashMap<String, Object>();
map.put("userCollection", beanList);
vars.put("userMap", map);
processInstance = runtimeService.startProcessInstanceByKey("testCollectionInJsonVarInExpression", vars);
taskId = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId();
taskService.complete(taskId);
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertEquals(3, tasks.size());
tasks.forEach(task -> taskService.complete(task.getId()));
}
@Deployment
public void testPOJOCollectionInJsonVarInExpression() throws Exception {
Map<String, Object> vars = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<String, Object>();
vars = new HashMap<String, Object>();
List<SomeSerializable> beanList = Arrays.asList(new SomeSerializable("salaboy"), new SomeSerializable("salaboy"), new SomeSerializable("salaboy"));
map = new HashMap<String, Object>();
map.put("userCollection", beanList);
vars.put("userMap", map);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testPOJOCollectionInJsonVarInExpression", vars);
String taskId = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult().getId();
taskService.complete(taskId);
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processInstance.getId()).list();
assertEquals(3, tasks.size());
tasks.forEach(task -> taskService.complete(task.getId()));
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="Examples">
<process id="testCollectionInJsonVarInExpression" name="Test Collection In Json Var In Expression" isExecutable="true">
<startEvent id="theStart"></startEvent>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="userTask"></sequenceFlow>
<userTask id="userTask"></userTask>
<endEvent id="theEndSuccess"></endEvent>
<userTask id="usertask1" name="User Task">
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${userMap.userCollection}"></multiInstanceLoopCharacteristics>
</userTask>
<sequenceFlow id="flow2" sourceRef="userTask" targetRef="usertask1"></sequenceFlow>
<sequenceFlow id="flow3" sourceRef="usertask1" targetRef="theEndSuccess"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_testCollectionInJsonVarInExpression">
<bpmndi:BPMNPlane bpmnElement="testCollectionInJsonVarInExpression" id="BPMNPlane_testCollectionInJsonVarInExpression">
<bpmndi:BPMNShape bpmnElement="theStart" id="BPMNShape_theStart">
<omgdc:Bounds height="35.0" width="35.0" x="70.0" y="95.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="userTask" id="BPMNShape_userTask">
<omgdc:Bounds height="60.0" width="100.0" x="170.0" y="83.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="theEndSuccess" id="BPMNShape_theEndSuccess">
<omgdc:Bounds height="35.0" width="35.0" x="490.0" y="95.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="55.0" width="105.0" x="310.0" y="85.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="105.0" y="112.0"></omgdi:waypoint>
<omgdi:waypoint x="170.0" y="113.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="270.0" y="113.0"></omgdi:waypoint>
<omgdi:waypoint x="310.0" y="112.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="415.0" y="112.0"></omgdi:waypoint>
<omgdi:waypoint x="490.0" y="112.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="Examples">
<process id="testCollectionJsonVarInExpression" name="Test Collection Json Var In Expression" isExecutable="true">
<startEvent id="theStart"></startEvent>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="userTask"></sequenceFlow>
<userTask id="userTask"></userTask>
<endEvent id="theEndSuccess"></endEvent>
<userTask id="usertask1" name="User Task">
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${userCollection}"></multiInstanceLoopCharacteristics>
</userTask>
<sequenceFlow id="flow2" sourceRef="userTask" targetRef="usertask1"></sequenceFlow>
<sequenceFlow id="flow3" sourceRef="usertask1" targetRef="theEndSuccess"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_testCollectionJsonVarInExpression">
<bpmndi:BPMNPlane bpmnElement="testCollectionJsonVarInExpression" id="BPMNPlane_testCollectionJsonVarInExpression">
<bpmndi:BPMNShape bpmnElement="theStart" id="BPMNShape_theStart">
<omgdc:Bounds height="35.0" width="35.0" x="70.0" y="95.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="userTask" id="BPMNShape_userTask">
<omgdc:Bounds height="60.0" width="100.0" x="170.0" y="83.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="theEndSuccess" id="BPMNShape_theEndSuccess">
<omgdc:Bounds height="35.0" width="35.0" x="490.0" y="95.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="55.0" width="105.0" x="310.0" y="85.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="105.0" y="112.0"></omgdi:waypoint>
<omgdi:waypoint x="170.0" y="113.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="270.0" y="113.0"></omgdi:waypoint>
<omgdi:waypoint x="310.0" y="112.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="415.0" y="112.0"></omgdi:waypoint>
<omgdi:waypoint x="490.0" y="112.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="Examples">
<process id="testJsonVarInExpression" name="Test Json Var In Expression" isExecutable="true">
<startEvent id="theStart"></startEvent>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="userTask"></sequenceFlow>
<userTask id="userTask"></userTask>
<endEvent id="theEndSuccess"></endEvent>
<userTask id="usertask1" name="User Task" activiti:assignee="${userMap.assignee}" activiti:candidateUsers="${userMap.mapInMap.user}" activiti:category="${userMap.category}"></userTask>
<sequenceFlow id="flow2" sourceRef="userTask" targetRef="usertask1"></sequenceFlow>
<sequenceFlow id="flow3" sourceRef="usertask1" targetRef="theEndSuccess"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_testJsonVarInExpression">
<bpmndi:BPMNPlane bpmnElement="testJsonVarInExpression" id="BPMNPlane_testJsonVarInExpression">
<bpmndi:BPMNShape bpmnElement="theStart" id="BPMNShape_theStart">
<omgdc:Bounds height="35.0" width="35.0" x="70.0" y="95.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="userTask" id="BPMNShape_userTask">
<omgdc:Bounds height="60.0" width="100.0" x="170.0" y="83.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="theEndSuccess" id="BPMNShape_theEndSuccess">
<omgdc:Bounds height="35.0" width="35.0" x="490.0" y="95.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="55.0" width="105.0" x="310.0" y="85.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="105.0" y="112.0"></omgdi:waypoint>
<omgdi:waypoint x="170.0" y="113.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="270.0" y="113.0"></omgdi:waypoint>
<omgdi:waypoint x="310.0" y="112.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="415.0" y="112.0"></omgdi:waypoint>
<omgdi:waypoint x="490.0" y="112.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="Examples">
<process id="testPOJOCollectionInJsonVarInExpression" name="Test POJO Collection In Json Var In Expression" isExecutable="true">
<startEvent id="theStart"></startEvent>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="userTask"></sequenceFlow>
<userTask id="userTask"></userTask>
<endEvent id="theEndSuccess"></endEvent>
<userTask id="usertask1" name="User Task" activiti:assignee="${userMap.userCollection.get(0).value}">
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${userMap.userCollection}"></multiInstanceLoopCharacteristics>
</userTask>
<sequenceFlow id="flow2" sourceRef="userTask" targetRef="usertask1"></sequenceFlow>
<sequenceFlow id="flow3" sourceRef="usertask1" targetRef="theEndSuccess"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_testPOJOCollectionInJsonVarInExpression">
<bpmndi:BPMNPlane bpmnElement="testPOJOCollectionInJsonVarInExpression" id="BPMNPlane_testPOJOCollectionInJsonVarInExpression">
<bpmndi:BPMNShape bpmnElement="theStart" id="BPMNShape_theStart">
<omgdc:Bounds height="35.0" width="35.0" x="70.0" y="95.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="userTask" id="BPMNShape_userTask">
<omgdc:Bounds height="60.0" width="100.0" x="170.0" y="83.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="theEndSuccess" id="BPMNShape_theEndSuccess">
<omgdc:Bounds height="35.0" width="35.0" x="490.0" y="95.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="55.0" width="105.0" x="310.0" y="85.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="105.0" y="112.0"></omgdi:waypoint>
<omgdi:waypoint x="170.0" y="113.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="270.0" y="113.0"></omgdi:waypoint>
<omgdi:waypoint x="310.0" y="112.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="415.0" y="112.0"></omgdi:waypoint>
<omgdi:waypoint x="490.0" y="112.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="processEngineConfiguration" class="org.activiti.engine.impl.cfg.StandaloneProcessEngineConfiguration">
<property name="jdbcUrl" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000;MVCC=TRUE" />
<property name="jdbcDriver" value="org.h2.Driver" />
<property name="jdbcUsername" value="sa" />
<property name="jdbcPassword" value="" />
<!-- Database configurations -->
<property name="databaseSchemaUpdate" value="drop-create" />
<!-- Test logger -->
<!-- <property name="configurators">
<list>
<bean class="org.activiti.engine.test.impl.logger.ProcessExecutionLoggerConfigurator" />
</list>
</property> -->
<!-- job executor configurations -->
<property name="asyncExecutor" ref="asyncExecutor" />
<property name="asyncExecutorActivate" value="true" />
<property name="asyncFailedJobWaitTime" value="1" />
<!-- mail server configurations -->
<property name="mailServerPort" value="5025" />
<property name="mailServers">
<map>
<entry key="myEmailTenant">
<bean class="org.activiti.engine.cfg.MailServerInfo">
<property name="mailServerHost" value="localhost" />
<property name="mailServerPort" value="5025" />
<property name="mailServerUseSSL" value="false" />
<property name="mailServerUseTLS" value="false" />
<property name="mailServerDefaultFrom" value="activiti@myTenant.com" />
<property name="mailServerUsername" value="activiti@myTenant.com" />
<property name="mailServerPassword" value="password" />
</bean>
</entry>
</map>
</property>
<property name="history" value="full" />
<property name="enableProcessDefinitionInfoCache" value="true" />
<property name="serializePOJOsInVariablesToJson" value="true" />
</bean>
<bean id="asyncExecutor" class="org.activiti.engine.impl.asyncexecutor.DefaultAsyncJobExecutor">
<property name="defaultAsyncJobAcquireWaitTimeInMillis" value="1000" />
<property name="defaultTimerJobAcquireWaitTimeInMillis" value="1000" />
</bean>
</beans>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册