Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Vertex


 
  private Vertex getVertextForUnknownSerializable(GraphDatabaseDriver database, ServiceRepository repository, Serializable value) {
    String serialized = writeSerializable(value);
    // Then indexed vertex id (for neo4j, typically)
    Vertex returned = database.loadVertexFor(serialized, value.getClass().getName());
    // Finally create vertex
    if(returned==null) {
      returned = database.createEmptyVertex(Serializable.class, serialized, value);
      database.setValue(returned, serialized);
    }
View Full Code Here


   * @see com.dooapp.gaedo.blueprints.queries.tests.VertexTest#matches(com.tinkerpop.blueprints.pgm.Vertex)
   */
  @Override
  public boolean matches(Vertex examined) {
    // Navigates to the first target edge and perform test when reached
    Vertex currentVertex = examined;
    for(Property currentProperty : path) {
      Iterator<Edge> edges = strategy.getOutEdgesFor(currentVertex, currentProperty).iterator();
      if(edges.hasNext()) {
        currentVertex = edges.next().getVertex(Direction.IN);
      } else {
View Full Code Here

      this.vertex = vertex;
    }

    public Object get(FieldInformer key) {
      if(!fieldValues.containsKey(key)) {
        Vertex currentVertex = vertex;
        Object value = null;
        for(Property currentProperty : key.getFieldPath()) {
          Iterator<Edge> edges = service.getStrategy().getOutEdgesFor(currentVertex, currentProperty).iterator();
          if(edges.hasNext()) {
            currentVertex = edges.next().getVertex(com.tinkerpop.blueprints.Direction.IN);
View Full Code Here

   * @param possibleRoots a map linking vertices to the property path used to navigate from searched vertices to these vertices.
   * @return an object containing informations about the best matching vertex (like a cache of vertices in solution space).
   */
  private VertexValueRange findBestRootIn(Map<Iterable<Vertex>, Iterable<Property>> possibleRoots) {
    VertexValueRange initial = new VertexValueRange();
    Vertex root;
    for(Entry<Iterable<Vertex>, Iterable<Property>> entry : possibleRoots.entrySet()) {
      initial = initial.findBestMatch(entry);
    }
    return initial;
  }
View Full Code Here

   * @see com.dooapp.gaedo.blueprints.queries.tests.VertexTest#matches(com.tinkerpop.blueprints.pgm.Vertex)
   */
  @Override
  public boolean matches(Vertex examined) {
    // Navigates to the first target edge and perform etest when reached
    Vertex currentVertex = examined;
    Property finalProperty = null;
    // Counting path length allows us to check if we expect a null value
    int currentPathLength = 0;
    for(Property currentProperty : path) {
      Iterator<Edge> edges = strategy.getOutEdgesFor(currentVertex, currentProperty).iterator();
View Full Code Here

   * Load if possible vertex associated to entry
   * @param expected
   * @return a list containing that vertex if it existed, or null elsewhere.
   */
  private Collection<Vertex> load(Object expected) {
    Vertex vertexFor = service.getVertexFor(expected, CascadeType.REFRESH, objectsBeingAccessed);
    if(vertexFor==null)
      return Collections.emptyList();
    else
      return Arrays.asList(vertexFor);
  }
View Full Code Here

   * @return
   */
  protected Collection<Vertex> getVerticesToExamine() {
    List<Vertex> returned = new LinkedList<Vertex>();
    // First step is to locate the class node
    Vertex classVertex = getClassVertex();
    ClassCollectionProperty classes = new ClassCollectionProperty(getSearchedClass());
    if(classVertex==null) {
      if (logger.isLoggable(Level.WARNING)) {
        logger.log(Level.WARNING, "graph doesn't seem to know source class "+getSearchedClass().getCanonicalName());
      }
      return returned;
    }
    // Now iterate on all instances and perform test on each one
    Iterable<Edge> objectsClassEdges = classVertex.getEdges(Direction.IN, GraphUtils.getEdgeNameFor(classes));
    for(Edge e : objectsClassEdges) {
      returned.add(e.getVertex(Direction.OUT));
    }
    return returned;
  }
View Full Code Here

    }
  }

  @Override
  public Vertex loadVertexFor(String objectVertexId, String className) {
    Vertex defaultVertex = null;
    CloseableIterable<Vertex> matchingIterable = database.getIndex(IndexNames.VERTICES.getIndexName(), Vertex.class).get(Properties.value.name(), objectVertexId);
    Iterator<Vertex> matching = matchingIterable.iterator();
    if (matching.hasNext()) {
      while (matching.hasNext()) {
        Vertex vertex = matching.next();
        String vertexTypeName = null;
        try {
          vertexTypeName = getEffectiveType(vertex);
          switch (GraphUtils.getKindOf(vertex)) {
          case literal:
View Full Code Here

   */
  @Override
  protected Vertex createEmptyVertex(String vertexId, Class<? extends Object> valueClass, Object value) {
    // technical vertex id is no more used by gaedo which only rley upon the
    // getIdOfVertex method !
    Vertex returned = database.addVertex(valueClass.getName() + ":" + vertexId);
    setIndexedProperty(returned, Properties.value.name(), vertexId, IndexNames.VERTICES);
    if (Literals.containsKey(valueClass)) {
      // some literals aren't so ... literal, as they can accept incoming
      // connections (like classes)
      setIndexedProperty(returned, Properties.kind.name(), Literals.get(valueClass).getKind().name(), IndexNames.VERTICES);
      setIndexedProperty(returned, Properties.type.name(), Literals.get(valueClass).getTypeOf(value), IndexNames.VERTICES);
    } else {
      if (repository.containsKey(valueClass)) {
        setIndexedProperty(returned, Properties.kind.name(), Kind.uri.name(), IndexNames.VERTICES);
      } else if (Tuples.containsKey(valueClass)) {
        // some literals aren't so ... literal, as they can accept
        // incoming connections (like classes)
        setIndexedProperty(returned, Properties.kind.name(), Tuples.get(valueClass).getKind().name(), IndexNames.VERTICES);
      }
      // 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
View Full Code Here

  @Override
  protected Vertex createEmptyVertex(String vertexId, Class<? extends Object> valueClass, Object value) {
    // Vertex will be created after having selected which node kind is to be
    // used, as the id used by SailGraph IS meaningfull :
    // for a literal, it must be a Literal URI
    Vertex returned = null;
    try {
      if (Literals.containsKey(valueClass)) {
        // some literals aren't so ... literal, as they can accept
        // incoming connections (like classes)
        LiteralTransformer literalTransformer = Literals.get(valueClass);
        Kind kind = literalTransformer.getKind();
        returned = database.addVertex(kind.getURIFor(vertexId, valueClass));
        if (Kind.literal.equals(kind)) {
          returned.setProperty(Properties.type.name(), TypeUtils.getType(valueClass));
        }
      } else {
        if (repository.containsKey(valueClass)) {
          returned = database.addVertex(Kind.uri.getURIFor(vertexId, valueClass));
        } else if (Tuples.containsKey(valueClass)) {
          TupleTransformer tupleTransformer = Tuples.get(valueClass);
          returned = database.addVertex(tupleTransformer.getKind().getURIFor(vertexId, valueClass));
        }
        // 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
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.Vertex

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.