Search in sources :

Example 1 with ServerGeoObjectStrategyIF

use of net.geoprism.registry.conversion.ServerGeoObjectStrategyIF in project geoprism-registry by terraframe.

the class ServerGeoObjectService method getGeoObject.

public ServerGeoObjectIF getGeoObject(String uid, String typeCode) {
    ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
    this.permissionService.enforceCanRead(type.getOrganization().getCode(), type);
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    ServerGeoObjectIF object = strategy.getGeoObjectByUid(uid);
    if (object == null) {
        InvalidRegistryIdException ex = new InvalidRegistryIdException();
        ex.setRegistryId(uid);
        throw ex;
    }
    return object;
}
Also used : InvalidRegistryIdException(net.geoprism.registry.InvalidRegistryIdException) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)

Example 2 with ServerGeoObjectStrategyIF

use of net.geoprism.registry.conversion.ServerGeoObjectStrategyIF in project geoprism-registry by terraframe.

the class ServerGeoObjectService method apply.

@Transaction
public ServerGeoObjectIF apply(GeoObject object, Date startDate, Date endDate, boolean isNew, boolean isImport) {
    ServerGeoObjectType type = ServerGeoObjectType.get(object.getType());
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    if (isNew) {
        permissionService.enforceCanCreate(type.getOrganization().getCode(), type);
    } else {
        permissionService.enforceCanWrite(type.getOrganization().getCode(), type);
    }
    ServerGeoObjectIF geoObject = strategy.constructFromGeoObject(object, isNew);
    geoObject.setDate(startDate);
    if (!isNew) {
        geoObject.lock();
    }
    geoObject.populate(object, startDate, endDate);
    try {
        geoObject.apply(isImport);
        // Return the refreshed copy of the geoObject
        return this.build(type, geoObject.getRunwayId());
    } catch (DuplicateDataException e) {
        VertexServerGeoObject.handleDuplicateDataException(type, e);
        throw e;
    }
}
Also used : DuplicateDataException(com.runwaysdk.dataaccess.DuplicateDataException) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 3 with ServerGeoObjectStrategyIF

use of net.geoprism.registry.conversion.ServerGeoObjectStrategyIF in project geoprism-registry by terraframe.

the class ServerGeoObjectService method getGeoObject.

public ServerGeoObjectIF getGeoObject(GeoObject go) {
    ServerGeoObjectType type = ServerGeoObjectType.get(go.getType());
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    return strategy.constructFromGeoObject(go, false);
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)

Example 4 with ServerGeoObjectStrategyIF

use of net.geoprism.registry.conversion.ServerGeoObjectStrategyIF in project geoprism-registry by terraframe.

the class ServerGeoObjectService method getGeoObject.

public ServerGeoObjectIF getGeoObject(GeoObjectOverTime timeGO) {
    ServerGeoObjectType type = ServerGeoObjectType.get(timeGO.getType());
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    return strategy.constructFromGeoObjectOverTime(timeGO, false);
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)

Example 5 with ServerGeoObjectStrategyIF

use of net.geoprism.registry.conversion.ServerGeoObjectStrategyIF 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)

Aggregations

ServerGeoObjectStrategyIF (net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)10 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)6 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)5 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)3 JsonArray (com.google.gson.JsonArray)2 DuplicateDataException (com.runwaysdk.dataaccess.DuplicateDataException)2 Date (java.util.Date)2 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)2 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)2 VertexObject (com.runwaysdk.business.graph.VertexObject)1 DataNotFoundException (net.geoprism.registry.DataNotFoundException)1 InvalidRegistryIdException (net.geoprism.registry.InvalidRegistryIdException)1 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)1 ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)1 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)1