Package com.tinkerpop.blueprints.pgm

Examples of com.tinkerpop.blueprints.pgm.Vertex


    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.getInVertex();
            oldVertices.put(inVertex, e);
        }
        for (Object v : values.entrySet()) {
            Vertex valueVertex = service.getVertexFor(v, CascadeType.REFRESH, objectsBeingAccessed);
            if (oldVertices.containsKey(valueVertex)) {
                Edge oldEdge = oldVertices.remove(valueVertex);
                database.removeEdge(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.getInVertex();
            oldVertices.put(inVertex, e);
        }
        for (Object v : values) {
            Vertex valueVertex = service.getVertexFor(v, CascadeType.REFRESH, objectsBeingAccessed);
            if (oldVertices.containsKey(valueVertex)) {
                Edge oldEdge = oldVertices.remove(valueVertex);
                database.removeEdge(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.getInVertex();
                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.getInVertex();
                if (newVertices.contains(inVertex)) {
                    newVertices.remove(inVertex);
                } else {
                    oldVertices.put(inVertex, e);
                }
View Full Code Here

     */
    public <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);
        }
        Edge link = null;
        // Get previously existing vertex
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.getInVertex();
            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

    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

   *            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

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.