Package org.activiti.engine.repository

Examples of org.activiti.engine.repository.ProcessDefinition


  @Test
  public void startProcess() throws Exception {
    RepositoryService repositoryService = activitiRule.getRepositoryService();
    repositoryService.createDeployment().addInputStream("DymaticForm.bpmn20.xml", new FileInputStream(filename)).deploy();
   
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionKey("DymaticForm").latestVersion().singleResult();
    FormService formService = activitiRule.getFormService();
    StartFormData startFormData = formService.getStartFormData(processDefinition.getId());
    assertNull(startFormData.getFormKey());
   
    Map<String, String> formProperties = new HashMap<String, String>();
    formProperties.put("name", "HenryYan");
   
    ProcessInstance processInstance = formService.submitStartFormData(processDefinition.getId(), formProperties);
    assertNotNull(processInstance);
   
    // 运行时变量
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variables = runtimeService.getVariables(processInstance.getId());
View Full Code Here


     */
    public void waitForProcessDeployment(String processKey) throws InterruptedException, TimeoutException {
        ProcessEngine engine = getOsgiService(ProcessEngine.class, 5000);
        int iteration = 0;
        while (iteration < 10) {
            ProcessDefinition definition = engine.getRepositoryService()
                .createProcessDefinitionQuery()
                .processDefinitionKey(processKey).singleResult();
            if (definition != null) {
                break;
            }
View Full Code Here

            pdId = pi.getProcessDefinitionId();
        } else if (hpi != null) {
            pdId = hpi.getProcessDefinitionId();
        }

        ProcessDefinition pd = repo.createProcessDefinitionQuery().processDefinitionId(pdId).singleResult();
        Deployment depInfo = repo.createDeploymentQuery().deploymentId(pd.getDeploymentId()).singleResult();
        // print
        if (isVerbose()) {
            out().println("======== Deployment Details");
            printDeploymentInfo(depInfo);
View Full Code Here

    }

    @Override
    public WorkflowDefinitionTO getDefinition() throws WorkflowException {

        ProcessDefinition procDef;
        try {
            procDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey(
                    ActivitiUserWorkflowAdapter.WF_PROCESS_ID).latestVersion().singleResult();
        } catch (ActivitiException e) {
            throw new WorkflowException(e);
        }

        InputStream procDefIS = repositoryService.getResourceAsStream(procDef.getDeploymentId(), WF_PROCESS_RESOURCE);
        Reader reader = null;
        Writer writer = new StringWriter();
        try {
            reader = new BufferedReader(new InputStreamReader(procDefIS));

            int n;
            char[] buffer = new char[1024];
            while ((n = reader.read(buffer)) != -1) {
                writer.write(buffer, 0, n);
            }
        } catch (IOException e) {
            LOG.error("While reading workflow definition {}", procDef.getKey(), e);
        } finally {
            try {
                if (reader != null) {
                    reader.close();
                }
                if (procDefIS != null) {
                    procDefIS.close();
                }
            } catch (IOException ioe) {
                LOG.error("While closing input stream for {}", procDef.getKey(), ioe);
            }
        }

        WorkflowDefinitionTO definitionTO = new WorkflowDefinitionTO();
        definitionTO.setId(ActivitiUserWorkflowAdapter.WF_PROCESS_ID);
View Full Code Here

    @Override
    public List<String> getDefinedTasks() throws WorkflowException {

        List<String> result = new ArrayList<String>();

        ProcessDefinition procDef;
        try {
            procDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey(
                    ActivitiUserWorkflowAdapter.WF_PROCESS_ID).latestVersion().singleResult();
        } catch (ActivitiException e) {
            throw new WorkflowException(e);
        }

        InputStream procDefIS = repositoryService.getResourceAsStream(procDef.getDeploymentId(), WF_PROCESS_RESOURCE);

        DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
        try {
            DocumentBuilder builder = domFactory.newDocumentBuilder();
            Document doc = builder.parse(procDefIS);

            XPath xpath = XPathFactory.newInstance().newXPath();

            NodeList nodeList = (NodeList) xpath.evaluate("//userTask | //serviceTask | //scriptTask", doc,
                    XPathConstants.NODESET);
            for (int i = 0; i < nodeList.getLength(); i++) {
                result.add(nodeList.item(i).getAttributes().getNamedItem("id").getNodeValue());
            }
        } catch (Exception e) {
            throw new WorkflowException(e);
        } finally {
            try {
                procDefIS.close();
            } catch (IOException ioe) {
                LOG.error("While closing input stream for {}", procDef.getKey(), ioe);
            }
        }

        return result;
    }
View Full Code Here

    Annotation[] qualifiers = getQualifiers(event);          
    getBeanManager().fireEvent(event, qualifiers);   
  }

  protected BusinessProcessEvent createEvent(DelegateExecution execution) {
    ProcessDefinition processDefinition = Context.getExecutionContext().getProcessDefinition();
    return new CdiBusinessProcessEvent(activityId, transitionName, processDefinition, execution, type, new Date());
  }
View Full Code Here

    if (processDefinitionId == null) {
      throw new ActivitiException("No process definition id provided");
    }

    RepositoryService repositoryService = ActivitiUtil.getRepositoryService();
    ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
        .processDefinitionId(processDefinitionId).singleResult();

    if (processDefinition == null) {
      throw new ActivitiException("Process definition " + processDefinitionId + " could not be found");
    }

    if (processDefinition.getDiagramResourceName() == null) {
      throw new ActivitiException("Diagram resource could not be found");
    }
    final InputStream definitionImageStream = repositoryService.getResourceAsStream(
        processDefinition.getDeploymentId(), processDefinition.getDiagramResourceName());

    if (definitionImageStream == null) {
      throw new ActivitiException("Diagram resource could not be found");
    }
    return new InputRepresentation(definitionImageStream, MediaType.IMAGE_PNG);
View Full Code Here

    }
    return items;
  }
 
  public Item loadSingleResult(String id) {
    ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
    if (definition != null) {
      return filter.createItem(definition);
    }
    return null;
  }
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

       
        ClassLoader previous = Thread.currentThread().getContextClassLoader();
        RuntimeService rtSvc = JenkowEngine.getEngine().getRuntimeService();
       
        try {
            ProcessDefinition pDef = getDeployedWf(wfName);
            if (pDef == null) throw new RuntimeException("no deployed process definition for "+wfName);

            Map<String,Object> varMap = new HashMap<String,Object>();
            // TODO 9: move jenkow variables into JenkowProcessData
            varMap.put("jenkow_build_parent",parentName);
            varMap.put("jenkow_build_number",buildNo);
            varMap.put("console",new ConsoleLogger(parentName,buildNo));
            JobMD.setJobs(varMap,JobMD.newJobs());
           
            log.println(Consts.UI_PREFIX+": \""+wfName+"\" started");
long t = System.currentTimeMillis();           
System.out.println("starting process "+pDef.getId());
// TODO 9: why is this blocking????
            ProcessInstance proc = rtSvc.startProcessInstanceById(pDef.getId(),varMap);
//            String procId = startProcess(pDef.getId(),varMap);
            String procId = proc.getId();
System.out.println("process started procId="+procId+" ("+(System.currentTimeMillis()-t)+")");           
            return procId;
        } finally {
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.