Search in sources :

Example 51 with RestBodyResponse

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

the class TransitionEventController method getHistoricalReport.

@Endpoint(method = ServletMethod.GET, error = ErrorSerialization.JSON, url = "historical-report")
public ResponseIF getHistoricalReport(ClientRequestIF request, @RequestParamter(name = "typeCode", required = true) String typeCode, @RequestParamter(name = "startDate") String startDate, @RequestParamter(name = "endDate") String endDate, @RequestParamter(name = "pageSize") Integer pageSize, @RequestParamter(name = "pageNumber") Integer pageNumber) throws ParseException {
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    Date sDate = startDate != null ? format.parse(startDate) : new Date();
    Date eDate = endDate != null ? format.parse(endDate) : new Date();
    return new RestBodyResponse(service.getHistoricalReport(request.getSessionId(), typeCode, sDate, eDate, pageSize, pageNumber));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 52 with RestBodyResponse

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

the class UndirectedGraphController method getChildren.

@Endpoint(url = "get-related-geo-objects", method = ServletMethod.GET, error = ErrorSerialization.JSON)
public ResponseIF getChildren(ClientRequestIF request, @RequestParamter(name = "sourceCode", required = true) String sourceCode, @RequestParamter(name = "sourceTypeCode", required = true) String sourceTypeCode, @RequestParamter(name = "undirectedRelationshipCode", required = true) String undirectedRelationshipCode, @RequestParamter(name = "recursive", required = true) Boolean recursive, @RequestParamter(name = "date", required = true) String sDate) {
    Date date = GeoRegistryUtil.parseDate(sDate, true);
    JsonObject response = this.service.getChildren(request.getSessionId(), sourceCode, sourceTypeCode, undirectedRelationshipCode, recursive, date);
    return new RestBodyResponse(response);
}
Also used : JsonObject(com.google.gson.JsonObject) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Date(java.util.Date) Endpoint(com.runwaysdk.mvc.Endpoint)

Example 53 with RestBodyResponse

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

the class AccountServiceControllerTest method queryUsers.

/**
 * Test returning possible roles that can be assigned to a person for a given
 * organization.
 */
@Test
public void queryUsers() {
    String rmDistrictRole = RegistryRole.Type.getRM_RoleName(moiOrg.getCode(), district.getCode());
    String rmVillageRole = RegistryRole.Type.getRM_RoleName(moiOrg.getCode(), village.getCode());
    String rcDistrictRole = RegistryRole.Type.getRC_RoleName(moiOrg.getCode(), district.getCode());
    String rcVillageRole = RegistryRole.Type.getRC_RoleName(moiOrg.getCode(), village.getCode());
    JSONObject johny = createUser("johny@gmail.com", rmDistrictRole + "," + rmVillageRole);
    JSONObject sally = createUser("sallyy@gmail.com", rcDistrictRole + "," + rcVillageRole);
    String rmHealthFacilityRole = RegistryRole.Type.getRM_RoleName(mohOrg.getCode(), healthFacility.getCode());
    String rcHealthFacilityRole = RegistryRole.Type.getRC_RoleName(mohOrg.getCode(), healthFacility.getCode());
    JSONObject franky = createUser("franky@gmail.com", rmHealthFacilityRole);
    JSONObject becky = createUser("beckyy@gmail.com", rcHealthFacilityRole);
    // try
    // {
    JSONArray orgCodeArray = new JSONArray();
    orgCodeArray.put(moiOrg.getCode());
    // orgCodeArray.put(mohOrg.getCode());
    // orgCodeArray.put("TEST1");
    // orgCodeArray.put("TEST2");
    RestBodyResponse response = (RestBodyResponse) controller.page(clientRequest, 1, 10);
// }
// finally
// {
// controller.remove(clientRequest, johny.getString(GeoprismUserDTO.OID));
// controller.remove(clientRequest, sally.getString(GeoprismUserDTO.OID));
// 
// controller.remove(clientRequest, franky.getString(GeoprismUserDTO.OID));
// controller.remove(clientRequest, becky.getString(GeoprismUserDTO.OID));
// }
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) RestBodyResponse(com.runwaysdk.mvc.RestBodyResponse) Test(org.junit.Test)

Aggregations

RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)53 Endpoint (com.runwaysdk.mvc.Endpoint)52 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)25 Date (java.util.Date)16 JsonObject (com.google.gson.JsonObject)14 HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)11 JsonArray (com.google.gson.JsonArray)10 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)8 JSONArray (org.json.JSONArray)7 JSONObject (org.json.JSONObject)7 SimpleDateFormat (java.text.SimpleDateFormat)5 InputStream (java.io.InputStream)4 GeoObjectOverTime (org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime)4 OrganizationDTO (org.commongeoregistry.adapter.metadata.OrganizationDTO)4 ImportStrategy (net.geoprism.registry.etl.upload.ImportConfiguration.ImportStrategy)3 ParentTreeNode (org.commongeoregistry.adapter.dataaccess.ParentTreeNode)3 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)3 PermissionContext (net.geoprism.registry.permission.PermissionContext)2 TreeNode (org.commongeoregistry.adapter.dataaccess.TreeNode)2 ValueObjectDTO (com.runwaysdk.business.ValueObjectDTO)1