Search in sources :

Example 1 with RemoteMap

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;
}
Also used : QueryFilter(org.kie.internal.query.QueryFilter) RemoteMap(org.jbpm.services.ejb.remote.api.RemoteMap) TaskSummary(org.kie.api.task.model.TaskSummary) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 2 with RemoteMap

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;
}
Also used : RemoteMap(org.jbpm.services.ejb.remote.api.RemoteMap) RemoteObject(org.jbpm.services.ejb.remote.api.RemoteObject) HashMap(java.util.HashMap) RemoteObject(org.jbpm.services.ejb.remote.api.RemoteObject)

Aggregations

RemoteMap (org.jbpm.services.ejb.remote.api.RemoteMap)2 HashMap (java.util.HashMap)1 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)1 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)1 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)1 RemoteObject (org.jbpm.services.ejb.remote.api.RemoteObject)1 Test (org.junit.Test)1 TaskSummary (org.kie.api.task.model.TaskSummary)1 QueryFilter (org.kie.internal.query.QueryFilter)1