private Set<Connected> getERByPreviousIds(Set<String> previousIds) {
    Set<Connected> matchedERs = new HashSet<Connected>();

    for (Connected er : currentERNetwork) {
      for (String previousId : previousIds) {
        if (er.isConnectedTo(previousId)) {

          // check for useOnly
          if (!useOnlyAttrMap.isEmpty()) {
            if (isMatch(er, this.useOnlyAttrMap, true)) {
              matchedERs.add(er);
              break;
            }
          } else if (!ignoreAttrMap.isEmpty()) {
            // check for ignore match
            if (!isMatch(er, this.ignoreAttrMap, false)) {
              matchedERs.add(er);
              break;
            }
          } else {
            // no use-only or ignore filters -> just add it
            matchedERs.add(er);
            break;
          }
        } // if (er.isConnectedTo(previousId))
      }
    } // for (ERBase er : currentERNetwork.getERBases())

    return matchedERs;
  }
Example #2
0
 public DirectionRelation(String relation, Connected b1, Connected b2) {
   super(relation, b1, b2);
   setProperty(FROM_KEY, b1.getUuid());
   setProperty(TO_KEY, b2.getUuid());
   start = b1;
   end = b2;
 }
  public String next() {

    if (null == next) return null;

    /*		Don't check it - in next() call outputNetworkLimit is much more then in hasNext()
    		because it updated in updateIterator()

    		if (outputNetworkLimit < getCurrentOutputNetSize())
    			return null;
    */

    Connected er = next;

    next = null;

    if (null == inputStream) {
      // very first decorator
      // create Paths
      Path p = new Path(er.getUuid());
      currentMatchedPaths.add(p);
    } else {
      // not first decorator
      updateMatchedPaths(er);
    }

    return er.getUuid();
  }
Example #4
0
  /*
   * does recursive call depends on depth
   */
  private void doDepthView(Connected e, Collection<Connected> eList, int depth) {
    eList.add(e);
    if (depth == 1) return;

    for (Connected r : e.getConnected()) {
      for (Connected rpe : r.getAllConnectedFiltered(e.getUuid())) {
        eList.add(rpe);

        doDepthView(rpe, eList, depth - 1);
      }
    }

    return;
  }
  /**
   * validate er stream with query filters. (skip er's which over filter amount)
   *
   * @return
   */
  private boolean checkQueryFilters() {
    boolean hasNext = iter.hasNext();

    if (!hasNext) // nothing found in current iterator
    {
      // check if parent stream has more elements
      if (inputStream.hasNext()) {
        // recreate current iterator with new data from parent stream
        updateIterator();
        // recursive check
        return checkQueryFilters();

      } else {
        // end of parent iterator
        next = null;
        return hasNext; // return false;
      }
    }

    boolean goThroughIterator = false;
    do {
      goThroughIterator = false;
      next = iter.next();

      Connected er = next;
      for (Filter f : filterMap.keySet()) {
        if (f.propertyValue.equals(er.getProperty(f.propertyName))) {
          // er match this filter
          int matchCount = filterMap.get(f);
          matchCount++;
          filterMap.put(f, matchCount);

          if (matchCount > f.filterAmount) {
            // skip current doc
            next = null;

            if (iter.hasNext()) goThroughIterator = true;
            else
              hasNext = checkQueryFilters(); // do recursive check - may need updateIterator() call

            break;
          }
        }
      }
    } while (goThroughIterator);
    return hasNext;
  }
  private void updateMatchedPaths(Connected newERBase) {
    Set<Path> newMatchedPaths = new HashSet<Path>();

    for (Path p : inputStream.getCurrentMatchedPaths()) {

      // if current level is optional -> move through current paths
      if (optional) newMatchedPaths.add(p);

      String lastId = p.getLast();
      Connected lastER = pipeNet.getById(lastId); // last er in the path can be virtual
      if (newERBase.isConnectedTo(lastId)
          || (lastER.isVirtual() && lastER.isConnectedTo(newERBase.getUuid()))) {
        if (!ALLOW_REENTRANCE) { // check for re-entrance
          if (p.contains(newERBase.getUuid())) continue;
        }

        p = p.clone();
        p.add(newERBase.getUuid());
        newMatchedPaths.add(p);
      }
    }

    for (Path p : newMatchedPaths) currentMatchedPaths.add(p);

    return;
  }
  private boolean isMatch(Connected er, String key, Set<String> values) {
    String erValue = er.getProperty(key);
    if (null != erValue) for (String value : values) if (value.equals(erValue)) return true;

    return false;
  }
Example #8
0
  private List<Node> adaptNodes(Collection<Connected> eList, Network net) {
    List<Node> nodes = new ArrayList<Node>(eList.size());
    List<Connected> dependentEntities = new ArrayList<Connected>();
    for (Connected e : eList) {
      Node n = new Node();
      if (null != e.getUuid()) {
        n.id = e.getUuid();
      } else {
        n.id = e.getName();
      }
      n.name = e.getName();
      n.data.put("$color", "#83548B");
      String nodeType = getNodeType(e);
      if (null != nodeType) {
        n.data.put("$type", nodeType);
        //				n.data.put("$type", "circle");
      } else {
        n.data.put("$type", "circle");
      }
      n.data.put("$dim", 10);

      for (Connected r : e.getConnected()) {
        if (null == net.getById(r.getUuid())) // show relations in network only
        continue;

        //				for (ERBase rp : r.getAllConnectedFiltered(e.getUuid()))
        {
          Adjacency a = new Adjacency();
          a.nodeFrom = e.getUuid();
          a.nodeTo = r.getUuid();
          dependentEntities.add(r);
          //					a.nodeFrom = e.getName();
          //					a.nodeTo = rp.getEntity().getName();
          a.data.put("$name", r.getName());
          a.data.put("$color", "#557EAA");
          // TODO: how to add label to relation?
          //					a.data.put("$text", "test");
          //					a.data.put("$label", "test");
          n.adjacencies.add(a);
        }
      }
      nodes.add(n);
    }

    // update names for denepndent nodes (add depenent nodes without relations)
    for (Connected e : dependentEntities) {
      if (!eList.contains(e)) {
        Node n = new Node();
        if (null != e.getUuid()) {
          n.id = e.getUuid();
        } else {
          n.id = e.getName();
        }
        n.name = e.getName();
        n.data.put("$color", "#83548B");
        n.data.put("$type", "circle");
        n.data.put("$dim", 10);

        nodes.add(n);
      }
    }

    return nodes;
  }
Example #9
0
 private String getNodeType(Connected e) {
   return e.getProperty("N4J_CONSOLE_NODE_TYPE");
 }