Search in sources :

Example 26 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class BlueprintBasicTest method exportedServices.

@Test
public void exportedServices() throws Exception {
    assertNotNull(processEngine);
    assertNotNull(repositoryService);
    // wait for deployment to be done
    Thread.sleep(5000);
    Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
    assertEquals("org.activiti.osgi.example", deployment.getName());
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
    assertEquals("osgiProcess", processDefinition.getKey());
}
Also used : Deployment(org.activiti.engine.repository.Deployment) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 27 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class EventJavaTest method testStartEventWithExecutionListener.

public void testStartEventWithExecutionListener() throws Exception {
    BpmnModel bpmnModel = new BpmnModel();
    Process process = new Process();
    process.setId("simpleProcess");
    process.setName("Very simple process");
    bpmnModel.getProcesses().add(process);
    StartEvent startEvent = new StartEvent();
    startEvent.setId("startEvent1");
    TimerEventDefinition timerDef = new TimerEventDefinition();
    timerDef.setTimeDuration("PT5M");
    startEvent.getEventDefinitions().add(timerDef);
    ActivitiListener listener = new ActivitiListener();
    listener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION);
    listener.setImplementation("${test}");
    listener.setEvent("end");
    startEvent.getExecutionListeners().add(listener);
    process.addFlowElement(startEvent);
    UserTask task = new UserTask();
    task.setId("reviewTask");
    task.setAssignee("kermit");
    process.addFlowElement(task);
    SequenceFlow flow1 = new SequenceFlow();
    flow1.setId("flow1");
    flow1.setSourceRef("startEvent1");
    flow1.setTargetRef("reviewTask");
    process.addFlowElement(flow1);
    EndEvent endEvent = new EndEvent();
    endEvent.setId("endEvent1");
    process.addFlowElement(endEvent);
    byte[] xml = new BpmnXMLConverter().convertToXML(bpmnModel);
    new BpmnXMLConverter().validateModel(new InputStreamSource(new ByteArrayInputStream(xml)));
    Deployment deployment = repositoryService.createDeployment().name("test").addString("test.bpmn20.xml", new String(xml)).deploy();
    repositoryService.deleteDeployment(deployment.getId());
}
Also used : SequenceFlow(org.activiti.bpmn.model.SequenceFlow) UserTask(org.activiti.bpmn.model.UserTask) Deployment(org.activiti.engine.repository.Deployment) Process(org.activiti.bpmn.model.Process) ActivitiListener(org.activiti.bpmn.model.ActivitiListener) BpmnModel(org.activiti.bpmn.model.BpmnModel) BpmnXMLConverter(org.activiti.bpmn.converter.BpmnXMLConverter) InputStreamSource(org.activiti.engine.impl.util.io.InputStreamSource) ByteArrayInputStream(java.io.ByteArrayInputStream) StartEvent(org.activiti.bpmn.model.StartEvent) EndEvent(org.activiti.bpmn.model.EndEvent) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 28 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class SerializableVariablesDiabledTest method removeUsers.

@After
public void removeUsers() {
    identityService.deleteMembership(testUserId, testGroupId);
    identityService.deleteGroup(testGroupId);
    identityService.deleteUser(testUserId);
    for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
        repositoryService.deleteDeployment(deployment.getId(), true);
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment) After(org.junit.After)

Example 29 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class ProcessDefinitionCollectionResourceTest method testGetProcessDefinitions.

/**
  * Test getting process definitions.
  * GET repository/process-definitions
  */
