Package org.activiti.engine.repository

Examples of org.activiti.engine.repository.Deployment


  @Autowired
  protected RepositoryService repositoryService;
 
  @RequestMapping(value="/repository/deployments/{deploymentId}", method = RequestMethod.GET, produces = "application/json")
  public DeploymentResponse getDeployment(@PathVariable String deploymentId, HttpServletRequest request) {
    Deployment deployment = repositoryService.createDeploymentQuery()
            .deploymentId(deploymentId)
            .singleResult();
   
    if (deployment == null) {
      throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", Deployment.class);
View Full Code Here


  * GET repository/deployments/{deploymentId}/resources
  */
  public void testGetDeploymentResources() throws Exception {

    try {
      Deployment deployment = repositoryService.createDeployment().name("Deployment 1")
              .addClasspathResource("org/activiti/rest/service/api/repository/oneTaskProcess.bpmn20.xml")
              .addInputStream("test.txt", new ByteArrayInputStream("Test content".getBytes()))
              .deploy();
     
      HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX +
          RestUrls.createRelativeResourceUrl(RestUrls.URL_DEPLOYMENT_RESOURCES, deployment.getId()));
      CloseableHttpResponse response = executeRequest(httpGet, HttpStatus.SC_OK);
      JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent());
      closeResponse(response);
      assertTrue(responseNode.isArray());
      assertEquals(2, responseNode.size());
     
      // Since resources can be returned in any arbitrary order, find the right one to check
      JsonNode txtNode = null;
      for(int i=0; i< responseNode.size(); i++) {
        if("test.txt".equals(responseNode.get(i).get("id").textValue())) {
          txtNode = responseNode.get(i);
          break;
        }
      }
     
      // Check URL's for the resource
      assertNotNull(txtNode);
      assertTrue(txtNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(
              RestUrls.URL_DEPLOYMENT_RESOURCE, deployment.getId(), "test.txt")));
      assertTrue(txtNode.get("contentUrl").textValue().endsWith(RestUrls.createRelativeResourceUrl(
              RestUrls.URL_DEPLOYMENT_RESOURCE_CONTENT, deployment.getId(), "test.txt")));
      assertTrue(txtNode.get("mediaType").isNull());
      assertEquals("resource", txtNode.get("type").textValue());
     
    } 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);
      }
    }
  }
View Full Code Here

          .name("noCategory")
          .addClasspathResource("org/activiti/engine/test/repository/two.bpmn20.xml")
          .deploy()
          .getId();
     
      Deployment deploymentNoCategory = repositoryService.createDeploymentQuery().deploymentId(deploymentTwoNoCategory).singleResult();
      assertNull(deploymentNoCategory.getCategory());
     
      repositoryService.setDeploymentCategory(deploymentTwoNoCategory, "newCategory");
      deploymentNoCategory = repositoryService.createDeploymentQuery().deploymentId(deploymentTwoNoCategory).singleResult();
      assertEquals("newCategory", deploymentNoCategory.getCategory());

    } finally {
      if (noCategoryDeploymentId!=null) undeploy(noCategoryDeploymentId);
      if (deploymentOneId!=null) undeploy(deploymentOneId);
      if (deploymentTwoV1Id!=null) undeploy(deploymentTwoV1Id);
View Full Code Here

  @RequestMapping(value="/repository/deployments/{deploymentId}/resources/**", method = RequestMethod.GET, produces = "application/json")
  public DeploymentResourceResponse getDeploymentResource(@PathVariable("deploymentId") String deploymentId,
      HttpServletRequest request) {
   
    // Check if deployment exists
    Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
    if (deployment == null) {
      throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.");
    }
   
    String pathInfo = request.getPathInfo();
View Full Code Here

  protected RepositoryService repositoryService;

  @RequestMapping(value="/repository/deployments/{deploymentId}/resources", method = RequestMethod.GET, produces = "application/json")
  public List<DeploymentResourceResponse> getDeploymentResources(@PathVariable String deploymentId, HttpServletRequest request) {
    // Check if deployment exists
    Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
    if (deployment == null) {
      throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", Deployment.class);
    }
   
    List<String> resourceList = repositoryService.getDeploymentResourceNames(deploymentId);
View Full Code Here

    conversion.convert();
   
    // Deploy process

    BpmnModel bpmnModel = conversion.getBpmnModel();
    Deployment deployment = repositoryService.createDeployment()
      .addBpmnModel(bpmnModel.getProcesses().get(0).getName() + ".bpmn20.xml", bpmnModel)
      .deploy();
   
    // Fetch process definition id
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .deploymentId(deployment.getId()).singleResult();
    return new SimpleWorkflowSuccessResponse(processDefinition.getId());
  }
View Full Code Here

 
  /**
   * Test create, update and delete events of deployment entities.
   */
  public void testDeploymentEvents() throws Exception {
    Deployment deployment = null;
    try {
      listener.clearEventsReceived();
      deployment = repositoryService.createDeployment()
          .addClasspathResource("org/activiti/engine/test/api/runtime/oneTaskProcess.bpmn20.xml")
          .deploy();
      assertNotNull(deployment);
     
      // Check create-event
      assertEquals(2, listener.getEventsReceived().size());
      assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);
     
      ActivitiEntityEvent event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_CREATED, event.getType());
      assertEquals(deployment.getId(), ((Deployment) event.getEntity()).getId());
     
      assertTrue(listener.getEventsReceived().get(1) instanceof ActivitiEntityEvent);
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(1);
      assertEquals(ActivitiEventType.ENTITY_INITIALIZED, event.getType());
      assertEquals(deployment.getId(), ((Deployment) event.getEntity()).getId());
     
      listener.clearEventsReceived();
     
      // Check update event when category is updated
      repositoryService.setDeploymentCategory(deployment.getId(), "test");
      assertEquals(1, listener.getEventsReceived().size());
      assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_UPDATED, event.getType());
      assertEquals(deployment.getId(), ((Deployment) event.getEntity()).getId());
      assertEquals("test", ((Deployment) event.getEntity()).getCategory());
      listener.clearEventsReceived();
     
      // Check delete event when category is updated
      repositoryService.deleteDeployment(deployment.getId(), true);
      assertEquals(1, listener.getEventsReceived().size());
      assertTrue(listener.getEventsReceived().get(0) instanceof ActivitiEntityEvent);
     
      event = (ActivitiEntityEvent) listener.getEventsReceived().get(0);
      assertEquals(ActivitiEventType.ENTITY_DELETED, event.getType());
      assertEquals(deployment.getId(), ((Deployment) event.getEntity()).getId());
      listener.clearEventsReceived();
     
    } finally {
      if(deployment != null && repositoryService.createDeploymentQuery().deploymentId(deployment.getId()).count() > 0) {
        repositoryService.deleteDeployment(deployment.getId(), true);
      }
    }
  }
