Search in sources :

Example 1 with ServerParentTreeNodeOverTime

use of net.geoprism.registry.view.ServerParentTreeNodeOverTime in project geoprism-registry by terraframe.

the class SetParentAction method apply.

@Override
public void apply() {
    // Important to remember that the child may or may not exist at this point (so we can't fetch it from the DB here)
    ServerGeoObjectType type = ServiceFactory.getMetadataCache().getGeoObjectType(this.getChildTypeCode()).get();
    ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, this.getJson());
    ptnOt.enforceUserHasPermissionSetParents(this.getChildTypeCode(), true);
    super.apply();
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime)

Example 2 with ServerParentTreeNodeOverTime

use of net.geoprism.registry.view.ServerParentTreeNodeOverTime in project geoprism-registry by terraframe.

the class ETLService method submitImportErrorResolutionInTrans.

@Transaction
private void submitImportErrorResolutionInTrans(String sessionId, String json) {
    JsonObject config = JsonParser.parseString(json).getAsJsonObject();
    ImportHistory hist = ImportHistory.get(config.get("historyId").getAsString());
    hist.getConfig().enforceExecutePermissions();
    ImportError err = ImportError.get(config.get("importErrorId").getAsString());
    String resolution = config.get("resolution").getAsString();
    if (resolution.equals(ErrorResolution.APPLY_GEO_OBJECT.name())) {
        String parentTreeNode = config.get("parentTreeNode").toString();
        String geoObject = config.get("geoObject").toString();
        Boolean isNew = config.get("isNew").getAsBoolean();
        GeoObjectOverTime go = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), geoObject);
        if (isNew) {
            go.setUid(RegistryIdService.getInstance().next());
            geoObject = go.toJSON().toString();
            new ServerGeoObjectService().createGeoObject(sessionId, parentTreeNode, geoObject, null, null);
        } else {
            ServerGeoObjectService service = new ServerGeoObjectService();
            ServerGeoObjectIF serverGO = service.apply(go, isNew, false);
            final ServerGeoObjectType type = serverGO.getType();
            ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, parentTreeNode);
            serverGO.setParents(ptnOt);
        }
        err.appLock();
        err.setResolution(resolution);
        err.apply();
        hist.appLock();
        hist.setErrorResolvedCount(hist.getErrorResolvedCount() + 1);
        hist.setImportedRecords(hist.getImportedRecords() + 1);
        hist.apply();
    } else if (resolution.equals(ErrorResolution.IGNORE.name())) {
        err.appLock();
        err.setResolution(resolution);
        err.apply();
    } else {
        throw new UnsupportedOperationException("Invalid import resolution [" + resolution + "].");
    }
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 3 with ServerParentTreeNodeOverTime

use of net.geoprism.registry.view.ServerParentTreeNodeOverTime in project geoprism-registry by terraframe.

the class ServerGeoObjectService method createGeoObjectInTrans.

