Search in sources :

Example 1 with DElementStore

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

the class DFramedTransactionalGraph method addVertex.

public <F> F addVertex(final Object id, final Class<F> kind, final boolean temporary) {
    if (id != null && id instanceof NoteCoordinate) {
        Object cacheChk = getElement(id, kind);
        if (cacheChk != null) {
            return (F) cacheChk;
        }
    }
    DGraph base = (DGraph) this.getBaseGraph();
    org.openntf.domino.graph2.DElementStore store = null;
    if (kind != null) {
        store = base.findElementStore(kind);
    }
    if (store == null) {
        // System.out.println("TEMP DEBUG store was null for type " + kind.getName());
        if (id instanceof NoteCoordinate) {
            store = base.findElementStore(id);
        } else {
            String typeid = getTypedId(id);
            if (typeid == null) {
                store = base.getDefaultElementStore();
            } else {
                store = base.findElementStore(typeid);
            }
        }
    } else {
    // System.out.println("TEMP DEBUG adding to store " + ((Database) store.getStoreDelegate()).getApiPath());
    }
    Vertex vertex = store.addVertex(id, temporary);
    String typeValue = ((DConfiguration) this.getConfig()).getTypeValue(kind);
    // System.out.println("TEMP DEBUG Creating new instance of " + kind.getName() + " with typeValue of " + typeValue);
    vertex.setProperty("form", typeValue);
    F result = frame(vertex, kind, temporary);
    if (result instanceof Eventable) {
    }
    if (!temporary) {
        getFramedElementCache().put(vertex.getId(), result);
    }
    return result;
}
Also used : NoteCoordinate(org.openntf.domino.big.NoteCoordinate) DbInfoVertex(org.openntf.domino.graph2.builtin.DbInfoVertex) ViewVertex(org.openntf.domino.graph2.builtin.ViewVertex) CategoryVertex(org.openntf.domino.graph2.builtin.CategoryVertex) Vertex(com.tinkerpop.blueprints.Vertex) Eventable(org.openntf.domino.graph2.builtin.Eventable) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) DElementStore(org.openntf.domino.graph2.DElementStore)

Example 2 with DElementStore

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

the class DFramedTransactionalGraph method getFilteredElements.

public <F> Iterable<F> getFilteredElements(final String classname, final List<CharSequence> keys, final List<CaseInsensitiveString> values) {
    // System.out.println("Getting a filtered list of elements of type " + classname);
    org.openntf.domino.graph2.DElementStore store = null;
    DGraph base = (DGraph) this.getBaseGraph();
    Class<?> chkClass = getClassFromName(classname);
    if (chkClass != null) {
        store = base.findElementStore(chkClass);
        if (store != null) {
            List<String> keystrs = CaseInsensitiveString.toStrings(keys);
            List<Object> valobj = new ArrayList<Object>(values);
            String formulaFilter = org.openntf.domino.graph2.DGraph.Utils.getFramedElementFormula(keystrs, valobj, chkClass);
            long startTime = new Date().getTime();
            Iterable<Element> elements = (org.openntf.domino.graph2.impl.DElementIterable) store.getElements(formulaFilter);
            long endTime = new Date().getTime();
            System.out.println("TEMP DEBUG Retrieved elements for type " + classname + " in " + (endTime - startTime) + "ms. Framing...");
            return this.frameElements(elements, null);
        } else {
            return null;
        }
    } else {
        throw new IllegalArgumentException("Class " + classname + " not registered in graph");
    }
}
Also used : Element(com.tinkerpop.blueprints.Element) ArrayList(java.util.ArrayList) CaseInsensitiveString(org.openntf.domino.types.CaseInsensitiveString) Date(java.util.Date) DElementStore(org.openntf.domino.graph2.DElementStore)

Example 3 with DElementStore

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

the class DGraph method findDelegate.

