/*
   * (non-Javadoc)
   *
   * @seede.hpi.bpmn2_0.factory.AbstractBpmnFactory#createProcessElement(org.
   * oryxeditor.server.diagram.Shape)
   */
  @Override
  protected BaseElement createProcessElement(Shape shape) {
    SequenceFlow seqFlow = new SequenceFlow();
    this.setCommonAttributes(seqFlow, shape);
    seqFlow.setId(shape.getResourceId());
    seqFlow.setName(shape.getProperty("name"));

    String conditionType = shape.getProperty("conditiontype");
    String conditionExpression = shape.getProperty("conditionexpression");

    if (!(conditionType == null || conditionType.equals("Default"))
        && !(conditionExpression == null || conditionExpression.isEmpty())) {
      seqFlow.setConditionExpression(new FormalExpression(conditionExpression));
    }

    if (conditionType != null && conditionType.equals("Default")) {
      seqFlow.setDefaultSequenceFlow(true);
    }

    /* IsImmediate Property */
    String isImmediate = shape.getProperty("isimmediate");
    if (isImmediate != null) {
      if (isImmediate.equalsIgnoreCase("false")) seqFlow.setIsImmediate(false);
      else if (isImmediate.equalsIgnoreCase("true")) seqFlow.setIsImmediate(true);
    }

    return seqFlow;
  }
 /* (non-Javadoc)
  * @see de.hpi.bpmn2_0.factory.AbstractBpmnFactory#createProcessElement(org.oryxeditor.server.diagram.Shape)
  */
 @Override
 protected Message createProcessElement(Shape shape) throws BpmnConverterException {
   Message msg = new Message();
   this.setCommonAttributes(msg, shape);
   msg.setId(shape.getResourceId());
   msg.setName(shape.getProperty("name"));
   msg.setInitiating(shape.getProperty("initiating").equalsIgnoreCase("true"));
   return msg;
 }
  /* (non-Javadoc)
   * @see de.hpi.bpmn2_0.factory.AbstractBpmnFactory#createProcessElement(org.oryxeditor.server.diagram.Shape)
   */
  @Override
  protected ConversationLink createProcessElement(Shape shape) throws BpmnConverterException {
    ConversationLink link = new ConversationLink();
    this.setCommonAttributes(link, shape);
    link.setId(shape.getResourceId());
    link.setName(shape.getProperty("name"));

    return link;
  }
  /*
   * (non-Javadoc)
   *
   * @seede.hpi.bpmn2_0.factory.AbstractBpmnFactory#createDiagramElement(org.
   * oryxeditor.server.diagram.Shape)
   */
  @Override
  protected Object createDiagramElement(Shape shape) {
    SequenceFlowConnector sequenceFlowConnector = new SequenceFlowConnector();
    sequenceFlowConnector.setId(shape.getResourceId() + "_gui");

    // TODO: Gedanken machen zu Label-Positioning
    sequenceFlowConnector.setLabel(shape.getProperty("name"));

    this.setBendpoints(sequenceFlowConnector, shape);

    return sequenceFlowConnector;
  }
  /* (non-Javadoc)
   * @see de.hpi.bpmn2_0.factory.AbstractBpmnFactory#createDiagramElement(org.oryxeditor.server.diagram.Shape)
   */
  @Override
  protected ConversationLinkConnector createDiagramElement(Shape shape) {
    ConversationLinkConnector conLink = new ConversationLinkConnector();
    conLink.setId(shape.getResourceId() + "_gui");

    conLink.setLabel(shape.getProperty("name"));
    // TODO: Label position

    this.setBendpoints(conLink, shape);

    return conLink;
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * de.hpi.bpmn2_0.factory.AbstractBpmnFactory#createBpmnElement(org.oryxeditor
   * .server.diagram.Shape)
   */
  @Override
  public BPMNElement createBpmnElement(Shape shape, BPMNElement parent) {
    SequenceFlowConnector seqConnector = (SequenceFlowConnector) this.createDiagramElement(shape);
    SequenceFlow seqFlow = (SequenceFlow) this.createProcessElement(shape);

    seqConnector.setSequenceFlowRef(seqFlow);

    return new BPMNElement(seqConnector, seqFlow, shape.getResourceId());
  }
  /* (non-Javadoc)
   * @see de.hpi.bpmn2_0.factory.AbstractBpmnFactory#createBpmnElement(org.oryxeditor.server.diagram.Shape, de.hpi.bpmn2_0.factory.BPMNElement)
   */
  @Override
  public BPMNElement createBpmnElement(Shape shape, BPMNElement parent)
      throws BpmnConverterException {
    Message msg = this.createProcessElement(shape);
    MessageShape msgShape = this.createDiagramElement(shape);
    msgShape.setMessageRef(msg);

    return new BPMNElement(msgShape, msg, shape.getResourceId());
  }
  /* (non-Javadoc)
   * @see de.hpi.bpmn2_0.factory.AbstractBpmnFactory#createBpmnElement(org.oryxeditor.server.diagram.Shape, de.hpi.bpmn2_0.factory.BPMNElement)
   */
  @Override
  public BPMNElement createBpmnElement(Shape shape, BPMNElement parent)
      throws BpmnConverterException {
    ConversationLink link = this.createProcessElement(shape);
    ConversationLinkConnector conLink = this.createDiagramElement(shape);
    conLink.setConversationLinkRef(link);

    return new BPMNElement(conLink, link, shape.getResourceId());
  }
  private ArrayList<Shape> getEdgesFromDiagram(ArrayList<Shape> shapes) {
    ArrayList<Shape> edges = new ArrayList<Shape>();

    for (Shape shape : shapes) {
      String sid = shape.getStencilId();

      if (sid.equals("SequenceFlow")
          || sid.equals("MessageFlow")
          || sid.equals("Association_Undirected")
          || sid.equals("Association_Unidirectional")
          || sid.equals("Association_Bidirectional")) {
        edges.add(shape);
      } else if (shape.getChildShapes().size() > 0) {
        edges.addAll(this.getEdgesFromDiagram(shape.getChildShapes()));
      }
    }

    return edges;
  }
  private void expandSubProcesses(Diagram diagram) {
    List<Shape> shapes = diagram.getShapes();
    for (Shape shape : shapes) {
      if (STENCIL_COLLAPSED_SUBPROCESS.equals(shape.getStencilId())
          && !"true".equals(shape.getProperty(PROPERTY_IS_CALL_ACTIVITY))) {
        String subProcessUrl = shape.getProperty(PROPERTY_ENTRY);
        if (subProcessUrl != null && subProcessUrl.length() > 0) {
          String subProcessName = shape.getProperty(PROPERTY_NAME);
          try {
            String subProcessId = getModelIdFromSignavioUrl(subProcessUrl);

            //            RepositoryArtifact artifact =
            // connector.getRepositoryArtifact(subProcessId);
            String subProcessJson = connector.getContent(subProcessId).asString();

            Diagram subProcess = DiagramBuilder.parseJson(subProcessJson);

            // FIXME subProcess = new ExtractProcessOfParticipant("Process
            // Engine").transform(subProcess);

            expandSubProcesses(subProcess);

            shape.setStencil(new StencilType(STENCIL_SUBPROCESS));
            ArrayList<Shape> childShapes = shape.getChildShapes();
            childShapes.addAll(subProcess.getChildShapes());
          } catch (Exception e) {
            throw new JsonTransformationException(
                "Error while retrieving Sub-Process"
                    + " '"
                    + subProcessName
                    + "'"
                    + " (URL: "
                    + subProcessUrl
                    + ").",
                e);
          }
        }
      }
    }
  }
Exemple #11
0
  /**
   * Basic method to convert a gateway to its shape representation.
   *
   * @param shape The resource shape object containing graphical information only.
   */
  public void toShape(Shape shape) {
    super.toShape(shape);

    shape.setStencil(new StencilType("Exclusive_Databased_Gateway"));
    shape.getProperties().put("markervisible", "false");
  }