use of com.runwaysdk.dataaccess.MdEdgeDAOIF 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.dataaccess.MdEdgeDAOIF in project geoprism-registry by terraframe.
the class VertexServerGeoObject method getExternalIdEdge.
private EdgeObject getExternalIdEdge(ExternalSystem system) {
MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(GeoVertex.EXTERNAL_ID);
String statement = "SELECT expand(inE('" + mdEdge.getDBClassName() + "')[out = :parent])";
statement += " FROM :child";
GraphQuery<EdgeObject> query = new GraphQuery<EdgeObject>(statement);
query.setParameter("parent", system.getRID());
query.setParameter("child", this.getVertex().getRID());
return query.getSingleResult();
}
use of com.runwaysdk.dataaccess.MdEdgeDAOIF 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.dataaccess.MdEdgeDAOIF in project geoprism-registry by terraframe.
the class AttributeValueRestriction method subquery.
@Override
public void subquery(StringBuilder statement, Map<String, Object> parameters, String parameterName) {
String columnName = mdAttribute.getColumnName() + "_cot";
statement.append("(" + columnName + " CONTAINS (");
statement.append(":date BETWEEN startDate AND endDate AND ");
if (this.mdAttribute instanceof MdAttributeClassificationDAOIF && operation.equalsIgnoreCase("eq")) {
MdClassificationDAOIF mdClassification = ((MdAttributeClassificationDAOIF) this.mdAttribute).getMdClassificationDAOIF();
MdEdgeDAOIF mdEdge = mdClassification.getReferenceMdEdgeDAO();
statement.append("value IN ( TRAVERSE out(\"" + mdEdge.getDBClassName() + "\") FROM :" + parameterName + ")");
} else {
statement.append("value = :" + parameterName);
}
// Close CONTAINS parentheses
statement.append(")");
// Close CONDITION parentheses
statement.append(")");
parameters.put(parameterName, this.value);
parameters.put("date", this.date);
}
use of com.runwaysdk.dataaccess.MdEdgeDAOIF in project geoprism-registry by terraframe.
the class VertexExternalIdRestriction method restrict.
@Override
public void restrict(StringBuilder statement, Map<String, Object> parameters) {
MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(GeoVertex.EXTERNAL_ID);
statement.append("}.inE('" + mdEdge.getDBClassName() + "'){where: (id = :id AND out = :out)");
parameters.put("out", this.system.getRID());
parameters.put("id", this.externalId);
}
Aggregations