Class DefaultRESTIndexHandler

All Implemented Interfaces:
Handler, RouterNanoHTTPD.UriResponder
Direct Known Subclasses:
TasksRESTIndexHandler

public class DefaultRESTIndexHandler extends BaseHandler
Default JSON-REST handler for listing entities.
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
  • Constructor Details

    • DefaultRESTIndexHandler

      public DefaultRESTIndexHandler(String entity)
      New default index handler.
      Parameters:
      entity - entity
    • DefaultRESTIndexHandler

      public DefaultRESTIndexHandler(String entity, String msg)
      New default index handler.
      Parameters:
      msg - message
      entity - entity
  • Method Details

    • readData

      public HandlerResponse readData(BeetRootHTTPSession session, int id) throws Exception
      Description copied from class: BaseHandler
      Read data from DB that must be filled when the template is parsed. Used by index and view handlers.
      Overrides:
      readData in class BaseHandler
      Parameters:
      session - HTTP session
      id - db record id > 0 if a single record should be read otherwise < 0;
      Returns:
      response or null, null means success, response's status must be checked!
      Throws:
      Exception - exception
    • prepare

      public void prepare(BeetRootHTTPSession session, Entity entity)
      Prepare call to to something with the current entity bean processed in the list if necessary. Called before all extractSingleTableData(BeetRootHTTPSession, ResultSet, String, String, int, Entity) calls.
      Parameters:
      session - HTTP session
      entity - entity bean
    • extractSingleTableData

      public String extractSingleTableData(BeetRootHTTPSession session, ResultSet set, String columnName, String guiColumnName, int idx, Entity entity) throws Exception
      Extract one single table data field from result set standing at current row. NOTE: Never call "set.next()" !
      Parameters:
      session - HTTP session
      set - database result set pointing to current record
      columnName - column name as configured in 'web/<entity>/columns.cfg'
      guiColumnName - GUI column name as configured in 'web/<entity>/columns.cfg'
      idx - SQL result set column index
      entity - whole entity bean
      Returns:
      JSON data extract <td>...</td>
      Throws:
      Exception - exception
    • getPaginator

      public String getPaginator(BeetRootHTTPSession session)
      Get whole index paginator.
      Overrides:
      getPaginator in class BaseHandler
      Parameters:
      session - HTTP session
      Returns:
      HTML paginator code
    • getResource

      public String getResource()
      Description copied from class: BaseHandler
      Get web resource file as it lies on the file system relatively to the started server process.
      Specified by:
      getResource in interface Handler
      Specified by:
      getResource in class BaseHandler
      Returns:
      web resource
    • getBeanClass

      public Class<?> getBeanClass()
      Get bean entity class that has been generated trough PLANT, self-written or null (then null in extract calls too).
      Overrides:
      getBeanClass in class BaseHandler
      Returns:
      bean entity class
    • getMimeType

      public String getMimeType()
      Overrides:
      getMimeType in class BaseHandler