Search in sources :

Example 1 with ProcessDefinitionMeta

use of org.activiti.cloud.services.api.model.ProcessDefinitionMeta in project activiti-cloud by Activiti.

the class ProcessDefinitionMetaResourceAssemblerTest method toResourceShouldReturnResourceWithSelfLinkContainingResourceId.

@Test
public void toResourceShouldReturnResourceWithSelfLinkContainingResourceId() {
    ProcessDefinitionMeta model = mock(ProcessDefinitionMeta.class);
    when(model.getId()).thenReturn("my-identifier");
    Resource<ProcessDefinitionMeta> resource = resourceAssembler.toResource(model);
    Link selfResourceLink = resource.getLink("self");
    assertThat(selfResourceLink).isNotNull();
    assertThat(selfResourceLink.getHref()).contains("my-identifier");
    Link metaResourceLink = resource.getLink("meta");
    assertThat(metaResourceLink).isNotNull();
    assertThat(metaResourceLink.getHref()).contains("my-identifier");
}
Also used : Link(org.springframework.hateoas.Link) ProcessDefinitionMeta(org.activiti.cloud.services.api.model.ProcessDefinitionMeta) Test(org.junit.jupiter.api.Test)

Example 2 with ProcessDefinitionMeta

use of org.activiti.cloud.services.api.model.ProcessDefinitionMeta in project activiti-cloud by Activiti.

the class ProcessDefinitionIT method shouldReturnProcessDefinitionMetadata.

@Test
public void shouldReturnProcessDefinitionMetadata() {
    // given
    ParameterizedTypeReference<ProcessDefinitionMeta> responseType = new ParameterizedTypeReference<ProcessDefinitionMeta>() {
    };
    ProcessDefinition aProcessDefinition = getProcessDefinition(PROCESS_WITH_VARIABLES_2);
    // when
    ResponseEntity<ProcessDefinitionMeta> entity = restTemplate.exchange(PROCESS_DEFINITIONS_URL + aProcessDefinition.getId() + "/meta", HttpMethod.GET, null, responseType);
    // then
    assertThat(entity).isNotNull();
    assertThat(entity.getBody()).isNotNull();
    assertThat(entity.getBody().getVariables()).hasSize(3);
    assertThat(entity.getBody().getUsers()).hasSize(4);
    assertThat(entity.getBody().getGroups()).hasSize(4);
    assertThat(entity.getBody().getUserTasks()).hasSize(2);
    assertThat(entity.getBody().getServiceTasks()).hasSize(2);
}
Also used : ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) CloudProcessDefinition(org.activiti.cloud.api.process.model.CloudProcessDefinition) ProcessDefinitionMeta(org.activiti.cloud.services.api.model.ProcessDefinitionMeta) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with ProcessDefinitionMeta

use of org.activiti.cloud.services.api.model.ProcessDefinitionMeta in project activiti-cloud by Activiti.

the class ProcessDefinitionIT method shouldReturnProcessDefinitionMetadataForPoolLane.

@Test
public void shouldReturnProcessDefinitionMetadataForPoolLane() {
    // given
    ParameterizedTypeReference<ProcessDefinitionMeta> responseType = new ParameterizedTypeReference<ProcessDefinitionMeta>() {
    };
    ProcessDefinition aProcessDefinition = getProcessDefinition(PROCESS_POOL_LANE);
    // when
    ResponseEntity<ProcessDefinitionMeta> entity = restTemplate.exchange(PROCESS_DEFINITIONS_URL + aProcessDefinition.getId() + "/meta", HttpMethod.GET, null, responseType);
    // then
    assertThat(entity).isNotNull();
    assertThat(entity.getBody()).isNotNull();
    assertThat(entity.getBody().getVariables()).hasSize(6);
    assertThat(entity.getBody().getUsers()).hasSize(4);
    assertThat(entity.getBody().getGroups()).hasSize(4);
    assertThat(entity.getBody().getUserTasks()).hasSize(3);
    assertThat(entity.getBody().getServiceTasks()).hasSize(3);
}
Also used : ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) ProcessDefinition(org.activiti.api.process.model.ProcessDefinition) CloudProcessDefinition(org.activiti.cloud.api.process.model.CloudProcessDefinition) ProcessDefinitionMeta(org.activiti.cloud.services.api.model.ProcessDefinitionMeta) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with ProcessDefinitionMeta

