use of org.openntf.domino.graph2.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;
}
use of org.openntf.domino.graph2.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");
}
}
use of org.openntf.domino.graph2.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);
}
use of org.openntf.domino.graph2.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;
}
use of org.openntf.domino.graph2.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;
}
Aggregations