Search in sources :

Example 61 with Endpoint

use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.

the class RegistryController method addToHierarchy.

/**
 * Adds the {@link GeoObjectType} with the given child code to the parent
 * {@link GeoObjectType} with the given code for the given
 * {@link HierarchyType} code.
 *
 * @param sessionId
 * @param hierarchyCode
 *          code of the {@link HierarchyType} the child is being added to.
 * @param parentGeoObjectTypeCode
 *          parent {@link GeoObjectType}.
 * @param childGeoObjectTypeCode
 *          child {@link GeoObjectType}.
 */
@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON, url = RegistryUrls.HIERARCHY_TYPE_ADD)
public ResponseIF addToHierarchy(ClientRequestIF request, @RequestParamter(name = "hierarchyCode", required = true) String hierarchyCode, @RequestParamter(name = "parentGeoObjectTypeCode", required = true) String parentGeoObjectTypeCode, @RequestParamter(name = "childGeoObjectTypeCode", required = true) String childGeoObjectTypeCode) {
    HierarchyType ht = ServiceFactory.getHierarchyService().addToHierarchy(request.getSessionId(), hierarchyCode, parentGeoObjectTypeCode, childGeoObjectTypeCode);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    return new RestBodyResponse(ht.toJSON(serializer));
}
Also used : HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 62 with Endpoint

use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.

the class RegistryController method getHierarchyTypes.

/**
 * Returns an array of {@link HierarchyType} that define the given list of
 * types. If no types are provided then all will be returned.
 *
 * @param types
 *          A serialized json array of HierarchyType codes that will be
 *          retrieved.
 */
@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = RegistryUrls.HIERARCHY_TYPE_GET_ALL)
public ResponseIF getHierarchyTypes(ClientRequestIF request, @RequestParamter(name = "types") String types, @RequestParamter(name = "context") String context) {
    String[] aTypes = null;
    if (types != null) {
        JSONArray jaTypes = new JSONArray(types);
        aTypes = new String[jaTypes.length()];
        for (int i = 0; i < jaTypes.length(); i++) {
            aTypes[i] = jaTypes.getString(i);
        }
    }
    PermissionContext pContext = PermissionContext.get(context);
    HierarchyType[] hts = ServiceFactory.getHierarchyService().getHierarchyTypes(request.getSessionId(), aTypes, pContext);
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    JsonArray jarray = new JsonArray();
    for (int i = 0; i < hts.length; ++i) {
        jarray.add(hts[i].toJSON(serializer));
    }
    return new RestBodyResponse(jarray);
}
Also used : JsonArray(com.google.gson.JsonArray) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) JSONArray(org.json.JSONArray) PermissionContext(net.geoprism.registry.permission.PermissionContext) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 63 with Endpoint

use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.

the class RegistryController method search.

@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = "geoobject/search")
public ResponseIF search(ClientRequestIF request, @RequestParamter(name = RegistryUrls.GEO_OBJECT_GET_PARAM_TYPE_CODE, required = true) String typeCode, @RequestParamter(name = "text", required = true) String text, @RequestParamter(name = "date", required = true) String date) throws JSONException, ParseException {
    List<GeoObject> results = this.registryService.search(request.getSessionId(), typeCode, text, GeoRegistryUtil.parseDate(date, true));
    CustomSerializer serializer = this.registryService.serializer(request.getSessionId());
    JsonArray response = new JsonArray();
    for (GeoObject result : results) {
        response.add(result.toJSON(serializer));
    }
    return new RestBodyResponse(response);
}
Also used : JsonArray(com.google.gson.JsonArray) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) CustomSerializer(org.commongeoregistry.adapter.metadata.CustomSerializer) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 64 with Endpoint

use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.

the class RegistrySessionController method login.

