Search in sources :

Example 6 with DElementStore

use of org.openntf.domino.graph2.DElementStore in project org.openntf.domino by OpenNTF.

the class DConfiguration method readExternal.

@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
    defaultElementStoreKey_ = in.readLong();
    int count = in.readInt();
    for (int i = 0; i < count; i++) {
        DElementStore store = (DElementStore) in.readObject();
        addElementStore(store);
        store.setConfiguration(this);
    }
}
Also used : DElementStore(org.openntf.domino.graph2.DElementStore)

Example 7 with DElementStore

use of org.openntf.domino.graph2.DElementStore in project org.openntf.domino by OpenNTF.

the class DConfiguration method writeExternal.

@Override
public void writeExternal(final ObjectOutput out) throws IOException {
    out.writeLong(defaultElementStoreKey_);
    out.writeInt(getElementStores().size());
    for (DElementStore store : getElementStores().values()) {
        out.writeObject(store);
    }
}
Also used : DElementStore(org.openntf.domino.graph2.DElementStore)

Example 8 with DElementStore

use of org.openntf.domino.graph2.DElementStore in project org.openntf.domino by OpenNTF.

the class AbstractIncidenceHandler method processVertexAdjacency.

@SuppressWarnings({ "rawtypes", "unchecked" })
public Object processVertexAdjacency(final Annotation annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Vertex vertex) {
    Edge resultEdge = null;
    Class<?> returnType = method.getReturnType();
    Direction dir = Direction.BOTH;
    String label = "";
    boolean unique = false;
    if (annotation instanceof Adjacency) {
        dir = ((Adjacency) annotation).direction();
        label = ((Adjacency) annotation).label();
    } else if (annotation instanceof AdjacencyUnique) {
        dir = ((AdjacencyUnique) annotation).direction();
        label = ((AdjacencyUnique) annotation).label();
        unique = true;
    } else if (annotation instanceof Incidence) {
        dir = ((Incidence) annotation).direction();
        label = ((Incidence) annotation).label();
    } else if (annotation instanceof IncidenceUnique) {
        dir = ((IncidenceUnique) annotation).direction();
        label = ((IncidenceUnique) annotation).label();
        unique = true;
    }
    if (ClassUtilities.isGetMethod(method)) {
        final FramedVertexList r = new FramedVertexList(framedGraph, vertex, vertex.getVertices(dir, label), ClassUtilities.getGenericClass(method));
        if (ClassUtilities.returnsIterable(method)) {
            return r;
        } else {
            return r.iterator().hasNext() ? r.iterator().next() : null;
        }
    } else if (ClassUtilities.isAddMethod(method)) {
        Vertex newVertex;
        Object returnValue = null;
        if (arguments == null) {
            // Use this method to get the vertex so that the vertex
            // initializer is called.
            returnValue = framedGraph.addVertex(null, returnType);
            newVertex = ((VertexFrame) returnValue).asVertex();
        } else {
            newVertex = ((VertexFrame) arguments[0]).asVertex();
        }
        if (unique) {
            resultEdge = findEdge(annotation, framedGraph, vertex, newVertex);
        }
        if (resultEdge == null) {
            String replicaid = null;
            if (framedGraph instanceof DFramedTransactionalGraph) {
                DElementStore store = ((DFramedTransactionalGraph) framedGraph).getElementStore(returnType);
                long rawkey = store.getStoreKey();
                replicaid = NoteCoordinate.Utils.getReplidFromLong(rawkey);
            }
            resultEdge = addEdge(annotation, framedGraph, vertex, newVertex, replicaid);
        }
        if (returnType.isPrimitive()) {
            return null;
        } else if (Edge.class.isAssignableFrom(returnType)) {
            return resultEdge;
        } else if (EdgeFrame.class.isAssignableFrom(returnType)) {
            // System.out.println("TEMP DEBUG about to wrap edge with id " + resultEdge.getId());
            Object result = framedGraph.frame(resultEdge, returnType);
            return result;
        } else {
            return returnValue;
        }
    } else if (ClassUtilities.isRemoveMethod(method)) {
        removeEdges(dir, label, vertex, ((VertexFrame) arguments[0]).asVertex(), framedGraph);
        return null;
    } else if (AnnotationUtilities.isCountMethod(method)) {
        return countEdges(annotation, vertex);
    } else if (ClassUtilities.isSetMethod(method)) {
        removeEdges(dir, label, vertex, null, framedGraph);
        if (ClassUtilities.acceptsIterable(method)) {
            for (Object o : (Iterable) arguments[0]) {
                Vertex v = ((VertexFrame) o).asVertex();
                addEdge(annotation, framedGraph, vertex, v, null);
            }
            return null;
        } else {
            if (null != arguments[0]) {
                Vertex newVertex = ((VertexFrame) arguments[0]).asVertex();
                addEdge(annotation, framedGraph, vertex, newVertex, null);
            }
            return null;
        }
    }
    return null;
}
Also used : DVertex(org.openntf.domino.graph2.DVertex) Vertex(com.tinkerpop.blueprints.Vertex) EdgeFrame(com.tinkerpop.frames.EdgeFrame) DFramedTransactionalGraph(org.openntf.domino.graph2.impl.DFramedTransactionalGraph) DElementStore(org.openntf.domino.graph2.DElementStore) Direction(com.tinkerpop.blueprints.Direction) Incidence(com.tinkerpop.frames.Incidence) VertexFrame(com.tinkerpop.frames.VertexFrame) Adjacency(com.tinkerpop.frames.Adjacency) Edge(com.tinkerpop.blueprints.Edge)

