Package com.tinkerpop.blueprints

Examples of com.tinkerpop.blueprints.Vertex


     */
    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.getVertex(Direction.IN);
            GraphUtils.removeSafely(database, 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
                Object value = p.get(toDelete);
                if(value!=null) {
                  Vertex knownValueVertex = service.getVertexFor(value, CascadeType.REFRESH, objectsBeingAccessed);
                  if(knownValueVertex!=null && knownValueVertex.equals(valueVertex))
                    service.deleteOutEdgeVertex(objectVertex, valueVertex, value, objectsBeingAccessed);
                }

            }
        }
View Full Code Here


    private void deleteMap(AbstractBluePrintsBackedFinderService<? extends Graph, ?, ?> service, Graph database, Property p, Object toDelete, Vertex objectVertex, Collection<CascadeType> toCascade, Map<String, Object> objectsBeingAccessed) {
        Iterable<Edge> edges = service.getStrategy().getOutEdgesFor(objectVertex, p);
        Map<?, ?> values = (Map<?, ?>) p.get(toDelete);
        Map<Vertex, Edge> oldVertices = new HashMap<Vertex, Edge>();
        for (Edge e : edges) {
            Vertex inVertex = e.getVertex(Direction.IN);
            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

    private void deleteCollection(AbstractBluePrintsBackedFinderService<? extends Graph, ?, ?> service, Graph database, Property p, Object toDelete, Vertex objectVertex, Collection<CascadeType> toCascade, Map<String, Object> objectsBeingAccessed) {
        Iterable<Edge> edges = service.getStrategy().getOutEdgesFor(objectVertex, p);
        Collection<?> values = (Collection<?>) p.get(toDelete);
        Map<Vertex, Edge> oldVertices = new HashMap<Vertex, Edge>();
        for (Edge e : edges) {
            Vertex inVertex = e.getVertex(Direction.IN);
            oldVertices.put(inVertex, e);
        }
        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

            // Which is done in that call : as vertex is always looked up before creation, there is little duplication risk
            // 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

            // Which is done in that call : as vertex is always looked up before creation, there is little duplication risk
            // or at elast that risk should be covered by selected Blueprints implementation
            Collection<Vertex> newVertices = createCollectionVerticesFor(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

     */
    private <DataType> void updateSingle(AbstractBluePrintsBackedFinderService<? extends Graph, DataType, ?> service, Graph database, Property p, Object toUpdate, Vertex rootVertex, CascadeType cascade, Map<String, Object> objectsBeingAccessed) {
        Object value = p.get(toUpdate);
        // As a convention, null values are never stored but they may replace existing ones, in which case previous values must be removed
        // as a consequenc,v alueVertex is loaded only for non null values
        Vertex valueVertex = null;
        if (value != null) {
            valueVertex = service.getVertexFor(value, cascade, objectsBeingAccessed);
        }
        /* Totally crazy confident non-nullity lack of test :
         * this method is only called when cascade type is either PERSIST or MERGE. In both cases the call to getVertexFor will create the vertex if missing.
View Full Code Here

    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.getVertex(Direction.IN);
            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

   *            cascade type. if nor PERSIST neither MERGE and vertex doesn't
   *            exist, null may be returned
   * @return vertex associated to literal or null if none found.
   */
  public static Vertex getVertexForLiteral(GraphDatabaseDriver database, Object value, CascadeType cascade) {
    Vertex returned = null;
    // Now distinct behaviour between known objects and unknown ones
    Class<? extends Object> valueClass = value.getClass();
    if (Literals.containsKey(valueClass)) {
      LiteralTransformer transformer = Literals.get(valueClass);
      returned = transformer.getVertexFor(database, valueClass.cast(value), cascade);
View Full Code Here

   *            object
   * @return the
   */
  public static Vertex getVertexForTuple(AbstractBluePrintsBackedFinderService<? extends Graph, ?, ?> service, ServiceRepository repository, Object value,
          CascadeType cascade, Map<String, Object> objectsBeingUpdated) {
    Vertex returned = null;
    // Now distinct behaviour between known objects and unknown ones
    Class<? extends Object> valueClass = value.getClass();
    if (Tuples.containsKey(valueClass)) {
      TupleTransformer transformer = Tuples.get(valueClass);
      returned = transformer.getVertexFor(service, valueClass.cast(value), cascade, objectsBeingUpdated);
View Full Code Here

  public static void removeSafely(Graph database, Vertex existing) {
    if (logger.isLoggable(REMOVAL_LOG_LEVEL)) {
      logger.log(REMOVAL_LOG_LEVEL, "removing safely " + existing);
    }
    Vertex toRemove = null;
    if ((toRemove = database.getVertex(existing.getId())) == null) {
      if (logger.isLoggable(Level.WARNING)) {
        logger.log(Level.WARNING, "We tried to remove non existing vertex " + toString(existing));
      }
    } else {
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.