Package org.activiti.engine.repository

Examples of org.activiti.engine.repository.ProcessDefinition


   
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    RepositoryService repositoryService = processEngine.getRepositoryService();
   
    // Fetch process definition
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
            .processDefinitionId(processDefinitionId).singleResult();
   
    // Report descriptin
    String reportDescription = "Average task duration report for process definition " + processDefinition.getName() + " ( version " + processDefinition.getVersion() + ")";
   
    // Script (just plain String for the moment)
    String script = "importPackage(java.sql);" +
                    "importPackage(java.lang);" +
                    "importPackage(org.activiti.explorer.reporting);" +
                    "" +
                    "var processDefinitionId = '" + processDefinitionId + "';" +
                    "" +
                    "var result = ReportingUtil.executeSelectSqlQuery(\"select NAME_, avg(DURATION_) from ACT_HI_TASKINST where PROC_DEF_ID_ = '"
                      + processDefinitionId + "' and END_TIME_ is not null group by NAME_\");" +
                    "" +
                    "var reportData = new ReportData();" +
                    "var dataset = reportData.newDataset();" +
                    "dataset.type = 'pieChart';" +
                    "dataset.description = '" + reportDescription + "';" +
                    "" +
                    "while (result.next()) { "+
                    "  var name = result.getString(1);" +
                    "  var val = result.getLong(2) / 1000;" +
                    "  dataset.add(name, val);" +
                    "}" +
                    "" +
                    "execution.setVariable('reportData', reportData.toBytes());";
   
    // Generate bpmn model
    WorkflowDefinition workflowDefinition = new WorkflowDefinition()
      .name(processDefinition.getName() + " task duration report")
      .description(reportDescription)
      .addScriptStep(script);
   
    // Convert to BPMN 2.0 XML
    WorkflowDefinitionConversion conversion = ExplorerApp.get().getWorkflowDefinitionConversionFactory()
            .createWorkflowDefinitionConversion(workflowDefinition);
    conversion.convert();
    conversion.getBpmnModel().setTargetNamespace("activiti-report");
   
    // Generate DI
    BpmnAutoLayout bpmnAutoLayout = new BpmnAutoLayout(conversion.getBpmnModel());
    bpmnAutoLayout.execute();
   
    // Deploy
    repositoryService.createDeployment()
      .name(processDefinition.getName() + " - task duration report")
      .addString(conversion.getProcess().getId() + ".bpmn20.xml", conversion.getBpmn20Xml())
      .deploy();
  }
View Full Code Here


  public void testIdentityLinks() throws Exception {
   
    setUpUsersAndGroups();
   
    try {
      ProcessDefinition latestProcessDef = repositoryService
          .createProcessDefinitionQuery().processDefinitionKey("process1")
          .singleResult();
      assertNotNull(latestProcessDef);
      List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
      assertEquals(0, links.size());
     
      latestProcessDef = repositoryService
          .createProcessDefinitionQuery().processDefinitionKey("process2")
          .singleResult();
      assertNotNull(latestProcessDef);
      links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
      assertEquals(2, links.size());
      assertEquals(true, containsUserOrGroup("user1", null, links));
      assertEquals(true, containsUserOrGroup("user2", null, links));
     
      latestProcessDef = repositoryService
          .createProcessDefinitionQuery().processDefinitionKey("process3")
          .singleResult();
      assertNotNull(latestProcessDef);
      links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
      assertEquals(1, links.size());
      assertEquals("user1", links.get(0).getUserId());
     
      latestProcessDef = repositoryService
          .createProcessDefinitionQuery().processDefinitionKey("process4")
          .singleResult();
      assertNotNull(latestProcessDef);
      links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
      assertEquals(4, links.size());
      assertEquals(true, containsUserOrGroup("userInGroup2", null, links));
      assertEquals(true, containsUserOrGroup(null, "group1", links));
      assertEquals(true, containsUserOrGroup(null, "group2", links));
      assertEquals(true, containsUserOrGroup(null, "group3", links));
View Full Code Here

  public void testAddAndRemoveIdentityLinks() throws Exception {
   
    setUpUsersAndGroups();
   
    try {
      ProcessDefinition latestProcessDef = repositoryService
          .createProcessDefinitionQuery().processDefinitionKey("potentialStarterNoDefinition")
          .singleResult();
      assertNotNull(latestProcessDef);
      List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
      assertEquals(0, links.size());
     
      repositoryService.addCandidateStarterGroup(latestProcessDef.getId(), "group1");
      links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
      assertEquals(1, links.size());
      assertEquals("group1", links.get(0).getGroupId());
     
      repositoryService.addCandidateStarterUser(latestProcessDef.getId(), "user1");
      links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
      assertEquals(2, links.size());
      assertEquals(true, containsUserOrGroup(null, "group1", links));
      assertEquals(true, containsUserOrGroup("user1", null, links));
     
      repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), "nonexisting");
      links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
      assertEquals(2, links.size());
     
      repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), "group1");
      links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
      assertEquals(1, links.size());
      assertEquals("user1", links.get(0).getUserId());
     
      repositoryService.deleteCandidateStarterUser(latestProcessDef.getId(), "user1");
      links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
      assertEquals(0, links.size());
     
    } finally {
      tearDownUsersAndGroups();
    }
