예제 #1
0
 @Override
 public WeightedPath findSinglePath(Node start, Node end) {
   lastMetadata = new Metadata();
   AStarIterator iterator = new AStarIterator(start, end);
   while (iterator.hasNext()) {
     Node node = iterator.next();
     GraphDatabaseService graphDb = node.getGraphDatabase();
     if (node.equals(end)) {
       // Hit, return path
       double weight = iterator.visitData.get(node.getId()).wayLength;
       LinkedList<Relationship> rels = new LinkedList<Relationship>();
       Relationship rel =
           graphDb.getRelationshipById(iterator.visitData.get(node.getId()).cameFromRelationship);
       while (rel != null) {
         rels.addFirst(rel);
         node = rel.getOtherNode(node);
         long nextRelId = iterator.visitData.get(node.getId()).cameFromRelationship;
         rel = nextRelId == -1 ? null : graphDb.getRelationshipById(nextRelId);
       }
       Path path = toPath(start, rels);
       lastMetadata.paths++;
       return new WeightedPathImpl(weight, path);
     }
   }
   return null;
 }
예제 #2
0
  void setProperty(String nodeName, String propertyName, Object propertyValue) {
    Node i = this.getNode(nodeName);
    GraphDatabaseService db = i.getGraphDatabase();

    Transaction tx = db.beginTx();
    i.setProperty(propertyName, propertyValue);
    tx.success();
    tx.finish();
  }
예제 #3
0
 protected void add(Node geomNode, Geometry geom, String property, Comparable<?> value) {
   SpatialDatabaseRecord result = new SpatialDatabaseRecord(layer, geomNode, geom);
   Transaction tx = geomNode.getGraphDatabase().beginTx();
   try {
     result.setProperty(property, value);
     tx.success();
   } finally {
     tx.finish();
   }
   result.setUserData(value);
   results.add(result);
 }
  @Override
  public void delete() {
    Transaction tx = node.getGraphDatabase().beginTx();
    try {
      getRelationTo().delete();
      node.delete();

      tx.success();
    } finally {
      tx.finish();
    }
  }
예제 #5
0
 @Override
 public synchronized Object getRootNode() {
   return (node.getGraphDatabase().getReferenceNode());
 }