Package org.activiti.workflow.simple.converter

Examples of org.activiti.workflow.simple.converter.WorkflowDefinitionConversion


            if (SimpleTableEditorConstants.TABLE_EDITOR_CATEGORY.equals(modelData.getCategory())) {
              WorkflowDefinition workflowDefinition = ExplorerApp.get().getSimpleWorkflowJsonConverter()
                  .readWorkflowDefinition(repositoryService.getModelEditorSource(modelData.getId()));
             
              filename = workflowDefinition.getName();
              WorkflowDefinitionConversion conversion =
                      ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
              bpmnBytes = conversion.getBpmn20Xml().getBytes("utf-8");
            } else {
              JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
              BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
              BpmnModel model = jsonConverter.convertToBpmnModel(editorNode);
              filename = model.getMainProcess().getId() + ".bpmn20.xml";
View Full Code Here


        // Update model name
        modelData.setName(deployModelPopupWindow.getProcessName());
        workflowDefinition.setName(deployModelPopupWindow.getProcessName());
       
        WorkflowDefinitionConversion conversion =
                ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
        conversion.convert();
       
        // Deploy to database
        byte[] bpmnBytes = null;
        try {
          bpmnBytes = conversion.getBpmn20Xml().getBytes("utf-8");
         
          String processName = modelData.getName() + ".bpmn20.xml";
          Deployment deployment = repositoryService.createDeployment()
                  .name(modelData.getName())
                  .addString(processName, new String(bpmnBytes))
View Full Code Here

      .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

  // Helper methods -----------------------------------------------------------------------------
 
  protected String convertAndDeploy(WorkflowDefinition workflowDefinition) {
  
    // Convert
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(workflowDefinition);
    conversion.convert();
   
    log.info("Converted process : " + conversion.getBpmn20Xml());
   
//    InputStream is = conversion.getWorkflowDiagramImage();
//    try {
//      write(is, new FileOutputStream("temp" + UUID.randomUUID().toString() + ".png"), new byte[1024]);
//    } catch (FileNotFoundException e) {
View Full Code Here

    // Convert json to simple workflow definition
    SimpleWorkflowJsonConverter jsonConverter = new SimpleWorkflowJsonConverter();
    WorkflowDefinition workflowDefinition = jsonConverter.readWorkflowDefinition(json.getBytes());
   
    WorkflowDefinitionConversionFactory conversionFactory = new WorkflowDefinitionConversionFactory();
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(workflowDefinition);
    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
View Full Code Here

          WorkflowDefinition workflowDefinition = loadWorkflowDefinition();
       
          // When using the modeler, the format must first be converted to the modeler json format
          if (selectEditorComponent.isModelerPreferred()) {
            
            WorkflowDefinitionConversion conversion = ExplorerApp.get()
                    .getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
            conversion.convert();
           
            RepositoryService repositoryService = ProcessEngines.getDefaultProcessEngine().getRepositoryService();
            model.setCategory(null);
           
            ObjectMapper objectMapper = new ObjectMapper();
            ObjectNode metaInfoJson = objectMapper.createObjectNode();
            metaInfoJson.put("name", model.getName());
            model.setMetaInfo(metaInfoJson.toString());
            repositoryService.saveModel(model);
           
            BpmnJsonConverter bpmnJsonConverter = new BpmnJsonConverter();
            ObjectNode json = bpmnJsonConverter.convertToJson(conversion.getBpmnModel());
            repositoryService.addModelEditorSource(model.getId(), json.toString().getBytes("utf-8"));
           
            // Show modeler
            showModeler();
           
View Full Code Here

    StreamResource.StreamSource streamSource = new StreamSource() {
     
      private static final long serialVersionUID = 6993112534181068935L;

      public InputStream getStream() {
        WorkflowDefinitionConversion workflowDefinitionConversion =
                ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(createWorkflow());
        final ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
        final ProcessEngineConfiguration processEngineConfiguration = defaultProcessEngine.getProcessEngineConfiguration();
        final ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();

        return diagramGenerator.generateDiagram(workflowDefinitionConversion.getBpmnModel(), "png", processEngineConfiguration.getActivityFontName(),
            processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getClassLoader());
      }
    };
   
    // resource must have unique id (or cache-crap can happen)!
View Full Code Here

    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

    WorkflowDefinition definition = new WorkflowDefinition();
    definition.setDescription("This is the description");
    definition.setId("workflowdefinition");
    definition.setName("My workflow definition");
   
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
   
    BpmnModel bpmnModel = conversion.getBpmnModel();
    assertNotNull(bpmnModel);
   
    Process process = bpmnModel.getMainProcess();
    assertNotNull(process);
    assertEquals("This is the description", process.getDocumentation());
View Full Code Here

   */
  @Test
  public void testGeneratedWorkflowDefinitionId() {
    WorkflowDefinition definition = new WorkflowDefinition();
   
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
   
    BpmnModel bpmnModel = conversion.getBpmnModel();
    assertNotNull(bpmnModel);
   
    Process process = bpmnModel.getMainProcess();
    assertNotNull(process);
   
View Full Code Here

TOP

Related Classes of org.activiti.workflow.simple.converter.WorkflowDefinitionConversion

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.