use of org.jbpm.services.ejb.remote.api.RemoteMap in project jbpm by kiegroup.
the class ClientProcessServiceWithCustomDataEJBTest method testStartProcessWithCustomData.
@Test
public void testStartProcessWithCustomData() {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
Map<String, Object> parameters = new RemoteMap();
Object person = getInstance("org.jbpm.test.Person", new Object[] { "john", 25, true });
parameters.put("person", person);
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "custom-data-project.work-on-custom-data", parameters);
assertNotNull(processInstanceId);
List<TaskSummary> taskSummaries = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter(0, 10));
assertNotNull(taskSummaries);
assertEquals(1, taskSummaries.size());
List<Long> tasks = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(tasks);
assertEquals(1, tasks.size());
Long taskId = tasks.get(0);
userTaskService.start(taskId, "john");
Map<String, Object> data = userTaskService.getTaskInputContentByTaskId(taskId);
assertNotNull(data);
Object fromTaskPerson = data.get("_person");
assertNotNull(fromTaskPerson);
assertEquals("john", getFieldValue(fromTaskPerson, "name"));
setFieldValue(fromTaskPerson, "name", "John Doe");
RemoteMap outcome = new RemoteMap();
outcome.put("person_", fromTaskPerson);
userTaskService.complete(taskId, "john", outcome);
ProcessInstanceDesc desc = runtimeDataService.getProcessInstanceById(processInstanceId);
assertNotNull(desc);
assertEquals(2, (int) desc.getState());
processInstanceId = null;
}
use of org.jbpm.services.ejb.remote.api.RemoteMap in project jbpm by kiegroup.
the class RemoteObjectProcessor method processRemoteObjects.
@SuppressWarnings("unchecked")
public static <T> T processRemoteObjects(T variables, ClassLoader cl) {
if (variables instanceof RemoteMap) {
RemoteMap remoteMap = ((RemoteMap) variables);
remoteMap.setClassLoader(cl);
Map<String, Object> data = new HashMap<String, Object>();
for (String key : remoteMap.keySet()) {
data.put(key, remoteMap.get(key));
}
return (T) data;
} else if (variables instanceof RemoteObject) {
((RemoteObject) variables).setClassLoader(cl);
return (T) ((RemoteObject) variables).get();
}
return null;
}
Aggregations