Examples of BpmnParse


Examples of org.activiti.engine.impl.bpmn.parser.BpmnParse

      if (isBpmnResource(resourceName)) {
        ResourceEntity resource = resources.get(resourceName);
        byte[] bytes = resource.getBytes();
        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
       
        BpmnParse bpmnParse = bpmnParser
          .createParse()
          .sourceInputStream(inputStream)
          .deployment(deployment)
          .name(resourceName);
       
        if (deploymentSettings != null) {
         
          // Schema validation if needed
          if (deploymentSettings.containsKey(DeploymentSettings.IS_BPMN20_XSD_VALIDATION_ENABLED)) {
            bpmnParse.setValidateSchema((Boolean) deploymentSettings.get(DeploymentSettings.IS_BPMN20_XSD_VALIDATION_ENABLED));
          }
         
          // Process validation if needed
          if (deploymentSettings.containsKey(DeploymentSettings.IS_PROCESS_VALIDATION_ENABLED)) {
            bpmnParse.setValidateProcess((Boolean) deploymentSettings.get(DeploymentSettings.IS_PROCESS_VALIDATION_ENABLED));
          }
         
        } else {
          // On redeploy, we assume it is validated at the first deploy
          bpmnParse.setValidateSchema(false);
          bpmnParse.setValidateProcess(false);
        }
       
        bpmnParse.execute();
       
        for (ProcessDefinitionEntity processDefinition: bpmnParse.getProcessDefinitions()) {
          processDefinition.setResourceName(resourceName);
         
          if (deployment.getTenantId() != null) {
            processDefinition.setTenantId(deployment.getTenantId()); // process definition inherits the tenant id
          }
         
          String diagramResourceName = getDiagramResourceForProcess(resourceName, processDefinition.getKey(), resources);
                  
          // Only generate the resource when deployment is new to prevent modification of deployment resources
          // after the process-definition is actually deployed. Also to prevent resource-generation failure every
          // time the process definition is added to the deployment-cache when diagram-generation has failed the first time.
          if(deployment.isNew()) {
            if (processEngineConfiguration.isCreateDiagramOnDeploy() &&
                  diagramResourceName==null && processDefinition.isGraphicalNotationDefined()) {
              try {
                  byte[] diagramBytes = IoUtil.readInputStream(processEngineConfiguration.
                    getProcessDiagramGenerator().generateDiagram(bpmnParse.getBpmnModel(), "png", processEngineConfiguration.getActivityFontName(),
                        processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getClassLoader()), null);
                  diagramResourceName = getProcessImageResourceName(resourceName, processDefinition.getKey(), "png");
                  createResource(diagramResourceName, diagramBytes, deployment);
              } catch (Throwable t) { // if anything goes wrong, we don't store the image (the process will still be executable).
                LOG.warn("Error while generating process diagram, image will not be stored in repository", t);
View Full Code Here

Examples of org.activiti.engine.impl.bpmn.parser.BpmnParse

public class MessageEventDefinitionWithExtensionElementsTest {

  @Test
  public void testParseMessagedDefinitionWithExtension() {
    BpmnParse bpmnParseMock = Mockito.mock(BpmnParse.class);
    MessageEventDefinition messageEventDefinitionMock = Mockito.mock(MessageEventDefinition.class);
    BpmnModel bpmnModelMock = Mockito.mock(BpmnModel.class);
    Message messageMock = Mockito.mock(Message.class);
    @SuppressWarnings("unchecked")
    Map<String,List<ExtensionElement>> extensionElementMap = Mockito.mock(Map.class);
   
    Mockito.when(bpmnParseMock.getBpmnModel()).thenReturn(bpmnModelMock);
    Mockito.when(messageEventDefinitionMock.getMessageRef()).thenReturn("messageId");
    Mockito.when(bpmnModelMock.containsMessageId("messageId")).thenReturn(true);
    Mockito.when(bpmnModelMock.getMessage("messageId")).thenReturn(messageMock);
    Mockito.when(messageMock.getName()).thenReturn("MessageWithExtensionElements");
    Mockito.when(messageMock.getExtensionElements()).thenReturn(extensionElementMap);
View Full Code Here

Examples of org.activiti.engine.impl.bpmn.parser.BpmnParse

* @author Nico Rehwaldt
*/
public class DefaultBpmnParseFactory implements BpmnParseFactory {

  public BpmnParse createBpmnParse(BpmnParser bpmnParser) {
    return new BpmnParse(bpmnParser);
  }
View Full Code Here

Examples of org.activiti.engine.impl.bpmn.parser.BpmnParse

      if (isBpmnResource(resourceName)) {
        ResourceEntity resource = resources.get(resourceName);
        byte[] bytes = resource.getBytes();
        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
       
        BpmnParse bpmnParse = bpmnParser
          .createParse()
          .sourceInputStream(inputStream)
          .deployment(deployment)
          .name(resourceName);
       
        if (!deployment.isValidatingSchema()) {
          bpmnParse.setSchemaResource(null);
        }
       
        bpmnParse.execute();
       
        for (ProcessDefinitionEntity processDefinition: bpmnParse.getProcessDefinitions()) {
          processDefinition.setResourceName(resourceName);
         
          String diagramResourceName = getDiagramResourceForProcess(resourceName, processDefinition.getKey(), resources);
                  
          // Only generate the resource when deployment is new to prevent modification of deployment resources
View Full Code Here

Examples of org.camunda.bpm.engine.impl.bpmn.parser.BpmnParse

    Map<String, List<JobDeclaration<?>>> jobDeclarations = new HashMap<String, List<JobDeclaration<?>>>();
    List<ProcessDefinitionEntity> processDefinitions = new ArrayList<ProcessDefinitionEntity>();
    Map<String, ResourceEntity> resources = deployment.getResources();

    for (String resourceName : resources.keySet()) {
      BpmnParse bpmnParse = null;

      LOG.fine("Processing resource " + resourceName);
      if (isBpmnResource(resourceName)) {
        ResourceEntity resource = resources.get(resourceName);
        byte[] bytes = resource.getBytes();
        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);


        bpmnParse = bpmnParser
          .createParse()
          .sourceInputStream(inputStream)
          .deployment(deployment)
          .name(resourceName);

        if (!deployment.isValidatingSchema()) {
          bpmnParse.setSchemaResource(null);
        }

        bpmnParse.execute();

        for (ProcessDefinitionEntity processDefinition: bpmnParse.getProcessDefinitions()) {
          processDefinition.setResourceName(resourceName);

          String diagramResourceName = getDiagramResourceForProcess(resourceName, processDefinition.getKey(), resources);

          // Only generate the resource when deployment is new to prevent modification of deployment resources
          // after the process-definition is actually deployed. Also to prevent resource-generation failure every
          // time the process definition is added to the deployment-cache when diagram-generation has failed the first time.
          if(deployment.isNew()) {
            if (Context.getProcessEngineConfiguration().isCreateDiagramOnDeploy() &&
                  diagramResourceName==null && processDefinition.isGraphicalNotationDefined()) {
              try {
                  byte[] diagramBytes = IoUtil.readInputStream(ProcessDiagramGenerator.generatePngDiagram(processDefinition), null);
                  diagramResourceName = getProcessImageResourceName(resourceName, processDefinition.getKey(), "png");
                  createResource(diagramResourceName, diagramBytes, deployment);
              } catch (Throwable t) { // if anything goes wrong, we don't store the image (the process will still be executable).
                LOG.log(Level.WARNING, "Error while generating process diagram, image will not be stored in repository", t);
              }
            }
          }

          processDefinition.setDiagramResourceName(diagramResourceName);
          processDefinitions.add(processDefinition);
        }

        jobDeclarations.putAll(bpmnParse.getJobDeclarations());
      }
    }

    // check if there are process definitions with the same process key to prevent database unique index violation
    List<String> keyList = new ArrayList<String>();
View Full Code Here

Examples of org.camunda.bpm.engine.impl.bpmn.parser.BpmnParse

* @author Nico Rehwaldt
*/
public class DefaultBpmnParseFactory implements BpmnParseFactory {

  public BpmnParse createBpmnParse(BpmnParser bpmnParser) {
    return new BpmnParse(bpmnParser);
  }
View Full Code Here

Examples of org.camunda.bpm.engine.impl.bpmn.parser.BpmnParse

    Map<String, List<JobDeclaration<?>>> jobDeclarations = new HashMap<String, List<JobDeclaration<?>>>();
    List<ProcessDefinitionEntity> processDefinitions = new ArrayList<ProcessDefinitionEntity>();
    Map<String, ResourceEntity> resources = deployment.getResources();

    for (String resourceName : resources.keySet()) {
      BpmnParse bpmnParse = null;

      LOG.info("Processing resource " + resourceName);
      if (isBpmnResource(resourceName)) {
        ResourceEntity resource = resources.get(resourceName);
        byte[] bytes = resource.getBytes();
        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);


        bpmnParse = bpmnParser
          .createParse()
          .sourceInputStream(inputStream)
          .deployment(deployment)
          .name(resourceName);

        if (!deployment.isValidatingSchema()) {
          bpmnParse.setSchemaResource(null);
        }

        bpmnParse.execute();

        for (ProcessDefinitionEntity processDefinition: bpmnParse.getProcessDefinitions()) {
          processDefinition.setResourceName(resourceName);

          String diagramResourceName = getDiagramResourceForProcess(resourceName, processDefinition.getKey(), resources);

          // Only generate the resource when deployment is new to prevent modification of deployment resources
          // after the process-definition is actually deployed. Also to prevent resource-generation failure every
          // time the process definition is added to the deployment-cache when diagram-generation has failed the first time.
          if(deployment.isNew()) {
            if (Context.getProcessEngineConfiguration().isCreateDiagramOnDeploy() &&
                  diagramResourceName==null && processDefinition.isGraphicalNotationDefined()) {
              try {
                  byte[] diagramBytes = IoUtil.readInputStream(ProcessDiagramGenerator.generatePngDiagram(processDefinition), null);
                  diagramResourceName = getProcessImageResourceName(resourceName, processDefinition.getKey(), "png");
                  createResource(diagramResourceName, diagramBytes, deployment);
              } catch (Throwable t) { // if anything goes wrong, we don't store the image (the process will still be executable).
                LOG.log(Level.WARNING, "Error while generating process diagram, image will not be stored in repository", t);
              }
            }
          }

          processDefinition.setDiagramResourceName(diagramResourceName);
          processDefinitions.add(processDefinition);
        }

        jobDeclarations.putAll(bpmnParse.getJobDeclarations());
      }
    }

    // check if there are process definitions with the same process key to prevent database unique index violation
    List<String> keyList = new ArrayList<String>();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.