Package com.asakusafw.compiler.flow.jobflow

Examples of com.asakusafw.compiler.flow.jobflow.JobflowModel$Process


                                // we have to iterate again through all flow elements
                                // in order to find our activity name
                                List<RootElement> re =  def.getRootElements();
                                for(RootElement r : re) {
                                    if(r instanceof Process) {
                                        Process p = (Process) r;
                                        List<FlowElement> fes =  p.getFlowElements();
                                        for(FlowElement f : fes) {
                                            if(f instanceof Activity && ((Activity) f).getName().equals(activityNameRef)) {
                                                ((CompensateEventDefinition) ed).setActivityRef((Activity)f);
                                                ((Activity) f).setIsForCompensation(true);
                                            }
View Full Code Here


        List<Interface> toAddInterfaces = new ArrayList<Interface>();
        List<Message> toAddMessages = new ArrayList<Message>();
        List<ItemDefinition> toAddDefinitions = new ArrayList<ItemDefinition>();
        for(RootElement root : rootElements) {
            if(root instanceof Process) {
                Process process = (Process) root;
                List<FlowElement> flowElements =  process.getFlowElements();
                for(FlowElement fe : flowElements) {
                    if(fe instanceof ServiceTask) {
                        Iterator<FeatureMap.Entry> iter = fe.getAnyAttribute().iterator();
                        String  serviceImplementation = null;
                        String serviceInterface = null;
View Full Code Here

    }
   
    private void createDiagram(Definitions def) {
      for (RootElement rootElement: def.getRootElements()) {
        if (rootElement instanceof Process) {
          Process process = (Process) rootElement;
            BpmnDiFactory factory = BpmnDiFactory.eINSTANCE;
            BPMNDiagram diagram = factory.createBPMNDiagram();
            BPMNPlane plane = factory.createBPMNPlane();
            plane.setBpmnElement(process);
            diagram.setPlane(plane);
          // first process flowNodes
            for (FlowElement flowElement: process.getFlowElements()) {
              if (flowElement instanceof FlowNode) {
                Bounds b = _bounds.get(flowElement.getId());
                if (b != null) {
                  BPMNShape shape = factory.createBPMNShape();
                  shape.setBpmnElement(flowElement);
                  shape.setBounds(b);
                  plane.getPlaneElement().add(shape);
                  if(flowElement instanceof BoundaryEvent) {
                    BPMNEdge edge = factory.createBPMNEdge();
                    edge.setBpmnElement(flowElement);
                    List<Point> dockers = _dockers.get(flowElement.getId());
                    DcFactory dcFactory = DcFactory.eINSTANCE;
                    Point addedDocker = dcFactory.createPoint();
                    for (int i = 0; i < dockers.size(); i++) {
                      edge.getWaypoint().add(dockers.get(i));
                      if(i == 0) {
                        addedDocker.setX(dockers.get(i).getX());
                        addedDocker.setY(dockers.get(i).getY());
                      }
                    }
                    if(dockers.size() == 1) {
                      edge.getWaypoint().add(addedDocker);
                    }
                    plane.getPlaneElement().add(edge);
                  }
                }
                // check if its a subprocess
                if(flowElement instanceof SubProcess) {
                  createSubProcessDiagram(plane, flowElement, factory);
                }
              } else if(flowElement instanceof DataObject) {
                Bounds b = _bounds.get(flowElement.getId());
                if (b != null) {
                  BPMNShape shape = factory.createBPMNShape();
                  shape.setBpmnElement(flowElement);
                  shape.setBounds(b);
                  plane.getPlaneElement().add(shape);
                }
              }
              else if (flowElement instanceof SequenceFlow) {
                SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
                BPMNEdge edge = factory.createBPMNEdge();
              edge.setBpmnElement(flowElement);
              DcFactory dcFactory = DcFactory.eINSTANCE;
              Point point = dcFactory.createPoint();
              if(sequenceFlow.getSourceRef() != null) {
                Bounds sourceBounds = _bounds.get(sequenceFlow.getSourceRef().getId());
                point.setX(sourceBounds.getX() + (sourceBounds.getWidth()/2));
                point.setY(sourceBounds.getY() + (sourceBounds.getHeight()/2));
              }
              edge.getWaypoint().add(point);
              List<Point> dockers = _dockers.get(sequenceFlow.getId());
              for (int i = 1; i < dockers.size() - 1; i++) {
                edge.getWaypoint().add(dockers.get(i));
              }
              point = dcFactory.createPoint();
              if(sequenceFlow.getTargetRef() != null) {
                Bounds targetBounds = _bounds.get(sequenceFlow.getTargetRef().getId());
                point.setX(targetBounds.getX() + (targetBounds.getWidth()/2));
                point.setY(targetBounds.getY() + (targetBounds.getHeight()/2));
              }
              edge.getWaypoint().add(point);
              plane.getPlaneElement().add(edge);
              }
            }
            // artifacts
                if (process.getArtifacts() != null){
                    for (Artifact artifact : process.getArtifacts()) {
                        if (artifact instanceof TextAnnotation || artifact instanceof Group) {
                          Bounds b = _bounds.get(artifact.getId());
                          if (b != null) {
                            BPMNShape shape = factory.createBPMNShape();
                            shape.setBpmnElement(artifact);
                            shape.setBounds(b);
                            plane.getPlaneElement().add(shape);
                          }
                        }
                        if (artifact instanceof Association){
                            Association association = (Association)artifact;
                            BPMNEdge edge = factory.createBPMNEdge();
                            edge.setBpmnElement(association);
                            DcFactory dcFactory = DcFactory.eINSTANCE;
                            Point point = dcFactory.createPoint();
                            Bounds sourceBounds = _bounds.get(association.getSourceRef().getId());
                            point.setX(sourceBounds.getX() + (sourceBounds.getWidth()/2));
                            point.setY(sourceBounds.getY() + (sourceBounds.getHeight()/2));
                            edge.getWaypoint().add(point);
                            List<Point> dockers = _dockers.get(association.getId());
                            for (int i = 1; i < dockers.size() - 1; i++) {
                                    edge.getWaypoint().add(dockers.get(i));
                            }
                            point = dcFactory.createPoint();
                            Bounds targetBounds = _bounds.get(association.getTargetRef().getId());
                            point.setX(targetBounds.getX()); // TODO check
                            point.setY(targetBounds.getY() + (targetBounds.getHeight()/2));
                            edge.getWaypoint().add(point);
                            plane.getPlaneElement().add(edge);
                        }
                    }
                }
            // lanes
            if(process.getLaneSets() != null && process.getLaneSets().size() > 0) {
              for(LaneSet ls : process.getLaneSets()) {
                for(Lane lane : ls.getLanes()) {
                  Bounds b = _bounds.get(lane.getId());
                    if (b != null) {
                      BPMNShape shape = factory.createBPMNShape();
                      shape.setBpmnElement(lane);
View Full Code Here

        _idMap.put(resourceId, baseElt);
        // baseElt.setId(resourceId); commented out as bpmn2 seems to create
        // duplicate ids right now.
        applyProperties(baseElt, properties, preProcessingData);
        if (baseElt instanceof Definitions) {
          Process rootLevelProcess = null;
          if(childElements == null || childElements.size() < 1) {
            if (rootLevelProcess == null) {
                    rootLevelProcess = Bpmn2Factory.eINSTANCE.createProcess();
                    // set the properties and item definitions first
                    if(properties.get("vardefs") != null && properties.get("vardefs").length() > 0) {
                        String[] vardefs = properties.get("vardefs").split( ",\\s*" );
                        for(String vardef : vardefs) {
                            Property prop = Bpmn2Factory.eINSTANCE.createProperty();
                            ItemDefinition itemdef =  Bpmn2Factory.eINSTANCE.createItemDefinition();
                            // check if we define a structure ref in the definition
                            if(vardef.contains(":")) {
                                String[] vardefParts = vardef.split( ":\\s*" );
                                prop.setId(vardefParts[0]);
                                itemdef.setId("_" + prop.getId() + "Item");
                                itemdef.setStructureRef(vardefParts[1]);
                            } else {
                                prop.setId(vardef);
                                itemdef.setId("_" + prop.getId() + "Item");
                            }
                            prop.setItemSubjectRef(itemdef);
                            rootLevelProcess.getProperties().add(prop);
                            ((Definitions) baseElt).getRootElements().add(itemdef);
                        }
                    }

                    if(properties.get("adhocprocess") != null && properties.get("adhocprocess").equals("true")) {
                      ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                        EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                                    "http://www.jboss.org/drools", "adHoc", false, false);
                        SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                            properties.get("adhocprocess"));
                        rootLevelProcess.getAnyAttribute().add(extensionEntry);
                    }

                    if(properties.get("customdescription") != null && properties.get("customdescription").length() > 0) {
                        MetaDataType metadata = DroolsFactory.eINSTANCE.createMetaDataType();
                        metadata.setName("customDescription");
                        metadata.setMetaValue(wrapInCDATABlock(properties.get("customdescription")));

                        if(rootLevelProcess.getExtensionValues() == null || rootLevelProcess.getExtensionValues().size() < 1) {
                            ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                            rootLevelProcess.getExtensionValues().add(extensionElement);
                        }
                        FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry(
                                (Internal) DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, metadata);
                        rootLevelProcess.getExtensionValues().get(0).getValue().add(extensionElementEntry);
                    }

                    rootLevelProcess.setId(properties.get("id"));
                    applyProcessProperties(rootLevelProcess, properties);
                    ((Definitions) baseElt).getRootElements().add(rootLevelProcess);
                }
          } else {
            for (BaseElement child : childElements) {
                  // tasks are only permitted under processes.
                  // a process should be created implicitly for tasks at the root
                  // level.
 
                  // process designer doesn't make a difference between tasks and
                  // global tasks.
                  // if a task has sequence edges it is considered a task,
                  // otherwise it is considered a global task.
  //                if (child instanceof Task && _outgoingFlows.get(child).isEmpty() && !_sequenceFlowTargets.contains(_objMap.get(child))) {
  //                    // no edges on a task at the top level! We replace it with a
  //                    // global task.
  //                    GlobalTask task = null;
  //                    if (child instanceof ScriptTask) {
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalScriptTask();
  //                        ((GlobalScriptTask) task).setScript(((ScriptTask) child).getScript());
  //                        ((GlobalScriptTask) task).setScriptLanguage(((ScriptTask) child).getScriptFormat());
  //                        // TODO scriptLanguage missing on scriptTask
  //                    } else if (child instanceof UserTask) {
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalUserTask();
  //                    } else if (child instanceof ServiceTask) {
  //                        // we don't have a global service task! Fallback on a
  //                        // normal global task
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalTask();
  //                    } else if (child instanceof BusinessRuleTask) {
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalBusinessRuleTask();
  //                    } else if (child instanceof ManualTask) {
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalManualTask();
  //                    } else {
  //                        task = Bpmn2Factory.eINSTANCE.createGlobalTask();
  //                    }
  //
  //                    task.setName(((Task) child).getName());
  //                    task.setIoSpecification(((Task) child).getIoSpecification());
  //                    task.getDocumentation().addAll(((Task) child).getDocumentation());
  //                    ((Definitions) baseElt).getRootElements().add(task);
  //                    continue;
  //                } else {
                      if (child instanceof SequenceFlow) {
                          // for some reason sequence flows are placed as root elements.
                          // find if the target has a container, and if we can use it:
                          List<String> ids = _outgoingFlows.get(child);
                          FlowElementsContainer container = null;
                          for (String id : ids) { // yes, we iterate, but we'll take the first in the list that will work.
                              Object obj = _idMap.get(id);
                              if (obj instanceof EObject && ((EObject) obj).eContainer() instanceof FlowElementsContainer) {
                                  container = (FlowElementsContainer) ((EObject) obj).eContainer();
                                  break;
                              }
                          }
                          if (container != null) {
                              container.getFlowElements().add((SequenceFlow) child);
                              continue;
                          }
                         
                      }
                      if (child instanceof Task || child instanceof SequenceFlow
                              || child instanceof Gateway || child instanceof Event
                              || child instanceof Artifact || child instanceof DataObject || child instanceof SubProcess
                              || child instanceof Lane || child instanceof CallActivity) {
                          if (rootLevelProcess == null) {
                              rootLevelProcess = Bpmn2Factory.eINSTANCE.createProcess();
                              // set the properties and item definitions first
                              if(properties.get("vardefs") != null && properties.get("vardefs").length() > 0) {
                                  String[] vardefs = properties.get("vardefs").split( ",\\s*" );
                                  for(String vardef : vardefs) {
                                      Property prop = Bpmn2Factory.eINSTANCE.createProperty();
                                      ItemDefinition itemdef =  Bpmn2Factory.eINSTANCE.createItemDefinition();
                                      // check if we define a structure ref in the definition
                                      if(vardef.contains(":")) {
                                          String[] vardefParts = vardef.split( ":\\s*" );
                                          prop.setId(vardefParts[0]);
                                          itemdef.setId("_" + prop.getId() + "Item");
                                          itemdef.setStructureRef(vardefParts[1]);
                                      } else {
                                          prop.setId(vardef);
                                          itemdef.setId("_" + prop.getId() + "Item");
                                      }
                                      prop.setItemSubjectRef(itemdef);
                                      rootLevelProcess.getProperties().add(prop);
                                      ((Definitions) baseElt).getRootElements().add(itemdef);
                                  }
                              }
                              if(properties.get("adhocprocess") != null && properties.get("adhocprocess").equals("true")) {
                                ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
                                  EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
                                              "http://www.jboss.org/drools", "adHoc", false, false);
                                  SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
                                      properties.get("adhocprocess"));
                                  rootLevelProcess.getAnyAttribute().add(extensionEntry);
                              }
                                if(properties.get("customdescription") != null && properties.get("customdescription").length() > 0) {
                                    MetaDataType metadata = DroolsFactory.eINSTANCE.createMetaDataType();
                                    metadata.setName("customDescription");
                                    metadata.setMetaValue(wrapInCDATABlock(properties.get("customdescription")));

                                    if(rootLevelProcess.getExtensionValues() == null || rootLevelProcess.getExtensionValues().size() < 1) {
                                        ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
                                        rootLevelProcess.getExtensionValues().add(extensionElement);
                                    }
                                    FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry(
                                            (Internal) DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, metadata);
                                    rootLevelProcess.getExtensionValues().get(0).getValue().add(extensionElementEntry);
                                }
                              rootLevelProcess.setId(properties.get("id"));
                              applyProcessProperties(rootLevelProcess, properties);
                              ((Definitions) baseElt).getRootElements().add(rootLevelProcess);
                          }
                      }
                      if (child instanceof Task) {
                          rootLevelProcess.getFlowElements().add((Task) child);
                      } else if (child instanceof CallActivity) {
                        rootLevelProcess.getFlowElements().add((CallActivity) child);
                      } else if (child instanceof RootElement) {
                          ((Definitions) baseElt).getRootElements().add((RootElement) child);
                      } else if (child instanceof SequenceFlow) {
                          rootLevelProcess.getFlowElements().add((SequenceFlow) child);
                      } else if (child instanceof Gateway) {
                          rootLevelProcess.getFlowElements().add((Gateway) child);
                      } else if (child instanceof Event) {
                          rootLevelProcess.getFlowElements().add((Event) child);
                      } else if (child instanceof Artifact) {
                          rootLevelProcess.getArtifacts().add((Artifact) child);
                      } else if (child instanceof DataObject) {
                            // bubble up data objects
                          //rootLevelProcess.getFlowElements().add(0, (DataObject) child);
                        rootLevelProcess.getFlowElements().add((DataObject) child);
  //                        ItemDefinition def = ((DataObject) child).getItemSubjectRef();
  //                        if (def != null) {
  //                            if (def.eResource() == null) {
  //                                ((Definitions) rootLevelProcess.eContainer()).getRootElements().add(0, def);
  //                            }
  //                            Import imported = def.getImport();
  //                            if (imported != null && imported.eResource() == null) {
  //                                ((Definitions) rootLevelProcess.eContainer()).getImports().add(0, imported);
  //                            }
  //                        }
                      } else if(child instanceof SubProcess) {
                          rootLevelProcess.getFlowElements().add((SubProcess) child);
                      } else if(child instanceof Lane) {
                        // lanes handled later
                      } else {
                            _logger.error("Don't know what to do of " + child);
                      }
View Full Code Here

                Definitions def = ((JbpmProfileImpl) profile).getDefinitions((String) ab.getAssetContent());

                List<RootElement> rootElements = def.getRootElements();
                for(RootElement root : rootElements) {
                    if(root instanceof Process) {
                        Process process = (Process) root;
                        info.put("processid", process.getId());

                        boolean foundVersion = false;
                        Iterator<FeatureMap.Entry> iter = process.getAnyAttribute().iterator();
                        while(iter.hasNext()) {
                            FeatureMap.Entry entry = iter.next();
                            if(entry.getEStructuralFeature().getName().equals("version")) {
                                info.put("assetversion", entry.getValue());
                                foundVersion = true;
View Full Code Here

              // find the embedded subprocess
              SubProcess selectedContainer = null;
              List<RootElement> rootElements =  def.getRootElements();
                for(RootElement root : rootElements) {
                  if(root instanceof Process) {
                    Process process = (Process) root;
                    selectedContainer = findSelectedContainer(selectionId, process);
                    if(selectedContainer != null) {
                          pfinder = PathFinderFactory.getInstance(selectedContainer);
                        }
                    else {
View Full Code Here

    private void revisitNodeNames(Definitions def) {
        List<RootElement> rootElements =  def.getRootElements();
        for(RootElement root : rootElements) {
            if(root instanceof Process) {
                Process process = (Process) root;
                List<FlowElement> flowElements = process.getFlowElements();
                for(FlowElement fe : flowElements) {
                    if(fe.getName() != null && fe.getId().equals(fe.getName())) {
                        // change the name so they are not the same
                        fe.setName("_" + fe.getName());
                    }
View Full Code Here

                }
            }
            List<RootElement> rootElements =  def.getRootElements();
            for(RootElement root : rootElements) {
                if(root instanceof Process) {
                    Process process = (Process) root;
                    List<FlowElement> flowElements = process.getFlowElements();
                    for(FlowElement fe : flowElements) {
                        if(fe instanceof SequenceFlow) {
                            SequenceFlow sf = (SequenceFlow) fe;
                            if(sequenceFlowMapping.containsKey(sf.getId())) {
                                sf.setSourceRef(getFlowNode(def, sequenceFlowMapping.get(sf.getId()).get("sourceRef")));
View Full Code Here

    private FlowNode getFlowNode(Definitions def, String nodeId) {
        List<RootElement> rootElements =  def.getRootElements();
        for(RootElement root : rootElements) {
            if(root instanceof Process) {
                Process process = (Process) root;
                List<FlowElement> flowElements = process.getFlowElements();
                for(FlowElement fe : flowElements) {
                    if(fe instanceof FlowNode) {
                        if(fe.getId().equals(nodeId)) {
                            return (FlowNode) fe;
                        }
View Full Code Here

                }
            }

            for (RootElement rootElement: def.getRootElements()) {
                if (rootElement instanceof Process) {
                    Process process = (Process) rootElement;
                    BpmnDiFactory diFactory = BpmnDiFactory.eINSTANCE;
                    BPMNDiagram diagram = diFactory.createBPMNDiagram();
                    BPMNPlane plane = diFactory.createBPMNPlane();
                    plane.setBpmnElement(process);
                    diagram.setPlane(plane);
                    for (FlowElement flowElement: process.getFlowElements()) {
                        if (flowElement instanceof FlowNode) {
                            Bounds b = _bounds.get(flowElement.getId());
                            if (b != null) {
                                BPMNShape shape = diFactory.createBPMNShape();
                                shape.setBpmnElement(flowElement);
View Full Code Here

TOP

Related Classes of com.asakusafw.compiler.flow.jobflow.JobflowModel$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.