Package org.eclipse.bpmn2

Examples of org.eclipse.bpmn2.Definitions


            if (result == null)
                result = defaultCase(theEObject);
            return result;
        }
        case Bpmn2Package.DEFINITIONS: {
            Definitions definitions = (Definitions) theEObject;
            T result = caseDefinitions(definitions);
            if (result == null)
                result = caseBaseElement(definitions);
            if (result == null)
                result = defaultCase(theEObject);
View Full Code Here


     * Sets all ID attributes of contained and referenced objects
     * that are not yet set, to a generated UUID.
     */
    protected void prepareSave() {
        EObject cur;
        Definitions thisDefinitions = ImportHelper.getDefinitions(this);
        for (Iterator<EObject> iter = getAllContents(); iter.hasNext();) {
            cur = iter.next();

            setIdIfNotSet(cur);

View Full Code Here

    protected void createImportIfNecessary(Definitions definitions, Resource referenced) {
        if (ImportHelper.findImportForLocation(definitions, referenced.getURI()) == null) {
            URI referencingURI = ImportHelper.makeURICanonical(definitions.eResource().getURI());
            URI referencedURI = ImportHelper.makeURICanonical(referenced.getURI());

            Definitions importedDef = ImportHelper.getDefinitions(referenced);
            // only handle BPMN imports (with declared target namespace)
            if (importedDef != null && importedDef.getTargetNamespace() != null) {
                Import newImport = Bpmn2Factory.eINSTANCE.createImport();
                newImport.setImportType(NamespaceHelper.xmiToXsdNamespaceUri(Bpmn2Package.eNS_URI));
                newImport.setNamespace(importedDef.getTargetNamespace());
                // Counterpart: location.resolve(referencingURI) == referencedURI !
                newImport.setLocation(referencedURI.deresolve(referencingURI).toString());
                definitions.getImports().add(newImport);
            }
        }
View Full Code Here

    try {
      FixFlowConverter fixFlowConverter = new FixFlowConverter();
     
        ObjectMapper objectMapper = new ObjectMapper();
            InputStream input = new FileInputStream(buildPath() +File.separator+request.getParameter("fileName"));
            Definitions definitions = fixFlowConverter.getDefinitions("process_1", input);
            Process process = (Process)definitions.getRootElements().get(0);
        ObjectNode on = fixFlowConverter.convertDefinitions2Json(definitions);
        ObjectNode rootNode = objectMapper.createObjectNode();
        rootNode.put("name", process.getName());
        rootNode.put("description", process.getName());
        rootNode.put("modelId", process.getId());
View Full Code Here

     */

    public Definitions createAndInitResource(URI uri) {
        Resource resource = createResource(uri);
        Bpmn2Factory factory = Bpmn2Factory.eINSTANCE;
        Definitions definitions = factory.createDefinitions();
        DocumentRoot docummentRoot = factory.createDocumentRoot();
        docummentRoot.setDefinitions(definitions);
        resource.getContents().add(docummentRoot);

        return definitions;
View Full Code Here

   * @param processKey
   * @param input
   * @return
   */
  public ObjectNode convertBpmn2Json(String processKey,InputStream input){
    Definitions model = getDefinitions(processKey,input);
    BpmnJsonConverter converter = new BpmnJsonConverter();
    ObjectNode jsonNode = converter.convertToJson(model);
    return jsonNode;
  }
View Full Code Here

        // TODO Auto-generated catch block
        throw new FixFlowException(ExceptionCode.EXCEPTION_DEFAULT,e);
      }
    }
    URI uri = URI.createFileURI(path);
    Definitions definitions = getDefinitions("process_1",inputStreamNewFile);
    Process process =  (Process)definitions.getRootElements().get(0);
    process.setId(processId);
    process.setName(processName);
    save(definitions, uri);
  }
View Full Code Here

   * 将jsonNode转换并保存成bpmn文件
   * @param modelNode
   * @param uri
   */
  public void save(JsonNode modelNode,URI uri){
    Definitions defintion = new BpmnJsonConverter().convertToBpmnModel(modelNode);
    save(defintion,uri);
  }
View Full Code Here

  /**
   * 获取一个空的definitions
   * @return
   */
  public Definitions getNoneDefinitions(){
    Definitions definitions = null;
    String filePath = ProcessEngineManagement.getDefaultProcessEngine().getProcessEngineConfiguration().getNoneTemplateFilePath();;
    try {
      InputStream in = null;
      in = ReflectUtil.getResourceAsStream(filePath);
      definitions = getDefinitions("node-tempplate",in);
View Full Code Here

  public Definitions convertToBpmnModel(JsonNode modelNode) {
    //加载一个空的definitions
   
    String nodeTempPath = ProcessEngineManagement.getDefaultProcessEngine().getProcessEngineConfiguration().getCopyTemplatePath();
    InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(nodeTempPath);
    Definitions bpmnModel = new FixFlowConverter().getDefinitions("temp", inputStream);
    BPMNDiagram bpmnDiagram=bpmnModel.getDiagrams().get(0);
    BPMNPlane bpmnPlane = bpmnDiagram.getPlane();
    Process process = (Process)bpmnModel.getRootElements().get(0);
    Map<String, JsonNode> shapeMap = new HashMap<String, JsonNode> ();
    Map<String, JsonNode> sourceRefMap = new HashMap<String, JsonNode>();
    Map<String, JsonNode> edgeMap = new HashMap<String, JsonNode>();
    Map<String, List<JsonNode>> sourceAndTargetMap = new HashMap<String, List<JsonNode>>();
    readShapeDI(modelNode, 0, 0, shapeMap, sourceRefMap, bpmnModel);
    filterAllEdges(modelNode, edgeMap, sourceAndTargetMap, shapeMap, sourceRefMap);
    ArrayNode shapesArrayNode = (ArrayNode) modelNode.get(EDITOR_CHILD_SHAPES);
    //做pool的时候用
    boolean nonEmptyPoolFound = false;

    if (nonEmptyPoolFound == false) {
        JsonNode processIdNode = JsonConverterUtil.getProperty(PROPERTY_OVERRIDE_ID, modelNode);
        if(processIdNode != null && StringUtils.isNotEmpty(processIdNode.asText())) {
          process.setId(processIdNode.asText());
        }
        JsonNode processNameNode = JsonConverterUtil.getProperty(PROPERTY_NAME, modelNode);
        if(processNameNode != null && StringUtils.isNotEmpty(processNameNode.asText())) {
          process.setName(processNameNode.asText());
        }
       
        //加载process的扩展元素
        //任务主题
        JsonNode processSubject = JsonConverterUtil.getProperty(PROPERTY_PROCESS_SUBJECT, modelNode);
        if(processSubject != null && StringUtils.isNotEmpty(processSubject.asText())) {
          TaskSubject taskSubject = FixFlowFactory.eINSTANCE.createTaskSubject();
            Expression subjectExpression = FixFlowFactory.eINSTANCE.createExpression();
            subjectExpression.setName(processSubject.asText());
            subjectExpression.setValue(processSubject.asText());
            taskSubject.setExpression(subjectExpression);
            taskSubject.setId("TaskSubject_1");
            BpmnModelUtil.addExtensionElement(process, FixFlowPackage.Literals.DOCUMENT_ROOT__TASK_SUBJECT, taskSubject);
        }
       
        //流程分类
        JsonNode processCategory = JsonConverterUtil.getProperty(PROPERTY_PROCESS_CATEGORY, modelNode);
        if(processCategory != null &&!"null".equals(processCategory.asText()) && StringUtil.isNotEmpty(processCategory.asText())){
          BpmnModelUtil.addExtensionAttribute(process, FixFlowPackage.Literals.DOCUMENT_ROOT__CATEGORY, processCategory.asText());
        }
       
        //默认表单
        JsonNode processFormUri = JsonConverterUtil.getProperty(PROPERTY_PROCESS_DEFAULT_FORMURI, modelNode);
        if(processFormUri != null && StringUtil.isNotEmpty(processFormUri.asText())){
          FormUri formUri = FixFlowFactory.eINSTANCE.createFormUri();
          Expression expression = FixFlowFactory.eINSTANCE.createExpression();
          expression.setName(processFormUri.asText());
          expression.setValue(processFormUri.asText());
          formUri.setExpression(expression);
          BpmnModelUtil.addExtensionElement(process, FixFlowPackage.Literals.DOCUMENT_ROOT__FORM_URI, formUri);
        }
       
        //流程变量
        JsonNode dataVariablesNode = JsonConverterUtil.getProperty(PROPERTY_PROCESS_DATAVARIABLE, modelNode);
        if(dataVariablesNode != null){
          JsonNode itemsNode = dataVariablesNode.get(EDITOR_PROPERTIES_GENERAL_ITEMS);
          if(itemsNode != null) {
                Iterator<JsonNode> variableIterator = itemsNode.getElements();
                while(variableIterator.hasNext()) {
                  JsonNode variableNode = variableIterator.next();
                  String id = variableNode.get(PROPERTY_DATAVARIABLE_ID).asText();
                  String dataType = variableNode.get(PROPERTY_DATAVARIABLE_TYPE).asText();
                  String bizType = variableNode.get(PROPERTY_DATAVARIABLE_BIZTYPE).asText();
                  boolean isPersistence = StringUtil.getBoolean(variableNode.get(PROPERTY_DATAVARIABLE_IS_PERSISTENCE));
                  String expression = "";
                  JsonNode tmpNode = variableNode.get(PROPERTY_DATAVARIABLE_DEFAULT_VALUE);
                  if(tmpNode != null){
                    expression = tmpNode.asText();
                  }
                  DataVariable dataVariableObj = FixFlowFactory.eINSTANCE.createDataVariable();
                  dataVariableObj.setBizType(bizType);
                  dataVariableObj.setId(id);
                  dataVariableObj.setDataType(dataType);
                  dataVariableObj.setIsPersistence(isPersistence);
                  Expression variableExpression = FixFlowFactory.eINSTANCE.createExpression();
                  variableExpression.setValue(expression);
                  variableExpression.setName(expression);
                  dataVariableObj.setExpression(variableExpression);
                  BpmnModelUtil.addExtensionElement(process, FixFlowPackage.Literals.DOCUMENT_ROOT__DATA_VARIABLE, dataVariableObj);
                }
          }
        }
        String isVerify = JsonConverterUtil.getProperty(PROPERTY_PROCESS_IS_VERIFY, modelNode).asText();
        BpmnModelUtil.addExtensionAttribute(process, FixFlowPackage.Literals.DOCUMENT_ROOT__VERIFICATION, isVerify);
       
        JsonNode processTargetNamespace = JsonConverterUtil.getProperty(PROPERTY_PROCESS_NAMESPACE, modelNode);
        if(processTargetNamespace != null && StringUtils.isNotEmpty(processTargetNamespace.asText())) {
          bpmnModel.setTargetNamespace(processTargetNamespace.asText());
        }
      
        ConnectorInstanceElm cie = new ConnectorInstanceElm();
        List<ConnectorInstance> list_ci = cie.convertJsonToElement(modelNode);
        if(list_ci != null){
          for (int i = 0; i < list_ci.size(); i++) {
            BpmnModelUtil.addExtensionElement(process, FixFlowPackage.Literals.DOCUMENT_ROOT__CONNECTOR_INSTANCE, list_ci.get(i));
          }
        }
        processJsonElements(shapesArrayNode, modelNode, process, shapeMap,sourceAndTargetMap,bpmnModel);
    }
   
      // Add flows to map for later processing
   
    Map<String, SequenceFlow> flowSourceMap = new HashMap<String, SequenceFlow>();
    Map<String, SequenceFlow> flowTargetMap = new HashMap<String, SequenceFlow>();
    //初始化线条的source map和target map,后面为flowNode加载来源和target
    addAllSequenceFlows(process.getFlowElements(), flowSourceMap, flowTargetMap);
    //flowElement的incoming和outgoing处理
    postProcessElements(process, process.getFlowElements(), flowSourceMap, flowTargetMap);
    //给根plane set 关联元素
    bpmnPlane.setBpmnElement(BpmnModelUtil.getBaseElement(bpmnModel, process.getId()));
    //给shape元素 set 关联元素
    for(DiagramElement diagram :  bpmnModel.getDiagrams().get(0).getPlane().getPlaneElement()){
      if(diagram instanceof BPMNShape){
        BPMNShape bpmnShape = (BPMNShape)diagram;
        String shapeId = bpmnShape.getId();
        String elementId = BpmnJsonConverterUtil.getElementIdFromShapeId(shapeId);
        BaseElement bpmnElement = BpmnModelUtil.getElement(bpmnModel,elementId,BaseElement.class);
View Full Code Here

TOP

Related Classes of org.eclipse.bpmn2.Definitions

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.