public void testGetProcessDefinitions() throws Exception {
    try {
        Deployment firstDeployment = repositoryService.createDeployment().name("Deployment 1").addClasspathResource("org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml").deploy();
        Deployment secondDeployment = repositoryService.createDeployment().name("Deployment 2").addClasspathResource("org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml").addClasspathResource("org/activiti/rest/service/api/repository/twoTaskProcess.bpmn20.xml").deploy();
        Deployment thirdDeployment = repositoryService.createDeployment().name("Deployment 3").addClasspathResource("org/activiti/rest/service/api/repository/oneTaskProcessWithDi.bpmn20.xml").deploy();
        ProcessDefinition oneTaskProcess = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskProcess").deploymentId(firstDeployment.getId()).singleResult();
        ProcessDefinition latestOneTaskProcess = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskProcess").deploymentId(secondDeployment.getId()).singleResult();
        ProcessDefinition twoTaskprocess = repositoryService.createProcessDefinitionQuery().processDefinitionKey("twoTaskProcess").deploymentId(secondDeployment.getId()).singleResult();
        ProcessDefinition oneTaskWithDiProcess = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskProcessWithDi").deploymentId(thirdDeployment.getId()).singleResult();
        // Test parameterless call
        String baseUrl = RestUrls.createRelativeResourceUrl(RestUrls.URL_PROCESS_DEFINITION_COLLECTION);
        assertResultsPresentInDataResponse(baseUrl, oneTaskProcess.getId(), twoTaskprocess.getId(), latestOneTaskProcess.getId(), oneTaskWithDiProcess.getId());
        // Verify ACT-2141 Persistent isGraphicalNotation flag for process definitions
        CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + baseUrl), HttpStatus.SC_OK);
        JsonNode dataNode = objectMapper.readTree(response.getEntity().getContent()).get("data");
        closeResponse(response);
        for (int i = 0; i < dataNode.size(); i++) {
            JsonNode processDefinitionJson = dataNode.get(i);
            String key = processDefinitionJson.get("key").asText();
            JsonNode graphicalNotationNode = processDefinitionJson.get("graphicalNotationDefined");
            if (key.equals("oneTaskProcessWithDi")) {
                assertTrue(graphicalNotationNode.asBoolean());
            } else {
                assertFalse(graphicalNotationNode.asBoolean());
            }
        }
        // Verify
        // Test name filtering
        String url = baseUrl + "?name=" + encode("The Two Task Process");
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
        // Test nameLike filtering
        url = baseUrl + "?nameLike=" + encode("The Two%");
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
        // Test key filtering
        url = baseUrl + "?key=twoTaskProcess";
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
        // Test returning multiple versions for the same key
        url = baseUrl + "?key=oneTaskProcess";
        assertResultsPresentInDataResponse(url, oneTaskProcess.getId(), latestOneTaskProcess.getId());
        // Test keyLike filtering
        url = baseUrl + "?keyLike=" + encode("two%");
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
        // Test category filtering
        url = baseUrl + "?category=TwoTaskCategory";
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
        // Test categoryLike filtering
        url = baseUrl + "?categoryLike=" + encode("Two%");
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
        // Test categoryNotEquals filtering
        url = baseUrl + "?categoryNotEquals=OneTaskCategory";
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId(), oneTaskWithDiProcess.getId());
        // Test resourceName filtering
        url = baseUrl + "?resourceName=org/activiti/rest/service/api/repository/twoTaskProcess.bpmn20.xml";
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
        // Test resourceNameLike filtering
        url = baseUrl + "?resourceNameLike=" + encode("%twoTaskProcess%");
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
        // Test version filtering
        url = baseUrl + "?version=2";
        assertResultsPresentInDataResponse(url, latestOneTaskProcess.getId());
        // Test latest filtering
        url = baseUrl + "?latest=true";
        assertResultsPresentInDataResponse(url, latestOneTaskProcess.getId(), twoTaskprocess.getId(), oneTaskWithDiProcess.getId());
        url = baseUrl + "?latest=false";
        assertResultsPresentInDataResponse(baseUrl, oneTaskProcess.getId(), twoTaskprocess.getId(), latestOneTaskProcess.getId(), oneTaskWithDiProcess.getId());
        // Test deploymentId
        url = baseUrl + "?deploymentId=" + secondDeployment.getId();
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId(), latestOneTaskProcess.getId());
        // Test startableByUser
        url = baseUrl + "?startableByUser=kermit";
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
        // Test suspended
        repositoryService.suspendProcessDefinitionById(twoTaskprocess.getId());
        url = baseUrl + "?suspended=true";
        assertResultsPresentInDataResponse(url, twoTaskprocess.getId());
        url = baseUrl + "?suspended=false";
        assertResultsPresentInDataResponse(url, latestOneTaskProcess.getId(), oneTaskProcess.getId(), oneTaskWithDiProcess.getId());
    } finally {
        // Always cleanup any created deployments, even if the test failed
        List<Deployment> deployments = repositoryService.createDeploymentQuery().list();
        for (Deployment deployment : deployments) {
            repositoryService.deleteDeployment(deployment.getId(), true);
        }
    }
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) Deployment(org.activiti.engine.repository.Deployment) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 30 with Deployment

use of org.activiti.engine.repository.Deployment in project midpoint by Evolveum.

the class ActivitiEngine method autoDeployResource.

private void autoDeployResource(Resource resource) throws IOException, XPathExpressionException {
    RepositoryService repositoryService = processEngine.getRepositoryService();
    URL url = resource.getURL();
    String name = url.toString();
    long resourceLastModified = resource.lastModified();
    LOGGER.debug("Checking resource " + name + " (last modified = " + new Date(resourceLastModified) + ")");
    boolean tooOld = false;
    List<Deployment> existingList = repositoryService.createDeploymentQuery().deploymentName(name).orderByDeploymenTime().desc().listPage(1, 1);
    Deployment existing = existingList != null && !existingList.isEmpty() ? existingList.get(0) : null;
    if (existing != null) {
        if (resourceLastModified >= existing.getDeploymentTime().getTime()) {
            tooOld = true;
        }
        LOGGER.debug("Found deployment " + existing.getName() + ", last modified " + existing.getDeploymentTime() + (tooOld ? " (too old)" : " (current)"));
    } else {
        LOGGER.debug("Deployment with name " + name + " was not found.");
    }
    if (existing == null || tooOld) {
        repositoryService.createDeployment().name(name).addInputStream(name, resource.getInputStream()).deploy();
        // + " as deployment with id = " + deployment.getId() + ", name = " + deployment.getName());
        LOGGER.info("Successfully deployed Activiti resource " + name);
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment) URL(java.net.URL) Date(java.util.Date)

Aggregations

Deployment (org.activiti.engine.repository.Deployment)66 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)12 BpmnModel (org.activiti.bpmn.model.BpmnModel)10 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 ActivitiException (org.activiti.engine.ActivitiException)7 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)6 HttpGet (org.apache.http.client.methods.HttpGet)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 InputStream (java.io.InputStream)3 HashSet (java.util.HashSet)3 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)3 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)3 ProcessEngine (org.activiti.engine.ProcessEngine)3 RuntimeService (org.activiti.engine.RuntimeService)3 DeploymentBuilder (org.activiti.engine.repository.DeploymentBuilder)3 Task (org.activiti.engine.task.Task)3