use of com.runwaysdk.business.graph.VertexObject in project geoprism-registry by terraframe.
the class VertexServerGeoObject method getParentCollection.
public ValueOverTimeCollection getParentCollection(ServerHierarchyType hierarchyType) {
ValueOverTimeCollection votc = new ValueOverTimeCollection();
SortedSet<EdgeObject> edges = this.getEdges(hierarchyType);
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);
votc.add(new ValueOverTime(edge.getOid(), startDate, endDate, parent));
}
return votc;
}
use of com.runwaysdk.business.graph.VertexObject in project geoprism-registry by terraframe.
the class VertexServerGeoObject method internalGetParentOverTime.
protected static ServerParentTreeNodeOverTime internalGetParentOverTime(VertexServerGeoObject child, String[] parentTypes, boolean recursive) {
final ServerGeoObjectType cType = child.getType();
final List<ServerHierarchyType> hierarchies = cType.getHierarchies();
ServerParentTreeNodeOverTime response = new ServerParentTreeNodeOverTime(cType);
for (ServerHierarchyType ht : hierarchies) {
response.add(ht);
}
Map<String, Object> parameters = new HashedMap<String, Object>();
parameters.put("rid", child.getVertex().getRID());
StringBuilder statement = new StringBuilder();
statement.append("SELECT EXPAND(inE()");
if (parentTypes != null && parentTypes.length > 0) {
statement.append("[");
for (int i = 0; i < parentTypes.length; i++) {
ServerGeoObjectType type = ServerGeoObjectType.get(parentTypes[i]);
if (i > 0) {
statement.append(" OR ");
}
statement.append("out.@class = :a" + i);
parameters.put("a" + Integer.toString(i), type.getMdVertex().getDBClassName());
}
statement.append("]");
}
statement.append(") FROM :rid");
statement.append(" ORDER BY startDate ASC");
GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement.toString(), parameters);
List<EdgeObject> edges = query.getResults();
for (EdgeObject edge : edges) {
MdEdgeDAOIF mdEdge = (MdEdgeDAOIF) edge.getMdClass();
if (HierarchicalRelationshipType.isEdgeAHierarchyType(mdEdge)) {
ServerHierarchyType ht = ServerHierarchyType.get(mdEdge);
VertexObject parentVertex = edge.getParent();
MdVertexDAOIF mdVertex = (MdVertexDAOIF) parentVertex.getMdClass();
ServerGeoObjectType parentType = ServerGeoObjectType.get(mdVertex);
Date date = edge.getObjectValue(GeoVertex.START_DATE);
Date endDate = edge.getObjectValue(GeoVertex.END_DATE);
String oid = edge.getObjectValue(GeoVertex.OID);
ServerParentTreeNode tnRoot = new ServerParentTreeNode(child, null, date, null, oid);
tnRoot.setEndDate(endDate);
tnRoot.setOid(oid);
VertexServerGeoObject parent = new VertexServerGeoObject(parentType, parentVertex, date);
ServerParentTreeNode tnParent;
if (recursive) {
tnParent = internalGetParentGeoObjects(parent, parentTypes, recursive, ht, date);
} else {
tnParent = new ServerParentTreeNode(parent, ht, date, null, oid);
}
tnRoot.addParent(tnParent);
response.add(ht, tnRoot);
}
}
return response;
}
use of com.runwaysdk.business.graph.VertexObject in project geoprism-registry by terraframe.
the class VertexServerGeoObject method buildAncestorQuery.
// @Override
// public Map<String, LocationInfo> getAncestorMap(ServerHierarchyType
// hierarchy, boolean includeInheritedTypes)
// {
// TreeMap<String, LocationInfo> map = new TreeMap<String, LocationInfo>();
//
// GraphQuery<VertexObject> query = buildAncestorQuery(hierarchy);
//
// List<VertexObject> results = query.getResults();
// results.forEach(result -> {
// MdVertexDAOIF mdClass = (MdVertexDAOIF) result.getMdClass();
// ServerGeoObjectType vType = ServerGeoObjectType.get(mdClass);
// VertexServerGeoObject object = new VertexServerGeoObject(type, result,
// this.date);
//
// map.put(vType.getUniversal().getKey(), object);
//
// if (includeInheritedTypes && vType.isRoot(hierarchy))
// {
// ServerHierarchyType inheritedHierarchy =
// vType.getInheritedHierarchy(hierarchy);
//
// if (inheritedHierarchy != null)
// {
// map.putAll(object.getAncestorMap(inheritedHierarchy, true));
// }
// }
// });
//
// return map;
// }
private GraphQuery<VertexObject> buildAncestorQuery(ServerHierarchyType hierarchy) {
String dbClassName = this.getMdClass().getDBClassName();
if (this.date == null) {
StringBuilder statement = new StringBuilder();
statement.append("MATCH ");
statement.append("{class:" + dbClassName + ", where: (@rid=:rid)}");
statement.append(".in('" + hierarchy.getMdEdge().getDBClassName() + "')");
statement.append("{as: ancestor, where: (exists=true AND invalid=false), while: (true)}");
statement.append("RETURN $elements");
GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
query.setParameter("rid", this.vertex.getRID());
return query;
} else {
StringBuilder statement = new StringBuilder();
statement.append("MATCH ");
statement.append("{class:" + dbClassName + ", where: (@rid=:rid)}");
statement.append(".(inE('" + hierarchy.getMdEdge().getDBClassName() + "'){where: (:date BETWEEN startDate AND endDate)}.outV())");
statement.append("{as: ancestor, where: (invalid=false AND exists_cot CONTAINS (value=true AND :date BETWEEN startDate AND endDate )), while: (true)}");
statement.append("RETURN $elements");
GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
query.setParameter("rid", this.vertex.getRID());
query.setParameter("date", this.date);
return query;
}
}
use of com.runwaysdk.business.graph.VertexObject in project geoprism-registry by terraframe.
the class VertexGeoObjectQuery method getResults.
public List<ServerGeoObjectIF> getResults() {
List<ServerGeoObjectIF> list = new LinkedList<ServerGeoObjectIF>();
GraphQuery<VertexObject> query = this.getQuery();
List<VertexObject> results = query.getResults();
for (VertexObject result : results) {
list.add(new VertexServerGeoObject(type, result, this.date));
}
return list;
}
use of com.runwaysdk.business.graph.VertexObject in project geoprism-registry by terraframe.
the class VertexSelectGeoObjectQuery method getSingleResult.
public ServerGeoObjectIF getSingleResult() {
GraphQuery<VertexObject> query = this.getQuery();
VertexObject vertex = query.getSingleResult();
if (vertex != null) {
return new VertexServerGeoObject(type, vertex, this.date);
}
return null;
}
Aggregations