View Full Code Here

      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("potentialStarter");
      assertProcessEnded(processInstance.getId());
      assertTrue(processInstance.isEnded());
         
      //check extensionElements with : <formalExpression>group2, group(group3), user(user3)</formalExpression>
      ProcessDefinition potentialStarter = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarter").startableByUser("user1").latestVersion().singleResult();
      assertNotNull(potentialStarter);
     
      potentialStarter = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarter").startableByUser("user3").latestVersion().singleResult();
      assertNotNull(potentialStarter);
     
View Full Code Here

   
    setUpUsersAndGroups();
    try {
     
      // Process 1 has no potential starters
      ProcessDefinition latestProcessDef = repositoryService
              .createProcessDefinitionQuery().processDefinitionKey("process1")
              .singleResult();     
      List<User> authorizedUsers = identityService.createUserQuery().potentialStarter(latestProcessDef.getId()).list();
      assertEquals(0, authorizedUsers.size());

      // user1 and user2 are potential Startes of Process2
      latestProcessDef = repositoryService
              .createProcessDefinitionQuery().processDefinitionKey("process2")
              .singleResult();     
      authorizedUsers =  identityService.createUserQuery().potentialStarter(latestProcessDef.getId()).orderByUserId().asc().list();
      assertEquals(2, authorizedUsers.size());
      assertEquals("user1", authorizedUsers.get(0).getId());
      assertEquals("user2", authorizedUsers.get(1).getId());

      // Process 2 has no potential starter groups
      latestProcessDef = repositoryService
              .createProcessDefinitionQuery().processDefinitionKey("process2")
              .singleResult();     
      List<Group> authorizedGroups = identityService.createGroupQuery().potentialStarter(latestProcessDef.getId()).list();
      assertEquals(0, authorizedGroups.size());
     
      // Process 3 has 3 groups as authorized starter groups
      latestProcessDef = repositoryService
              .createProcessDefinitionQuery().processDefinitionKey("process4")
              .singleResult();     
      authorizedGroups = identityService.createGroupQuery().potentialStarter(latestProcessDef.getId()).orderByGroupId().asc().list();
      assertEquals(3, authorizedGroups.size());
      assertEquals("group1", authorizedGroups.get(0).getId());
      assertEquals("group2", authorizedGroups.get(1).getId());
      assertEquals("group3", authorizedGroups.get(2).getId());
View Full Code Here

      os.write(buf, 0, numRead);
    }
  }
 
  protected String getDeployedProcessKey() {
    ProcessDefinition processDefinition = activitiRule.getRepositoryService().createProcessDefinitionQuery().singleResult();
    assertNotNull(processDefinition);
    return processDefinition.getKey();
  }
View Full Code Here

    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());
  }
View Full Code Here

  }

  @Override
  public Object convertFormValueToModelValue(String propertyValue) {
    if(propertyValue != null) {
      ProcessDefinition processDefinition = ProcessEngines.getDefaultProcessEngine()
              .getRepositoryService()
              .createProcessDefinitionQuery()
              .processDefinitionId(propertyValue)
              .singleResult();
     
View Full Code Here

  }
 
  @ManagedOperation(description = "get a specific process definition")
  public List<String> getProcessDefinitionById(String id) {
    ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
    List<String> item = new ArrayList<String>(3);
    item.add(pd.getId());
    item.add(pd.getName());
    item.add(Integer.toString(pd.getVersion()));
    item.add(Boolean.toString(pd.isSuspended()));
    item.add(pd.getDescription());
   
    return item;

  }
View Full Code Here

  }

  @Override
  public Object convertFormValueToModelValue(String propertyValue) {
    if(propertyValue != null) {
      ProcessDefinition processDefinition = ProcessEngines.getDefaultProcessEngine()
              .getRepositoryService()
              .createProcessDefinitionQuery()
              .processDefinitionId(propertyValue)
              .singleResult();
     
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.