use of com.runwaysdk.business.graph.EdgeObject in project geoprism-registry by terraframe.
the class VertexServerGeoObject method addParent.
@Override
public ServerParentTreeNode addParent(ServerGeoObjectIF parent, ServerHierarchyType hierarchyType) {
if (!hierarchyType.getUniversalType().equals(AllowedIn.CLASS)) {
hierarchyType.validateUniversalRelationship(this.getType(), parent.getType());
}
String edgeOid = null;
if (this.getVertex().isNew() || !this.exists(parent, hierarchyType, null, null)) {
EdgeObject edge = this.getVertex().addParent(((VertexComponent) parent).getVertex(), hierarchyType.getMdEdge());
edge.apply();
edgeOid = edge.getOid();
}
ServerParentTreeNode node = new ServerParentTreeNode(this, hierarchyType, this.date, null, null);
node.addParent(new ServerParentTreeNode(parent, hierarchyType, this.date, null, edgeOid));
return node;
}
use of com.runwaysdk.business.graph.EdgeObject 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.business.graph.EdgeObject in project geoprism-registry by terraframe.
the class VertexServerGeoObject method setParents.
@Override
public void setParents(ServerParentTreeNodeOverTime parentsOverTime) {
parentsOverTime.enforceUserHasPermissionSetParents(this.getType().getCode(), false);
final Collection<ServerHierarchyType> hierarchyTypes = parentsOverTime.getHierarchies();
for (ServerHierarchyType hierarchyType : hierarchyTypes) {
final List<ServerParentTreeNode> entries = parentsOverTime.getEntries(hierarchyType);
this.removeAllEdges(hierarchyType);
final TreeSet<EdgeObject> edges = new TreeSet<EdgeObject>(new EdgeComparator());
for (ServerParentTreeNode entry : entries) {
final ServerGeoObjectIF parent = entry.getGeoObject();
EdgeObject newEdge = this.getVertex().addParent(((VertexComponent) parent).getVertex(), hierarchyType.getMdEdge());
newEdge.setValue(GeoVertex.START_DATE, entry.getStartDate());
newEdge.setValue(GeoVertex.END_DATE, entry.getEndDate());
edges.add(newEdge);
}
for (EdgeObject e : edges) {
e.apply();
}
}
}
use of com.runwaysdk.business.graph.EdgeObject 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.EdgeObject in project geoprism-registry by terraframe.
the class UpdateParentValueOverTimeView method executeParent.
public void executeParent(UpdateChangeOverTimeAttributeView cotView, VertexServerGeoObject go, SortedSet<EdgeObject> looseVotc) {
UpdateParentView parentView = (UpdateParentView) cotView;
final ServerHierarchyType hierarchyType = ServerHierarchyType.get(parentView.getHierarchyCode());
if (this.action.equals(UpdateActionType.DELETE)) {
EdgeObject edge = this.getEdgeByOid(looseVotc, this.oid);
if (edge == null) {
ExecuteOutOfDateChangeRequestException ex = new ExecuteOutOfDateChangeRequestException();
throw ex;
}
edge.delete();
looseVotc.remove(edge);
} else if (this.action.equals(UpdateActionType.UPDATE)) {
EdgeObject edge = this.getEdgeByOid(looseVotc, this.oid);
if (edge == null) {
ExecuteOutOfDateChangeRequestException ex = new ExecuteOutOfDateChangeRequestException();
throw ex;
}
final VertexServerGeoObject newParent = this.getNewValueAsGO();
final String parentCode = newParent == null ? null : newParent.getCode();
String currentCode = edge.getParent().getObjectValue(DefaultAttribute.CODE.getName());
// Parent values can only be changed by deleting the current edge and creating a new one unfortunately
if (this.newValue != null && (currentCode != parentCode)) {
Date _newStartDate = this.newStartDate;
Date _newEndDate = this.newEndDate;
if (_newStartDate == null) {
_newStartDate = edge.getObjectValue(GeoVertex.START_DATE);
}
if (_newEndDate == null) {
_newEndDate = edge.getObjectValue(GeoVertex.END_DATE);
}
edge.delete();
looseVotc.remove(edge);
if (newParent != null) {
// We unfortunately can't use this method because we have to bypass the votc reordering and validation
// go.addParent(newParent, hierarchyType, _newStartDate, _newEndDate);
EdgeObject newEdge = go.getVertex().addParent(((VertexComponent) newParent).getVertex(), hierarchyType.getMdEdge());
newEdge.setValue(GeoVertex.START_DATE, _newStartDate);
newEdge.setValue(GeoVertex.END_DATE, _newEndDate);
newEdge.apply();
looseVotc.add(newEdge);
}
return;
}
if (newStartDate != null) {
edge.setValue(GeoVertex.START_DATE, newStartDate);
}
if (newEndDate != null) {
edge.setValue(GeoVertex.END_DATE, newEndDate);
}
edge.apply();
} else if (this.action.equals(UpdateActionType.CREATE)) {
final VertexServerGeoObject newParent = this.getNewValueAsGO();
if (newParent == null || this.newStartDate == null || this.newEndDate == null) {
throw new InvalidChangeRequestException();
}
EdgeObject edge = go.getEdge(newParent, hierarchyType, this.newStartDate, this.newEndDate);
if (edge != null) {
ExecuteOutOfDateChangeRequestException ex = new ExecuteOutOfDateChangeRequestException();
throw ex;
}
// We unfortunately can't use this method because we have to bypass the votc reordering and validation
// go.addParent(newParent, hierarchyType, this.newStartDate, this.newEndDate);
EdgeObject newEdge = go.getVertex().addParent(((VertexComponent) newParent).getVertex(), hierarchyType.getMdEdge());
newEdge.setValue(GeoVertex.START_DATE, this.newStartDate);
newEdge.setValue(GeoVertex.END_DATE, this.newEndDate);
newEdge.apply();
looseVotc.add(newEdge);
} else {
throw new UnsupportedOperationException("Unsupported action type [" + this.action + "].");
}
}
Aggregations