@Transaction
public JsonObject createGeoObjectInTrans(String sPtn, String sTimeGo, String masterListId, String notes) {
    GeoObjectOverTime timeGO = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sTimeGo);
    ServerGeoObjectType serverGOT = ServerGeoObjectType.get(timeGO.getType());
    RolePermissionService perms = ServiceFactory.getRolePermissionService();
    final String orgCode = serverGOT.getOrganization().getCode();
    if (perms.isSRA() || perms.isRA(orgCode) || perms.isRM(orgCode, serverGOT)) {
        ServerGeoObjectService service = new ServerGeoObjectService();
        ServerGeoObjectIF serverGO = service.apply(timeGO, true, false);
        final ServerGeoObjectType type = serverGO.getType();
        if (sPtn != null) {
            ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, sPtn);
            serverGO.setParents(ptnOt);
        }
        // Update the master list record
        if (masterListId != null) {
            ListTypeVersion.get(masterListId).publishRecord(serverGO);
        }
        JsonObject resp = new JsonObject();
        resp.addProperty("isChangeRequest", false);
        resp.add("geoObject", serverGO.toGeoObjectOverTime().toJSON(ServiceFactory.getRegistryService().serializer(Session.getCurrentSession().getOid())));
        return resp;
    } else if (ServiceFactory.getRolePermissionService().isRC(orgCode, serverGOT)) {
        Instant base = Instant.now();
        int sequence = 0;
        ChangeRequest request = new ChangeRequest();
        request.addApprovalStatus(AllGovernanceStatus.PENDING);
        request.setContributorNotes(notes);
        request.setGeoObjectCode(timeGO.getCode());
        request.setGeoObjectTypeCode(timeGO.getType().getCode());
        request.setOrganizationCode(orgCode);
        request.apply();
        CreateGeoObjectAction action = new CreateGeoObjectAction();
        action.addApprovalStatus(AllGovernanceStatus.PENDING);
        action.setCreateActionDate(Date.from(base.plus(sequence++, ChronoUnit.MINUTES)));
        action.setGeoObjectJson(sTimeGo);
        action.setParentJson(sPtn);
        action.setApiVersion(CGRAdapterProperties.getApiVersion());
        action.setContributorNotes(notes);
        action.apply();
        request.addAction(action).apply();
        JsonObject resp = new JsonObject();
        resp.addProperty("isChangeRequest", true);
        resp.addProperty("changeRequestId", request.getOid());
        return resp;
    } else {
        throw new CGRPermissionException();
    }
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) CGRPermissionException(net.geoprism.registry.CGRPermissionException) CreateGeoObjectAction(net.geoprism.registry.action.geoobject.CreateGeoObjectAction) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Instant(java.time.Instant) JsonObject(com.google.gson.JsonObject) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 4 with ServerParentTreeNodeOverTime

use of net.geoprism.registry.view.ServerParentTreeNodeOverTime 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;
}
Also used : MdVertexDAOIF(com.runwaysdk.dataaccess.MdVertexDAOIF) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) VertexObject(com.runwaysdk.business.graph.VertexObject) ServerParentTreeNode(net.geoprism.registry.model.ServerParentTreeNode) 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) Date(java.util.Date) LocalDate(java.time.LocalDate) 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) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime) HashedMap(org.apache.commons.collections4.map.HashedMap) GraphQuery(com.runwaysdk.business.graph.GraphQuery)

Example 5 with ServerParentTreeNodeOverTime

use of net.geoprism.registry.view.ServerParentTreeNodeOverTime in project geoprism-registry by terraframe.

the class CreateGeoObjectAction method execute.

@Override
public void execute() {
    String sJson = this.getGeoObjectJson();
    GeoObjectOverTime geoObject = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sJson);
    ServerGeoObjectService service = new ServerGeoObjectService();
    service.apply(geoObject, true, false);
    ServerGeoObjectIF child = service.getGeoObjectByCode(geoObject.getCode(), geoObject.getType().getCode());
    ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(child.getType(), this.getParentJson());
    child.setParents(ptnOt);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime)

Aggregations

ServerParentTreeNodeOverTime (net.geoprism.registry.view.ServerParentTreeNodeOverTime)9 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)6 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)5 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 JsonObject (com.google.gson.JsonObject)3 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)3 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 Request (com.runwaysdk.session.Request)2 Date (java.util.Date)2 ChangeRequest (net.geoprism.registry.action.ChangeRequest)2 ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)2 EdgeObject (com.runwaysdk.business.graph.EdgeObject)1 GraphObject (com.runwaysdk.business.graph.GraphObject)1 GraphQuery (com.runwaysdk.business.graph.GraphQuery)1 VertexObject (com.runwaysdk.business.graph.VertexObject)1 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)1 MdVertexDAOIF (com.runwaysdk.dataaccess.MdVertexDAOIF)1 LineString (com.vividsolutions.jts.geom.LineString)1 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)1 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)1