Search in sources :

Example 56 with Request

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

the class RegistryService method deleteAttributeType.

/**
 * Deletes an attribute from the given {@link GeoObjectType}.
 *
 * @pre given {@link GeoObjectType} must already exist.
 * @pre given {@link GeoObjectType} must already exist.
 *
 * @param sessionId
 * @param gtId
 *          string of the {@link GeoObjectType} to be updated.
 * @param attributeName
 *          Name of the attribute to be removed from the GeoObjectType
 * @return updated {@link GeoObjectType}
 */
@Request(RequestType.SESSION)
public void deleteAttributeType(String sessionId, String gtId, String attributeName) {
    ServerGeoObjectType got = ServerGeoObjectType.get(gtId);
    ServiceFactory.getGeoObjectTypePermissionService().enforceCanWrite(got.getOrganization().getCode(), got, got.getIsPrivate());
    got.removeAttribute(attributeName);
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 57 with Request

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

the class RegistryService method oauthGetAll.

@Request(RequestType.SESSION)
public String oauthGetAll(String sessionId, String id) {
    final JsonArray ja = new JsonArray();
    if (id == null || id.length() == 0) {
        OauthServer[] servers = OauthServer.getAll();
        for (OauthServer server : servers) {
            Gson gson2 = new GsonBuilder().registerTypeAdapter(OauthServer.class, new RunwayJsonAdapters.RunwayDeserializer()).create();
            JsonObject json = (JsonObject) gson2.toJsonTree(server);
            json.addProperty("url", buildOauthServerUrl(server));
            ja.add(json);
        }
    } else {
        OauthServer server = OauthServer.get(id);
        Gson gson2 = new GsonBuilder().registerTypeAdapter(OauthServer.class, new RunwayJsonAdapters.RunwayDeserializer()).create();
        JsonObject json = (JsonObject) gson2.toJsonTree(server);
        json.addProperty("url", buildOauthServerUrl(server));
        ja.add(json);
    }
    return ja.toString();
}
Also used : JsonArray(com.google.gson.JsonArray) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject) OauthServer(net.geoprism.account.OauthServer) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 58 with Request

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

the class RegistryService method getAncestors.

@Request(RequestType.SESSION)
public List<GeoObjectType> getAncestors(String sessionId, String code, String hierarchyCode, Boolean includeInheritedTypes, Boolean includeChild) {
    ServerGeoObjectType child = ServerGeoObjectType.get(code);
    ServerHierarchyType hierarchyType = ServerHierarchyType.get(hierarchyCode);
    List<GeoObjectType> ancestors = child.getTypeAncestors(hierarchyType, includeInheritedTypes);
    if (includeChild) {
        ancestors.add(child.getType());
    }
    return ancestors;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 59 with Request

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

the class RegistryService method oauthGetPublic.

@Request(RequestType.SESSION)
public String oauthGetPublic(String sessionId, String id) {
    final JsonArray ja = new JsonArray();
    if (id == null || id.length() == 0) {
        OauthServer[] servers = OauthServer.getAll();
        for (OauthServer server : servers) {
            if (!FhirExternalSystem.isFhirOauth(server)) {
                JsonObject json = new JsonObject();
                json.add("label", LocalizedValueConverter.convert(server.getDisplayLabel()).toJSON());
                json.addProperty("url", buildOauthServerUrl(server));
                ja.add(json);
            }
        }
    } else {
        OauthServer server = OauthServer.get(id);
        JsonObject json = new JsonObject();
        json.add("label", LocalizedValueConverter.convert(server.getDisplayLabel()).toJSON());
        json.addProperty("url", buildOauthServerUrl(server));
        ja.add(json);
    }
    return ja.toString();
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) OauthServer(net.geoprism.account.OauthServer) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 60 with Request

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

the class RegistryService method getGeoObjectByCode.

@Request(RequestType.SESSION)
public GeoObject getGeoObjectByCode(String sessionId, String code, String typeCode, Date date) {
    ServerGeoObjectIF object = service.getGeoObjectByCode(code, typeCode, true);
    ServiceFactory.getGeoObjectPermissionService().enforceCanRead(object.getType().getOrganization().getCode(), object.getType());
    return object.toGeoObject(date);
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

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