Esempio n. 1
0
  /**
   * Cleans up the process by ensuring that any isolated ActivityElements are added as unordered
   * paths.
   */
  public void finalizeProcess() {
    List<Resource> isolatedActivities = process.getIsolatedActivities();
    if (isolatedActivities.size() > 0) {
      Model model = process.getModel();
      // TODO: Fix this so that it doesn't keep stacking outer fork/joins
      // when they aren't necessary

      // create fork/join for all elements
      Resource fork = createForkElement();
      Resource join = createJoinElement();

      Resource start = process.getStartElement();
      Resource end = process.getEndElement();
      // insert fork after the start
      insertAfter(fork, start);

      // insert join before the finish
      insertBefore(join, end);

      // add any isolated activities
      for (Resource r : isolatedActivities) {
        model.add(fork, RNRM.isFlowingTo, r);
        model.add(r, RNRM.isFlowingTo, join);
      }
    }
  }
Esempio n. 2
0
  /**
   * Converts the given process into an unordered set of ActivityElements
   *
   * @param processResource
   */
  public void removeProcessOrder() {
    if (logger.isWarnEnabled()) {
      logger.warn(
          String.format(
              "Giving up all attempts to repair process, %1$s. Treating it as an unordered set of Activities.",
              process.getLabel()));
    }
    Resource startElement = process.getStartElement();
    Resource endElement = process.getEndElement();
    // make sure start element is ready to go with no arcs
    if (null == startElement) {
      // create a start element
      startElement = createStartElement();
    } else {
      isolateElement(startElement);
    }

    // make sure end element is ready to go with no arcs
    if (null == endElement) {
      // create an end element
      endElement = createEndElement();
    } else {
      isolateElement(endElement);
    }
    // isolate activity elements
    Set<Resource> processElements = process.getProcessElements();
    for (Resource r : processElements) {
      // isolate will remove in/out links and delete the element if it's
      // not Activity, Start, or End
      isolateElement(r);
    }

    finalizeProcess();
  }
Esempio n. 3
0
 /**
  * Removes all incoming and outgoing rnrm:isFlowingTo edges from the specified element. If this is
  * a fork, join, decision, or merge and it's not the start or end, then it will just be deleted
  * since you cannot recover it.
  *
  * @param procElement
  */
 public void isolateElement(Resource procElement) {
   removeOutgoingLinks(procElement);
   removeIncomingLinks(procElement);
   // if this is something other than an ActivityElement and isn't the
   // start or end, then remove it from the model
   if (!RDFHelper.hasRdfType(process.getModel(), procElement, RNRM.ActivityElement)
       && !procElement.equals(process.getStartElement())
       && !procElement.equals(process.getEndElement())) {
     removeFromProcess(procElement);
   }
 }
Esempio n. 4
0
 /**
  * Removes an incoming rnrm:isFlowingTo edge from the specified element such that a path from the
  * start element to the specified element still exists.
  *
  * @param procElement Element to remove an incoming edge from
  * @return True if an edge was safely removed. False if no edges could be removed without
  *     eliminating the path.
  */
 public boolean removeNonBreakingIncomingArc(Resource procElement) {
   boolean foundSafeRemoval = false;
   if (process.completePathExists()) {
     List<Statement> incomingArcs = process.getIncomingEdges(procElement);
     for (Statement stmt : incomingArcs) {
       process.getModel().remove(stmt);
       if (process.pathExists(process.getStartElement(), procElement)) {
         foundSafeRemoval = true;
         break;
       } else {
         process.getModel().add(stmt);
       }
     }
   }
   return foundSafeRemoval;
 }