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();
}
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);
}
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));
}
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);
}
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;
}
Aggregations