Package org.activiti.engine

Examples of org.activiti.engine.RepositoryService


        ProcessEngine engine = (ProcessEngine) engineServiceTracker.waitForService(timeout);
        if (engine == null) {
          throw new IllegalStateException("Unable to find a ProcessEngine service");
        }

        RepositoryService service = engine.getRepositoryService();
        DeploymentBuilder builder = service.createDeployment();
        builder.name(bundle.getSymbolicName());
        for (URL url : pathList) {
          InputStream is = url.openStream();
          if (is == null) {
              throw new IOException("Error opening url: " + url);
View Full Code Here


*/
public class CleanTestExecutionListener extends AbstractTestExecutionListener {

    @Override
    public void afterTestClass(TestContext testContext) throws Exception {
        RepositoryService repositoryService = testContext.getApplicationContext().getBean(RepositoryService.class);
        for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
            repositoryService.deleteDeployment(deployment.getId(), true);
        }
    }
View Full Code Here

    @Test
    public void testLaunchingGatewayProcessDefinition() throws Exception {
        AnnotationConfigApplicationContext applicationContext = this.context(InboundGatewayConfiguration.class);

        RepositoryService repositoryService = applicationContext.getBean(RepositoryService.class);
        RuntimeService runtimeService = applicationContext.getBean(RuntimeService.class);
        ProcessEngine processEngine = applicationContext.getBean(ProcessEngine.class);

        Assert.assertNotNull("the process engine should not be null", processEngine);
        Assert.assertNotNull("we should have a default repositoryService included", repositoryService);
        String integrationGatewayProcess = "integrationGatewayProcess";
        List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery()
                .processDefinitionKey(integrationGatewayProcess)
                .list();
        ProcessDefinition processDefinition = processDefinitionList.iterator().next();
        Assert.assertEquals(processDefinition.getKey(), integrationGatewayProcess);
        Map<String, Object> vars = new HashMap<String, Object>();
View Full Code Here

 
  // WARNING!!! DemoWare!!!
  public static void generateTaskDurationReport(String processDefinitionId) {
   
    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

        processScopeTestEngine = new ProcessScopeTestEngine(this.processEngine);
    }

    @After
    public void after() {
        RepositoryService repositoryService = this.processEngine.getRepositoryService();
        for (Deployment deployment : repositoryService.createDeploymentQuery().list()) {
            repositoryService.deleteDeployment(deployment.getId(), true);
        }
    }
View Full Code Here

  @Test
  public void send() throws Exception {
    Assert.assertTrue(muleContext.isStarted());
   
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    RepositoryService repositoryService = processEngine.getRepositoryService();
    Deployment deployment = repositoryService.createDeployment()
        .addClasspathResource("org/activiti/mule/testVM.bpmn20.xml")
        .deploy();
   
    RuntimeService runtimeService = processEngine.getRuntimeService();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("muleProcess");
    Assert.assertFalse(processInstance.isEnded());
    Object result = runtimeService.getVariable(processInstance.getProcessInstanceId(), "theVariable");
    Assert.assertEquals(30, result);
    runtimeService.deleteProcessInstance(processInstance.getId(), "test");
   
    processEngine.getHistoryService().deleteHistoricProcessInstance(processInstance.getId());
    repositoryService.deleteDeployment(deployment.getId());
    assertAndEnsureCleanDb(processEngine);
    ProcessEngines.destroy();
  }
View Full Code Here

    @Test
    public void launchProcessDefinition() throws Exception {
        AnnotationConfigApplicationContext applicationContext = this.context(
                DataSourceAutoConfiguration.class, DataSourceProcessEngineAutoConfiguration.DataSourceConfiguration.class);
        RepositoryService repositoryService = applicationContext.getBean(RepositoryService.class);
        Assert.assertNotNull("we should have a default repositoryService included", repositoryService);
        List<ProcessDefinition> processDefinitionList = repositoryService.createProcessDefinitionQuery()
                .processDefinitionKey("waiter")
                .list();
        Assert.assertNotNull(processDefinitionList);
        Assert.assertTrue(!processDefinitionList.isEmpty());
        ProcessDefinition processDefinition = processDefinitionList.iterator().next();
View Full Code Here

      .setProcessEngineName("reboot-test-schema")
      .setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE)
      .setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000")
      .setJobExecutorActivate(false)
      .buildProcessEngine();
    RepositoryService repositoryService1 = processEngine1.getRepositoryService();
   
    ProcessEngine processEngine2 = new StandaloneProcessEngineConfiguration()
      .setProcessEngineName("reboot-test")
      .setDatabaseSchemaUpdate(org.activiti.engine.ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE)
      .setJdbcUrl("jdbc:h2:mem:activiti-process-cache-test;DB_CLOSE_DELAY=1000")
      .setJobExecutorActivate(false)
      .buildProcessEngine();
    RepositoryService repositoryService2 = processEngine2.getRepositoryService();
    RuntimeService runtimeService2 = processEngine2.getRuntimeService();
    TaskService taskService2 = processEngine2.getTaskService();
   
    // Deploy first version of process: start->originalTask->end on first process engine
    String deploymentId = repositoryService1.createDeployment()
      .addClasspathResource("org/activiti/engine/test/cache/originalProcess.bpmn20.xml")
      .deploy()
      .getId();
   
    // Start process instance on second engine
    String processDefinitionId = repositoryService2.createProcessDefinitionQuery().singleResult().getId();
    runtimeService2.startProcessInstanceById(processDefinitionId);
    Task task = taskService2.createTaskQuery().singleResult();
    assertEquals("original task", task.getName());
   
    // Delete the deployment on second process engine
    repositoryService2.deleteDeployment(deploymentId, true);
    assertEquals(0, repositoryService2.createDeploymentQuery().count());
    assertEquals(0, runtimeService2.createProcessInstanceQuery().count());
   
    // deploy a revised version of the process: start->revisedTask->end on first process engine
    //
    // Before the bugfix, this would set the cache on the first process engine,
    // but the second process engine still has the original process definition in his cache.
    // Since there is a deployment delete in between, the new generated process definition id is the same
    // as in the original deployment, making the second process engine using the old cached process definition.
    deploymentId = repositoryService1.createDeployment()
      .addClasspathResource("org/activiti/engine/test/cache/revisedProcess.bpmn20.xml")
      .deploy()
      .getId();
   
    // Start process instance on second process engine -> must use revised process definition
    repositoryService2.createProcessDefinitionQuery().singleResult().getId();
    runtimeService2.startProcessInstanceByKey("oneTaskProcess");
    task = taskService2.createTaskQuery().singleResult();
    assertEquals("revised task", task.getName());
   
    // cleanup
View Full Code Here

 
  protected void save() {
    WorkflowDefinition workflowDefinition = createWorkflow();

    final ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
    RepositoryService repositoryService = defaultProcessEngine.getRepositoryService();
    ProcessEngineConfiguration processEngineConfiguration = defaultProcessEngine.getProcessEngineConfiguration();
    ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
   
    Model model = null;
    if (modelId == null) { // new process
      model = repositoryService.newModel();
    } else { // update existing process
      model = repositoryService.getModel(modelId);
    }

    model.setName(workflowDefinition.getName());
    model.setCategory(SimpleTableEditorConstants.TABLE_EDITOR_CATEGORY);
    repositoryService.saveModel(model);

    // Store model entity
    WorkflowDefinitionConversion conversion =
            ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
    conversion.convert();
   
    try {
      // Write JSON to byte-array and set as editor-source
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ExplorerApp.get().getSimpleWorkflowJsonConverter().writeWorkflowDefinition(workflowDefinition, new OutputStreamWriter(baos));
      repositoryService.addModelEditorSource(model.getId(), baos.toByteArray());
     
      // Store process image
      // TODO: we should really allow the service to take an inputstream as input. Now we load it into memory ...
      repositoryService.addModelEditorSourceExtra(model.getId(), IOUtils.toByteArray(
          diagramGenerator.generateDiagram(conversion.getBpmnModel(), "png", processEngineConfiguration.getActivityFontName(),
              processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getClassLoader())));
    } catch (IOException e) {
      logger.warn("Could not generate process image. Image is not stored and will not be shown.", e);
    }
View Full Code Here

      }
    }
  }

  protected WorkflowDefinition loadWorkflowDefinition() throws JsonProcessingException, IOException {
    RepositoryService repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
    return ExplorerApp.get().getSimpleWorkflowJsonConverter().readWorkflowDefinition(repositoryService.getModelEditorSource(model.getId()));
  }
View Full Code Here

TOP

Related Classes of org.activiti.engine.RepositoryService

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.