Search in sources :

Example 51 with Request

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

the class ListTypeService method data.

@Request(RequestType.SESSION)
public JsonObject data(String sessionId, String oid, String criteria, Boolean showInvalid, Boolean includeGeometries) {
    ListTypeVersion version = ListTypeVersion.get(oid);
    Page<JsonSerializable> page = version.data(JsonParser.parseString(criteria).getAsJsonObject(), showInvalid, includeGeometries);
    return page.toJSON();
}
Also used : JsonSerializable(net.geoprism.registry.view.JsonSerializable) ListTypeVersion(net.geoprism.registry.ListTypeVersion) Request(com.runwaysdk.session.Request)

Example 52 with Request

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

the class RegistryService method updateGeoObject.

@Request(RequestType.SESSION)
public GeoObject updateGeoObject(String sessionId, String jGeoObj, Date startDate, Date endDate) {
    GeoObject geoObject = GeoObject.fromJSON(adapter, jGeoObj);
    ServerGeoObjectIF object = service.apply(geoObject, startDate, endDate, false, false);
    return object.toGeoObject(startDate);
}
Also used : ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 53 with Request

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

the class RegistryService method importTypes.

/**
 * Creates a {@link GeoObjectType} from the given JSON.
 *
 * @param sessionId
 * @param gtJSON
 *          JSON of the {@link GeoObjectType} to be created.
 * @return newly created {@link GeoObjectType}
 */
@Request(RequestType.SESSION)
public void importTypes(String sessionId, String orgCode, InputStream istream) {
    ServiceFactory.getGeoObjectTypePermissionService().enforceCanCreate(orgCode, true);
    GeoRegistryUtil.importTypes(orgCode, istream);
    this.refreshMetadataCache();
    NotificationFacade.queue(new GlobalNotificationMessage(MessageType.TYPE_CACHE_CHANGE, null));
}
Also used : GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 54 with Request

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

the class RegistryService method deleteOrganization.

/**
 * Deletes the {@link OrganizationDTO} with the given code.
 *
 * @param sessionId
 * @param code
 *          code of the {@link OrganizationDTO} to delete.
 */
@Request(RequestType.SESSION)
public void deleteOrganization(String sessionId, String code) {
    Organization organization = Organization.getByKey(code);
    ServiceFactory.getOrganizationPermissionService().enforceActorCanDelete();
    organization.delete();
    // If this did not error out then remove from the cache
    ServiceFactory.getMetadataCache().removeOrganization(code);
}
Also used : Organization(net.geoprism.registry.Organization) Request(com.runwaysdk.session.Request) OAuthClientRequest(org.apache.oltu.oauth2.client.request.OAuthClientRequest)

Example 55 with Request

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

the class RegistryService method getGeoObjectSuggestions.

/*
   * 
   * select $filteredLabel,* from province0 let $dateLabel =
   * first(displayLabel_cot[(date('2020-05-01', 'yyyy-MM-dd') BETWEEN startDate
   * AND endDate) AND (date('2020-05-01', 'yyyy-MM-dd') BETWEEN startDate AND
   * endDate)]), $filteredLabel = COALESCE($dateLabel.value.defaultLocale) where
   * ( displayLabel_cot CONTAINS ( (date('2020-05-01', 'yyyy-MM-dd') BETWEEN
   * startDate AND endDate) AND (date('2020-05-01', 'yyyy-MM-dd') BETWEEN
   * startDate AND endDate) AND COALESCE(value.defaultLocale).toLowerCase() LIKE
   * '%' + 'a' + '%' ) OR code.toLowerCase() LIKE '%' + 'a' + '%' ) AND
   * invalid=false AND ( exists_cot CONTAINS ( (date('2020-05-01', 'yyyy-MM-dd')
   * BETWEEN startDate AND endDate) AND (date('2020-05-01', 'yyyy-MM-dd')
   * BETWEEN startDate AND endDate) AND value=true ) ) ORDER BY $filteredLabel
   * ASC LIMIT 10
   */
