Search in sources :

Example 1 with ColumnJsonWriter

use of org.activityinfo.store.query.output.ColumnJsonWriter in project activityinfo by bedatadriven.

the class FormResource method queryColumns.

@GET
@NoCache
@Path("query/columns")
@Produces(MediaType.APPLICATION_JSON)
public Response queryColumns(@Context UriInfo uriInfo) {
    final ColumnSet columnSet = query(uriInfo);
    final StreamingOutput output = outputStream -> {
        ColumnJsonWriter columnSetWriter = new ColumnJsonWriter(outputStream, Charsets.UTF_8);
        columnSetWriter.write(columnSet);
        columnSetWriter.flush();
    };
    return Response.ok(output).type(JSON_CONTENT_TYPE).build();
}
Also used : ColumnView(org.activityinfo.model.query.ColumnView) ColumnJsonWriter(org.activityinfo.store.query.output.ColumnJsonWriter) FormTreeBuilder(org.activityinfo.model.formTree.FormTreeBuilder) JsonFormTreeBuilder(org.activityinfo.model.formTree.JsonFormTreeBuilder) GeoAreaType(org.activityinfo.model.type.geo.GeoAreaType) ResourceId.valueOf(org.activityinfo.model.resource.ResourceId.valueOf) UserDatabaseMeta(org.activityinfo.model.database.UserDatabaseMeta) WKBReader(com.vividsolutions.jts.io.WKBReader) PermissionsEnforcer(org.activityinfo.store.query.server.PermissionsEnforcer) org.activityinfo.model.form(org.activityinfo.model.form) NotFoundException(com.sun.jersey.api.NotFoundException) Level(java.util.logging.Level) HashSet(java.util.HashSet) Operation(io.swagger.v3.oas.annotations.Operation) SQLException(java.sql.SQLException) ResourceId(org.activityinfo.model.resource.ResourceId) Optional(com.google.common.base.Optional) Geometry(com.vividsolutions.jts.geom.Geometry) RecordRef(org.activityinfo.model.type.RecordRef) JsonValue(org.activityinfo.json.JsonValue) FormTreePrettyPrinter(org.activityinfo.model.formTree.FormTreePrettyPrinter) VersionedFormStorage(org.activityinfo.store.spi.VersionedFormStorage) RecordLockSet(org.activityinfo.model.database.RecordLockSet) InvalidUpdateException(org.activityinfo.store.query.server.InvalidUpdateException) PrintWriter(java.io.PrintWriter) Charsets(com.google.common.base.Charsets) ParseException(com.vividsolutions.jts.io.ParseException) StringWriter(java.io.StringWriter) Set(java.util.Set) javax.ws.rs.core(javax.ws.rs.core) Logger(java.util.logging.Logger) String.format(java.lang.String.format) FormStorage(org.activityinfo.store.spi.FormStorage) RecordLock(org.activityinfo.model.database.RecordLock) List(java.util.List) javax.ws.rs(javax.ws.rs) ColumnSet(org.activityinfo.model.query.ColumnSet) QueryModel(org.activityinfo.model.query.QueryModel) Tag(io.swagger.v3.oas.annotations.tags.Tag) XlsFormBuilder(org.activityinfo.io.xlsform.XlsFormBuilder) AuthenticatedUser(org.activityinfo.legacy.shared.AuthenticatedUser) GeometryFactory(com.vividsolutions.jts.geom.GeometryFactory) InjectParam(com.sun.jersey.api.core.InjectParam) FormTree(org.activityinfo.model.formTree.FormTree) RowBasedJsonWriter(org.activityinfo.store.query.output.RowBasedJsonWriter) ColumnJsonWriter(org.activityinfo.store.query.output.ColumnJsonWriter) ColumnSet(org.activityinfo.model.query.ColumnSet)

Example 2 with ColumnJsonWriter

use of org.activityinfo.store.query.output.ColumnJsonWriter in project activityinfo by bedatadriven.

the class QueryResource method queryColumns.

@POST
@Path("columns")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Executes a query over a set of forms in columnar format")
public Response queryColumns(QueryModel model) {
    ColumnSetBuilder builder = backend.newQueryBuilder();
    final ColumnSet columnSet = builder.build(model);
    final StreamingOutput output = outputStream -> {
        ColumnJsonWriter columnSetWriter = new ColumnJsonWriter(outputStream, Charsets.UTF_8);
        columnSetWriter.write(columnSet);
        columnSetWriter.flush();
    };
    return Response.ok(output).type(MediaType.APPLICATION_JSON_TYPE).build();
}
Also used : ColumnSetBuilder(org.activityinfo.store.query.server.ColumnSetBuilder) Charsets(com.google.common.base.Charsets) ColumnJsonWriter(org.activityinfo.store.query.output.ColumnJsonWriter) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) Path(javax.ws.rs.Path) StreamingOutput(javax.ws.rs.core.StreamingOutput) Operation(io.swagger.v3.oas.annotations.Operation) MediaType(javax.ws.rs.core.MediaType) Consumes(javax.ws.rs.Consumes) Response(javax.ws.rs.core.Response) ColumnSet(org.activityinfo.model.query.ColumnSet) QueryModel(org.activityinfo.model.query.QueryModel) ColumnSetBuilder(org.activityinfo.store.query.server.ColumnSetBuilder) RowBasedJsonWriter(org.activityinfo.store.query.output.RowBasedJsonWriter) ColumnJsonWriter(org.activityinfo.store.query.output.ColumnJsonWriter) ColumnSet(org.activityinfo.model.query.ColumnSet) StreamingOutput(javax.ws.rs.core.StreamingOutput) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) Operation(io.swagger.v3.oas.annotations.Operation)

Aggregations

Charsets (com.google.common.base.Charsets)2 Operation (io.swagger.v3.oas.annotations.Operation)2 ColumnSet (org.activityinfo.model.query.ColumnSet)2 QueryModel (org.activityinfo.model.query.QueryModel)2 ColumnJsonWriter (org.activityinfo.store.query.output.ColumnJsonWriter)2 RowBasedJsonWriter (org.activityinfo.store.query.output.RowBasedJsonWriter)2 Optional (com.google.common.base.Optional)1 NotFoundException (com.sun.jersey.api.NotFoundException)1 InjectParam (com.sun.jersey.api.core.InjectParam)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 GeometryFactory (com.vividsolutions.jts.geom.GeometryFactory)1 ParseException (com.vividsolutions.jts.io.ParseException)1 WKBReader (com.vividsolutions.jts.io.WKBReader)1 Tag (io.swagger.v3.oas.annotations.tags.Tag)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 String.format (java.lang.String.format)1 SQLException (java.sql.SQLException)1 HashSet (java.util.HashSet)1 List (java.util.List)1