Search in sources :

Example 6 with ServerGeoObjectStrategyIF

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

the class ServerGeoObjectService method getGeoObjectByCode.

public ServerGeoObjectIF getGeoObjectByCode(String code, ServerGeoObjectType type, boolean throwException) {
    this.permissionService.enforceCanRead(type.getOrganization().getCode(), type);
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    ServerGeoObjectIF geoObject = strategy.getGeoObjectByCode(code);
    if (geoObject == null && throwException) {
        DataNotFoundException ex = new DataNotFoundException();
        ex.setTypeLabel(GeoObjectMetadata.get().getClassDisplayLabel());
        ex.setDataIdentifier(code);
        ex.setAttributeLabel(GeoObjectMetadata.get().getAttributeDisplayLabel(DefaultAttribute.CODE.getName()));
        throw ex;
    }
    return geoObject;
}
Also used : DataNotFoundException(net.geoprism.registry.DataNotFoundException) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)

Example 7 with ServerGeoObjectStrategyIF

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

the class ServerGeoObjectService method build.

public ServerGeoObjectIF build(ServerGeoObjectType type, String runwayId) {
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    VertexObject vertex = VertexObject.get(type.getMdVertex(), runwayId);
    return strategy.constructFromDB(vertex);
}
Also used : VertexObject(com.runwaysdk.business.graph.VertexObject) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)

Example 8 with ServerGeoObjectStrategyIF

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

the class ServerGeoObjectService method apply.

@Transaction
public ServerGeoObjectIF apply(GeoObjectOverTime goTime, boolean isNew, boolean isImport) {
    ServerGeoObjectType type = ServerGeoObjectType.get(goTime.getType());
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    if (isNew) {
        permissionService.enforceCanCreate(type.getOrganization().getCode(), type);
    } else {
        permissionService.enforceCanWrite(type.getOrganization().getCode(), type);
    }
    ServerGeoObjectIF goServer = strategy.constructFromGeoObjectOverTime(goTime, isNew);
    if (!isNew) {
        goServer.lock();
    }
    goServer.populate(goTime);
    try {
        goServer.apply(isImport);
        // Return the refreshed copy of the geoObject
        return this.build(type, goServer.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 9 with ServerGeoObjectStrategyIF

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

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

the class ServerChildGraphNode method fromJSON.

public static ServerChildGraphNode 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();
    }
    ServerChildGraphNode node = new ServerChildGraphNode(goif, graphType, startDate, endDate, oid);
    if (jo.has(ChildTreeNode.JSON_CHILDREN)) {
        JsonArray jaChildren = jo.get(ChildTreeNode.JSON_CHILDREN).getAsJsonArray();
        for (int i = 0; i < jaChildren.size(); ++i) {
            node.addChild(ServerChildGraphNode.fromJSON(jaChildren.get(i).getAsJsonObject()));
        }
    }
    return node;
}
Also used : JsonArray(com.google.gson.JsonArray) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF) 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