use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.
the class DElementStore method getElementIds.
protected List<NoteCoordinate> getElementIds(final String formulaFilter) {
List<NoteCoordinate> result = null;
Object raw = getStoreDelegate();
if (raw instanceof Database) {
Database db = (Database) raw;
NoteCollection nc = db.createNoteCollection(false);
nc.setSelectDocuments(true);
nc.setSelectionFormula(formulaFilter);
nc.buildCollection();
if (nc.getCount() == 0) {
raw = this.getProxyStoreDelegate();
if (raw != null) {
db = (Database) raw;
nc = db.createNoteCollection(false);
nc.setSelectDocuments(true);
nc.setSelectionFormula(formulaFilter);
nc.buildCollection();
}
}
result = Lists.newArrayListWithCapacity(nc.getCount());
for (String noteid : nc) {
result.add(NoteCoordinate.Utils.getNoteCoordinate(nc, noteid));
}
} else {
// TODO NTF implement alternative
throw new IllegalStateException("Non-Domino implementations not yet available");
}
return ImmutableList.copyOf(result);
}
use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.
the class DElementStore method getElementIds.
protected List<NoteCoordinate> getElementIds() {
List<NoteCoordinate> result = null;
Object raw = getStoreDelegate();
if (raw instanceof Database) {
Database db = (Database) raw;
NoteCollection nc = db.createNoteCollection(false);
nc.setSelectDocuments(true);
nc.setSelectionFormula(org.openntf.domino.graph2.DEdge.FORMULA_FILTER + " | " + org.openntf.domino.graph2.DVertex.FORMULA_FILTER);
nc.buildCollection();
result = Lists.newArrayListWithCapacity(nc.getCount());
for (String noteid : nc) {
result.add(NoteCoordinate.Utils.getNoteCoordinate(nc, noteid));
}
} else {
// TODO NTF implement alternative
throw new IllegalStateException("Non-Domino implementations not yet available");
}
return ImmutableList.copyOf(result);
}
use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.
the class DFramedTransactionalGraph method flushCache.
public void flushCache(final String id) {
((DGraph) this.getBaseGraph()).flushCache(id);
try {
if (this.getFramedElementCache() != null) {
NoteCoordinate nc = NoteCoordinate.Utils.getNoteCoordinate(id);
Object chk = getFramedElementCache().getIfPresent(nc);
if (chk != null) {
getFramedElementCache().invalidate(nc);
// System.out.println("Invalidated id " + id + " in Framed Cache");
}
}
} catch (Throwable t) {
t.printStackTrace();
}
}
use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.
the class DFramedTransactionalGraph method addEdge.
// public <F> F addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) {
// return (F) super.addEdge(id, outVertex, inVertex, label);
// }
@Override
public <F> F addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label, final Direction direction, final Class<F> kind) {
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 (id instanceof NoteCoordinate) {
store = base.findElementStore(id);
} else {
String typeid = getTypedId(id);
if (typeid == null) {
store = base.findElementStore(kind);
} else {
store = base.findElementStore(typeid);
}
}
Edge edge = store.addEdge(id);
((DEdge) edge).setLabel(label);
((DEdge) edge).setInVertex(inVertex);
((DEdge) edge).setOutVertex(outVertex);
F result = frame(edge, kind);
getFramedElementCache().put(edge.getId(), result);
return result;
}
use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.
the class DGraph method findElementStore.
@Override
public DElementStore findElementStore(final Object delegateKey) {
DElementStore result = null;
if (delegateKey == null) {
// System.out.println("delegateKey is null");
return getDefaultElementStore();
}
if (delegateKey instanceof CharSequence) {
CharSequence skey = (CharSequence) delegateKey;
// System.out.println("delegateKey is CharSequence " + skey.length());
if (skey.length() == 16) {
if (DominoUtils.isReplicaId(skey)) {
Long rid = NoteCoordinate.Utils.getLongFromReplid(skey);
result = getElementStores().get(rid);
if (result == null) {
DElementStore newStore = new org.openntf.domino.graph2.impl.DElementStore();
newStore.setStoreKey(rid);
DConfiguration config = this.getConfiguration();
if (config.getDefaultProxyStore() != null) {
newStore.setProxyStoreDelegate(config.getDefaultProxyStore());
}
if (config.getDefaultReverseProxyStore() != null) {
newStore.setReverseProxyStoreDelegate(config.getDefaultReverseProxyStore());
// System.out.println(
// "TEMP DEBUG Setting reverse proxy default on " + ((Database) newStore.getStoreDelegate()).getApiPath()
// + " to " + ((Database) config.getDefaultReverseProxyStore().getStoreDelegate()).getApiPath());
}
config.addElementStore(newStore);
// newStore.setConfiguration(config);
getElementStores().put(rid, newStore);
// System.out.println("TEMP DEBUG Added new dynamic element store " + String.valueOf(rid));
result = newStore;
}
} else {
throw new ElementKeyException("Cannot resolve a key of " + skey.toString());
}
} else if (skey.length() == 32) {
result = getDefaultElementStore();
} else if (skey.length() > 50) {
String prefix = skey.subSequence(0, 2).toString();
if (prefix.equals("EC") || prefix.equals("ED") || prefix.equals("ET") || prefix.equals("EU")) {
CharSequence mid = skey.subSequence(2, 50);
if (DominoUtils.isMetaversalId(mid)) {
CharSequence ridStr = skey.subSequence(2, 18);
Long rid = NoteCoordinate.Utils.getLongFromReplid(ridStr);
result = getElementStores().get(rid);
if (result == null) {
DElementStore newStore = new org.openntf.domino.graph2.impl.DElementStore();
newStore.setStoreKey(rid);
DConfiguration config = this.getConfiguration();
if (config.getDefaultProxyStore() != null) {
newStore.setProxyStoreDelegate(config.getDefaultProxyStore());
// System.out.println(
// "TEMP DEBUG Setting proxy default on " + ((Database) newStore.getStoreDelegate()).getApiPath()
// + " to " + ((Database) config.getDefaultProxyStore().getStoreDelegate()).getApiPath());
}
if (config.getDefaultReverseProxyStore() != null) {
newStore.setReverseProxyStoreDelegate(config.getDefaultReverseProxyStore());
// System.out.println("TEMP DEBUG Setting reverse proxy default on "
// + ((Database) newStore.getStoreDelegate()).getApiPath() + " to "
// + ((Database) config.getDefaultReverseProxyStore().getStoreDelegate()).getApiPath());
}
config.addElementStore(newStore);
getElementStores().put(rid, newStore);
// System.out.println("TEMP DEBUG Added new dynamic element store " + String.valueOf(rid));
result = newStore;
}
}
} else if (prefix.equals("VC") || prefix.equals("VD") || prefix.equals("VT") || prefix.equals("VU")) {
CharSequence mid = skey.subSequence(2, 50);
if (DominoUtils.isMetaversalId(mid)) {
CharSequence ridStr = skey.subSequence(2, 18);
Long rid = NoteCoordinate.Utils.getLongFromReplid(ridStr);
result = getElementStores().get(rid);
if (result == null) {
DElementStore newStore = new org.openntf.domino.graph2.impl.DElementStore();
newStore.setStoreKey(rid);
DConfiguration config = this.getConfiguration();
if (config.getDefaultProxyStore() != null) {
newStore.setProxyStoreDelegate(config.getDefaultProxyStore());
// System.out.println(
// "TEMP DEBUG Setting proxy default on " + ((Database) newStore.getStoreDelegate()).getApiPath()
// + " to " + ((Database) config.getDefaultProxyStore().getStoreDelegate()).getApiPath());
}
if (config.getDefaultReverseProxyStore() != null) {
newStore.setReverseProxyStoreDelegate(config.getDefaultReverseProxyStore());
// System.out.println("TEMP DEBUG Setting reverse proxy default on "
// + ((Database) newStore.getStoreDelegate()).getApiPath() + " to "
// + ((Database) config.getDefaultReverseProxyStore().getStoreDelegate()).getApiPath());
}
config.addElementStore(newStore);
getElementStores().put(rid, newStore);
// System.out.println("TEMP DEBUG Added new dynamic element store " + String.valueOf(rid));
result = newStore;
}
}
}
if (result == null) {
throw new ElementKeyException("Cannot resolve a key of " + skey.toString());
}
} else if (skey.length() > 16) {
CharSequence prefix = skey.subSequence(0, 16);
if (DominoUtils.isReplicaId(prefix)) {
// System.out.println("TEMP DEBUG Attempting to resolve replica id " + prefix + " to an element store");
Long rid = NoteCoordinate.Utils.getLongFromReplid(prefix);
result = getElementStores().get(rid);
if (result == null) {
DElementStore newStore = new org.openntf.domino.graph2.impl.DElementStore();
DConfiguration config = this.getConfiguration();
newStore.setStoreKey(rid);
// newStore.setConfiguration(config);
if (config.getDefaultProxyStore() != null) {
newStore.setProxyStoreDelegate(config.getDefaultProxyStore());
// System.out
// .println("TEMP DEBUG Setting proxy default on " + ((Database) newStore.getStoreDelegate()).getApiPath()
// + " to " + ((Database) config.getDefaultProxyStore().getStoreDelegate()).getApiPath());
}
if (config.getDefaultReverseProxyStore() != null) {
newStore.setReverseProxyStoreDelegate(config.getDefaultReverseProxyStore());
// System.out.println(
// "TEMP DEBUG Setting reverse proxy default on " + ((Database) newStore.getStoreDelegate()).getApiPath()
// + " to " + ((Database) config.getDefaultReverseProxyStore().getStoreDelegate()).getApiPath());
}
config.addElementStore(newStore);
getElementStores().put(rid, newStore);
// System.out.println("TEMP DEBUG Added new dynamic element store " + String.valueOf(rid));
result = newStore;
}
} else {
throw new ElementKeyException("Cannot resolve a key of " + skey.toString());
}
} else {
throw new ElementKeyException("Cannot resolve a key of " + skey.toString());
}
} else if (delegateKey instanceof NoteCoordinate) {
// System.out.println("delegateKey is a NoteCoordinate");
long key = ((NoteCoordinate) delegateKey).getReplicaLong();
result = getElementStores().get(key);
if (result == null) {
DElementStore newStore = new org.openntf.domino.graph2.impl.DElementStore();
DConfiguration config = this.getConfiguration();
newStore.setStoreKey(key);
// newStore.setConfiguration(config);
if (config.getDefaultProxyStore() != null) {
newStore.setProxyStoreDelegate(config.getDefaultProxyStore());
// System.out.println("TEMP DEBUG Setting proxy default on " + ((Database) newStore.getStoreDelegate()).getApiPath()
// + " to " + ((Database) config.getDefaultProxyStore().getStoreDelegate()).getApiPath());
}
if (config.getDefaultReverseProxyStore() != null) {
newStore.setReverseProxyStoreDelegate(config.getDefaultReverseProxyStore());
// System.out
// .println("TEMP DEBUG Setting reverse proxy default on " + ((Database) newStore.getStoreDelegate()).getApiPath()
// + " to " + ((Database) config.getDefaultReverseProxyStore().getStoreDelegate()).getApiPath());
}
config.addElementStore(newStore);
getElementStores().put(key, newStore);
// System.out.println("TEMP DEBUG Added new dynamic element store " + String.valueOf(key));
result = newStore;
}
// System.out.println("TEMP DEBUG returning an element store for key " + NoteCoordinate.Utils.getReplidFromLong(key)
// + " and isProxied is " + result.isProxied());
} else {
System.err.println("delegateKey is a " + delegateKey.getClass().getName());
}
if (result == null) {
result = getDefaultElementStore();
// System.out.println("Returning default element store");
}
return result;
}
Aggregations