use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.
the class DElementIterable method containsAll.
@Override
public boolean containsAll(final Collection<?> c) {
List<NoteCoordinate> nclist = new ArrayList<NoteCoordinate>();
for (Object raw : c) {
if (raw instanceof Element) {
Element e = (Element) raw;
Object rawid = e.getId();
if (rawid instanceof NoteCoordinate) {
nclist.add((NoteCoordinate) rawid);
}
}
}
return index_.containsAll(nclist);
}
use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.
the class DElementIterable method toArray.
@Override
public Object[] toArray() {
int size = index_.size();
Object[] result = new Object[size];
for (int i = 0; i < size; i++) {
NoteCoordinate e = index_.get(i);
result[i] = store_.getElement(e);
}
return result;
}
use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.
the class DElementStore method getVertexIds.
// @Override
// public Set<Vertex> getCachedVertices() {
// FastSet<Vertex> result = new FastSet<Vertex>();
// for (Element elem : getElementCache().values()) {
// if (elem instanceof Vertex) {
// result.add((Vertex) elem);
// }
// }
// return result.unmodifiable();
// }
protected List<NoteCoordinate> getVertexIds() {
FastTable<NoteCoordinate> result = new FastTable<NoteCoordinate>();
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.DVertex.FORMULA_FILTER);
nc.buildCollection();
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 result;
}
use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.
the class DElementStore method findElementDelegate.
// @Override
@Override
public Object findElementDelegate(final Object delegateKey) throws IllegalStateException, IllegalArgumentException {
Object result = null;
Object del = null;
del = getStoreDelegate();
if (isProxied()) {
// System.out.println("TEMP DEBUG Retrieving from proxied store for key " + String.valueOf(delegateKey));
NoteCoordinate nc = null;
if (delegateKey instanceof NoteCoordinate) {
nc = (NoteCoordinate) delegateKey;
} else if (delegateKey instanceof CharSequence) {
nc = NoteCoordinate.Utils.getNoteCoordinate((CharSequence) delegateKey);
}
if (nc != null) {
long dbkey = nc.getReplicaLong();
if (getProxyStoreKey().equals(dbkey)) {
del = getProxyStoreDelegate();
}
}
}
if (del instanceof Database) {
Database db = (Database) del;
boolean isDeletedDoc;
db.getAncestorSession().setFixEnable(Fixes.MIME_BLOCK_ITEM_INTERFACE, false);
if (delegateKey instanceof Serializable) {
if (delegateKey instanceof ViewEntryCoordinate) {
result = ((ViewEntryCoordinate) delegateKey).getViewEntry();
} else if (delegateKey instanceof NoteCoordinate) {
String unid = ((NoteCoordinate) delegateKey).getUNID();
try {
result = db.getDocumentWithKey(unid, false);
} catch (UserAccessException uae) {
// this is normal and acceptable. Don't report.
} catch (RuntimeException re) {
throw re;
}
if (result != null) {
if (((Document) result).isDeleted()) {
isDeletedDoc = true;
result = null;
}
}
// System.out.println("Retrieved result using NoteCoordinate with unid " + unid);
} else if (delegateKey instanceof CharSequence) {
String skey = ((CharSequence) delegateKey).toString();
if (skey.length() > 50) {
String prefix = skey.subSequence(0, 2).toString();
String mid = skey.subSequence(2, 50).toString();
if ((prefix.equals("EC") || prefix.equals("ED") || prefix.equals("ET") || prefix.equals("EU")) && DominoUtils.isMetaversalId(mid)) {
ViewEntryCoordinate vec = ViewEntryCoordinate.Utils.getViewEntryCoordinate(skey);
result = vec.getViewEntry();
} else if ((prefix.equals("VC") || prefix.equals("VD") || prefix.equals("VT") || prefix.equals("VU")) && DominoUtils.isMetaversalId(mid)) {
ViewEntryCoordinate vec = ViewEntryCoordinate.Utils.getViewEntryCoordinate(skey);
result = vec.getViewEntry();
}
}
}
if (result == null) {
result = db.getDocumentWithKey((Serializable) delegateKey, false);
if (result != null) {
if (((Document) result).isDeleted()) {
isDeletedDoc = true;
result = null;
}
}
}
if (result != null) {
// }
if (isProxied()) {
// System.out.println("TEMP DEBUG from findElementDelegate: ElementStore "
// + ((Database) getStoreDelegate()).getApiPath() + "is proxied. Setting up proxy on delegate...");
result = setupProxy(result, (Serializable) delegateKey);
} else {
// System.out.println("TEMP DEBUG ElementStore " + ((Database) getStoreDelegate()).getApiPath() + " is not proxied.");
}
}
} else {
if (delegateKey != null) {
System.out.println("WARNING: Unknown delegatekey of type " + delegateKey.getClass().getName() + ". Creating a brand new delegate.");
}
// null is a perfectly valid key, since it means we want to let the system assign it.
result = db.createDocument();
// throw new IllegalArgumentException("Cannot find a delegate with a key of type "
// + (delegateKey == null ? "null" : delegateKey.getClass().getName()));
}
} else {
throw new IllegalStateException("ElementStore delegate is not a Database; it's a " + (del == null ? "null" : del.getClass().getName()) + ". We don't handle this case yet.");
// TODO NTF alternative strategies...
}
// }
return result;
}
use of org.openntf.domino.big.NoteCoordinate in project org.openntf.domino by OpenNTF.
the class DElementStore method setupProxy.
@SuppressWarnings("unchecked")
protected DProxyVertex setupProxy(final Object proxy, final Serializable originalKey) {
// System.out.println("TEMP DEBUG Setting up proxy vertex");
DProxyVertex result = new DProxyVertex(getConfiguration().getGraph(), (Map<String, Object>) proxy);
Object rawpid = result.getProxiedId();
if (rawpid != null) {
if (result.getProxyDelegate() == null) {
DElement elem = (DElement) getConfiguration().getGraph().getElement(rawpid);
if (elem == null) {
rawpid = null;
}
}
}
if (rawpid == null) {
CustomProxyResolver resolver = getCustomProxyResolver();
if (resolver == null) {
System.err.println("No default resolver implemented yet");
throw new UnimplementedException("Generics resolution of proxied vertices not yet implemented");
} else {
// System.out.println("Resolving using a " + resolver.getClass().getName());
Map<String, Object> originalDelegate = resolver.getOriginalDelegate(originalKey);
if (originalDelegate instanceof Document) {
String pid = ((Document) originalDelegate).getMetaversalID();
NoteCoordinate nc = NoteCoordinate.Utils.getNoteCoordinate(pid);
// System.out.println("Setting up proxy with id " + nc.toString());
try {
result.setProxiedId(nc);
} catch (Throwable t) {
t.printStackTrace();
}
} else {
if (originalDelegate == null) {
// System.out.println("No original delegate found for key " + String.valueOf(originalKey));
} else {
// System.err.println("original delegate returned a " + originalDelegate.getClass().getName());
}
}
}
} else {
}
// System.out.println("Setup a proxy with an id of " + String.valueOf(result.getProxiedId()));
return result;
}
Aggregations