Search in sources :

Example 46 with Request

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

the class ListTypeService method getPublishJobs.

@Request(RequestType.SESSION)
public JsonObject getPublishJobs(String sessionId, String oid, int pageSize, int pageNumber, String sortAttr, boolean isAscending) {
    QueryFactory qf = new QueryFactory();
    final ListTypeJobQuery query = new ListTypeJobQuery(qf);
    query.WHERE(query.getListType().EQ(oid));
    query.ORDER_BY_DESC(query.getCreateDate());
    // query.ORDER_BY(ihq.get(sortAttr), order);
    query.restrictRows(pageSize, pageNumber);
    try (OIterator<? extends ListTypeJob> it = query.getIterator()) {
        List<JsonSerializable> results = new LinkedList<>(it.getAll());
        return new Page<JsonSerializable>(query.getCount(), query.getPageNumber(), query.getPageSize(), results).toJSON();
    }
}
Also used : ListTypeJobQuery(net.geoprism.registry.etl.ListTypeJobQuery) QueryFactory(com.runwaysdk.query.QueryFactory) JsonSerializable(net.geoprism.registry.view.JsonSerializable) LinkedList(java.util.LinkedList) Request(com.runwaysdk.session.Request)

Example 47 with Request

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

the class ListTypeService method record.

@Request(RequestType.SESSION)
public JsonObject record(String sessionId, String oid, String uid) {
    ListTypeVersion version = ListTypeVersion.get(oid);
    if (version.getWorking()) {
        ListType type = version.getListType();
        if (type.doesActorHaveExploratoryPermission()) {
            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
            format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
            ServerGeoObjectType geoObjectType = type.getGeoObjectType();
            ServerGeoObjectIF geoObject = new ServerGeoObjectService().getGeoObject(uid, geoObjectType.getCode());
            JsonObject object = new JsonObject();
            object.addProperty("recordType", "GEO_OBJECT");
            object.add("type", geoObject.getType().toJSON(new DefaultSerializer()));
            object.addProperty("code", geoObject.getCode());
            object.addProperty(ListTypeVersion.FORDATE, format.format(version.getForDate()));
            // Add geometry so we can zoom to it
            object.add("geoObject", geoObject.toGeoObject(version.getForDate()).toJSON());
            return object;
        }
    }
    return version.record(uid);
}
Also used : DefaultSerializer(org.commongeoregistry.adapter.metadata.DefaultSerializer) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ListType(net.geoprism.registry.ListType) JsonObject(com.google.gson.JsonObject) ListTypeVersion(net.geoprism.registry.ListTypeVersion) SimpleDateFormat(java.text.SimpleDateFormat) Request(com.runwaysdk.session.Request)

Example 48 with Request

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

the class ListTypeService method apply.

@Request(RequestType.SESSION)
public JsonObject apply(String sessionId, JsonObject list) {
    ListType mList = ListType.apply(list);
    ((Session) Session.getCurrentSession()).reloadPermissions();
    // Auto publish the working versions of the lists
    List<ListTypeVersion> versions = mList.getVersions();
    for (ListTypeVersion version : versions) {
        if (version.getWorking()) {
            this.publishVersion(sessionId, version.getOid());
        }
    }
    return mList.toJSON();
}
Also used : ListType(net.geoprism.registry.ListType) ListTypeVersion(net.geoprism.registry.ListTypeVersion) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request)

Example 49 with Request

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

the class ListTypeService method createVersion.

@Request(RequestType.SESSION)
public JsonObject createVersion(String sessionId, String oid, String metadata) {
    ListTypeEntry entry = ListTypeEntry.get(oid);
    ListType listType = entry.getListType();
    if (!listType.isValid()) {
        throw new InvalidMasterListException();
    }
    this.enforceWritePermissions(listType);
    String version = entry.publish(metadata);
    ((Session) Session.getCurrentSession()).reloadPermissions();
    return JsonParser.parseString(version).getAsJsonObject();
// return entry.toJSON(false);
}
Also used : ListTypeEntry(net.geoprism.registry.ListTypeEntry) ListType(net.geoprism.registry.ListType) InvalidMasterListException(net.geoprism.registry.InvalidMasterListException) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request)

Example 50 with Request

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

the class ListTypeService method remove.

@Request(RequestType.SESSION)
public void remove(String sessionId, String oid) {
    try {
        ListType listType = ListType.get(oid);
        this.enforceWritePermissions(listType);
        listType.delete();
        ((Session) Session.getCurrentSession()).reloadPermissions();
    } catch (DataNotFoundException e) {
    // Do nothing
    }
}
Also used : DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) ListType(net.geoprism.registry.ListType) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request)

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