use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.
the class UndirectedGraphStrategy method getParentCollection.
private Set<ValueOverTime> getParentCollection(VertexServerGeoObject geoObject) {
Set<ValueOverTime> set = new TreeSet<ValueOverTime>(new Comparator<ValueOverTime>() {
@Override
public int compare(ValueOverTime o1, ValueOverTime o2) {
return o1.getOid().compareTo(o2.getOid());
}
});
SortedSet<EdgeObject> edges = this.getParentEdges(geoObject);
for (EdgeObject edge : edges) {
final Date startDate = edge.getObjectValue(GeoVertex.START_DATE);
final Date endDate = edge.getObjectValue(GeoVertex.END_DATE);
VertexObject parentVertex = edge.getParent();
MdVertexDAOIF mdVertex = (MdVertexDAOIF) parentVertex.getMdClass();
ServerGeoObjectType parentType = ServerGeoObjectType.get(mdVertex);
VertexServerGeoObject parent = new VertexServerGeoObject(parentType, parentVertex, startDate);
set.add(new ValueOverTime(edge.getOid(), startDate, endDate, parent));
}
return set;
}
use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.
the class UndirectedGraphStrategy method addParent.
@SuppressWarnings("unchecked")
@Override
public <T extends ServerGraphNode> T addParent(VertexServerGeoObject geoObject, VertexServerGeoObject parent, Date startDate, Date endDate) {
if (this.isCycle(geoObject, parent, startDate, endDate)) {
throw new UnsupportedOperationException("Cyclic graph is not supported");
}
if (this.getEdges(geoObject, parent, startDate, endDate).size() > 0) {
throw new UnsupportedOperationException("Duplicate edge");
}
Set<ValueOverTime> votc = this.getParentCollection(geoObject);
votc.add(new ValueOverTime(startDate, endDate, parent));
SortedSet<EdgeObject> newEdges = this.setParentCollection(geoObject, votc);
ServerParentGraphNode node = new ServerParentGraphNode(geoObject, this.type, startDate, endDate, null);
node.addParent(new ServerParentGraphNode(parent, this.type, startDate, endDate, newEdges.first().getOid()));
return (T) node;
}
use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.
the class UndirectedGraphStrategy method getChildren.
private ServerChildGraphNode getChildren(VertexServerGeoObject source, Boolean recursive, Date date, TreeSet<String> visited) {
ServerChildGraphNode tnRoot = new ServerChildGraphNode(source, this.type, date, null, null);
List<EdgeObject> edges = this.getEdges(source, date);
for (EdgeObject edge : edges) {
Object sourceRid = source.getVertex().getRID();
final VertexObject vertex = edge.getChild().getRID().equals(sourceRid) ? edge.getParent() : edge.getChild();
MdVertexDAOIF mdVertex = (MdVertexDAOIF) vertex.getMdClass();
ServerGeoObjectType vertexType = ServerGeoObjectType.get(mdVertex);
VertexServerGeoObject target = new VertexServerGeoObject(vertexType, vertex, date);
if (!source.getUid().equals(target.getUid())) {
ServerChildGraphNode tnParent;
if (recursive && !visited.contains(target.getUid())) {
visited.add(target.getUid());
tnParent = this.getChildren(target, recursive, date, visited);
tnParent.setOid(edge.getOid());
} else {
tnParent = new ServerChildGraphNode(target, this.type, date, null, edge.getOid());
}
tnRoot.addChild(tnParent);
}
}
return tnRoot;
}
use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.
the class VertexServerGeoObject method getEdges.
public SortedSet<EdgeObject> getEdges(ServerHierarchyType hierarchyType) {
TreeSet<EdgeObject> set = new TreeSet<EdgeObject>(new EdgeComparator());
String statement = "SELECT expand(inE('" + hierarchyType.getMdEdge().getDBClassName() + "'))";
statement += " FROM :child";
GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement);
query.setParameter("child", this.getVertex().getRID());
set.addAll(query.getResults());
return set;
}
use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.
the class VertexServerGeoObject method removeParent.
@Override
public void removeParent(ServerGeoObjectIF parent, ServerHierarchyType hierarchyType, Date startDate, Date endDate) {
EdgeObject edge = this.getEdge(parent, hierarchyType, startDate, endDate);
edge.delete();
//
// this.getVertex().removeParent( ( (VertexComponent) parent ).getVertex(), hierarchyType.getMdEdge());
}
Aggregations