Interface Executor

    • Method Detail

      • getName

        String getName()
        Return the name of the Executor
        Returns:
        String The Executor name
      • getPriority

        int getPriority()
        Return the Executor priority
        Returns:
        int The Executor priority
      • validate

        ValidationErrors validate​(ChangeSet changeSet)
        Validate if the changeset can be executed by this Executor If the ChangeSet can be executed return an empty ValidationErrors object otherwise return the errors
        Parameters:
        changeSet - The changeset to validate
        Returns:
        ValidationErrors Any errors which occur during validation
      • modifyChangeSet

        void modifyChangeSet​(ChangeSet changeSet)
        Allow this Executor to make any needed changes to the changeset
        Parameters:
        changeSet - The changeset to operate on
      • setResourceAccessor

        void setResourceAccessor​(ResourceAccessor resourceAccessor)
        Set a ResourceAccessor on this Executor to be used in file access
        Parameters:
        resourceAccessor -
      • setDatabase

        void setDatabase​(Database database)
        Configures the Executor for the Database to run statements/queries against.
        Parameters:
        database - The database
      • queryForObject

        <T> T queryForObject​(SqlStatement sql,
                             Class<T> requiredType)
                      throws DatabaseException
        Execute a query that is expected to return a scalar (1 row, 1 column). It is expected that the scalar can be cast into an object of type T.
        Parameters:
        sql - The query to execute
        Returns:
        An object of type T, if successful. May also return null if no object is found.
        Throws:
        DatabaseException - in case something goes wrong during the query execution
      • queryForObject

        <T> T queryForObject​(SqlStatement sql,
                             Class<T> requiredType,
                             List<SqlVisitor> sqlVisitors)
                      throws DatabaseException
        Applies a number of SqlVisitors to the sql query. Then, executes the (possibly modified) query. The query is expected to return a scalar (1 row, 1 column). That scalar is expected to return a single value that can be cast into an object of type T.
        Parameters:
        sql - The query to execute
        Returns:
        An object of type T, if successful. May also return null if no object is found.
        Throws:
        DatabaseException - in case something goes wrong during the query execution
      • queryForLong

        long queryForLong​(SqlStatement sql)
                   throws DatabaseException
        Executes a query that is expected to return a scalar (1 row, 1 column). It is expected that the scalar can be cast into a long.
        Parameters:
        sql - The query to execute
        Returns:
        A long value, if successful
        Throws:
        DatabaseException - in case something goes wrong during the query execution
      • queryForLong

        long queryForLong​(SqlStatement sql,
                          List<SqlVisitor> sqlVisitors)
                   throws DatabaseException
        Applies a number of SqlVisitors to the sql query. Then, executes the (possibly modified) query. The query is expected to return a scalar (1 row, 1 column), and that scalar is expected to be a long value.
        Parameters:
        sql - The query to execute
        Returns:
        A long value, if successful
        Throws:
        DatabaseException - in case something goes wrong during the query execution
      • queryForInt

        int queryForInt​(SqlStatement sql)
                 throws DatabaseException
        Executes a query that is expected to return a scalar (1 row, 1 column). It is expected that the scalar can be cast into an int.
        Parameters:
        sql - The query to execute
        Returns:
        An integer, if successful
        Throws:
        DatabaseException - in case something goes wrong during the query execution
      • queryForInt

        int queryForInt​(SqlStatement sql,
                        List<SqlVisitor> sqlVisitors)
                 throws DatabaseException
        Applies a number of SqlVisitors to the sql query. Then, executes the (possibly modified) query. The query is expected to return a scalar (1 row, 1 column), and that scalar is expected to be an int.
        Parameters:
        sql - The query to execute
        Returns:
        An integer, if successful
        Throws:
        DatabaseException - in case something goes wrong during the query execution
      • queryForList

        List<Map<String,​?>> queryForList​(SqlStatement sql)
                                        throws DatabaseException
        Executes a given SQL statement and returns a List of rows. Each row is represented a a Map, where the String is the column name and the value if the content of the column in the row (=cell).
        Parameters:
        sql - the SQL query to execute
        Returns:
        a List of [Column name] -> [column value]-mapped rows.
        Throws:
        DatabaseException - if an error occurs during SQL processing (e.g. the SQL is not valid for the database)
      • queryForList

        List<Map<String,​?>> queryForList​(SqlStatement sql,
                                               List<SqlVisitor> sqlVisitors)
                                        throws DatabaseException
        Applies a list of SqlVisitors to the SQL query, then executes the (possibly modified) SQL query and lastly, returns the list of rows. Each row is represented a a Map, where the String is the column name and the value if the content of the column in the row (=cell).
        Parameters:
        sql - the SQL query to execute
        Returns:
        a List of [Column name] -> [column value]-mapped rows.
        Throws:
        DatabaseException - if an error occurs during SQL processing (e.g. the SQL is not valid for the database)
      • comment

        void comment​(String message)
              throws DatabaseException
        Adds a comment to the database. Currently does nothing but is overridden in the output JDBC template
        Parameters:
        message -
        Throws:
        DatabaseException
      • updatesDatabase

        boolean updatesDatabase()
      • supports

        default boolean supports​(Database database)
        Default implementation for compatibility with a Database. Requires default implementation in order to provide backward compatibility. Method is used when ExecutorService is looking by a Executor implementation for a Database. Can be overridden in Executor implementations with a higher priority to check against a Database.
        Parameters:
        database - the Database implementation opened from a url connection string
        Returns:
        true if Database is supported by current Executor implementation.