Package com.tinkerpop.blueprints.pgm

Examples of com.tinkerpop.blueprints.pgm.Edge


  private <DataType> void updateSingle(BluePrintsBackedFinderService<DataType, ?> service, IndexableGraph database, Property p, Object toUpdate, Vertex rootVertex, CascadeType cascade, Map<String, Object> objectsBeingAccessed) {
    Object value = p.get(toUpdate);
    // As a convention, null values are never stored
    if(value!=null) {
      Vertex valueVertex = service.getVertexFor(value, cascade, objectsBeingAccessed);
      Edge link = null;
      // Get previously existing vertex
      String edgeNameFor = GraphUtils.getEdgeNameFor(p);
      Iterator<Edge> existingIterator = rootVertex.getOutEdges(edgeNameFor).iterator();
      // property is single-valued, so iteration can be done at most one
      if(existingIterator.hasNext()) {
        // There is an existing edge, change its target and maybe delete previous one
        Edge existing = existingIterator.next();
        if(existing.getInVertex().equals(valueVertex)) {
          // Nothing to do
          link = existing;
        } else {
          // delete edge (TODO maybe delete vertex)
          database.removeEdge(existing);
View Full Code Here


      oldVertices.put(inVertex, e);
    }
    for(Object v : values.entrySet()) {
      Vertex valueVertex = getVertexFor(v, CascadeType.REFRESH, objectsBeingAccessed);
      if(oldVertices.containsKey(valueVertex)) {
        Edge oldEdge = oldVertices.remove(valueVertex);
        database.removeEdge(oldEdge);
        if(toCascade.contains(CascadeType.REMOVE)) {
          deleteOutEdgeVertex(objectVertex, valueVertex, v, objectsBeingAccessed);
        }
      }
View Full Code Here

      oldVertices.put(inVertex, e);
    }
    for(Object v : values) {
      Vertex valueVertex = getVertexFor(v, CascadeType.REFRESH, objectsBeingAccessed);
      if(oldVertices.containsKey(valueVertex)) {
        Edge oldEdge = oldVertices.remove(valueVertex);
        database.removeEdge(oldEdge);
        if(toCascade.contains(CascadeType.REMOVE)) {
          deleteOutEdgeVertex(objectVertex, valueVertex, v, objectsBeingAccessed);
        }
      }
View Full Code Here

  private <DataType> void updateSingle(BluePrintsBackedFinderService<DataType, ?> service, IndexableGraph database, Property p, Object toUpdate, Vertex rootVertex, CascadeType cascade, Map<String, Object> objectsBeingAccessed) {
    Object value = p.get(toUpdate);
    // As a convention, null values are never stored
    if(value!=null) {
      Vertex valueVertex = service.getVertexFor(value, cascade, objectsBeingAccessed);
      Edge link = null;
      // Get previously existing vertex
      String edgeNameFor = GraphUtils.getEdgeNameFor(p);
      Iterator<Edge> existingIterator = rootVertex.getOutEdges(edgeNameFor).iterator();
      // property is single-valued, so iteration can be done at most one
      if(existingIterator.hasNext()) {
        // There is an existing edge, change its target and maybe delete previous one
        Edge existing = existingIterator.next();
        if(existing.getInVertex().equals(valueVertex)) {
          // Nothing to do
          link = existing;
        } else {
          // delete edge (TODO maybe delete vertex)
          database.removeEdge(existing);
View Full Code Here

      oldVertices.put(inVertex, e);
    }
    for(Object v : values.entrySet()) {
      Vertex valueVertex = getVertexFor(v, CascadeType.REFRESH, objectsBeingAccessed);
      if(oldVertices.containsKey(valueVertex)) {
        Edge oldEdge = oldVertices.remove(valueVertex);
        database.removeEdge(oldEdge);
        if(toCascade.contains(CascadeType.REMOVE)) {
          deleteOutEdgeVertex(objectVertex, valueVertex, v, objectsBeingAccessed);
        }
      }
View Full Code Here

      oldVertices.put(inVertex, e);
    }
    for(Object v : values) {
      Vertex valueVertex = getVertexFor(v, CascadeType.REFRESH, objectsBeingAccessed);
      if(oldVertices.containsKey(valueVertex)) {
        Edge oldEdge = oldVertices.remove(valueVertex);
        database.removeEdge(oldEdge);
        if(toCascade.contains(CascadeType.REMOVE)) {
          deleteOutEdgeVertex(objectVertex, valueVertex, v, objectsBeingAccessed);
        }
      }
View Full Code Here

        // incoming connections (like classes)
        returned.setProperty(Properties.kind.name(), Tuples.get(valueClass).getKind().name());
      }
      // obtain vertex for type
      Vertex classVertex = classTransformer.getVertexFor(getDriver(), valueClass, CascadeType.PERSIST);
      Edge toType = getDriver().createEdgeFor(returned, classVertex, TypeProperty.INSTANCE);
      /*
       * Make sure literals are literals by changing that particular edge
       * context to a null value. Notice we COULD have stored literal type
       * as a property, instead of using
       */
      toType.setProperty(GraphSail.CONTEXT_PROP, GraphUtils.asSailProperty(GraphUtils.GAEDO_CONTEXT));
    }
    // Yup, this if has no default else statement, and that's normal.

    return returned;
  }
View Full Code Here

    return vertex.getProperty(Properties.value.name());
  }

  public Edge createEdgeFor(Vertex fromVertex, Vertex toVertex, Property property) {
    String edgeNameFor = GraphUtils.getEdgeNameFor(property);
    Edge edge = database.addEdge(getEdgeId(fromVertex, toVertex, property), fromVertex, toVertex, edgeNameFor);
    String predicateProperty = GraphUtils.asSailProperty(GraphUtils.getEdgeNameFor(property));
    edge.setProperty(GraphSail.PREDICATE_PROP, predicateProperty);
    Collection<String> contexts = getLens();
    StringBuilder contextPropertyBuilder = new StringBuilder();
    if (contexts.size() == 0) {
      contextPropertyBuilder.append(GraphUtils.asSailProperty(GraphSail.NULL_CONTEXT_NATIVE));
    } else {
      for (String context : contexts) {
        if (contextPropertyBuilder.length() > 0)
          contextPropertyBuilder.append(" ");
        contextPropertyBuilder.append(GraphUtils.asSailProperty(context));

      }
    }
    String contextProperty = contextPropertyBuilder.toString();
    edge.setProperty(GraphSail.CONTEXT_PROP, contextProperty);
    // Finally build the context-predicate property by concatenating both
    edge.setProperty(GraphSail.CONTEXT_PROP + GraphSail.PREDICATE_PROP, contextProperty + " " + predicateProperty);
    return edge;
  }
View Full Code Here

            oldVertices.put(inVertex, e);
        }
        for (Object v : values.entrySet()) {
            Vertex valueVertex = service.getVertexFor(v, CascadeType.REFRESH, objectsBeingAccessed);
            if (oldVertices.containsKey(valueVertex)) {
                Edge oldEdge = oldVertices.remove(valueVertex);
                GraphUtils.removeSafely(database, oldEdge);
                if (toCascade.contains(CascadeType.REMOVE)) {
                    service.deleteOutEdgeVertex(objectVertex, valueVertex, v, objectsBeingAccessed);
                }
            }
View Full Code Here

        for (Object v : values) {
          // already heard about null-containing collections ? I do know them, and they're pure EVIL
          if(v!=null) {
              Vertex valueVertex = service.getVertexFor(v, CascadeType.REFRESH, objectsBeingAccessed);
              if (oldVertices.containsKey(valueVertex)) {
                  Edge oldEdge = oldVertices.remove(valueVertex);
                  GraphUtils.removeSafely(database, oldEdge);
                  if (toCascade.contains(CascadeType.REMOVE)) {
                      service.deleteOutEdgeVertex(objectVertex, valueVertex, v, objectsBeingAccessed);
                  }
              }
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.pgm.Edge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.