Package com.tinkerpop.blueprints.pgm

Examples of com.tinkerpop.blueprints.pgm.Vertex


    String vertexId = getIdVertexId(toDelete, false /*
                                   * no id
                                   * generation
                                   * on delete
                                   */);
    Vertex objectVertex = loadVertexFor(vertexId, toDelete.getClass().getName());
    if (objectVertex != null) {
      Map<Property, Collection<CascadeType>> containedProperties = strategy.getContainedProperties(toDelete, objectVertex, CascadeType.REMOVE);
      persister.performDelete(this, vertexId, objectVertex, containedClass, containedProperties, toDelete, CascadeType.REMOVE, objectsBeingAccessed);
    }
  }
View Full Code Here


   * @param value
   *            object value
   */
  <Type> void deleteOutEdgeVertex(Vertex objectVertex, Vertex valueVertex, Type value, Map<String, Object> objectsBeingUpdated) {
    // Locate vertex
    Vertex knownValueVertex = getVertexFor(value, CascadeType.REMOVE, objectsBeingUpdated);
    // Ensure vertex is our out one
    if (valueVertex.equals(knownValueVertex)) {
      // Delete vertex and other associated ones, only if they have no
      // other input links (elsewhere delete is silently ignored)
      if (valueVertex.getInEdges().iterator().hasNext()) {
View Full Code Here

   *            map of objects already used
   */
  private DataType doUpdate(DataType toUpdate, CascadeType cascade, Map<String, Object> treeMap) {
    boolean generatesId = strategy.isIdGenerationRequired() ? (CascadeType.PERSIST == cascade) : false;
    String objectVertexId = getIdVertexId(toUpdate, generatesId);
    Vertex objectVertex = loadVertexFor(objectVertexId, toUpdate.getClass().getName());
    return (DataType) persister.performUpdate(this, objectVertexId, objectVertex, toUpdate.getClass(), strategy.getContainedProperties(toUpdate, objectVertex, cascade), toUpdate, cascade,
            treeMap);
  }
View Full Code Here

  public Vertex getVertexFor(Object value, CascadeType cascade, Map<String, Object> objectsBeingUpdated) {
    boolean allowIdGeneration = CascadeType.PERSIST.equals(cascade) || CascadeType.MERGE.equals(cascade);
    // Here we suppose the service is the right one for the job (which may
    // not be the case)
    if (containedClass.isInstance(value)) {
      Vertex returned = getIdVertexFor(containedClass.cast(value), allowIdGeneration);
      if (returned == null) {
        doUpdate(containedClass.cast(value), cascade, objectsBeingUpdated);
        returned = getIdVertexFor(containedClass.cast(value), allowIdGeneration);
      } else {
        // vertex already exist, but maybe object needs an update
View Full Code Here

   *            during loading, but is absolutely NOT a persistent cache
   * @see #loadObject(String, Vertex, Map)
   */
  public DataType loadObject(String objectVertexId, Map<String, Object> objectsBeingAccessed) {
    // If cast fails, well, that's some fuckin mess, no ?
    Vertex objectVertex = loadVertexFor(objectVertexId, containedClass.getName());
    return persister.loadObject(this, 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

 
  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

                    deleteSingle(service, database, p, toDelete, objectVertex, toCascade, objectsBeingAccessed);
                }
            }
        }
        /* We try to locate vertex in graph before to delete it. Indeed, mainly due cascade delete, this vertex may have already been removed */
        Vertex notYetDeleted = service.getDriver().loadVertexFor(objectVertexId, service.getContainedClass().getName());
        if(notYetDeleted!=null)
          database.removeVertex(notYetDeleted);
    }
View Full Code Here

    private void deleteSingle(AbstractBluePrintsBackedFinderService<? extends Graph, ?, ?> service, Graph database, Property p, Object toDelete, Vertex objectVertex, Collection<CascadeType> toCascade, Map<String, Object> objectsBeingAccessed) {
        // there should be only one vertex to delete
        Iterable<Edge> edges = service.getStrategy().getOutEdgesFor(objectVertex, p);
        for (Edge e : edges) {
            Vertex valueVertex = e.getInVertex();
            database.removeEdge(e);
            // Now what to do with vertex ? Delete it ?
            if (toCascade.contains(CascadeType.REMOVE)) {
                // yes, delete it forever (but before, see if there aren't more datas to delete
                service.deleteOutEdgeVertex(objectVertex, valueVertex, p.get(toDelete), objectsBeingAccessed);
View Full Code Here

TOP

Related Classes of com.tinkerpop.blueprints.pgm.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.