Package org.activiti.engine.repository

Examples of org.activiti.engine.repository.ProcessDefinition


        List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery()
                .processDefinitionKey("waiter")
                .list();
        Assert.assertNotNull(processDefinitionList);
        Assert.assertTrue(!processDefinitionList.isEmpty());
        ProcessDefinition processDefinition = processDefinitionList.iterator().next();
        Assert.assertEquals(processDefinition.getKey(), "waiter");
    }
View Full Code Here


     
      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());
     
      // Test using latest without key -> not allowed
      url = baseUrl + "?latest=true&name=anyname";
      HttpGet httpGet = new HttpGet(SERVER_URL_PREFIX + url);
      closeResponse(executeRequest(httpGet, HttpStatus.SC_BAD_REQUEST));
View Full Code Here

  /**
   * Returns the {@link ProcessDefinition} that is requested. Throws the right exceptions
   * when bad request was made or definition is not found.
   */
  protected ProcessDefinition getProcessDefinitionFromRequest(String processDefinitionId) {
    ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processDefinitionId);
  
    if (processDefinition == null) {
      throw new ActivitiObjectNotFoundException("Could not find a process definition with id '" + processDefinitionId + "'.", ProcessDefinition.class);
    }
    return processDefinition;
View Full Code Here

public class ProcessDefinitionIdentityLinkCollectionResource extends BaseProcessDefinitionResource {

  @RequestMapping(value="/repository/process-definitions/{processDefinitionId}/identitylinks", method = RequestMethod.GET, produces = "application/json")
  public List<RestIdentityLink> getIdentityLinks(@PathVariable String processDefinitionId, HttpServletRequest request) {
    List<RestIdentityLink> result = new ArrayList<RestIdentityLink>();
    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/repository/process-definitions/"));
   
    List<IdentityLink> identityLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
    for (IdentityLink link : identityLinks) {
      result.add(restResponseFactory.createRestIdentityLink(link, serverRootUrl));
    }
    return result;
  }
View Full Code Here

 
  @RequestMapping(value="/repository/process-definitions/{processDefinitionId}/identitylinks", method = RequestMethod.POST, produces = "application/json")
  public RestIdentityLink createIdentityLink(@PathVariable String processDefinitionId, @RequestBody RestIdentityLink identityLink,
      HttpServletRequest request, HttpServletResponse response) {
   
    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
   
    if (identityLink.getGroup() == null && identityLink.getUser() == null) {
      throw new ActivitiIllegalArgumentException("A group or a user is required to create an identity link.");
    }
   
    if (identityLink.getGroup() != null && identityLink.getUser() != null) {
      throw new ActivitiIllegalArgumentException("Only one of user or group can be used to create an identity link.");
    }
   
    if (identityLink.getGroup() != null) {
      repositoryService.addCandidateStarterGroup(processDefinition.getId(), identityLink.getGroup());
    } else {
      repositoryService.addCandidateStarterUser(processDefinition.getId(), identityLink.getUser());
    }
   
    // Always candidate for process-definition. User-provided value is ignored
    identityLink.setType(IdentityLinkType.CANDIDATE);
   
    response.setStatus(HttpStatus.CREATED.value());
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/repository/process-definitions/"));
   
    return restResponseFactory.createRestIdentityLink(identityLink.getType(), identityLink.getUser(), identityLink.getGroup(), null,
        processDefinition.getId(), null, serverRootUrl);
  }
View Full Code Here

@RestController
public class ProcessDefinitionImageResource extends BaseProcessDefinitionResource {

  @RequestMapping(value="/repository/process-definitions/{processDefinitionId}/image", method = RequestMethod.GET, produces="image/png")
  public @ResponseBody byte[] getModelResource(@PathVariable String processDefinitionId) {
    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
    InputStream imageStream = repositoryService.getProcessDiagram(processDefinition.getId());
    try {
      return IOUtils.toByteArray(imageStream);
    } catch(Exception e) {
      throw new ActivitiException("Error reading image stream", e);
    }
View Full Code Here

  @RequestMapping(value="/repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}", method = RequestMethod.GET, produces = "application/json")
  public RestIdentityLink getIdentityLink(@PathVariable("processDefinitionId") String processDefinitionId, @PathVariable("family") String family,
      @PathVariable("identityId") String identityId, HttpServletRequest request) {
   
    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);

    validateIdentityLinkArguments(family, identityId);

    // Check if identitylink to get exists
    IdentityLink link = getIdentityLink(family, identityId, processDefinition.getId());
   
    String serverRootUrl = request.getRequestURL().toString();
    serverRootUrl = serverRootUrl.substring(0, serverRootUrl.indexOf("/repository/process-definitions/"));
   
    return restResponseFactory.createRestIdentityLink(link, serverRootUrl);
View Full Code Here

  @RequestMapping(value="/repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}", method = RequestMethod.DELETE)
  public void deleteIdentityLink(@PathVariable("processDefinitionId") String processDefinitionId, @PathVariable("family") String family,
      @PathVariable("identityId") String identityId, HttpServletResponse response) {
   
    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);

    validateIdentityLinkArguments(family, identityId);

    // Check if identitylink to delete exists
    IdentityLink link = getIdentityLink(family, identityId, processDefinition.getId());
    if (link.getUserId() != null) {
      repositoryService.deleteCandidateStarterUser(processDefinition.getId(), link.getUserId());
    } else {
      repositoryService.deleteCandidateStarterGroup(processDefinition.getId(), link.getGroupId());
    }
   
    response.setStatus(HttpStatus.NO_CONTENT.value());
  }
View Full Code Here

public class ProcessInstanceSuspensionTest extends PluggableActivitiTestCase {

  @Deployment(resources={"org/activiti/engine/test/db/oneJobProcess.bpmn20.xml"})
  public void testJobsNotVisisbleToAcquisitionIfInstanceSuspended() {
   
    ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().singleResult();   
    ProcessInstance pi = runtimeService.startProcessInstanceByKey(pd.getKey());
   
    // now there is one job:
    // now there is one job:
    Job job = managementService.createJobQuery().singleResult();
    assertNotNull(job);
View Full Code Here

  }
 
  @Deployment(resources={"org/activiti/engine/test/db/oneJobProcess.bpmn20.xml"})
  public void testJobsNotVisisbleToAcquisitionIfDefinitionSuspended() {
   
    ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().singleResult();   
    runtimeService.startProcessInstanceByKey(pd.getKey());   
    // now there is one job:
    Job job = managementService.createJobQuery()
      .singleResult();
    assertNotNull(job);
   
    makeSureJobDue(job);
       
    // the acquirejobs command sees the job:
    AcquiredJobEntities acquiredJobs = executeAcquireJobsCommand();
    assertEquals(1, acquiredJobs.size());
   
    // suspend the process instance:
    repositoryService.suspendProcessDefinitionById(pd.getId());
   
    // now, the acquirejobs command does not see the job:
    acquiredJobs = executeAcquireJobsCommand();
    assertEquals(0, acquiredJobs.size());
  }
View Full Code Here

TOP

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

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.