Search in sources :

Example 11 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class ServerGeoObjectService method doesGeoObjectExistAtRange.

@Request(RequestType.SESSION)
public JsonObject doesGeoObjectExistAtRange(String sessionId, Date startDate, Date endDate, String typeCode, String code) {
    VertexServerGeoObject vsgo = (VertexServerGeoObject) new ServerGeoObjectService().getGeoObjectByCode(code, typeCode);
    JsonObject jo = new JsonObject();
    jo.addProperty("exists", vsgo.existsAtRange(startDate, endDate));
    jo.addProperty("invalid", vsgo.getInvalid());
    return jo;
}
Also used : JsonObject(com.google.gson.JsonObject) VertexServerGeoObject(net.geoprism.registry.model.graph.VertexServerGeoObject) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 12 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class ServerGeoObjectService method getAll.

@Request(RequestType.SESSION)
public JsonObject getAll(String sessionId, String gotCode, String hierarchyCode, Date since, Boolean includeLevel, String format, String externalSystemId, Integer pageNumber, Integer pageSize) {
    GeoObjectExportFormat goef = null;
    if (format != null && format.length() > 0) {
        goef = GeoObjectExportFormat.valueOf(format);
    }
    GeoObjectJsonExporter exporter = new GeoObjectJsonExporter(gotCode, hierarchyCode, since, includeLevel, goef, externalSystemId, pageSize, pageNumber);
    try {
        return exporter.export();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : GeoObjectExportFormat(net.geoprism.registry.etl.export.GeoObjectExportFormat) GeoObjectJsonExporter(net.geoprism.registry.etl.export.GeoObjectJsonExporter) IOException(java.io.IOException) Request(com.runwaysdk.session.Request) ChangeRequest(net.geoprism.registry.action.ChangeRequest)

Example 13 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class HierarchyService method removeInheritedHierarchy.

/**
 * Modifies a hierarchy to remove inheritance from another hierarchy for the
 * given root
 *
 * @param sessionId
 * @param hierarchyTypeCode
 *          code of the {@link HierarchyType} being modified.
 * @param geoObjectTypeCode
 *          code of the root {@link GeoObjectType}.
 */
@Request(RequestType.SESSION)
public HierarchyType removeInheritedHierarchy(String sessionId, String hierarchyTypeCode, String geoObjectTypeCode) {
    ServerHierarchyType forHierarchy = ServerHierarchyType.get(hierarchyTypeCode);
    ServerGeoObjectType childType = ServerGeoObjectType.get(geoObjectTypeCode);
    ServiceFactory.getGeoObjectTypeRelationshipPermissionService().enforceCanAddChild(forHierarchy, null, childType);
    ServerGeoObjectType type = ServerGeoObjectType.get(geoObjectTypeCode);
    type.removeInheritedHierarchy(forHierarchy);
    forHierarchy.refresh();
    return forHierarchy.toHierarchyType();
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request)

Example 14 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class HierarchyService method getHierarchyGroupedTypes.

@Request(RequestType.SESSION)
public JsonArray getHierarchyGroupedTypes(String sessionId) {
    final HierarchyTypePermissionServiceIF hierarchyPermissions = ServiceFactory.getHierarchyPermissionService();
    final GeoObjectTypePermissionServiceIF typePermissions = ServiceFactory.getGeoObjectTypePermissionService();
    final RolePermissionService rps = ServiceFactory.getRolePermissionService();
    final boolean isSRA = rps.isSRA();
    JsonArray allHiers = new JsonArray();
    List<ServerHierarchyType> shts = ServiceFactory.getMetadataCache().getAllHierarchyTypes();
    for (ServerHierarchyType sht : shts) {
        final String htOrgCode = sht.getOrganizationCode();
        if (hierarchyPermissions.canRead(htOrgCode) && (isSRA || rps.isRA(htOrgCode) || rps.isRM(htOrgCode))) {
            JsonObject hierView = new JsonObject();
            hierView.addProperty("code", sht.getCode());
            hierView.addProperty("label", sht.getDisplayLabel().getValue());
            hierView.addProperty("orgCode", sht.getOrganizationCode());
            JsonArray allHierTypes = new JsonArray();
            List<ServerGeoObjectType> types = sht.getAllTypes();
            for (ServerGeoObjectType type : types) {
                final String gotOrgCode = type.getOrganizationCode();
                if (typePermissions.canRead(gotOrgCode, type, type.getIsPrivate()) && (isSRA || rps.isRA(gotOrgCode) || rps.isRM(gotOrgCode, type))) {
                    if (type.getIsAbstract()) {
                        JsonObject superView = new JsonObject();
                        superView.addProperty("code", type.getCode());
                        superView.addProperty("label", type.getLabel().getValue());
                        superView.addProperty("orgCode", type.getOrganizationCode());
                        superView.addProperty("isAbstract", true);
                        List<ServerGeoObjectType> subtypes = type.getSubtypes();
                        for (ServerGeoObjectType subtype : subtypes) {
                            JsonObject typeView = new JsonObject();
                            typeView.addProperty("code", subtype.getCode());
                            typeView.addProperty("label", subtype.getLabel().getValue());
                            typeView.addProperty("orgCode", subtype.getOrganization().getCode());
                            typeView.add("super", superView);
                            allHierTypes.add(typeView);
                        }
                    } else {
                        JsonObject typeView = new JsonObject();
                        typeView.addProperty("code", type.getCode());
                        typeView.addProperty("label", type.getLabel().getValue());
                        typeView.addProperty("orgCode", type.getOrganizationCode());
                        allHierTypes.add(typeView);
                    }
                }
            }
            hierView.add("types", allHierTypes);
            allHiers.add(hierView);
        }
    }
    return allHiers;
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) JsonArray(com.google.gson.JsonArray) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyTypePermissionServiceIF(net.geoprism.registry.permission.HierarchyTypePermissionServiceIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) GeoObjectTypePermissionServiceIF(net.geoprism.registry.permission.GeoObjectTypePermissionServiceIF) Request(com.runwaysdk.session.Request)

Example 15 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class HierarchyService method updateHierarchyType.

/**
 * Updates the given {@link HierarchyType} represented as JSON.
 *
 * @param sessionId
 * @param gtJSON
 *          JSON of the {@link HierarchyType} to be updated.
 */
@Request(RequestType.SESSION)
public HierarchyType updateHierarchyType(String sessionId, String htJSON) {
    HierarchyType hierarchyType = HierarchyType.fromJSON(htJSON, ServiceFactory.getAdapter());
    ServerHierarchyType type = ServerHierarchyType.get(hierarchyType);
    ServiceFactory.getHierarchyPermissionService().enforceCanWrite(type.getOrganization().getCode());
    type.update(hierarchyType);
    return type.toHierarchyType();
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) Request(com.runwaysdk.session.Request)

Aggregations

Request (com.runwaysdk.session.Request)340 Test (org.junit.Test)145 JsonObject (com.google.gson.JsonObject)85 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)73 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)73 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)53 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)40 JsonArray (com.google.gson.JsonArray)36 Date (java.util.Date)33 ChangeRequest (net.geoprism.registry.action.ChangeRequest)32 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)31 QueryFactory (com.runwaysdk.query.QueryFactory)30 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)26 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)22 ListType (net.geoprism.registry.ListType)21 SimpleDateFormat (java.text.SimpleDateFormat)19 Classification (net.geoprism.registry.model.Classification)19 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)19 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)17 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)17