Class JdbcTable<T extends ResultSet>

  • All Implemented Interfaces:
    groovy.lang.GroovyObject, AutoCloseable, Iterable<T>, ResultSet, Wrapper, org.orbisgis.data.api.dataset.IDataSet<T>, org.orbisgis.data.api.dataset.IJdbcTable<T>, org.orbisgis.data.api.dataset.IMatrix<T>, org.orbisgis.data.api.dataset.ITable<T,​T>, org.orbisgis.data.api.dsl.IBuilderResult, org.orbisgis.data.api.dsl.IFilterBuilder, org.orbisgis.data.api.dsl.IQueryBuilder
    Direct Known Subclasses:
    JdbcSpatialTable

    public abstract class JdbcTable<T extends ResultSet>
    extends DefaultResultSet
    implements org.orbisgis.data.api.dataset.IJdbcTable<T>, groovy.lang.GroovyObject
    Contains the methods which are in common to all the IJdbcTable subclasses. Implements the GroovyObject to simplify the methods calling (i.e. .tableLocation instead of .getTableLocation() ).
    Author:
    Sylvain Palominos (Lab-STICC UBS 2019 / Chaire GEOTERA 2020)
    • Field Detail

      • resultSet

        protected ResultSet resultSet
        Cached resultSet
    • Constructor Detail

      • JdbcTable

        public JdbcTable​(org.h2gis.utilities.dbtypes.DBTypes dataBaseType,
                         org.orbisgis.data.api.datasource.IJdbcDataSource jdbcDataSource,
                         org.h2gis.utilities.TableLocation tableLocation,
                         Statement statement,
                         List<Object> params,
                         String baseQuery)
        Main constructor.
        Parameters:
        dataBaseType - Type of the DataBase where this table comes from.
        tableLocation - TableLocation that identify the represented table.
        baseQuery - Query for the creation of the ResultSet.
        statement - PreparedStatement used to request the database.
        params - Map containing the parameters for the query.
        jdbcDataSource - DataSource to use for the creation of the resultSet.
    • Method Detail

      • getBaseQuery

        public String getBaseQuery()
        Return the base query for the creation of the ResultSet.
        Returns:
        The base query.
      • reload

        public boolean reload()
                       throws SQLException
        Specified by:
        reload in interface org.orbisgis.data.api.dataset.IDataSet<T extends ResultSet>
        Throws:
        SQLException
      • getJdbcDataSource

        public org.orbisgis.data.api.datasource.IJdbcDataSource getJdbcDataSource()
        Return the parent DataSource.
        Returns:
        The parent DataSource.
      • getTableLocation

        public org.h2gis.utilities.TableLocation getTableLocation()
        Specified by:
        getTableLocation in interface org.orbisgis.data.api.dataset.IJdbcTable<T extends ResultSet>
      • getDbType

        public org.h2gis.utilities.dbtypes.DBTypes getDbType()
        Specified by:
        getDbType in interface org.orbisgis.data.api.dataset.IJdbcTable<T extends ResultSet>
      • getMetaClass

        public groovy.lang.MetaClass getMetaClass()
        Specified by:
        getMetaClass in interface groovy.lang.GroovyObject
      • setMetaClass

        public void setMetaClass​(groovy.lang.MetaClass metaClass)
        Specified by:
        setMetaClass in interface groovy.lang.GroovyObject
      • isSpatial

        public boolean isSpatial()
        Specified by:
        isSpatial in interface org.orbisgis.data.api.dataset.ITable<T extends ResultSet,​T extends ResultSet>
      • isLinked

        public boolean isLinked()
        Specified by:
        isLinked in interface org.orbisgis.data.api.dataset.IJdbcTable<T extends ResultSet>
      • isTemporary

        public boolean isTemporary()
        Specified by:
        isTemporary in interface org.orbisgis.data.api.dataset.IJdbcTable<T extends ResultSet>
      • save

        public String save​(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource,
                           boolean deleteTable)
                    throws Exception
        Specified by:
        save in interface org.orbisgis.data.api.dataset.ITable<T extends ResultSet,​T extends ResultSet>
        Throws:
        Exception
      • save

        public String save​(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource,
                           String outputTableName,
                           boolean deleteTable)
                    throws Exception
        Specified by:
        save in interface org.orbisgis.data.api.dataset.ITable<T extends ResultSet,​T extends ResultSet>
        Throws:
        Exception
      • save

        public String save​(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource,
                           int batchSize)
                    throws Exception
        Specified by:
        save in interface org.orbisgis.data.api.dataset.ITable<T extends ResultSet,​T extends ResultSet>
        Throws:
        Exception
      • save

        public String save​(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource,
                           String outputTableName,
                           boolean deleteTable,
                           int batchSize)
                    throws Exception
        Specified by:
        save in interface org.orbisgis.data.api.dataset.ITable<T extends ResultSet,​T extends ResultSet>
        Throws:
        Exception
      • save

        public String save​(org.orbisgis.data.api.datasource.IJdbcDataSource dataSource,
                           boolean deleteTable,
                           int batchSize)
                    throws Exception
        Specified by:
        save in interface org.orbisgis.data.api.dataset.ITable<T extends ResultSet,​T extends ResultSet>
        Throws:
        Exception
      • getQuery

        protected String getQuery​(String... columns)
      • filter

        public org.orbisgis.data.api.dsl.IBuilderResult filter​(String filter)
        Specified by:
        filter in interface org.orbisgis.data.api.dsl.IFilterBuilder
      • filter

        public org.orbisgis.data.api.dsl.IBuilderResult filter​(groovy.lang.GString filter)
        Specified by:
        filter in interface org.orbisgis.data.api.dsl.IFilterBuilder
      • filter

        public org.orbisgis.data.api.dsl.IBuilderResult filter​(String filter,
                                                               List<Object> params)
        Specified by:
        filter in interface org.orbisgis.data.api.dsl.IFilterBuilder
      • columns

        public org.orbisgis.data.api.dsl.IFilterBuilder columns​(String... columns)
        Specified by:
        columns in interface org.orbisgis.data.api.dsl.IQueryBuilder
      • getTable

        public org.orbisgis.data.api.dataset.IJdbcTable<? extends org.orbisgis.data.api.dataset.IStreamResultSet> getTable()
                                                                                                                    throws Exception
        Specified by:
        getTable in interface org.orbisgis.data.api.dsl.IBuilderResult
        Throws:
        Exception
      • getSpatialTable

        public org.orbisgis.data.api.dataset.IJdbcSpatialTable<org.orbisgis.data.api.dataset.IStreamSpatialResultSet> getSpatialTable()
                                                                                                                               throws Exception
        Specified by:
        getSpatialTable in interface org.orbisgis.data.api.dsl.IBuilderResult
        Throws:
        Exception
      • asType

        public Object asType​(Class<?> clazz)
                      throws Exception
        Specified by:
        asType in interface org.orbisgis.data.api.dsl.IBuilderResult
        Specified by:
        asType in interface org.orbisgis.data.api.dataset.IDataSet<T extends ResultSet>
        Throws:
        Exception
      • getSummary

        public JdbcTableSummary getSummary()
                                    throws Exception
        Specified by:
        getSummary in interface org.orbisgis.data.api.dataset.IDataSet<T extends ResultSet>
        Specified by:
        getSummary in interface org.orbisgis.data.api.dataset.IJdbcTable<T extends ResultSet>
        Throws:
        Exception
      • getParams

        public List<Object> getParams()
        Specified by:
        getParams in interface org.orbisgis.data.api.dsl.IBuilderResult
        Specified by:
        getParams in interface org.orbisgis.data.api.dataset.IJdbcTable<T extends ResultSet>
      • setResultSetProperties

        public void setResultSetProperties​(org.orbisgis.data.api.dsl.IResultSetProperties properties)
        Specified by:
        setResultSetProperties in interface org.orbisgis.data.api.dataset.IJdbcTable<T extends ResultSet>
      • getResultSetProperties

        public org.orbisgis.data.api.dsl.IResultSetProperties getResultSetProperties()
        Specified by:
        getResultSetProperties in interface org.orbisgis.data.api.dataset.IJdbcTable<T extends ResultSet>
      • eachRow

        public void eachRow​(groovy.lang.Closure<Object> closure)
        Specified by:
        eachRow in interface org.orbisgis.data.api.dsl.IBuilderResult
        Specified by:
        eachRow in interface org.orbisgis.data.api.dataset.IJdbcTable<T extends ResultSet>
        Specified by:
        eachRow in interface org.orbisgis.data.api.dataset.ITable<T extends ResultSet,​T extends ResultSet>
      • isEmpty

        public boolean isEmpty()
                        throws Exception
        Specified by:
        isEmpty in interface org.orbisgis.data.api.dataset.IDataSet<T extends ResultSet>
        Throws:
        Exception