use of net.geoprism.registry.model.ServerParentTreeNode in project geoprism-registry by terraframe.
the class ServerParentTreeNodeOverTime method isSame.
public boolean isSame(ServerParentTreeNodeOverTime other, ServerGeoObjectIF exclude) {
Set<Entry<String, Hierarchy>> entries = other.hierarchies.entrySet();
for (Entry<String, Hierarchy> entry : entries) {
Hierarchy hierarchy = entry.getValue();
ServerHierarchyType ht = hierarchy.getType();
if (this.hasEntries(ht) && hierarchy.nodes.size() == this.getEntries(ht).size()) {
for (int i = 0; i < hierarchy.nodes.size(); i++) {
ServerParentTreeNode node = hierarchy.nodes.get(i);
ServerParentTreeNode oNode = this.getEntries(ht).get(i);
if (!node.isSame(oNode, exclude)) {
return false;
}
}
} else {
return false;
}
}
return true;
}
use of net.geoprism.registry.model.ServerParentTreeNode in project geoprism-registry by terraframe.
the class ChangeRequestServiceTest method testImplementParentDecisionsVerify.
@Request
private void testImplementParentDecisionsVerify(String crOid) throws Exception {
ChangeRequest cr = ChangeRequest.get(crOid);
Assert.assertEquals(AllGovernanceStatus.ACCEPTED.name(), cr.getApprovalStatus().get(0).name());
AbstractAction action = cr.getAllAction().next();
Assert.assertEquals(AllGovernanceStatus.ACCEPTED.name(), action.getApprovalStatus().get(0).name());
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
Date newStartDate = sdf.parse(NEW_START_DATE);
Date newEndDate = sdf.parse(NEW_END_DATE);
ServerGeoObjectIF serverGo = FastTestDataset.PROV_CENTRAL.getServerObject();
List<ServerParentTreeNode> ptns = serverGo.getParentsOverTime(new String[] { FastTestDataset.COUNTRY.getCode() }, false).getEntries(FastTestDataset.HIER_ADMIN.getServerObject());
Assert.assertEquals(1, ptns.size());
ServerParentTreeNode ptn = ptns.get(0);
List<ServerParentTreeNode> parents = ptn.getParents();
Assert.assertEquals(1, parents.size());
ServerParentTreeNode parent = parents.get(0);
Assert.assertEquals(newStartDate, ptn.getStartDate());
Assert.assertEquals(newEndDate, ptn.getEndDate());
Assert.assertEquals(BELIZE.getCode(), parent.getGeoObject().getCode());
}
use of net.geoprism.registry.model.ServerParentTreeNode in project geoprism-registry by terraframe.
the class ServerGeoObjectService method split.
@Transaction
public ServerGeoObjectIF split(GeoObjectSplitView view) {
ServerGeoObjectType type = ServerGeoObjectType.get(view.getTypeCode());
ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
final ServerGeoObjectIF source = strategy.getGeoObjectByCode(view.getSourceCode());
source.setDate(view.getDate());
ServerGeoObjectIF target = strategy.newInstance();
target.setDate(view.getDate());
target.populate(source.toGeoObject(view.getDate()), view.getDate(), view.getDate());
target.setCode(view.getTargetCode());
target.setDisplayLabel(view.getLabel());
target.apply(false);
final ServerParentTreeNode sNode = source.getParentGeoObjects(null, false, view.getDate());
final List<ServerParentTreeNode> sParents = sNode.getParents();
for (ServerParentTreeNode sParent : sParents) {
final ServerGeoObjectIF parent = sParent.getGeoObject();
final ServerHierarchyType hierarchyType = sParent.getHierarchyType();
target.addParent(parent, hierarchyType, view.getDate(), null);
}
return target;
}
use of net.geoprism.registry.model.ServerParentTreeNode in project geoprism-registry by terraframe.
the class VertexServerGeoObject method internalGetParentGeoObjects.
protected static ServerParentTreeNode internalGetParentGeoObjects(VertexServerGeoObject child, String[] parentTypes, boolean recursive, ServerHierarchyType htIn, Date date) {
ServerParentTreeNode tnRoot = new ServerParentTreeNode(child, htIn, date, null, null);
Map<String, Object> parameters = new HashedMap<String, Object>();
parameters.put("rid", child.getVertex().getRID());
StringBuilder statement = new StringBuilder();
statement.append("SELECT EXPAND( inE(");
if (htIn != null) {
statement.append("'" + htIn.getMdEdge().getDBClassName() + "'");
}
statement.append(")");
if (date != null || (parentTypes != null && parentTypes.length > 0)) {
statement.append("[");
if (date != null) {
statement.append(" :date BETWEEN startDate AND endDate");
parameters.put("date", date);
}
if (parentTypes != null && parentTypes.length > 0) {
if (date != null) {
statement.append(" AND");
}
statement.append("(");
for (int i = 0; i < parentTypes.length; i++) {
ServerGeoObjectType type = ServerGeoObjectType.get(parentTypes[i]);
final String paramName = "p" + Integer.toString(i);
if (i > 0) {
statement.append(" OR ");
}
statement.append("out.@class = :" + paramName);
parameters.put(paramName, type.getMdVertex().getDBClassName());
}
statement.append(")");
}
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)) {
final VertexObject parentVertex = edge.getParent();
MdVertexDAOIF mdVertex = (MdVertexDAOIF) parentVertex.getMdClass();
ServerHierarchyType ht = ServerHierarchyType.get(mdEdge);
ServerGeoObjectType parentType = ServerGeoObjectType.get(mdVertex);
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, edge.getOid());
}
tnRoot.addParent(tnParent);
}
}
return tnRoot;
}
use of net.geoprism.registry.model.ServerParentTreeNode in project geoprism-registry by terraframe.
the class VertexServerGeoObject method addParent.
@Override
public ServerParentTreeNode addParent(ServerGeoObjectIF parent, ServerHierarchyType hierarchyType, Date startDate, Date endDate) {
if (!hierarchyType.getUniversalType().equals(AllowedIn.CLASS)) {
hierarchyType.validateUniversalRelationship(this.getType(), parent.getType());
}
ValueOverTimeCollection votc = this.getParentCollection(hierarchyType);
votc.add(new ValueOverTime(startDate, endDate, parent));
SortedSet<EdgeObject> newEdges = this.setParentCollection(hierarchyType, votc);
ServerParentTreeNode node = new ServerParentTreeNode(this, hierarchyType, startDate, null, null);
node.addParent(new ServerParentTreeNode(parent, hierarchyType, startDate, null, newEdges.first().getOid()));
return node;
}
Aggregations