Search in sources :

Example 1 with CreateSavedQueryBuilder

use of io.prestosql.queryeditorui.protocol.queries.CreateSavedQueryBuilder in project hetu-core by openlookeng.

the class QueryResource method saveQuery.

@POST
@Path("saved")
@Produces(MediaType.APPLICATION_JSON)
public Response saveQuery(@FormParam("description") String description, @FormParam("name") String name, @FormParam("query") String query, @Context HttpServletRequest servletRequest) throws IOException {
    String user = AccessControlUtil.getUser(accessControl, new HttpRequestSessionContext(servletRequest, groupProvider));
    CreateSavedQueryBuilder createFeaturedQueryRequest = CreateSavedQueryBuilder.notFeatured().description(description).name(name).query(query);
    if (user != null) {
        SavedQuery savedQuery = createFeaturedQueryRequest.user(user).build();
        if (queryStore.saveQuery((UserSavedQuery) savedQuery)) {
            return Response.ok(savedQuery.getUuid()).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    }
    return Response.status(Response.Status.UNAUTHORIZED).build();
}
Also used : HttpRequestSessionContext(io.prestosql.server.HttpRequestSessionContext) CreateSavedQueryBuilder(io.prestosql.queryeditorui.protocol.queries.CreateSavedQueryBuilder) UserSavedQuery(io.prestosql.queryeditorui.protocol.queries.UserSavedQuery) SavedQuery(io.prestosql.queryeditorui.protocol.queries.SavedQuery) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

CreateSavedQueryBuilder (io.prestosql.queryeditorui.protocol.queries.CreateSavedQueryBuilder)1 SavedQuery (io.prestosql.queryeditorui.protocol.queries.SavedQuery)1 UserSavedQuery (io.prestosql.queryeditorui.protocol.queries.UserSavedQuery)1 HttpRequestSessionContext (io.prestosql.server.HttpRequestSessionContext)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1