Class QueriesRestController

  • All Implemented Interfaces:
    QueriesRestOpenApi

    @RestController
    @RequestMapping("/v2.1.1/scripted-queries/")
    public class QueriesRestController
    extends Object
    implements QueriesRestOpenApi
    Queries Rest Controller.
    Author:
    Mauricio Ruiz Beltrán <mauricio.ruiz@kuwaiba.org>
    • Constructor Detail

      • QueriesRestController

        public QueriesRestController()
    • Method Detail

      • createScriptedQueriesPool

        @RequestMapping(method=POST,
                        value="createScriptedQueriesPool/{name}/{description}/{sessionId}",
                        produces="application/json")
        public String createScriptedQueriesPool​(@PathVariable("name")
                                                String name,
                                                @PathVariable("description")
                                                String description,
                                                @PathVariable("sessionId")
                                                String sessionId)
        Creates a scripted queries pool.
        Specified by:
        createScriptedQueriesPool in interface QueriesRestOpenApi
        Parameters:
        name - Scripted queries pool name.
        description - Scripted queries pool description.
        sessionId - The session token id.
        Returns:
        The scripted queries pool id.
      • updateScriptedQueriesPool

        @RequestMapping(method=PUT,
                        value="updateScriptedQueriesPool/{id}/{name}/{description}/{sessionId}",
                        produces="application/json")
        public void updateScriptedQueriesPool​(@PathVariable("id")
                                              String id,
                                              @PathVariable("name")
                                              String name,
                                              @PathVariable("description")
                                              String description,
                                              @PathVariable("sessionId")
                                              String sessionId)
        Updates a scripted queries pool.
        Specified by:
        updateScriptedQueriesPool in interface QueriesRestOpenApi
        Parameters:
        id - Scripted queries pool id.
        name - Scripted queries pool name.
        description - Scripted queries pool description.
        sessionId - The session token id.
      • deleteScriptedQueriesPool

        @RequestMapping(method=DELETE,
                        value="deleteScriptedQueriesPool/{id}/{sessionId}",
                        produces="application/json")
        public void deleteScriptedQueriesPool​(@PathVariable("id")
                                              String id,
                                              @PathVariable("sessionId")
                                              String sessionId)
        Deletes a scripted queries pool.
        Specified by:
        deleteScriptedQueriesPool in interface QueriesRestOpenApi
        Parameters:
        id - Scripted queries pool id.
        sessionId - The session token id.
      • getScriptedQueriesPoolByName

        @RequestMapping(method=GET,
                        value="getScriptedQueriesPoolByName/{name}/{sessionId}",
                        produces="application/json")
        public ScriptedQueriesPool getScriptedQueriesPoolByName​(@PathVariable("name")
                                                                String name,
                                                                @PathVariable("sessionId")
                                                                String sessionId)
        Gets a scripted queries pool given the name.
        Specified by:
        getScriptedQueriesPoolByName in interface QueriesRestOpenApi
        Parameters:
        name - Scripted queries pool name.
        sessionId - The session token id.
        Returns:
        A scripted queries pool.
      • getScriptedQueriesPool

        @RequestMapping(method=GET,
                        value="getScriptedQueriesPool/{id}/{sessionId}",
                        produces="application/json")
        public ScriptedQueriesPool getScriptedQueriesPool​(@PathVariable("id")
                                                          String id,
                                                          @PathVariable("sessionId")
                                                          String sessionId)
        Gets a scripted queries pool.
        Specified by:
        getScriptedQueriesPool in interface QueriesRestOpenApi
        Parameters:
        id - Scripted queries pool id.
        sessionId - The session token id.
        Returns:
        A scripted queries pool.
      • getScriptedQueriesPoolCount

        @RequestMapping(method=GET,
                        value="getScriptedQueriesPoolCount/{filterName}/{sessionId}",
                        produces="application/json")
        public int getScriptedQueriesPoolCount​(@PathVariable("filterName")
                                               String filterName,
                                               @PathVariable("sessionId")
                                               String sessionId)
        Counts the scripted queries pools.
        Specified by:
        getScriptedQueriesPoolCount in interface QueriesRestOpenApi
        Parameters:
        filterName - Scripted queries pool name to filter.
        sessionId - The session token id.
        Returns:
        The size of scripted queries pools.
      • getScriptedQueriesPools

        @RequestMapping(method=GET,
                        value="getScriptedQueriesPools/{filterName}/{skip}/{limit}/{sessionId}",
                        produces="application/json")
        public List<ScriptedQueriesPool> getScriptedQueriesPools​(@PathVariable("filterName")
                                                                 String filterName,
                                                                 @PathVariable("skip")
                                                                 int skip,
                                                                 @PathVariable("limit")
                                                                 int limit,
                                                                 @PathVariable("sessionId")
                                                                 String sessionId)
        Gets a set of scripted queries pools.
        Specified by:
        getScriptedQueriesPools in interface QueriesRestOpenApi
        Parameters:
        filterName - Filter by scripted queries pool name.
        skip - Result skip.
        limit - Result limit.
        sessionId - The session token id.
        Returns:
        A set of scripted queries pools.
      • getScriptedQueryCountByPoolId

        @RequestMapping(method=GET,
                        value="getScriptedQueryCountByPoolId/{id}/{filterName}/{ignoreDisabled}/{sessionId}",
                        produces="application/json")
        public int getScriptedQueryCountByPoolId​(@PathVariable("id")
                                                 String id,
                                                 @PathVariable("filterName")
                                                 String filterName,
                                                 @PathVariable("ignoreDisabled")
                                                 boolean ignoreDisabled,
                                                 @PathVariable("sessionId")
                                                 String sessionId)
        Counts the scripted queries filter by name in a scripted queries pool.
        Specified by:
        getScriptedQueryCountByPoolId in interface QueriesRestOpenApi
        Parameters:
        id - Scripted queries pool id.
        filterName - Filter by scripted query name.
        ignoreDisabled - True to ignore disabled scripted queries.
        sessionId - The session token id.
        Returns:
        The size of scripted queries.
      • getScriptedQueriesByPoolId

        @RequestMapping(method=GET,
                        value="getScriptedQueriesByPoolId/{id}/{filterName}/{ignoreDisabled}/{skip}/{limit}/{sessionId}",
                        produces="application/json")
        public List<ScriptedQuery> getScriptedQueriesByPoolId​(@PathVariable("id")
                                                              String id,
                                                              @PathVariable("filterName")
                                                              String filterName,
                                                              @PathVariable("ignoreDisabled")
                                                              boolean ignoreDisabled,
                                                              @PathVariable("skip")
                                                              int skip,
                                                              @PathVariable("limit")
                                                              int limit,
                                                              @PathVariable("sessionId")
                                                              String sessionId)
        Gets a set of scripted queries in a scripted queries pool the its id.
        Specified by:
        getScriptedQueriesByPoolId in interface QueriesRestOpenApi
        Parameters:
        id - Scripted queries pool id.
        filterName - Scripted query name filter.
        ignoreDisabled - True to return all scripted queries. False to return the enabled only.
        skip - Result skip.
        limit - Result limit.
        sessionId - The session token id.
        Returns:
        A set of scripted queries in a scripted queries pool.
      • getScriptedQueryCountByPoolName

        @RequestMapping(method=GET,
                        value="getScriptedQueryCountByPoolName/{name}/{filterName}/{sessionId}",
                        produces="application/json")
        public int getScriptedQueryCountByPoolName​(@PathVariable("name")
                                                   String name,
                                                   @PathVariable("filterName")
                                                   String filterName,
                                                   @PathVariable("sessionId")
                                                   String sessionId)
        Counts the scripted queries filter by name in a scripted queries pool.
        Specified by:
        getScriptedQueryCountByPoolName in interface QueriesRestOpenApi
        Parameters:
        name - Scripted queries pool name.
        filterName - Scripted query name to filter.
        sessionId - The session token id.
        Returns:
        The size of scripted queries.
      • getScriptedQueriesByPoolName

        @RequestMapping(method=GET,
                        value="getScriptedQueriesByPoolName/{name}/{filterName}/{ignoreDisabled}/{skip}/{limit}/{sessionId}",
                        produces="application/json")
        public List<ScriptedQuery> getScriptedQueriesByPoolName​(@PathVariable("name")
                                                                String name,
                                                                @PathVariable("filterName")
                                                                String filterName,
                                                                @PathVariable("ignoreDisabled")
                                                                boolean ignoreDisabled,
                                                                @PathVariable("skip")
                                                                int skip,
                                                                @PathVariable("limit")
                                                                int limit,
                                                                @PathVariable("sessionId")
                                                                String sessionId)
        Gets a set of scripted queries in a scripted queries pool the its name.
        Specified by:
        getScriptedQueriesByPoolName in interface QueriesRestOpenApi
        Parameters:
        name - Scripted queries pool name.
        filterName - Scripted query name filter.
        ignoreDisabled - True to return all scripted queries. False to return the enabled only.
        skip - Result skip.
        limit - Result limit.
        sessionId - The session token id.
        Returns:
        A set of scripted queries in a scripted queries pool.
      • createScriptedQuery

        @RequestMapping(method=POST,
                        value="createScriptedQuery/{id}/{name}/{description}/{script}/{enabled}/{sessionId}",
                        produces="application/json")
        public String createScriptedQuery​(@PathVariable("id")
                                          String id,
                                          @PathVariable("name")
                                          String name,
                                          @PathVariable("description")
                                          String description,
                                          @PathVariable("script")
                                          String script,
                                          @PathVariable("enabled")
                                          boolean enabled,
                                          @PathVariable("sessionId")
                                          String sessionId)
        Creates a scripted query.
        Specified by:
        createScriptedQuery in interface QueriesRestOpenApi
        Parameters:
        id - Scripted queries pool id.
        name - Scripted query name.
        description - Scripted query description.
        script - Scripted query script.
        enabled - True to enable the Scripted query.
        sessionId - The session token id.
        Returns:
        The scripted query id.
      • updateScriptedQuery

        @RequestMapping(method=PUT,
                        value="updateScriptedQuery/{id}/{name}/{description}/{script}/{enabled}/{sessionId}",
                        produces="application/json")
        public void updateScriptedQuery​(@PathVariable("id")
                                        String id,
                                        @PathVariable("name")
                                        String name,
                                        @PathVariable("description")
                                        String description,
                                        @PathVariable("script")
                                        String script,
                                        @PathVariable("enabled")
                                        boolean enabled,
                                        @PathVariable("sessionId")
                                        String sessionId)
        Updates a scripted query given its id.
        Specified by:
        updateScriptedQuery in interface QueriesRestOpenApi
        Parameters:
        id - The scripted query id.
        name - New scripting query name.
        description - New scripting query description.
        script - New query script.
        enabled - New value, true to enable the scripting query.
        sessionId - The session token id.
      • deleteScriptedQuery

        @RequestMapping(method=DELETE,
                        value="deleteScriptedQuery/{id}/{sessionId}",
                        produces="application/json")
        public void deleteScriptedQuery​(@PathVariable("id")
                                        String id,
                                        @PathVariable("sessionId")
                                        String sessionId)
        Deletes an scripted query given the id.
        Specified by:
        deleteScriptedQuery in interface QueriesRestOpenApi
        Parameters:
        id - The scripting query id.
        sessionId - The session token id.
      • getScriptedQuery

        @RequestMapping(method=GET,
                        value="getScriptedQuery/{id}/{sessionId}",
                        produces="application/json")
        public ScriptedQuery getScriptedQuery​(@PathVariable("id")
                                              String id,
                                              @PathVariable("sessionId")
                                              String sessionId)
        Gets a scripted query given its id.
        Specified by:
        getScriptedQuery in interface QueriesRestOpenApi
        Parameters:
        id - The scripted query id.
        sessionId - The session token id.
        Returns:
        A scripted query.
      • getScriptedQueryCount

        @RequestMapping(method=GET,
                        value="getScriptedQueryCount/{filterName}/{sessionId}",
                        produces="application/json")
        public int getScriptedQueryCount​(@PathVariable("filterName")
                                         String filterName,
                                         @PathVariable("sessionId")
                                         String sessionId)
        Counts the scripted queries.
        Specified by:
        getScriptedQueryCount in interface QueriesRestOpenApi
        Parameters:
        filterName - Scripted query name to filter.
        sessionId - The session token id.
        Returns:
        The size of scripted queries.
      • getScriptedQueries

        @RequestMapping(method=GET,
                        value="getScriptedQueries/{filterName}/{ignoreDisabled}/{skip}/{limit}/{sessionId}",
                        produces="application/json")
        public List<ScriptedQuery> getScriptedQueries​(@PathVariable("filterName")
                                                      String filterName,
                                                      @PathVariable("ignoreDisabled")
                                                      boolean ignoreDisabled,
                                                      @PathVariable("skip")
                                                      int skip,
                                                      @PathVariable("limit")
                                                      int limit,
                                                      @PathVariable("sessionId")
                                                      String sessionId)
        Gets a set of scripted queries.
        Specified by:
        getScriptedQueries in interface QueriesRestOpenApi
        Parameters:
        filterName - Scripted query name to filter.
        ignoreDisabled - True to return all scripted queries. False to return the enabled only.
        skip - Result skip.
        limit - Result limit.
        sessionId - The session token id.
        Returns:
        A set of scripted queries.
      • executeScriptedQuery

        @RequestMapping(method=PUT,
                        value="executeScriptedQuery/{id}/{sessionId}",
                        produces="application/json")
        public ScriptedQueryResult executeScriptedQuery​(@PathVariable("id")
                                                        String id,
                                                        @RequestBody
                                                        List<TransientScriptedQueryParameter> parameters,
                                                        @PathVariable("sessionId")
                                                        String sessionId)
        Executes the scripted query.
        Specified by:
        executeScriptedQuery in interface QueriesRestOpenApi
        Parameters:
        id - The scripted query class id.
        parameters - The scripted query parameters.
        sessionId - The session token id.
        Returns:
        The result of execute the scripted query.
      • createScriptedQueryParameter

        @RequestMapping(method=POST,
                        value="createScriptedQueryParameter/{id}/{name}/{description}/{type}/{mandatory}/{sessionId}",
                        produces="application/json")
        public String createScriptedQueryParameter​(@PathVariable("id")
                                                   String id,
                                                   @PathVariable("name")
                                                   String name,
                                                   @PathVariable("description")
                                                   String description,
                                                   @PathVariable("type")
                                                   String type,
                                                   @PathVariable("mandatory")
                                                   boolean mandatory,
                                                   @RequestBody
                                                   Object defaultValue,
                                                   @PathVariable("sessionId")
                                                   String sessionId)
        Creates a scripted query parameter.
        Specified by:
        createScriptedQueryParameter in interface QueriesRestOpenApi
        Parameters:
        id - The scripted query id.
        name - The scripted query parameter name.
        description - The scripted query parameter description.
        type - The scripted query parameter type.
        mandatory - True scripted query parameter is mandatory.
        defaultValue - The scripted query parameter default value.
        sessionId - The session token id.
        Returns:
        The scripted query parameter id.
      • updateScriptedQueryParameter

        @RequestMapping(method=PUT,
                        value="updateScriptedQueryParameter/{id}/{name}/{description}/{type}/{mandatory}/{sessionId}",
                        produces="application/json")
        public void updateScriptedQueryParameter​(@PathVariable("id")
                                                 String id,
                                                 @PathVariable("name")
                                                 String name,
                                                 @PathVariable("description")
                                                 String description,
                                                 @PathVariable("type")
                                                 String type,
                                                 @PathVariable("mandatory")
                                                 boolean mandatory,
                                                 @RequestBody
                                                 Object defaultValue,
                                                 @PathVariable("sessionId")
                                                 String sessionId)
        Updates a scripted query parameter.
        Specified by:
        updateScriptedQueryParameter in interface QueriesRestOpenApi
        Parameters:
        id - The scripted query parameter id.
        name - The scripted query parameter name.
        description - The scripted query parameter description.
        type - The scripted query parameter type.
        mandatory - True if the scripted query parameter is mandatory.
        defaultValue - The scripted query parameter default value.
        sessionId - The session token id.
      • deleteScriptedQueryParameter

        @RequestMapping(method=DELETE,
                        value="deleteScriptedQueryParameter/{id}/{sessionId}",
                        produces="application/json")
        public void deleteScriptedQueryParameter​(@PathVariable("id")
                                                 String id,
                                                 @PathVariable("sessionId")
                                                 String sessionId)
        Deletes a scripted query parameter.
        Specified by:
        deleteScriptedQueryParameter in interface QueriesRestOpenApi
        Parameters:
        id - The id of the scripted query parameter to delete.
        sessionId - The session token id.
      • getScriptedQueryParameter

        @RequestMapping(method=GET,
                        value="getScriptedQueryParameter/{id}/{sessionId}",
                        produces="application/json")
        public ScriptedQueryParameter getScriptedQueryParameter​(@PathVariable("id")
                                                                String id,
                                                                @PathVariable("sessionId")
                                                                String sessionId)
        Gets an scripted query parameter.
        Specified by:
        getScriptedQueryParameter in interface QueriesRestOpenApi
        Parameters:
        id - The scripted query parameter id.
        sessionId - The session token id.
        Returns:
        The scripted query parameter.
      • getScriptedQueryParameters

        @RequestMapping(method=GET,
                        value="getScriptedQueryParameters/{id}/{sessionId}",
                        produces="application/json")
        public List<ScriptedQueryParameter> getScriptedQueryParameters​(@PathVariable("id")
                                                                       String id,
                                                                       @PathVariable("sessionId")
                                                                       String sessionId)
        Gets the scripted query parameters.
        Specified by:
        getScriptedQueryParameters in interface QueriesRestOpenApi
        Parameters:
        id - The scripted query id.
        sessionId - The session token id.
        Returns:
        The scripted query parameters.
      • createQuery

        @RequestMapping(method=POST,
                        value="createQuery/{name}/{ownerId}/{structure}/{description}/{sessionId}",
                        produces="application/json")
        public long createQuery​(@PathVariable("name")
                                String name,
                                @PathVariable("ownerId")
                                long ownerId,
                                @PathVariable("structure")
                                String structure,
                                @PathVariable("description")
                                String description,
                                @PathVariable("sessionId")
                                String sessionId)
        Creates a Query.
        Specified by:
        createQuery in interface QueriesRestOpenApi
        Parameters:
        name - The name of the query.
        ownerId - The if of the user that will own the query. Use -1 to make it public.
        structure - The structure of the query as string Base64, from the XML document:
         
          <query version="" logicalconnector="" limit="">
              <class name="">
                  <visibleattributes>
                      <attribute name=""> </attribute>
                  </visibleattributes>
                  <filters>
                      <filter attribute="" condition=""> </filter>
                  </filters>
              </class>
          </query>
         
         
        description - The description of the query.
        sessionId - The session token id.
        Returns:
        The id of the newly created query.
      • saveQuery

        @RequestMapping(method=PUT,
                        value="saveQuery/{id}/{name}/{ownerId}/{structure}/{description}/{sessionId}",
                        produces="application/json")
        public ChangeDescriptor saveQuery​(@PathVariable("id")
                                          long id,
                                          @PathVariable("name")
                                          String name,
                                          @PathVariable("ownerId")
                                          long ownerId,
                                          @PathVariable("structure")
                                          String structure,
                                          @PathVariable("description")
                                          String description,
                                          @PathVariable("sessionId")
                                          String sessionId)
        Updates an existing query.
        Specified by:
        saveQuery in interface QueriesRestOpenApi
        Parameters:
        id - The id of the query.
        name - The name of the query. Leave null to keep the old value.
        ownerId - The id of the user that owns this query. Use -1 to keep the old value.
        structure - The structure of the query as string Base64, from an XML document
         
          <query version="" logicalconnector="" limit="">
              <class name="">
                  <visibleattributes>
                      <attribute name=""> </attribute>
                  </visibleattributes>
                  <filters>
                      <filter attribute="" condition=""> </filter>
                  </filters>
              </class>
          </query>
         
         
        description - The description of the query. Leave null to keep the old value.
        sessionId - The session token id.
        Returns:
        The summary of the changes.
      • deleteQuery

        @RequestMapping(method=DELETE,
                        value="deleteQuery/{id}/{sessionId}",
                        produces="application/json")
        public void deleteQuery​(@PathVariable("id")
                                long id,
                                @PathVariable("sessionId")
                                String sessionId)
        Deletes a Query.
        Specified by:
        deleteQuery in interface QueriesRestOpenApi
        Parameters:
        id - The id of the query.
        sessionId - The session token id.
      • getQueries

        @RequestMapping(method=GET,
                        value="getQueries/{showPublic}/{sessionId}",
                        produces="application/json")
        public List<CompactQuery> getQueries​(@PathVariable("showPublic")
                                             boolean showPublic,
                                             @PathVariable("sessionId")
                                             String sessionId)
        Gets all queries.
        Specified by:
        getQueries in interface QueriesRestOpenApi
        Parameters:
        showPublic - Include public queries or show only the private ones.
        sessionId - The session token id.
        Returns:
        The list of queries.
      • getQuery

        @RequestMapping(method=GET,
                        value="getQuery/{id}/{sessionId}",
                        produces="application/json")
        public CompactQuery getQuery​(@PathVariable("id")
                                     long id,
                                     @PathVariable("sessionId")
                                     String sessionId)
        Gets a single query.
        Specified by:
        getQuery in interface QueriesRestOpenApi
        Parameters:
        id - The id of the query.
        sessionId - The session token id.
        Returns:
        The query as an object.
      • executeQuery

        @RequestMapping(method=PUT,
                        value="executeQuery/{sessionId}",
                        produces="application/json")
        public List<ResultRecord> executeQuery​(@RequestBody
                                               ExtendedQuery query,
                                               @PathVariable("sessionId")
                                               String sessionId)
        Used to perform complex queries. Please note that the first record is reserved for the column headers, so and empty result set will have at least one record.
        Specified by:
        executeQuery in interface QueriesRestOpenApi
        Parameters:
        query - The code-friendly representation of the query made using the graphical query builder.
        sessionId - The session token id.
        Returns:
        A set of objects matching the specified criteria as ResultRecord array.