use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.
the class UndirectedGraphStrategy method getParents.
private ServerParentGraphNode getParents(VertexServerGeoObject source, Boolean recursive, Date date, TreeSet<String> visited) {
ServerParentGraphNode tnRoot = new ServerParentGraphNode(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 targetType = ServerGeoObjectType.get(mdVertex);
VertexServerGeoObject target = new VertexServerGeoObject(targetType, vertex, date);
if (!target.getUid().equals(source.getUid())) {
ServerParentGraphNode tnParent;
if (recursive & !visited.contains(target.getUid())) {
visited.add(target.getUid());
tnParent = this.getParents(target, recursive, date, visited);
tnParent.setOid(edge.getOid());
} else {
tnParent = new ServerParentGraphNode(target, this.type, date, null, edge.getOid());
}
tnRoot.addParent(tnParent);
}
}
return tnRoot;
}
use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.
the class VertexServerGeoObject method createExternalId.
@Override
public void createExternalId(ExternalSystem system, String id, ImportStrategy importStrategy) {
if (importStrategy.equals(ImportStrategy.NEW_ONLY)) {
EdgeObject edge = this.getVertex().addParent(system, GeoVertex.EXTERNAL_ID);
edge.setValue("id", id);
edge.apply();
} else {
EdgeObject edge = this.getExternalIdEdge(system);
if (edge == null) {
edge = this.getVertex().addParent(system, GeoVertex.EXTERNAL_ID);
}
edge.setValue("id", id);
edge.apply();
}
}
use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.
the class VertexServerGeoObject method internalGetChildGeoObjects.
private static ServerChildTreeNode internalGetChildGeoObjects(VertexServerGeoObject parent, String[] childrenTypes, Boolean recursive, ServerHierarchyType htIn, Date date) {
ServerChildTreeNode tnRoot = new ServerChildTreeNode(parent, htIn, date, null, null);
Map<String, Object> parameters = new HashedMap<String, Object>();
parameters.put("rid", parent.getVertex().getRID());
StringBuilder statement = new StringBuilder();
statement.append("SELECT EXPAND(outE(");
if (htIn != null) {
statement.append("'" + htIn.getMdEdge().getDBClassName() + "'");
}
statement.append(")");
if (childrenTypes != null && childrenTypes.length > 0) {
statement.append("[");
for (int i = 0; i < childrenTypes.length; i++) {
ServerGeoObjectType type = ServerGeoObjectType.get(childrenTypes[i]);
final String paramName = "p" + Integer.toString(i);
if (i > 0) {
statement.append(" OR ");
}
statement.append("in.@class = :" + paramName);
parameters.put(paramName, type.getMdVertex().getDBClassName());
}
statement.append("]");
}
statement.append(") FROM :rid");
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)) {
VertexObject childVertex = edge.getChild();
MdVertexDAOIF mdVertex = (MdVertexDAOIF) childVertex.getMdClass();
ServerHierarchyType ht = ServerHierarchyType.get(mdEdge);
ServerGeoObjectType childType = ServerGeoObjectType.get(mdVertex);
VertexServerGeoObject child = new VertexServerGeoObject(childType, childVertex, date);
ServerChildTreeNode tnChild;
if (recursive) {
tnChild = internalGetChildGeoObjects(child, childrenTypes, recursive, ht, date);
} else {
tnChild = new ServerChildTreeNode(child, ht, date, null, edge.getOid());
}
tnRoot.addChild(tnChild);
}
}
return tnRoot;
}
use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.
the class VertexServerGeoObject method getEdge.
public EdgeObject getEdge(ServerGeoObjectIF parent, ServerHierarchyType hierarchyType, Date startDate, Date endDate) {
String statement = "SELECT FROM " + hierarchyType.getMdEdge().getDBClassName();
statement += " WHERE out = :parent";
statement += " AND in = :child";
if (startDate != null) {
statement += " AND startDate = :startDate";
}
if (endDate != null) {
statement += " AND endDate = :endDate";
}
GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement);
query.setParameter("parent", ((VertexComponent) parent).getVertex().getRID());
query.setParameter("child", this.getVertex().getRID());
if (startDate != null) {
query.setParameter("startDate", startDate);
}
if (endDate != null) {
query.setParameter("endDate", endDate);
}
return query.getSingleResult();
}
use of com.runwaysdk.business.graph.EdgeObject 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;
}
Aggregations