Class DataSourceController

java.lang.Object
io.micronaut.controlpanel.panels.datasource.DataSourceController

@Controller("/datasource-control-panel-controller") @ExecuteOn("blocking") @Internal public final class DataSourceController extends Object
REST controller to execute SQL queries against a specific DataSource for the Control Panel. Designed to work with jQuery DataTables in server-side mode.
Since:
2.0.0
Author:
Álvaro Sánchez-Mariscal
  • Constructor Details

    • DataSourceController

      public DataSourceController(io.micronaut.context.BeanLocator locator, io.micronaut.json.JsonMapper jsonMapper)
  • Method Details

    • schemaJs

      @Get(value="/{dataSource}/schema.js", produces="application/javascript") public io.micronaut.http.HttpResponse<String> schemaJs(String dataSource)

      Build CodeMirror SQLNamespace with normalized lowercase keys for matching.

      { "schema": { "table": { self: {label:"EMP", type:"table"}, children: [{label:"EMPNO", type:"column"}, ...] } } }
      
      Parameters:
      dataSource - The name of the datasource
      Returns:
      HttpResponse containing the generated schema.js JavaScript
    • query

      @Post(value="/{dataSource}/query", produces="application/json") public io.micronaut.http.HttpResponse<DataSourceController.QueryResponse> query(String dataSource, @Body DataSourceController.QueryRequest body)
      Execute a SQL query against the specified datasource.
      Parameters:
      dataSource - The name of the datasource (path parameter)
      body - The query request containing SQL and pagination parameters
      Returns:
      The query results as a HttpResponse containing DataSourceController.QueryResponse, or an error response if the query fails