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);
}
}
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);
}
}
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;
}
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);
}
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;
}
Aggregations