@Override
public Object findDelegate(final Object delegateKey) {
    DElementStore store = findElementStore(delegateKey);
    if (store.isProxied()) {
        String key = NoteCoordinate.Utils.getReplidFromLong(store.getStoreKey());
        String proxykey = NoteCoordinate.Utils.getReplidFromLong(store.getProxyStoreKey());
        System.out.println("Found a proxied element store for element key" + String.valueOf(delegateKey) + ", key: " + key + ", proxykey: " + proxykey);
    }
    return store.findElementDelegate(delegateKey);
}
Also used : DElementStore(org.openntf.domino.graph2.DElementStore)

Example 4 with DElementStore

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

the class DGraph method getElement.

@Override
public Element getElement(final Object id) {
    if (id instanceof NoteCoordinate) {
    }
    // System.out.println("TEMP DEBUG Getting element from id " + String.valueOf(id));
    DElementStore store = findElementStore(id);
    // if (store.isProxied()) {
    // String key = NoteCoordinate.Utils.getReplidFromLong(store.getStoreKey());
    // String proxykey = NoteCoordinate.Utils.getReplidFromLong(store.getProxyStoreKey());
    // System.out.println(
    // "Found a proxied element store for element key " + String.valueOf(id) + ", key: " + key + ", proxykey: " + proxykey);
    // }
    Element result = store.getElement(id);
    return result;
}
Also used : NoteCoordinate(org.openntf.domino.big.NoteCoordinate) Element(com.tinkerpop.blueprints.Element) DElementStore(org.openntf.domino.graph2.DElementStore)

Example 5 with DElementStore

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

the class DConfiguration method addElementStore.

@Override
public DElementStore addElementStore(final DElementStore store) throws IllegalStateException {
    store.setConfiguration(this);
    Long key = store.getStoreKey();
    DElementStore schk = getElementStores().get(key);
    DElementStore pchk = null;
    DElementStore rpchk = null;
    if (schk == null) {
        getElementStores().put(key, store);
    }
    Long pkey = store.getProxyStoreKey();
    if (pkey != null) {
        pchk = getElementStores().get(pkey);
        if (pchk == null) {
            getElementStores().put(pkey, store);
        }
    }
    Long rpkey = store.getReverseProxyStoreKey();
    if (rpkey != null) {
        rpchk = getElementStores().get(rpkey);
        if (rpchk == null) {
            getElementStores().put(rpkey, store);
        }
    }
    List<Class<?>> types = store.getTypes();
    for (Class<?> type : types) {
        getTypeRegistry().add(type, store);
        Long chk = getTypeMap().get(type);
        if (chk != null) {
            if (!chk.equals(key)) {
                Shardable s = type.getAnnotation(Shardable.class);
                if (s == null) {
                    throw new IllegalStateException("Element store has already been registered for type " + type.getName());
                } else {
                    getTypeMap().put(type, key);
                }
            }
        } else {
            getTypeMap().put(type, key);
        }
    }
    if (pchk != null) {
        types = pchk.getTypes();
        for (Class<?> type : types) {
            getTypeRegistry().add(type, pchk);
            Long chk = getTypeMap().get(type);
            if (chk != null) {
                if (!chk.equals(key)) {
                    Shardable s = type.getAnnotation(Shardable.class);
                    if (s == null) {
                        throw new IllegalStateException("Element store has already been registered for type " + type.getName());
                    } else {
                        getTypeMap().put(type, key);
                    }
                }
            } else {
                getTypeMap().put(type, key);
            }
        }
    }
    if (rpchk != null) {
        types = rpchk.getTypes();
        for (Class<?> type : types) {
            getTypeRegistry().add(type, rpchk);
            Long chk = getTypeMap().get(type);
            if (chk != null) {
                if (!chk.equals(key)) {
                    Shardable s = type.getAnnotation(Shardable.class);
                    if (s == null) {
                        throw new IllegalStateException("Element store has already been registered for type " + type.getName());
                    } else {
                        getTypeMap().put(type, key);
                    }
                }
            } else {
                getTypeMap().put(type, key);
            }
        }
    }
    return store;
}
Also used : Shardable(org.openntf.domino.graph2.annotations.Shardable) DElementStore(org.openntf.domino.graph2.DElementStore)

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