Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Vertex


        if(linking.size()>0) {
          for(Edge e : linking) {
            GraphUtils.removeSafely(service.getDatabase(), e);
          }
        }
        Vertex valueVertex = service.getVertexFor(value, CascadeType.REMOVE, objectsBeingUpdated);
        // we got a vertex, now delete it, please, but for that, we before must delete edge linking entry vertex to that vertex
        service.deleteOutEdgeVertex(entryVertex, valueVertex, value, objectsBeingUpdated);
      } catch(LiteralsHaveNoAssociatedVerticesException e) {
        // a literal ? Then nothing has to be done, which is COOL
      }
View Full Code Here


      }
      VertexSet returned = new VertexSet().withPropertyPath(updatablePath);
      returned.setVertices(new IndexLazyLoader(vertices, propertyKeyInIndex, propertyValueInIndex));
      return returned;
    } else {
      Vertex vertexFor = service.getVertexFor(expected, CascadeType.REFRESH, objectsBeingAccessed);
      if (vertexFor == null) {
        return new VertexSet().withVertices(new LinkedList<Vertex>()).withPropertyPath(new LinkedList<Property>());
      } else {
        return new VertexSet().withVertices(Arrays.asList(vertexFor)).withPropertyPath(new LinkedList<Property>(CollectionUtils.asList(path)));
      }
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

     */
    private DataType doUpdate(DataType toUpdate, CascadeType cascade, ObjectCache treeMap) {
        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

      // or at last that risk should be covered by selected Blueprints
      // implementation
      Collection<Vertex> newVertices = createMapVerticesFor(service, value, cascade, objectsBeingAccessed);
      Map<Vertex, Edge> oldVertices = new HashMap<Vertex, Edge>();
      for (Edge e : existingIterator) {
        Vertex inVertex = e.getVertex(Direction.IN);
        if (newVertices.contains(inVertex)) {
          newVertices.remove(inVertex);
        } else {
          oldVertices.put(inVertex, e);
        }
View Full Code Here

      // ...and put the old, invalid vertices aside for later deletion.
      Set<Edge> edgesToRemove = new HashSet<Edge>();

      // Add previous edges
      for (Edge e : previousEdges) {
        Vertex inVertex = e.getVertex(Direction.IN);
        if (allVertices.values().contains(inVertex)) {
          if (!savedEdges.containsKey(inVertex))
            savedEdges.put(inVertex, new LinkedList<Edge>());
          savedEdges.get(inVertex).add(e);
        } else {
          edgesToRemove.add(e);
        }
      }
      // And previous properties
      String propertyNamePrefix = GraphUtils.getEdgeNameFor(p);
      Collection<String> suspectProperties = new TreeSet<String>();
      for(String propertyName : rootVertex.getPropertyKeys()) {
        if(propertyName.startsWith(propertyNamePrefix)) {
          suspectProperties.add(propertyName);
        }
      }

      // Delete the edges that we don't need anymore.
      for (Edge edge : edgesToRemove) {
        GraphUtils.removeSafely(database, edge);
      }

      // Then, go through the updated Vertices. Create edges if necessary,
      // then always set the order property.
      // This is possible since #createCollectionVerticesFor maintains the
      // ordering.
      int order = 0;
      for(Object element : value) {
        if(allVertices.containsKey(element)) {
          Vertex vertex = allVertices.get(element);
          Edge edgeForVertex;
          if (savedEdges.containsKey(vertex)) {
            List<Edge> edges = savedEdges.get(vertex);
            edgeForVertex = edges.remove(0);
            if (edges.size() == 0)
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.