Example 9 with DElementStore

use of org.openntf.domino.graph2.DElementStore in project org.openntf.domino by OpenNTF.

the class IndexFactory method initGraph.

public void initGraph() {
    DElementStore termsStore = new org.openntf.domino.graph2.builtin.search.IndexStore();
    termsStore.setStoreKey("ODADemo/terms.nsf");
    termsStore.addType(Term.class);
    DElementStore valuesStore = new org.openntf.domino.graph2.builtin.search.IndexStore();
    valuesStore.setStoreKey("ODADemo/values.nsf");
    valuesStore.addType(Value.class);
    DElementStore namesStore = new org.openntf.domino.graph2.builtin.search.IndexStore();
    namesStore.setStoreKey("ODADemo/names.nsf");
    namesStore.addType(Name.class);
    DConfiguration config = new DConfiguration();
    @SuppressWarnings("unused") DGraph graph = new DGraph(config);
    config.addElementStore(termsStore);
    config.addElementStore(valuesStore);
    config.addElementStore(namesStore);
}
Also used : DElementStore(org.openntf.domino.graph2.DElementStore) DGraph(org.openntf.domino.graph2.impl.DGraph) DConfiguration(org.openntf.domino.graph2.impl.DConfiguration)

Example 10 with DElementStore

use of org.openntf.domino.graph2.DElementStore in project org.openntf.domino by OpenNTF.

the class BasicGraphFactory method getGraph.

protected static synchronized DGraph getGraph(final String apipath) {
    DConfiguration config = new DConfiguration();
    DGraph graph = new DGraph(config);
    DElementStore store = new org.openntf.domino.graph2.impl.DElementStore();
    store.setStoreKey(apipath);
    config.setDefaultElementStore(store);
    return graph;
}
Also used : DElementStore(org.openntf.domino.graph2.DElementStore) DGraph(org.openntf.domino.graph2.impl.DGraph) DConfiguration(org.openntf.domino.graph2.impl.DConfiguration)

Aggregations

DElementStore (org.openntf.domino.graph2.DElementStore)24 CaseInsensitiveString (org.openntf.domino.types.CaseInsensitiveString)10 DConfiguration (org.openntf.domino.graph2.impl.DConfiguration)9 DGraph (org.openntf.domino.graph2.impl.DGraph)9 DElementStore (org.openntf.domino.graph2.impl.DElementStore)7 DFramedGraphFactory (org.openntf.domino.graph2.impl.DFramedGraphFactory)7 Element (com.tinkerpop.blueprints.Element)6 NoteCoordinate (org.openntf.domino.big.NoteCoordinate)5 Edge (com.tinkerpop.blueprints.Edge)4 Vertex (com.tinkerpop.blueprints.Vertex)4 ArrayList (java.util.ArrayList)4 DFramedTransactionalGraph (org.openntf.domino.graph2.impl.DFramedTransactionalGraph)3 Direction (com.tinkerpop.blueprints.Direction)2 Adjacency (com.tinkerpop.frames.Adjacency)2 Incidence (com.tinkerpop.frames.Incidence)2 VertexFrame (com.tinkerpop.frames.VertexFrame)2 Module (com.tinkerpop.frames.modules.Module)2 JavaHandlerModule (com.tinkerpop.frames.modules.javahandler.JavaHandlerModule)2 TypedGraphModuleBuilder (com.tinkerpop.frames.modules.typedgraph.TypedGraphModuleBuilder)2 List (java.util.List)2