Skip to content

Commit

Permalink
Merge pull request #162 from SPalominos/master
Browse files Browse the repository at this point in the history
Fixes and column filter
  • Loading branch information
ebocher authored Nov 13, 2019
2 parents 977525d + c97e209 commit e3633e8
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
package org.orbisgis.datamanagerapi.dataset;

import groovy.lang.Closure;
import org.orbisgis.datamanagerapi.dsl.IColumnsBuilder;
import org.orbisgis.datamanagerapi.dsl.IWhereBuilderOrOptionBuilder;

import java.sql.ResultSet;
Expand All @@ -48,7 +49,7 @@
* Extension of the {@link ITable} specially dedicated to the JDBC databases thanks to the extension of the
* {@link ResultSet} interface. It also extends the {@link IWhereBuilderOrOptionBuilder} for the SQL requesting
*/
public interface IJdbcTable extends ITable, ResultSet, IWhereBuilderOrOptionBuilder {
public interface IJdbcTable extends ITable, ResultSet, IWhereBuilderOrOptionBuilder, IColumnsBuilder {

/** {@link String} name of the metadata property */
String META_PROPERTY = "meta";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {

/**
* Return the {@link ITable} contained by the database with the given name. If the table contains a geometric
* field, return a ISpatialTable.
* field, return a {@link ISpatialTable}.
*
* @param tableName Name of the requested table.
*
Expand Down Expand Up @@ -108,7 +108,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* Load a file into the database.
*
* @param filePath Path of the file.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(String filePath);

Expand All @@ -117,7 +118,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
*
* @param filePath Path of the file.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(String filePath, boolean delete);

Expand All @@ -126,7 +128,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
*
* @param filePath Path of the file.
* @param tableName Name of the table.
* @return
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(String filePath, String tableName);

Expand All @@ -136,7 +139,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* @param filePath Path of the file.
* @param tableName Name of the table.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(String filePath, String tableName, boolean delete);

Expand All @@ -147,15 +151,17 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* @param tableName Name of the table
* @param encoding Encoding of the loaded file.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(String filePath, String tableName, String encoding, boolean delete);

/**
* Load a file into the database.
*
* @param url {@link URL} of the file.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(URL url);

Expand All @@ -164,7 +170,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
*
* @param url {@link URL} of the file.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(URL url, boolean delete);

Expand All @@ -173,7 +180,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
*
* @param url {@link URL} of the file.
* @param tableName Name of the table.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(URL url, String tableName);

Expand All @@ -183,7 +191,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* @param url {@link URL} of the file.
* @param tableName Name of the table.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(URL url, String tableName, boolean delete);

Expand All @@ -194,15 +203,17 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* @param tableName Name of the table
* @param encoding Encoding of the loaded file.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(URL url, String tableName, String encoding, boolean delete);

/**
* Load a file into the database.
*
* @param uri {@link URI} of the file.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(URI uri);

Expand All @@ -211,7 +222,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
*
* @param uri {@link URI} of the file.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(URI uri, boolean delete);

Expand All @@ -220,7 +232,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
*
* @param uri {@link URI} of the file.
* @param tableName Name of the table.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(URI uri, String tableName);

Expand All @@ -230,7 +243,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* @param uri {@link URI} of the file.
* @param tableName Name of the table.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(URI uri, String tableName, boolean delete);

Expand All @@ -241,15 +255,17 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* @param tableName Name of the table
* @param encoding Encoding of the loaded file.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(URI uri, String tableName, String encoding, boolean delete);

/**
* Load a file into the database.
*
* @param file {@link File}.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(File file);

Expand All @@ -258,7 +274,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
*
* @param file {@link File}.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(File file, boolean delete);

Expand All @@ -267,7 +284,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
*
* @param file {@link File}.
* @param tableName Name of the table.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(File file, String tableName);

Expand All @@ -277,7 +295,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* @param file {@link File}.
* @param tableName Name of the table.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(File file, String tableName, boolean delete);

Expand All @@ -288,7 +307,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* @param tableName Name of the table
* @param encoding Encoding of the loaded file.
* @param delete True to delete the table if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(File file, String tableName, String encoding, boolean delete);

Expand All @@ -297,7 +317,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
*
* @param properties Properties used to connect to the database.
* @param inputTableName Name of the table to import.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(Map<String, String> properties, String inputTableName);

Expand All @@ -308,7 +329,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* @param properties Properties used to connect to the database.
* @param inputTableName Name of the table to import.
* @param outputTableName Name of the imported table in the database.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(Map<String, String> properties, String inputTableName, String outputTableName);

Expand All @@ -318,7 +340,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* @param properties Properties used to connect to the database.
* @param inputTableName Name of the table to import.
* @param delete True to delete the outputTableName if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(Map<String, String> properties, String inputTableName, boolean delete);

Expand All @@ -329,7 +352,8 @@ public interface IJdbcDataSource extends IDataSource, GroovyObject {
* @param inputTableName Name of the table to import.
* @param outputTableName Name of the imported table in the database.
* @param delete True to delete the outputTableName if exists, false otherwise.
* @return a ITable
*
* @return The {@link ITable} containing the loaded data.
*/
ITable load(Map<String, String> properties, String inputTableName, String outputTableName, boolean delete);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Bundle DataManager API is part of the OrbisGIS platform
*
* OrbisGIS is a java GIS application dedicated to research in GIScience.
* OrbisGIS is developed by the GIS group of the DECIDE team of the
* Lab-STICC CNRS laboratory, see <http://www.lab-sticc.fr/>.
*
* The GIS group of the DECIDE team is located at :
*
* Laboratoire Lab-STICC – CNRS UMR 6285
* Equipe DECIDE
* UNIVERSITÉ DE BRETAGNE-SUD
* Institut Universitaire de Technologie de Vannes
* 8, Rue Montaigne - BP 561 56017 Vannes Cedex
*
* DataManager API is distributed under GPL 3 license.
*
* Copyright (C) 2019 CNRS (Lab-STICC UMR CNRS 6285)
*
*
* DataManager API is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* DataManager API is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* DataManager API. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, please consult: <http://www.orbisgis.org/>
* or contact directly:
* info_at_ orbisgis.org
*/
package org.orbisgis.datamanagerapi.dsl;

import org.orbisgis.datamanagerapi.dataset.ITable;

/**
* Interface defining methods for the SQL 'select ... from' building. The request construction can be continued thanks to the
* {@link IWhereBuilderOrOptionBuilder} or its result can be get calling 'eachRow' to iterate on the resultSet or
* 'as ITable' to get the {@link ITable} object
*
* @author Erwan Bocher (CNRS)
* @author Sylvain PALOMINOS (UBS 2019)
*/
public interface IColumnsBuilder {

/**
* Indicates the columns use for the selection.
*
* @param columns Array of the columns use for the selection.
*
* @return {@link IWhereBuilderOrOptionBuilder} instance to continue building.
*/
IWhereBuilderOrOptionBuilder columns(String... columns);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.junit.jupiter.api.Test;
import org.orbisgis.datamanagerapi.dsl.IConditionOrOptionBuilder;
import org.orbisgis.datamanagerapi.dsl.IOptionBuilder;
import org.orbisgis.datamanagerapi.dsl.IWhereBuilderOrOptionBuilder;

import javax.sql.rowset.RowSetMetaDataImpl;
import java.io.InputStream;
Expand Down Expand Up @@ -454,5 +455,6 @@ private void getPrivateMethod(){/*Does nothing*/}
@Override public Object asType(Class clazz) {return null;}
@Override public ITable getTable() {return null;}
@Override public ISpatialTable getSpatialTable() {return null;}
@Override public IWhereBuilderOrOptionBuilder columns(String... columns) {return null;}
}
}
Loading

0 comments on commit e3633e8

Please sign in to comment.