Package com.tinkerpop.blueprints.pgm

Examples of com.tinkerpop.blueprints.pgm.Edge


            if(Kind.literal.equals(GraphUtils.getKindOf(vertex))) {
                // a literal with no type information should always been considered a string literal
            } 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());
                }
            }
    }
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

      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);
        database.removeEdge(oldEdge);
        if(toCascade.contains(CascadeType.REMOVE)) {
          service.deleteOutEdgeVertex(objectVertex, valueVertex, v, objectsBeingAccessed);
        }
      }
View Full Code Here

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

    // as a consequenc,v alueVertex is loaded only for non null values
    Vertex valueVertex = null;
    if(value!=null) {
      valueVertex = service.getVertexFor(value, cascade, objectsBeingAccessed);
    }
    Edge link = null;
    // Get previously existing vertex
    Iterator<Edge> existingIterator = service.getStrategy().getOutEdgesFor(rootVertex, 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(valueVertex!=null && existing.getInVertex().equals(valueVertex)) {
        // Nothing to do
        link = existing;
      } else {
        // delete old edge (TODO maybe delete vertex, if there is no other link (excepted obvious ones, like type, Object.classes, and id)
        database.removeEdge(existing);
View Full Code Here

   */
  private <DataType> void loadSingle(GraphDatabaseDriver driver, GraphMappingStrategy strategy, ClassLoader classloader, ServiceRepository repository, Property p, DataType returned, Vertex objectVertex, Map<String, Object> objectsBeingAccessed) {
    Iterator<Edge> iterator = strategy.getOutEdgesFor(objectVertex, p).iterator();
    if(iterator.hasNext()) {
      // yeah, there is a value !
      Edge edge = iterator.next();
      Vertex firstVertex = edge.getInVertex();
      Object value = GraphUtils.createInstance(driver, strategy, classloader, firstVertex, p.getType(), repository, objectsBeingAccessed);
      if(repository.containsKey(value.getClass())) {
        // value requires fields loading
        AbstractBluePrintsBackedFinderService<IndexableGraph, DataType, ?> blueprints= (AbstractBluePrintsBackedFinderService<IndexableGraph, DataType, ?>) repository.get(value.getClass());
        value = loadObject(blueprints, firstVertex, objectsBeingAccessed);
View Full Code Here

          TupleTransformer tupleTransformer = Tuples.get(valueClass);
          returned = database.addVertex(tupleTransformer.getKind().getURIFor(vertexId, valueClass));
        }
        // 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.
      // returned.setProperty(Properties.value.name(), vertexId);
    } catch (RuntimeException e) {
      throw e;
View Full Code Here

  @Override
  protected String getEffectiveType(Vertex vertex) {
    if (vertex.getProperty(Properties.type.name()) != null) {
      return TypeUtils.getClass(vertex.getProperty(Properties.type.name()).toString());
    } else {
      Edge toType = vertex.getOutEdges(TYPE_EDGE_NAME).iterator().next();
      Vertex type = toType.getInVertex();
      // Do not use ClassLiteral here as this method must be blazing fast
      return classTransformer.extractClassIn(getValue(type).toString());
    }
  }
View Full Code Here

    }
  }

  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);
    // edge.setProperty(GraphSail.PREDICATE_PROP,
    // GraphSail.URI_PREFIX+" "+GraphUtils.getDefaultEdgeNameFor(property));
    // Create a common context for all gaedo relationships
    // edge.setProperty(GraphSail.CONTEXT_PROP,
    // GraphUtils.asSailProperty(GraphUtils.GAEDO_CONTEXT));
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.