Package org.activiti.bpmn.model

Examples of org.activiti.bpmn.model.Process


    definition.addStep(humanStep);
   
    WorkflowDefinitionConversion conversion = conversionFactory.createWorkflowDefinitionConversion(definition);
    conversion.convert();
   
    Process process = conversion.getProcess();
    assertNotNull(process);
   
    boolean listenerFound = false;
    for(FlowElement flowElement : process.getFlowElements()) {
      if(flowElement instanceof UserTask) {
          UserTask task = (UserTask) flowElement;
          assertNotNull(task.getTaskListeners());
          assertEquals(2L, task.getTaskListeners().size());
          assertEquals("create", task.getTaskListeners().get(0).getEvent());
View Full Code Here


    if (parentPool == null)
      return null;

    ContainerShape poolShape = (ContainerShape) getFeatureProvider().getPictogramElementForBusinessObject(parentPool);
    Process poolProcess = model.getBpmnModel().getProcess(parentPool.getId());

    if (poolProcess == null)
      return null;

    List<Lane> lanes = poolProcess.getLanes();
    int x = 0;
    int y = 0;
    int width = 0;
    int height = 0;
    if (lanes.size() == 0) {
      x = 20;
      y = 0;
      width = poolShape.getGraphicsAlgorithm().getWidth() - 20;
      height = poolShape.getGraphicsAlgorithm().getHeight();

    } else {
      ContainerShape lastLaneShape = (ContainerShape) getFeatureProvider().getPictogramElementForBusinessObject(lanes.get(lanes.size() - 1));
      x = lastLaneShape.getGraphicsAlgorithm().getX();
      y = lastLaneShape.getGraphicsAlgorithm().getY() + lastLaneShape.getGraphicsAlgorithm().getHeight();
      width = lastLaneShape.getGraphicsAlgorithm().getWidth();
      height = lastLaneShape.getGraphicsAlgorithm().getHeight();
    }

    Lane newLane = new Lane();
    newLane.setId(getNextId(newLane));
    newLane.setName("New lane");
    newLane.setParentProcess(poolProcess);
    poolProcess.getLanes().add(newLane);

    ResizeShapeContext resizeContext = new ResizeShapeContext(poolShape);
    resizeContext.setSize(poolShape.getGraphicsAlgorithm().getWidth(), poolShape.getGraphicsAlgorithm().getHeight() + height);
    resizeContext.setLocation(poolShape.getGraphicsAlgorithm().getX(), poolShape.getGraphicsAlgorithm().getY());
    resizeContext.setDirection(ResizeShapeContext.DIRECTION_SOUTH);
View Full Code Here

  public Object[] create(ICreateContext context) {
    Pool newPool = new Pool();
    newPool.setId(getNextId(newPool));
    newPool.setName("Pool");

    Process newProcess = new Process();
    newProcess.setId("process_" + newPool.getId());
    newProcess.setName(newProcess.getId());

    newPool.setProcessRef(newProcess.getId());

    Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
    model.getBpmnModel().getPools().add(newPool);
    model.getBpmnModel().addProcess(newProcess);

    PictogramElement poolElement = addGraphicalRepresentation(context, newPool);

    Lane lane = new Lane();
    lane.setId(getNextId(lane, "lane"));
    lane.setParentProcess(newProcess);
    newProcess.getLanes().add(lane);

    AddContext laneContext = new AddContext(new AreaContext(), lane);
    IAddFeature addFeature = getFeatureProvider().getAddFeature(laneContext);
    laneContext.setNewObject(lane);
    laneContext.setSize(poolElement.getGraphicsAlgorithm().getWidth() - 20, poolElement.getGraphicsAlgorithm().getHeight());
View Full Code Here

          parentPool = pool;
          break;
        }
      }
     
      Process laneProcess = model.getBpmnModel().getProcess(parentPool.getId());
     
      if (parentPool == null || laneProcess == null) return;
     
      if(laneProcess.getLanes().size() == 1) {
        Process process = model.getBpmnModel().getProcess(parentPool.getId());
        model.getBpmnModel().getProcesses().remove(process);
        model.getBpmnModel().getPools().remove(parentPool);
        PictogramElement poolElement = getFeatureProvider().getPictogramElementForBusinessObject(parentPool);
        IRemoveContext poolRc = new RemoveContext(poolElement);
        IRemoveFeature poolRemoveFeature = getFeatureProvider().getRemoveFeature(poolRc);
View Full Code Here

    for (Pool pool : model.getBpmnModel().getPools()) {
      PictogramElement pictElementPool = featureProvider.getPictogramElementForBusinessObject(pool);
      if (pictElementPool != null) {
        updateFlowElement(pool);
       
        Process process = model.getBpmnModel().getProcess(pool.getId());
        if(process != null) {
          List<Lane> toDeleteLaneList = new ArrayList<Lane>();
          for (Lane lane : process.getLanes()) {
            PictogramElement pictElementLane = featureProvider.getPictogramElementForBusinessObject(lane);
            if (pictElementLane != null) {
              updateFlowElement(lane);
            } else {
              toDeleteLaneList.add(lane);
            }
          }
         
          for (Lane toDeleteLane : toDeleteLaneList) {
            process.getLanes().remove(toDeleteLane);
            model.getBpmnModel().removeGraphicInfo(toDeleteLane.getId());
          }
        }
      } else {
        toDeletePoolList.add(pool);
      }
    }
   
    for (Pool toDeletePool : toDeletePoolList) {
      model.getBpmnModel().getPools().remove(toDeletePool);
      model.getBpmnModel().removeGraphicInfo(toDeletePool.getId());
    }
   
    for (Process process : model.getBpmnModel().getProcesses()) {
      loopThroughElements(process.getFlowElements(), process);
      loopThroughElements(process.getArtifacts(), process);
    }
  }
View Full Code Here

      }
    }
   
    if (toDeleteElementList.size() > 0) {
      if (parentElement instanceof Process) {
        Process process = (Process) parentElement;
        for (BaseElement toDeleteElement : toDeleteElementList) {
          process.removeFlowElement(toDeleteElement.getId());
          model.getBpmnModel().removeGraphicInfo(toDeleteElement.getId());
          model.getBpmnModel().removeFlowGraphicInfoList(toDeleteElement.getId());
          model.getBpmnModel().removeLabelGraphicInfo(toDeleteElement.getId());
        }
      } else if (parentElement instanceof SubProcess) {
View Full Code Here

    documentationText.removeFocusListener(listener);
    candidateStarterUsersText.removeFocusListener(listener);
    candidateStarterGroupsText.removeFocusListener(listener);
   
    Bpmn2MemoryModel model = ModelHandler.getModel(EcoreUtil.getURI(getDiagram()));
    Process process = null;
    if(getSelectedPictogramElement() instanceof Diagram) {
      if (model.getBpmnModel().getPools().size() > 0) {
        process = model.getBpmnModel().getProcess(model.getBpmnModel().getPools().get(0).getId());
        setEnabled(false);
      } else {
        process = model.getBpmnModel().getMainProcess();
        setEnabled(true);
      }
   
    } else {
      Pool pool = ((Pool) getBusinessObject(getSelectedPictogramElement()));
      process = model.getBpmnModel().getProcess(pool.getId());
      setEnabled(true);
    }
   
    if(StringUtils.isNotEmpty(model.getBpmnModel().getTargetNamespace())) {
      namespaceText.setText(model.getBpmnModel().getTargetNamespace());
    } else {
      namespaceText.setText("http://www.activiti.org/test");
    }
   
    if (process != null) {
      idText.setText(process.getId());
      if(StringUtils.isNotEmpty(process.getName())) {
        nameText.setText(process.getName());
      } else {
        nameText.setText("");
      }
      if(StringUtils.isNotEmpty(process.getDocumentation())) {
        documentationText.setText(process.getDocumentation());
      } else {
        documentationText.setText("");
      }
     
      candidateStarterUsersText.setText("");
      if (process.getCandidateStarterUsers().size() > 0) {
        StringBuffer expressionBuffer = new StringBuffer();
        for (String user : process.getCandidateStarterUsers()) {
          if (expressionBuffer.length() > 0) {
            expressionBuffer.append(",");
          }
          expressionBuffer.append(user.trim());
        }
        candidateStarterUsersText.setText(expressionBuffer.toString());
      }
     
      candidateStarterGroupsText.setText("");
      if (process.getCandidateStarterGroups().size() > 0) {
        StringBuffer expressionBuffer = new StringBuffer();
        for (String group : process.getCandidateStarterGroups()) {
          if (expressionBuffer.length() > 0) {
            expressionBuffer.append(",");
          }
          expressionBuffer.append(group.trim());
        }
View Full Code Here

  public BpmnModel convertToBpmnModel(XMLStreamReader xtr) {
    BpmnModel model = new BpmnModel();
    try {
      boolean processExtensionAvailable = false;
      Process activeProcess = null;
      List<SubProcess> activeSubProcessList = new ArrayList<SubProcess>();
      while (xtr.hasNext()) {
        try {
          xtr.next();
        } catch(Exception e) {
          LOGGER.log(Level.SEVERE, "Error reading XML document", e);
          return model;
        }

        if (xtr.isEndElement()  && ELEMENT_SUBPROCESS.equalsIgnoreCase(xtr.getLocalName())) {
          activeSubProcessList.remove(activeSubProcessList.size() - 1);
        }

        if (xtr.isStartElement() == false)
          continue;

        if ("definitions".equalsIgnoreCase(xtr.getLocalName())) {

          model.setTargetNamespace(xtr.getAttributeValue(null, TARGET_NAMESPACE_ATTRIBUTE));
       
        } else if (ELEMENT_SIGNAL.equalsIgnoreCase(xtr.getLocalName())) {
         
          if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
            String signalId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
            String signalName = xtr.getAttributeValue(null, ATTRIBUTE_NAME);
            model.addSignal(signalId, signalName);
          }
         
        } else if (ELEMENT_MESSAGE.equalsIgnoreCase(xtr.getLocalName())) {
         
          if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
            String messageId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
            String messageName = xtr.getAttributeValue(null, ATTRIBUTE_NAME);
            model.addMessage(messageId, messageName);
          }
         
        } else if (ELEMENT_PARTICIPANT.equalsIgnoreCase(xtr.getLocalName())) {
         
          if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
            Pool pool = new Pool();
            pool.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
            pool.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
            pool.setProcessRef(xtr.getAttributeValue(null, ATTRIBUTE_PROCESS_REF));
            model.getPools().add(pool);
          }

        } else if (ELEMENT_PROCESS.equalsIgnoreCase(xtr.getLocalName())) {
         
          if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_ID))) {
            String processId = xtr.getAttributeValue(null, ATTRIBUTE_ID);
            processExtensionAvailable = true;
            Process process = new Process();
            process.setId(processId);
            process.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
            model.getProcesses().add(process);
            activeProcess = process; 
          }
         
        } else if ("lane".equalsIgnoreCase(xtr.getLocalName())) {
View Full Code Here

  }
 
  private void addFlowNodeOrArtifact(final BaseElement baseElement, final BaseElement container) {
   
    if (container instanceof Process) {
      final Process process = (Process) container;
     
      if (baseElement instanceof FlowElement) {
        process.addFlowElement((FlowElement) baseElement);
      } else if (baseElement instanceof Artifact) {
        process.addArtifact((Artifact) baseElement);
      } else {
        throw new IllegalArgumentException("BaseElement must be FlowElement or Artifact.");
      }
     
    } else if (container instanceof SubProcess) {
View Full Code Here

            PictogramElement poolElement = addContainerElement(pool, model, diagram);
            if (poolElement == null) {
              continue;
            }

            Process process = model.getBpmnModel().getProcess(pool.getId());
            for (Lane lane : process.getLanes()) {
              addContainerElement(lane, model, (ContainerShape) poolElement);
            }
          }
        }

        for (Process process : model.getBpmnModel().getProcesses()) {
          drawFlowElements(process.getFlowElements(), model.getBpmnModel().getLocationMap(), diagram, process);
          drawArtifacts(process.getArtifacts(), model.getBpmnModel().getLocationMap(), diagram, process);
        }
        drawAllFlows(model);
      }
    });
  }
View Full Code Here

TOP

Related Classes of org.activiti.bpmn.model.Process

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.