use of org.activiti.cloud.services.api.model.ProcessDefinitionMeta in project activiti-cloud by Activiti.

the class ProcessDefinitionMetaControllerImpl method getProcessDefinitionMetadata.

@Override
public Resource<ProcessDefinitionMeta> getProcessDefinitionMetadata(@PathVariable String id) {
    org.activiti.engine.repository.ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
    if (processDefinition == null) {
        throw new ActivitiObjectNotFoundException("Unable to find process definition for the given id:'" + id + "'");
    }
    List<Process> processes = repositoryService.getBpmnModel(id).getProcesses();
    Set<ProcessDefinitionVariable> variables = new HashSet<>();
    Set<String> users = new HashSet<>();
    Set<String> groups = new HashSet<>();
    Set<ProcessDefinitionUserTask> userTasks = new HashSet<>();
    Set<ProcessDefinitionServiceTask> serviceTasks = new HashSet<>();
    for (Process process : processes) {
        variables.addAll(getVariables(process));
        List<FlowElement> flowElementList = (List<FlowElement>) process.getFlowElements();
        for (FlowElement flowElement : flowElementList) {
            if (flowElement.getClass().equals(UserTask.class)) {
                UserTask userTask = (UserTask) flowElement;
                ProcessDefinitionUserTask task = new ProcessDefinitionUserTask(userTask.getName(), userTask.getDocumentation());
                userTasks.add(task);
                users.addAll(userTask.getCandidateUsers());
                groups.addAll(userTask.getCandidateGroups());
            }
            if (flowElement.getClass().equals(ServiceTask.class)) {
                ServiceTask serviceTask = (ServiceTask) flowElement;
                ProcessDefinitionServiceTask task = new ProcessDefinitionServiceTask(serviceTask.getName(), serviceTask.getImplementation());
                serviceTasks.add(task);
            }
        }
    }
    return resourceAssembler.toResource(new ProcessDefinitionMeta(processDefinition.getId(), processDefinition.getName(), processDefinition.getDescription(), processDefinition.getVersion(), users, groups, variables, userTasks, serviceTasks));
}
Also used : ProcessDefinitionServiceTask(org.activiti.cloud.services.api.model.ProcessDefinitionServiceTask) ServiceTask(org.activiti.bpmn.model.ServiceTask) ProcessDefinitionUserTask(org.activiti.cloud.services.api.model.ProcessDefinitionUserTask) UserTask(org.activiti.bpmn.model.UserTask) Process(org.activiti.bpmn.model.Process) ProcessDefinitionServiceTask(org.activiti.cloud.services.api.model.ProcessDefinitionServiceTask) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) ProcessDefinitionMeta(org.activiti.cloud.services.api.model.ProcessDefinitionMeta) ProcessDefinitionVariable(org.activiti.cloud.services.api.model.ProcessDefinitionVariable) FlowElement(org.activiti.bpmn.model.FlowElement) ProcessDefinitionUserTask(org.activiti.cloud.services.api.model.ProcessDefinitionUserTask) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet)

Aggregations

ProcessDefinitionMeta (org.activiti.cloud.services.api.model.ProcessDefinitionMeta)4 Test (org.junit.jupiter.api.Test)3 ProcessDefinition (org.activiti.api.process.model.ProcessDefinition)2 CloudProcessDefinition (org.activiti.cloud.api.process.model.CloudProcessDefinition)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 ParameterizedTypeReference (org.springframework.core.ParameterizedTypeReference)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 FlowElement (org.activiti.bpmn.model.FlowElement)1 Process (org.activiti.bpmn.model.Process)1 ServiceTask (org.activiti.bpmn.model.ServiceTask)1 UserTask (org.activiti.bpmn.model.UserTask)1 ProcessDefinitionServiceTask (org.activiti.cloud.services.api.model.ProcessDefinitionServiceTask)1 ProcessDefinitionUserTask (org.activiti.cloud.services.api.model.ProcessDefinitionUserTask)1 ProcessDefinitionVariable (org.activiti.cloud.services.api.model.ProcessDefinitionVariable)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 Link (org.springframework.hateoas.Link)1