예제 #1
0
  /**
   * Innermost method for a reduction rule. Implementation of the abstract method from superclass.
   *
   * @net YNet to perform reduction
   * @element an for consideration. returns a reduced YNet or null if a given net cannot be reduced.
   */
  public YNet reduceElement(YNet net, YExternalNetElement nextElement) {
    YNet reducedNet = net;
    if (nextElement instanceof YCondition) {
      YCondition condition = (YCondition) nextElement;
      Set postSet = condition.getPostsetElements();
      Set preSet = condition.getPresetElements();

      // \pre{p} = 1, \post{p} = 1
      if (preSet.size() == 1 && postSet.size() == 1) {
        YTask t = (YTask) preSet.toArray()[0];
        YTask u = (YTask) postSet.toArray()[0];
        Set preSetOfu = u.getPresetElements();
        Set postSetOfu = u.getPostsetElements();
        // t,u and p are not reset
        // u does not have reset arcs

        Set postSetOft = new HashSet(t.getPostsetElements());
        postSetOft.retainAll(postSetOfu);

        if (t.getSplitType() == YTask._AND
            && u.getSplitType() == YTask._AND
            && preSetOfu.size() == 1
            && u.getRemoveSet().isEmpty()
            && t.getCancelledBySet().isEmpty()
            && u.getCancelledBySet().isEmpty()
            && condition.getCancelledBySet().isEmpty()
            && (!checkReset(postSetOfu))
            && postSetOft.isEmpty()) {

          // set postflows from u to t

          Iterator postFlowIter = postSetOfu.iterator();
          while (postFlowIter.hasNext()) {
            YExternalNetElement next = (YExternalNetElement) postFlowIter.next();
            t.addPostset(new YFlow(t, next));
          }

          // remove condition from postset of t
          t.removePostsetFlow(new YFlow(condition, t));

          reducedNet.removeNetElement(condition);
          reducedNet.removeNetElement(u);

          t.addToYawlMappings(condition);
          t.addToYawlMappings(condition.getYawlMappings());
          t.addToYawlMappings(u);
          t.addToYawlMappings(u.getYawlMappings());

          return reducedNet;
        } // if nested
      } // if - size 1
    } // endif - condition

    return null;
  }
예제 #2
0
  /*
   * (non-Javadoc)
   *
   * @see de.hbrs.oryx.yawl.converter.handler.oryx.OryxHandler#convert()
   */
  @Override
  public void convert() {
    YNet net = getContext().getNet(netShape);

    BasicShape incomingShape = getShape().getIncomingsReadOnly().get(0);
    BasicShape outgoingShape = getShape().getOutgoingsReadOnly().get(0);

    YExternalNetElement incomingElement = net.getNetElement(convertYawlId(net, incomingShape));
    YExternalNetElement outgoingElement = net.getNetElement(convertYawlId(net, outgoingShape));

    if (incomingElement == null
        || outgoingElement == null
        || incomingElement.getID() == null
        || outgoingElement.getID() == null) {
      getContext()
          .addConversionWarnings(
              new ConversionException(
                  "Missing source or target for Edge with ID "
                      + getShape().getResourceId()
                      + " in Net "
                      + net.getID()));
      return;
    }

    YFlow flow = new YFlow(incomingElement, outgoingElement);
    flow.setDocumentation(edgeShape.getProperty("documentation"));

    try {
      convertFlowsInto(flow, incomingShape, outgoingShape, net);
    } catch (JSONException e) {
      getContext().addConversionWarnings("Can not convert flow predicates and ordering", e);
    } catch (ConversionException e) {
      getContext().addConversionWarnings(e);
    }

    convertFlowLayout(incomingElement, outgoingElement, net);

    outgoingElement.addPreset(flow);
  }
예제 #3
0
 private JSONObject lookUpFlowsInto(final String id, final BasicShape shape, final YNet net)
     throws JSONException, ConversionException {
   JSONObject object = shape.getPropertyJsonObject("flowsinto");
   JSONArray items = object.getJSONArray("items");
   for (int index = 0; index < items.length(); index++) {
     JSONObject flowObj = items.getJSONObject(index);
     if (flowObj.getString("task").equals(id)
         || (net.getID() + "-" + flowObj.getString("task")).equals(id)) {
       return flowObj;
     }
   }
   throw new ConversionException("Could not find flow predicated for flow to: " + id);
 }
예제 #4
0
 private void convertFlowLayout(
     final YExternalNetElement incomingElement,
     final YExternalNetElement outgoingElement,
     final YNet net) {
   YNetLayout netLayout = getContext().getLayout().getNetLayout(net.getID());
   YFlowLayout flowLayout =
       new YFlowLayout(incomingElement, outgoingElement, getContext().getNumberFormat());
   flowLayout.setBounds(convertShapeBounds(getShape()));
   flowLayout.setLineStyle(convertLineStyle(getShape()));
   flowLayout.setSourcePort(convertPort(incomingElement, edgeShape.getDockerAt(0)));
   flowLayout.setPoints(convertDockers(edgeShape.getDockersReadOnly()));
   flowLayout.setTargetPort(
       convertPort(outgoingElement, edgeShape.getDockerAt(edgeShape.getNumDockers() - 1)));
   netLayout.addFlowLayout(flowLayout);
 }