Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Vertex


  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.getEdges(Direction.OUT, TYPE_EDGE_NAME).iterator().next();
      Vertex type = toType.getVertex(Direction.IN);
      // Do not use ClassLiteral here as this method must be blazing fast
      return classTransformer.extractClassIn(getValue(type).toString());
    }
  }
View Full Code Here


    returned.loadInitialPath(path);
    returned.push(source);

    while(returned.hasPath()) {
      Property currentProperty = returned.nextInPath();
      Vertex currentVertex = returned.vertex();
      Iterable<Edge> outEdges = strategy.getOutEdgesFor(currentVertex, currentProperty);
      Iterator<Edge> edges = outEdges.iterator();
      returned.push(currentProperty);
      if(edges.hasNext()) {
        returned.push(edges.next().getVertex(Direction.IN));
      } else {
        /*
         * maybe that property can contain literal value.
         * This literal value can be stored either as a direct literal (type is a literal one) or using the infamous
         * TUples.serializables, in which case further analysis must be performed ...
         */
        Class<?> propertyType = currentProperty.getType();
        if(driver.getRepository().containsKey(propertyType)) {
          returned.setNavigationSuccessfull(false);
        } else {
          Object value = currentVertex.getProperty(GraphUtils.getEdgeNameFor(currentProperty));
          if(Literals.containsKey(propertyType)) {
            returned.setNavigationSuccessfull(endNavigationForLiteral(value));
          } else if(Tuples.containsKey(propertyType)) {
            returned.setNavigationSuccessfull(endNavigationForTuple(currentProperty, currentVertex, propertyType, value));
          }
View Full Code Here

  private Vertex getVertextForUnknownSerializable(AbstractBluePrintsBackedFinderService<? extends Graph, ?, ?> service, ServiceRepository repository, Serializable value) {
    String serialized = writeSerializable(value);
    // Then indexed vertex id (for neo4j, typically)
    Class<? extends Serializable> valueClass = value.getClass();
    Vertex returned = service.loadVertexFor(serialized, valueClass.getName());
    // Finally create vertex
    if(returned==null) {
      returned = service.getDriver().createEmptyVertex(Serializable.class, serialized, value);
      service.getDriver().setValue(returned, serialized);
    }
View Full Code Here

                                                                     * no id
                                                                     * generation
                                                                     * on delete
                                                                     */);
        Class<? extends Object> toDeleteClass = toDelete.getClass();
        Vertex objectVertex = loadVertexFor(vertexId, toDeleteClass.getName());
        if (objectVertex != null) {
            Map<Property, Collection<CascadeType>> containedProperties = strategy.getContainedProperties(toDelete, objectVertex, CascadeType.REMOVE);
            new Deleter().performDelete(this, new VertexCachingDriver(new DelegatingDriver()), vertexId, objectVertex, toDeleteClass, containedProperties, toDelete, CascadeType.REMOVE, objectsBeingAccessed);
        }
    }
View Full Code Here

      if(toUpdate==null)
        return toUpdate;
        boolean generatesId = strategy.isIdGenerationRequired() ? (CascadeType.PERSIST == cascade) : false;
        String objectVertexId = getIdVertexId(toUpdate, generatesId);
        Class<? extends Object> toUpdateClass = toUpdate.getClass();
        Vertex objectVertex = loadVertexFor(objectVertexId, toUpdateClass.getName());
        Map<Property, Collection<CascadeType>> containedProperties = strategy.getContainedProperties(toUpdate, objectVertex, cascade);
        return (DataType) new Updater().performUpdate(this, new VertexCachingDriver(getDriver()), objectVertexId, objectVertex, toUpdateClass, containedProperties, toUpdate,
                        cascade, treeMap);
    }
View Full Code Here

     * @param allowIdGeneration true if null id should be replaced by a new one
     * @return a vertex for an instance of the given object. Under some rare circumstances, this vertex may be null.
     */
    protected Vertex getVertexForInstanceOfDataType(Object value, CascadeType cascade, ObjectCache objectsBeingUpdated, boolean allowIdGeneration) {
        // was there any vertex prior to that call ? (don't worry, it will be used later)
        Vertex existing = getIdVertexFor(containedClass.cast(value), false);
        Vertex returned = null;
        if(existing==null) {
            returned = getIdVertexFor(containedClass.cast(value), allowIdGeneration);
        } else {
            returned = existing;
        }
View Full Code Here

     *            during loading, but is absolutely NOT a persistent cache
     * @see #loadObject(String, Vertex, Map)
     */
    public DataType loadObject(String objectVertexId, ObjectCache objectsBeingAccessed) {
        // If cast fails, well, that's some fuckin mess, no ?
        Vertex objectVertex = loadVertexFor(objectVertexId, containedClass.getName());
        return new Loader().loadObject(this, new VertexCachingDriver(getDriver()), objectVertexId, objectVertex, objectsBeingAccessed);
    }
View Full Code Here

     */
    @Override
    public DataType findById(final Object... id) {
        // make sure entered type is a valid one
        String vertexIdValue = strategy.getAsId(id[0]);
        Vertex rootVertex = loadVertexFor(vertexIdValue, containedClass.getName());
        if (rootVertex == null) {
            // root vertex couldn't be found directly, mostly due to
            // https://github.com/Riduidel/gaedo/issues/11
            // So perform the longer (but always working) query
            return find().matching(new QueryBuilder<InformerType>() {
View Full Code Here

                    TransactionalOperation<Boolean, DataType, InformerType> operation = new TransactionalOperation<Boolean, DataType, InformerType>(this) {

                        @Override
                        protected Boolean doPerform() {
                            String idVertexId = getIdVertexId(value, strategy.isIdGenerationRequired());
                            Vertex returned = getDriver().createEmptyVertex(value.getClass(), idVertexId, value);
                            getDriver().setValue(returned, idVertexId);
                            return true;
                        }
                    };
                    return operation.perform();
View Full Code Here

          ObjectCache objectsBeingUpdated) {
    // First step is to build an id for given tuple by concatenating key and value id (which is hopefully done separately)
    String entryVertexId = getIdOfTuple(service.getRepository(), cast, cascade, objectsBeingUpdated);
    // No need to memorize updated version
    String className = cast.getClass().getName();
    Vertex objectVertex = service.loadVertexFor(entryVertexId, className);
    new Updater().performUpdate(service, driver, entryVertexId, objectVertex, getContainedClass(), getContainedProperties(), cast, cascade, objectsBeingUpdated);
    /* If object was null, this operation was a create.
     * As a consequence, the upper update call may have persisted key or value, which implies the id may have changed
     * See https://github.com/Riduidel/gaedo/issues/91#issuecomment-47937526 for more awful details
     */
 
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.