Package com.tinkerpop.blueprints.pgm

Examples of com.tinkerpop.blueprints.pgm.Edge


     */
    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


            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

   * Remove an edge "safely". That's to say with prior existence check.
   * @param database database from which edge should be removed
   * @param existing edge to remove
   */
  public static void removeSafely(Graph database, Edge existing) {
    Edge toRemove = null;
    if((toRemove = database.getEdge(existing.getId()))==null) {
      if (logger.isLoggable(Level.INFO)) {
        logger.log(Level.INFO, "We tried to remove non existing edge "+toString(existing));
      }
    } else {
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

          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

            oldVertices.put(inVertex, e);
        }
        for (Object v : values.entrySet()) {
            Vertex valueVertex = service.getVertexFor(v, CascadeType.REFRESH, objectsBeingAccessed);
            if (valueVertex!=null && 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 (valueVertex !=null && 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.