Search in sources :

Example 11 with ServerGeoObjectService

use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.

the class GeoObjectImporter method parsePostalCode.

private ServerGeoObjectIF parsePostalCode(FeatureRow feature) {
    LocationBuilder builder = PostalCodeFactory.get(this.configuration.getType());
    Location location = builder.build(this.configuration.getFunction(GeoObject.CODE));
    ShapefileFunction function = location.getFunction();
    String code = (String) function.getValue(feature);
    if (code != null) {
        // Search
        ServerGeoObjectQuery query = new ServerGeoObjectService().createQuery(location.getType(), this.configuration.getStartDate());
        query.setRestriction(new ServerCodeRestriction(code));
        // Assert.assertNull(query.getSingleResult());
        ServerGeoObjectIF result = query.getSingleResult();
        if (result != null) {
            return result;
        } else {
            PostalCodeLocationException e = new PostalCodeLocationException();
            e.setCode(code);
            e.setTypeLabel(location.getType().getLabel().getValue());
            throw e;
        }
    }
    return null;
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) LocationBuilder(net.geoprism.registry.io.LocationBuilder) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) PostalCodeLocationException(net.geoprism.registry.io.PostalCodeLocationException) ShapefileFunction(net.geoprism.data.importer.ShapefileFunction) ServerGeoObjectQuery(net.geoprism.registry.query.ServerGeoObjectQuery) ServerCodeRestriction(net.geoprism.registry.query.ServerCodeRestriction) Location(net.geoprism.registry.io.Location)

Example 12 with ServerGeoObjectService

use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.

the class ServerParentGraphNode method fromJSON.

public static ServerParentGraphNode fromJSON(JsonObject jo) {
    ServerGeoObjectIF goif = null;
    if (jo.has(TreeNode.JSON_GEO_OBJECT)) {
        GeoObject go = GeoObject.fromJSON(ServiceFactory.getAdapter(), jo.get(TreeNode.JSON_GEO_OBJECT).toString());
        ServerGeoObjectType type = ServerGeoObjectType.get(go.getType());
        ServerGeoObjectStrategyIF strategy = new ServerGeoObjectService().getStrategy(type);
        goif = strategy.constructFromGeoObject(go, false);
    }
    GraphType graphType = null;
    if (jo.has("graphType")) {
        String graphCode = jo.get("graphType").getAsString();
        String graphTypeClass = jo.get("graphTypeClass").getAsString();
        graphType = GraphType.getByCode(graphTypeClass, graphCode);
    }
    Date startDate = null;
    if (jo.has("startDate")) {
        startDate = GeoRegistryUtil.parseDate(jo.get("startDate").getAsString());
    }
    Date endDate = null;
    if (jo.has("endDate")) {
        endDate = GeoRegistryUtil.parseDate(jo.get("startDate").getAsString());
    }
    String oid = null;
    if (jo.has("oid")) {
        oid = jo.get("oid").getAsString();
    }
    ServerParentGraphNode node = new ServerParentGraphNode(goif, graphType, startDate, endDate, oid);
    if (jo.has(ParentTreeNode.JSON_PARENTS)) {
        JsonArray jaParents = jo.get(ParentTreeNode.JSON_PARENTS).getAsJsonArray();
        for (int i = 0; i < jaParents.size(); ++i) {
            node.addParent(ServerParentGraphNode.fromJSON(jaParents.get(i).getAsJsonObject()));
        }
    }
    return node;
}
Also used : JsonArray(com.google.gson.JsonArray) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) Date(java.util.Date)

Example 13 with ServerGeoObjectService

use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.

the class ChangeRequestService method update.

@Request(RequestType.SESSION)
public JsonObject update(String sessionId, String cr) {
    JsonObject obj = JsonParser.parseString(cr).getAsJsonObject();
    String oid = obj.get("oid").getAsString();
    JsonArray actions = obj.get("actions").getAsJsonArray();
    String notes = obj.get("contributorNotes").getAsString();
    ChangeRequest current = ChangeRequest.get(oid);
    ServerGeoObjectService service = new ServerGeoObjectService();
    service.updateChangeRequest(current, notes, actions);
    return current.getDetails();
}
Also used : JsonArray(com.google.gson.JsonArray) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) JsonObject(com.google.gson.JsonObject) ChangeRequest(net.geoprism.registry.action.ChangeRequest) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 14 with ServerGeoObjectService

use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.

the class GraphService method getChildren.

@Request(RequestType.SESSION)
public JsonObject getChildren(String sessionId, String parentCode, String parentGeoObjectTypeCode, String graphTypeCode, Boolean recursive, Date date) {
    ServerGeoObjectService service = ServiceFactory.getGeoObjectService();
    ServerGeoObjectIF parent = service.getGeoObjectByCode(parentCode, parentGeoObjectTypeCode, true);
    GraphType graphType = this.getGraphType(graphTypeCode);
    // ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanAddChild(ht.getOrganization().getCode(),
    // parent.getType(), child.getType());
    ServerGraphNode node = parent.getGraphChildren(graphType, recursive, date);
    return node.toJSON();
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) GraphType(net.geoprism.registry.model.GraphType) ServerGraphNode(net.geoprism.registry.model.ServerGraphNode) Request(com.runwaysdk.session.Request)

Example 15 with ServerGeoObjectService

use of net.geoprism.registry.geoobject.ServerGeoObjectService in project geoprism-registry by terraframe.

the class GraphService method removeChild.

@Request(RequestType.SESSION)
public void removeChild(String sessionId, String parentCode, String parentGeoObjectTypeCode, String childCode, String childGeoObjectTypeCode, String graphTypeCode, Date startDate, Date endDate) {
    ServerGeoObjectService service = ServiceFactory.getGeoObjectService();
    ServerGeoObjectIF parent = service.getGeoObjectByCode(parentCode, parentGeoObjectTypeCode, true);
    ServerGeoObjectIF child = service.getGeoObjectByCode(childCode, childGeoObjectTypeCode, true);
    GraphType graphType = this.getGraphType(graphTypeCode);
    // ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanAddChild(ht.getOrganization().getCode(),
    // parent.getType(), child.getType());
    parent.removeGraphChild(child, graphType, startDate, endDate);
}
Also used : ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) GraphType(net.geoprism.registry.model.GraphType) Request(com.runwaysdk.session.Request)

Aggregations

ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)33 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)23 Request (com.runwaysdk.session.Request)10 JsonObject (com.google.gson.JsonObject)8 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)7 AllowAllGeoObjectPermissionService (net.geoprism.registry.permission.AllowAllGeoObjectPermissionService)7 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)7 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)6 Date (java.util.Date)5 JsonArray (com.google.gson.JsonArray)4 Location (net.geoprism.registry.io.Location)4 GraphType (net.geoprism.registry.model.GraphType)4 ServerCodeRestriction (net.geoprism.registry.query.ServerCodeRestriction)4 ServerGeoObjectQuery (net.geoprism.registry.query.ServerGeoObjectQuery)4 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 ArrayList (java.util.ArrayList)3 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)3 ServerGraphNode (net.geoprism.registry.model.ServerGraphNode)3 Test (org.junit.Test)3 InputStream (java.io.InputStream)2