@Request(RequestType.SESSION)
public JsonArray getGeoObjectSuggestions(String sessionId, String text, String typeCode, String parentCode, String parentTypeCode, String hierarchyCode, Date startDate, Date endDate) {
    final ServerGeoObjectType type = ServerGeoObjectType.get(typeCode);
    ServerHierarchyType ht = hierarchyCode != null ? ServerHierarchyType.get(hierarchyCode) : null;
    final ServerGeoObjectType parentType = ServerGeoObjectType.get(parentTypeCode);
    List<String> conditions = new ArrayList<String>();
    StringBuilder statement = new StringBuilder();
    statement.append("select $filteredLabel,@class as clazz,* from " + type.getMdVertex().getDBClassName() + " ");
    statement.append("let $dateLabel = first(displayLabel_cot");
    if (startDate != null && endDate != null) {
        statement.append("[(:startDate BETWEEN startDate AND endDate) AND (:endDate BETWEEN startDate AND endDate)]");
    }
    statement.append("), ");
    statement.append("$filteredLabel = " + AbstractVertexRestriction.localize("$dateLabel.value") + " ");
    statement.append("where ");
    // Must be a child of parent type
    if (parentTypeCode != null && parentTypeCode.length() > 0) {
        StringBuilder parentCondition = new StringBuilder();
        parentCondition.append("(@rid in ( TRAVERSE outE('" + ht.getMdEdge().getDBClassName() + "')");
        if (startDate != null && endDate != null) {
            parentCondition.append("[(:startDate BETWEEN startDate AND endDate) AND (:endDate BETWEEN startDate AND endDate)]");
        }
        parentCondition.append(".inV() FROM (select from " + parentType.getMdVertex().getDBClassName() + " where code='" + parentCode + "') )) ");
        conditions.add(parentCondition.toString());
    }
    // Must have display label we expect
    if (text != null && text.length() > 0) {
        StringBuilder textCondition = new StringBuilder();
        textCondition.append("(displayLabel_cot CONTAINS (");
        if (startDate != null && endDate != null) {
            textCondition.append("  (:startDate BETWEEN startDate AND endDate) AND (:endDate BETWEEN startDate AND endDate) AND ");
        }
        textCondition.append(AbstractVertexRestriction.localize("value") + ".toLowerCase() LIKE '%' + :text + '%'");
        textCondition.append(")");
        textCondition.append(" OR code.toLowerCase() LIKE '%' + :text + '%')");
        conditions.add(textCondition.toString());
    }
    // Must not be invalid
    conditions.add("invalid=false");
    // Must exist at date
    {
        StringBuilder existCondition = new StringBuilder();
        existCondition.append("(exists_cot CONTAINS (");
        if (startDate != null && endDate != null) {
            existCondition.append("  (:startDate BETWEEN startDate AND endDate) AND (:endDate BETWEEN startDate AND endDate) AND ");
        }
        existCondition.append("value=true");
        existCondition.append("))");
        conditions.add(existCondition.toString());
    }
    statement.append(StringUtils.join(conditions, " AND "));
    statement.append(" ORDER BY $filteredLabel ASC LIMIT 10");
    GraphQuery<VertexObject> query = new GraphQuery<VertexObject>(statement.toString());
    if (startDate != null && endDate != null) {
        query.setParameter("startDate", startDate);
        query.setParameter("endDate", endDate);
    }
    if (text != null) {
        query.setParameter("text", text.toLowerCase().trim());
    } else {
        query.setParameter("text", text);
    }
    @SuppressWarnings("unchecked") List<HashMap<String, Object>> results = (List<HashMap<String, Object>>) ((Object) query.getResults());
    JsonArray array = new JsonArray();
    for (HashMap<String, Object> row : results) {
        ServerGeoObjectType rowType = ServerGeoObjectType.get((MdVertexDAOIF) MdGraphClassDAO.getMdGraphClassByTableName((String) row.get("clazz")));
        if (ServiceFactory.getGeoObjectPermissionService().canRead(rowType.getOrganization().getCode(), rowType)) {
            JsonObject result = new JsonObject();
            result.addProperty("id", (String) row.get("oid"));
            result.addProperty("name", (String) row.get("$filteredLabel"));
            result.addProperty(GeoObject.CODE, (String) row.get("code"));
            result.addProperty(GeoObject.UID, (String) row.get("uuid"));
            result.addProperty("typeCode", rowType.getCode());
            array.add(result);
        }
    }
    return array;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) VertexObject(com.runwaysdk.business.graph.VertexObject) HashMap(java.util.HashMap) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) JsonArray(com.google.gson.JsonArray) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) JsonObject(com.google.gson.JsonObject) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject) JSONObject(org.json.JSONObject) VertexObject(com.runwaysdk.business.graph.VertexObject) GraphQuery(com.runwaysdk.business.graph.GraphQuery) 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