private CanonicalProcessType buildCPF() {
    CanonicalProcessType cpf = new CanonicalProcessType();

    NetType net = new NetType();

    EventType event = new EventType();
    event.setId("1");
    event.setOriginalID("1");
    event.setName("event");

    TaskType task = new TaskType();
    task.setId("2");
    task.setOriginalID("2");
    task.setName("task");

    EdgeType edge = new EdgeType();
    edge.setId("3");
    edge.setOriginalID("3");
    edge.setSourceId("1");
    edge.setTargetId("2");

    net.getNode().add(event);
    net.getNode().add(task);
    net.getEdge().add(edge);
    cpf.getNet().add(net);

    return cpf;
  }
  @Test
  public void testSimpleMerge() {
    final NetType rootNet = yawl2Canonical.getCpf().getNet().get(0);
    assertEquals(9, rootNet.getEdge().size());
    assertEquals(8, rootNet.getNode().size());

    final List<EdgeType> edges = getOutgoingEdges(rootNet, getNodeByName(rootNet, "IN").getId());
    assertEquals(1, edges.size());
    final NodeType routingNode = getNodeByID(rootNet, edges.get(0).getTargetId());
    checkNode(rootNet, routingNode, StateType.class, 1, 3);

    final List<EdgeType> routingEdges = getOutgoingEdges(rootNet, routingNode.getId());
    for (final EdgeType edge : routingEdges) {
      assertNull("No condition after StateNode", edge.getConditionExpr());
    }

    checkNode(rootNet, "A", TaskType.class, 1, 1);
    checkNode(rootNet, "B", TaskType.class, 1, 1);
    final NodeType nodeC = checkNode(rootNet, "C", TaskType.class, 1, 1);

    final List<EdgeType> cEdges = getOutgoingEdges(rootNet, nodeC.getId());
    assertEquals(1, cEdges.size());
    final NodeType joiningNode = getNodeByID(rootNet, cEdges.get(0).getTargetId());
    checkNode(rootNet, joiningNode, XORJoinType.class, 3, 1);

    checkNode(rootNet, "D", TaskType.class, 1, 1);
  }
 /* loop through the list of edges and process each one. */
 private void manipulateEdges(
     CanonicalProcessType cpf, AnnotationsType anf, Map<String, AnnotationData> annotations) {
   GraphicsType annotation;
   for (NetType net : cpf.getNet()) {
     for (EdgeType edge : net.getEdge()) {
       annotation = findGraphicsType(anf, edge.getId());
       if (annotation != null) {
         manipulateEdge(annotation, edge, annotations);
       }
     }
   }
 }
  /* Changes the position on the Edges From and Two coordinates. */
  private void manipulateEdge(
      GraphicsType graphicsType, EdgeType edge, Map<String, AnnotationData> annotations) {
    AnnotationData annData;

    if (annotations.containsKey(edge.getSourceId())) {
      annData = annotations.get(edge.getSourceId());
      changeLocation(graphicsType, annData);
    }
    if (annotations.containsKey(edge.getTargetId())) {
      annData = annotations.get(edge.getTargetId());
      changeLocation(graphicsType, annData);
    }
  }
 private void convertEdge(final FlowsIntoType flowsInto, final EdgeType edge) {
   if (flowsInto.getIsDefaultFlow() != null) {
     edge.setDefault(true);
   } else {
     edge.setDefault(false);
   }
   if (flowsInto.getPredicate() != null) {
     ConditionExpressionType expressionType = CPF_FACTORY.createConditionExpressionType();
     expressionType.setLanguage(CPFSchema.EXPRESSION_LANGUAGE_XPATH);
     expressionType.setExpression(flowsInto.getPredicate().getValue());
     edge.setConditionExpr(expressionType);
   }
 }
 /**
  * Simple connection between two already converted element. Source and Target have to be SESE, as
  * we are not going to introduce any kind of routing node.
  *
  * @param sourceNode of CPF
  * @param targetNode of CPF
  * @return a CPF edge
  * @throws CanoniserException
  */
 protected EdgeType createSimpleEdge(final NodeType sourceNode, final NodeType targetNode)
     throws CanoniserException {
   final EdgeType edge = CPF_FACTORY.createEdgeType();
   // Assign unique ID that is reproducible by using sources and targets ID
   edge.setId(generateEdgeId(sourceNode, targetNode));
   edge.setSourceId(sourceNode.getId());
   edge.setTargetId(targetNode.getId());
   getConvertedParent().getEdge().add(edge);
   if (sourceNode.getOriginalID() != null && targetNode.getOriginalID() != null) {
     createGraphicsForFlow(sourceNode.getOriginalID(), targetNode.getOriginalID());
   } else {
     createGraphicsForFlow(sourceNode.getId(), targetNode.getId());
   }
   return edge;
 }
  public void translateArc(EdgeType edge) {
    // LOGGER.info("Translating edge " + edge.getId());
    org.apromore.pnml.NodeType arcsource = new org.apromore.pnml.NodeType();
    org.apromore.pnml.NodeType arctarget = new org.apromore.pnml.NodeType();

    NodeType source = data.get_nodeRefMap_value(edge.getSourceId());
    NodeType target = data.get_nodeRefMap_value(edge.getTargetId());

    data.put_id_map(edge.getId(), String.valueOf(ids));

    if (data.getStartNodeMap().containsKey(source)) {
      arcsource = data.getEndNodeMap().get(source);
    }

    if (data.getEndNodeMap().containsKey(target)) {
      arctarget = data.getStartNodeMap().get(target);
    }

    if (data.isCpfEdgePnmlPlace()) {
      // Create a PNML Place corresponding to the CPF Edge
      PlaceType place = new PlaceType();
      place.setId(String.valueOf(ids++));
      place.setGraphics(
          TranslateNode.newGraphicsNodeType(
              TranslateNode.dummyPosition(), TranslateNode.placeDefaultDimension()));
      data.getNet().getPlace().add(place);
      // data.put_pnmlRefMap(place.getId(), place);  TranslateNodeAnnotation can't cope with ANF
      // Edges generating PNML Place Graphics

      // Create incoming arc
      ArcType incomingArc = new ArcType();
      incomingArc.setId(String.valueOf(ids++));
      incomingArc.setTarget(place);
      data.getNet().getArc().add(incomingArc);
      data.put_pnmlRefMap(incomingArc.getId(), incomingArc);

      if (!(arcsource instanceof PlaceType)) {
        incomingArc.setSource(arcsource);
      } else { // insert a silent transition before the place
        TransitionType transition = new TransitionType();
        transition.setId(String.valueOf(ids++));
        transition.setGraphics(
            TranslateNode.newGraphicsNodeType(
                TranslateNode.dummyPosition(), TranslateNode.blindTransitionDefaultDimension()));
        data.getNet().getTransition().add(transition);
        data.put_pnmlRefMap(transition.getId(), transition);

        incomingArc.setSource(transition);

        ArcType arc = new ArcType();
        arc.setId(String.valueOf(ids++));
        arc.setSource(arcsource);
        arc.setTarget(transition);
        data.getNet().getArc().add(arc);
        data.put_pnmlRefMap(arc.getId(), arc);
      }

      // Create outgoing arc
      ArcType outgoingArc = new ArcType();
      outgoingArc.setId(String.valueOf(ids++));
      outgoingArc.setSource(place);
      data.getNet().getArc().add(outgoingArc);
      data.put_pnmlRefMap(outgoingArc.getId(), outgoingArc);

      if (!(arctarget instanceof PlaceType)) {
        outgoingArc.setTarget(arctarget);
      } else { // insert a silent transition after the place
        TransitionType transition = new TransitionType();
        transition.setId(String.valueOf(ids++));
        transition.setGraphics(
            TranslateNode.newGraphicsNodeType(
                TranslateNode.dummyPosition(), TranslateNode.blindTransitionDefaultDimension()));
        data.getNet().getTransition().add(transition);
        data.put_pnmlRefMap(transition.getId(), transition);

        outgoingArc.setTarget(transition);

        ArcType arc = new ArcType();
        arc.setId(String.valueOf(ids++));
        arc.setSource(transition);
        arc.setTarget(arctarget);
        data.getNet().getArc().add(arc);
        data.put_pnmlRefMap(arc.getId(), arc);
      }

      data.put_originalid_map(
          BigInteger.valueOf(Long.valueOf(place.getId())), edge.getOriginalID());
    } else { // !data.isCpfEdgePnmlPlace()
      ArcType arc = new ArcType();
      arc.setId(String.valueOf(ids++));

      // Synthesize a place in the case of an edge between two transitions
      if (arcsource instanceof TransitionType && arctarget instanceof TransitionType) {
        // Create the synthetic place
        PlaceType place = new PlaceType();
        place.setId(String.valueOf(ids++));
        place.setGraphics(
            TranslateNode.newGraphicsNodeType(
                TranslateNode.dummyPosition(), TranslateNode.placeDefaultDimension()));
        data.getNet().getPlace().add(place);
        data.getSynthesizedPlaces().add(place);
        data.put_pnmlRefMap(place.getId(), place);

        // Create outgoing arc from the synthetic place to the original arc's target
        ArcType arc2 = new ArcType();
        arc2.setId(String.valueOf(ids++));
        arc2.setSource(place);
        arc2.setTarget(arctarget);
        data.getNet().getArc().add(arc2);
        data.put_pnmlRefMap(arc2.getId(), arc2);

        // Our original arc now targets the synthesized place
        arctarget = place;
      }
      // changed by Marco Hipp
      ArcType removeArc = null;
      // implemented Method to reconnect misbehaving Place to Place Edge
      if (arcsource instanceof PlaceType && arctarget instanceof PlaceType) {
        // iterate through every Arc to get the Arc that has the source Place as Target
        for (ArcType arcList : data.getNet().getArc()) {
          if (arcList.getTarget() instanceof PlaceType) {
            PlaceType aclistTarget = (PlaceType) arcList.getTarget();
            if (aclistTarget.getId().equals(arcsource.getId())) {
              if (arcList.getSource() instanceof PlaceType) {
                PlaceType transitionSourcePlace = (PlaceType) arcList.getSource();
              }
              if (arcList.getSource() instanceof TransitionType) {
                TransitionType transitionSource = (TransitionType) arcList.getSource();
                org.apromore.pnml.NodeType nodeTransitionSource =
                    (org.apromore.pnml.NodeType) transitionSource;
                org.apromore.pnml.NodeType zwischenspeicher = arcsource;
                data.getNet().getPlace().remove((PlaceType) zwischenspeicher);
                arcsource = nodeTransitionSource;
                // data.getEndNodeMap().remove(source);
                data.getRunningPlaceMap().remove(source);
                removeArc = arcList;
                //	            				for (ArcType removeArc : data.getNet().getArc()) {
                //
                //	            				}

                //	            				data.get
              }
            }
          }
          if (arcList.getTarget() instanceof TransitionType) {
            TransitionType aclistTarget = (TransitionType) arcList.getTarget();
            if (aclistTarget.getId().equals(arcsource.getId())) {
              if (arcList.getSource() instanceof PlaceType) {
                PlaceType transitionSourcePlace = (PlaceType) arcList.getSource();
              }
              if (arcList.getSource() instanceof TransitionType) {
                TransitionType transitionSource = (TransitionType) arcList.getSource();
              }
            }
          }
        }
      }
      if (removeArc != null) data.getNet().getArc().remove(removeArc);
      arc.setSource(arcsource);
      arc.setTarget(arctarget);
      ArcNameType inscription = new ArcNameType();
      inscription.setText(1);
      arc.setInscription(inscription);
      data.getNet().getArc().add(arc);
      data.put_pnmlRefMap(arc.getId(), arc);

      data.put_originalid_map(BigInteger.valueOf(Long.valueOf(arc.getId())), edge.getOriginalID());
    }
    // LOGGER.info("Translated edge " + edge.getId() + " as arc " + arc.getId());
  }