Package com.tinkerpop.blueprints.pgm

Examples of com.tinkerpop.blueprints.pgm.Edge


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


  private void updateSingle(Property p, DataType toUpdate, Vertex rootVertex, CascadeType cascade) {
    Object value = p.get(toUpdate);
    // As a convention, null values are never stored
    if(value!=null) {
      Vertex valueVertex = getVertexFor(value, cascade);
      Edge link = null;
      // Get previously existing vertex
      Iterator<Edge> existingIterator = rootVertex.getOutEdges(GraphUtils.getEdgeNameFor(p)).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) {
      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.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);
      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

                // a literal with no type information should always been considered a string literal
                return STRING_CLASS;
            } else {
                Iterator<Edge> typeIterator = vertex.getOutEdges(IndexableGraphBackedFinderService.TYPE_EDGE_NAME).iterator();
                if(typeIterator.hasNext()) {
                    Edge toType = typeIterator.next();
                    Vertex type = toType.getInVertex();
                    // Do not use ClassLiteral here as this method must be blazing fast
                    return IndexableGraphBackedFinderService.classTransformer.extractClassIn(service.getDriver().getValue(type).toString());
                } else {
                    return STRING_CLASS;
                }
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.