Search in sources :

Example 36 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class FormServiceRestOnlyIntegrationTest method testGetTaskFormTest.

@Test
public void testGetTaskFormTest() throws Exception {
    Map<String, Object> valuesMap = new HashMap<String, Object>();
    valuesMap.put(RestURI.CONTAINER_ID, CONTAINER_ID);
    valuesMap.put(RestURI.PROCESS_ID, HIRING_PROCESS_ID);
    Marshaller marshaller = MarshallerFactory.getMarshaller(marshallingFormat, ClassLoader.getSystemClassLoader());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("name", "john");
    // start process instance
    WebTarget clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + START_PROCESS_POST_URI, valuesMap));
    logger.info("[POST] " + clientRequest.getUri());
    response = clientRequest.request(getMediaType()).post(createEntity(marshaller.marshall(params)));
    Assert.assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Long result = response.readEntity(JaxbLong.class).unwrap();
    assertNotNull(result);
    // find tasks by process instance id
    valuesMap.put(RestURI.PROCESS_INST_ID, result);
    clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), QUERY_URI + "/" + TASK_BY_PROCESS_INST_ID_GET_URI, valuesMap));
    logger.info("[GET] " + clientRequest.getUri());
    response = clientRequest.request(getMediaType()).get();
    Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    TaskSummaryList taskSummaryList = marshaller.unmarshall(response.readEntity(String.class), TaskSummaryList.class);
    logger.debug("Form content is '{}'", taskSummaryList);
    assertNotNull(taskSummaryList);
    TaskSummary[] task = taskSummaryList.getTasks();
    assertEquals(1, task.length);
    Long taskId = task[0].getId();
    valuesMap.put(RestURI.TASK_INSTANCE_ID, taskId);
    changeUser(USER_JOHN, DEFAULT_PASSWORD);
    clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), FORM_URI + "/" + TASK_FORM_GET_URI, valuesMap));
    logger.info("[GET] " + clientRequest.getUri());
    response = clientRequest.request(getMediaType()).get();
    Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    String formdata = response.readEntity(String.class);
    logger.debug("Form content is '{}'", formdata);
    assertNotNull(formdata);
    assertFalse(formdata.isEmpty());
    clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + ABORT_PROCESS_INST_DEL_URI, valuesMap));
    logger.info("[DELETE] " + clientRequest.getUri());
    response = clientRequest.request().delete();
    int noContentStatusCode = Response.Status.NO_CONTENT.getStatusCode();
    int okStatusCode = Response.Status.OK.getStatusCode();
    assertTrue("Wrong status code returned: " + response.getStatus(), response.getStatus() == noContentStatusCode || response.getStatus() == okStatusCode);
}
Also used : Marshaller(org.kie.server.api.marshalling.Marshaller) HashMap(java.util.HashMap) JaxbLong(org.kie.server.api.model.type.JaxbLong) TaskSummary(org.kie.server.api.model.instance.TaskSummary) WebTarget(javax.ws.rs.client.WebTarget) JaxbLong(org.kie.server.api.model.type.JaxbLong) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) Test(org.junit.Test)

Example 37 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class CaseManagementRuntimeDataServiceBase method getCaseTasks.

public TaskSummaryList getCaseTasks(String caseId, String user, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    List<Status> actualStatus = safeTaskStatus(status);
    user = getUser(user);
    sort = safeTaskSummarySort(sort);
    Collection<TaskSummary> taskSummaries = caseRuntimeDataService.getCaseTasksAssignedAsPotentialOwner(caseId, user, actualStatus, ConvertUtils.buildQueryContext(page, pageSize, sort, sortOrder));
    TaskSummaryList tasks = ConvertUtils.convertToTaskSummaryList(taskSummaries);
    return tasks;
}
Also used : CaseStatus(org.jbpm.casemgmt.api.model.CaseStatus) Status(org.kie.api.task.model.Status) TaskSummary(org.kie.api.task.model.TaskSummary) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

Aggregations

TaskSummaryList (org.kie.server.api.model.instance.TaskSummaryList)37 HashMap (java.util.HashMap)14 ServiceResponse (org.kie.server.api.model.ServiceResponse)14 CommandScript (org.kie.server.api.commands.CommandScript)13 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)13 KieServerCommand (org.kie.server.api.model.KieServerCommand)13 TaskSummary (org.kie.api.task.model.TaskSummary)12 ApiOperation (io.swagger.annotations.ApiOperation)9 ApiResponses (io.swagger.annotations.ApiResponses)9 GET (javax.ws.rs.GET)9 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)9 Variant (javax.ws.rs.core.Variant)9 Header (org.kie.server.remote.rest.common.Header)9 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)9 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)9 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)9 Status (org.kie.api.task.model.Status)8 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)6 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)6