View Full Code Here

    assertEquals(1, query.list().size());
    assertEquals(1, query.count());
  }
 
  public void testByDeploymentId() {
    Deployment deployment = repositoryService.createDeployment().addString("test", "test").deploy();
   
    assertEquals(0, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
    assertEquals(0, repositoryService.createModelQuery().deployed().count());
    assertEquals(1, repositoryService.createModelQuery().notDeployed().count());
   
    Model model = repositoryService.createModelQuery().singleResult();
    model.setDeploymentId(deployment.getId());
    repositoryService.saveModel(model);
   
    assertEquals(1, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
    assertEquals(1, repositoryService.createModelQuery().deployed().count());
    assertEquals(0, repositoryService.createModelQuery().notDeployed().count());
   
    // Cleanup
    repositoryService.deleteDeployment(deployment.getId(), true);
   
    // After cleanup the model should still exist
    assertEquals(0, repositoryService.createDeploymentQuery().count());
    assertEquals(0, repositoryService.createModelQuery().deploymentId(deployment.getId()).count());
    assertEquals(1, repositoryService.createModelQuery().notDeployed().count());
    assertEquals(1, repositoryService.createModelQuery().count());
  }
View Full Code Here

    List<Deployment> deployments = repositoryService.createDeploymentQuery()
      .orderByDeploymentName()
      .asc()
      .list();
   
    Deployment deploymentOne = deployments.get(0);
    assertEquals("org/activiti/engine/test/repository/one.bpmn20.xml", deploymentOne.getName());
    assertEquals(deploymentOneId, deploymentOne.getId());

    Deployment deploymentTwo = deployments.get(1);
    assertEquals("org/activiti/engine/test/repository/two.bpmn20.xml", deploymentTwo.getName());
    assertEquals(deploymentTwoId, deploymentTwo.getId());
   
    deployments = repositoryService.createDeploymentQuery()
      .deploymentNameLike("%one%")
       .orderByDeploymentName()
      .asc()
View Full Code Here

*/
public class ProcessDefinitionCategoryTest extends PluggableActivitiTestCase {

 
  public void testQueryByCategoryNotEquals() {
    Deployment deployment = repositoryService.createDeployment()
      .addClasspathResource("org/activiti/engine/test/api/repository/processCategoryOne.bpmn20.xml")
      .addClasspathResource("org/activiti/engine/test/api/repository/processCategoryTwo.bpmn20.xml")
      .addClasspathResource("org/activiti/engine/test/api/repository/processCategoryThree.bpmn20.xml")
    .deploy();
   
    HashSet<String> processDefinitionNames = getProcessDefinitionNames(repositoryService.createProcessDefinitionQuery()
      .processDefinitionCategoryNotEquals("one")
      .list());
    HashSet<String> expectedProcessDefinitionNames = new HashSet<String>();
    expectedProcessDefinitionNames.add("processTwo");
    expectedProcessDefinitionNames.add("processThree");
    assertEquals(expectedProcessDefinitionNames, processDefinitionNames);
   
    processDefinitionNames = getProcessDefinitionNames(repositoryService.createProcessDefinitionQuery()
      .processDefinitionCategoryNotEquals("two")
      .list());
    expectedProcessDefinitionNames = new HashSet<String>();
    expectedProcessDefinitionNames.add("processOne");
    expectedProcessDefinitionNames.add("processThree");
    assertEquals(expectedProcessDefinitionNames, processDefinitionNames);
   
    repositoryService.deleteDeployment(deployment.getId());
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.repository.Deployment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.