Search in sources :

Example 6 with ServerParentTreeNode

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;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Entry(java.util.Map.Entry) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode)

Example 7 with ServerParentTreeNode

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());
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) ChangeRequest(net.geoprism.registry.action.ChangeRequest) AbstractAction(net.geoprism.registry.action.AbstractAction) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 8 with ServerParentTreeNode

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;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 9 with ServerParentTreeNode

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;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) EdgeObject(com.runwaysdk.business.graph.EdgeObject) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) LineString(com.vividsolutions.jts.geom.LineString) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) Point(com.vividsolutions.jts.geom.Point) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) VertexObject(com.runwaysdk.business.graph.VertexObject) EdgeObject(com.runwaysdk.business.graph.EdgeObject) AbstractServerGeoObject(net.geoprism.registry.model.AbstractServerGeoObject) GraphObject(com.runwaysdk.business.graph.GraphObject) HashedMap(org.apache.commons.collections4.map.HashedMap) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 10 with ServerParentTreeNode

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;
}
Also used : ValueOverTime(com.runwaysdk.dataaccess.graph.attributes.ValueOverTime) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) EdgeObject(com.runwaysdk.business.graph.EdgeObject) ValueOverTimeCollection(com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)

Aggregations

ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)16 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)9 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)9 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)7 EdgeObject (com.runwaysdk.business.graph.EdgeObject)5 Request (com.runwaysdk.session.Request)5 Entry (java.util.Map.Entry)4 JsonObject (com.google.gson.JsonObject)3 VertexObject (com.runwaysdk.business.graph.VertexObject)3 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)3 LineString (com.vividsolutions.jts.geom.LineString)3 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)3 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)3 Point (com.vividsolutions.jts.geom.Point)3 Date (java.util.Date)3 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)3 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)3 GraphObject (com.runwaysdk.business.graph.GraphObject)2 GraphQuery (com.runwaysdk.business.graph.GraphQuery)2 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)2