Пример #1
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;
 }
  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;
  }
  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();
  }
Пример #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;
  }
Пример #5
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;
  }