@Endpoint(method = ServletMethod.POST, error = ErrorSerialization.JSON)
public ResponseIF login(ServletRequestIF req, @RequestParamter(name = "username", required = true) String username, @RequestParamter(name = "password", required = true) String password) throws JSONException {
    if (username != null) {
        username = username.trim();
    }
    Locale[] locales = this.getLocales(req);
    // Locale sessionLocale = req.getLocale();
    // 
    // JSONArray installedLocalesArr = new JSONArray();
    // Collection<Locale> installedLocales = LocalizationFacade.getInstalledLocales();
    // for (Locale loc : installedLocales)
    // {
    // JSONObject locObj = new JSONObject();
    // locObj.put("language", loc.getDisplayLanguage(sessionLocale));
    // locObj.put("country", loc.getDisplayCountry(sessionLocale));
    // locObj.put("name", loc.getDisplayName(sessionLocale));
    // locObj.put("variant", loc.getDisplayVariant(sessionLocale));
    // 
    // installedLocalesArr.put(locObj);
    // }
    ClientRequestIF clientRequest = loginWithLocales(req, username, password, locales);
    JSONArray jaLocales = new JSONArray(ServiceFactory.getRegistryService().getLocales(clientRequest.getSessionId()).toString());
    JsonArray roles = JsonParser.parseString(RoleViewDTO.getCurrentRoles(clientRequest)).getAsJsonArray();
    JsonArray roleDisplayLabels = JsonParser.parseString(RoleViewDTO.getCurrentRoleDisplayLabels(clientRequest)).getAsJsonArray();
    JsonObject cookieValue = new JsonObject();
    cookieValue.addProperty("loggedIn", clientRequest.isLoggedIn());
    cookieValue.add("roles", roles);
    cookieValue.add("roleDisplayLabels", roleDisplayLabels);
    cookieValue.addProperty("userName", username);
    cookieValue.addProperty("version", ClientConfigurationService.getServerVersion());
    CookieResponse response = new CookieResponse("user", -1, cookieValue.toString());
    response.set("installedLocales", jaLocales);
    return response;
}
Also used : Locale(java.util.Locale) JsonArray(com.google.gson.JsonArray) JSONArray(org.json.JSONArray) JsonObject(com.google.gson.JsonObject) CookieResponse(com.runwaysdk.mvc.CookieResponse) ClientRequestIF(com.runwaysdk.constants.ClientRequestIF) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 65 with Endpoint

use of com.runwaysdk.mvc.Endpoint in project geoprism-registry by terraframe.

the class TermController method getClassifierSuggestions.

@Endpoint(error = ErrorSerialization.JSON)
public ResponseIF getClassifierSuggestions(ClientRequestIF request, @RequestParamter(name = "mdAttributeId", required = true) String mdAttributeId, @RequestParamter(name = "text") String text, @RequestParamter(name = "limit") Integer limit) throws JSONException {
    JSONArray response = new JSONArray();
    ValueQueryDTO query = ClassifierDTO.getClassifierSuggestions(request, mdAttributeId, text, limit);
    List<ValueObjectDTO> results = query.getResultSet();
    for (ValueObjectDTO result : results) {
        JSONObject object = new JSONObject();
        object.put("label", result.getValue(ClassifierDTO.DISPLAYLABEL));
        object.put("value", result.getValue(ClassifierDTO.OID));
        response.put(object);
    }
    return new RestBodyResponse(response);
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) ValueQueryDTO(com.runwaysdk.business.ValueQueryDTO) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) ValueObjectDTO(com.runwaysdk.business.ValueObjectDTO) Endpoint(com.runwaysdk.mvc.Endpoint)

Aggregations

Endpoint (com.runwaysdk.mvc.Endpoint)68 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)52 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)25 Date (java.util.Date)21 JsonObject (com.google.gson.JsonObject)19 JsonArray (com.google.gson.JsonArray)16 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)11 JSONArray (org.json.JSONArray)11 JSONObject (org.json.JSONObject)11 RestResponse (com.runwaysdk.mvc.RestResponse)8 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)8 SimpleDateFormat (java.text.SimpleDateFormat)6 InputStreamResponse (com.runwaysdk.mvc.InputStreamResponse)5 InputStream (java.io.InputStream)5 RegistryRole (org.commongeoregistry.adapter.metadata.RegistryRole)5 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)4 Locale (java.util.Locale)3 ImportStrategy (net.geoprism.registry.etl.upload.ImportConfiguration.ImportStrategy)3 ParentTreeNode (org.commongeoregistry.adapter.dataaccess.ParentTreeNode)3