diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/IDataSetRegistrationTransaction.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/IDataSetRegistrationTransaction.java index cc4939d108f86ca6518254d0e6b3653f4623eb5f..d99c6826633e28989ee301bde5044f74c0ed9087 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/IDataSetRegistrationTransaction.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/IDataSetRegistrationTransaction.java @@ -16,6 +16,8 @@ package ch.systemsx.cisd.etlserver.registrator.api.v1; +import net.lemnik.eodsql.DynamicTransactionQuery; + import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IDataSetImmutable; import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IExperimentImmutable; import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IMaterialImmutable; @@ -209,5 +211,17 @@ public interface IDataSetRegistrationTransaction * @return The search service for this transaction. */ ISearchService getSearchService(); + + /** + * Returns a database query for the data source with the specified name. + * + * @param dataSourceName The name of the data source to query against, as declared in the + * service.properties file. + * @return The query. + * @throw IllegalArgumentException Thrown if there is no data source with the given name. + * @throw InvalidQueryException Thrown the given query string cannot be parsed, or doesn't match + * the given parameters. + */ + DynamicTransactionQuery getDatabaseQuery(String dataSourceName) throws IllegalArgumentException; } diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSetRegistrationTransaction.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSetRegistrationTransaction.java index dd3b80f71b2147c64dfb26d7dcb4f12acf53c1a4..49e17f9f47ed2f3a012327f0566bad23309ed30b 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSetRegistrationTransaction.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSetRegistrationTransaction.java @@ -21,6 +21,9 @@ import java.io.FilenameFilter; import java.util.Date; import java.util.List; +import net.lemnik.eodsql.DynamicTransactionQuery; +import net.lemnik.eodsql.QueryTool; + import org.apache.commons.lang.time.DateFormatUtils; import org.apache.log4j.Logger; @@ -446,4 +449,10 @@ public class DataSetRegistrationTransaction<T extends DataSetInformation> implem { return new SearchService(openBisService); } + + public DynamicTransactionQuery getDatabaseQuery(String dataSourceName) + throws IllegalArgumentException + { + return QueryTool.getQuery(DynamicTransactionQuery.class); + } } diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSourceQueryService.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSourceQueryService.java index 13ef4a6fa6a95a0d259b365b10ff92f05d4bfe72..2941f639fa426a639df1340fa66dccdfde003a02 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSourceQueryService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/DataSourceQueryService.java @@ -65,62 +65,4 @@ public class DataSourceQueryService implements IDataSourceQueryService return select(dataSourceName, query, new Object[0]); } - public int update(String dataSourceName, String query, Object... parameters) - throws IllegalArgumentException - { - final DataSource dataSource = getDataSourceProvider().getDataSource(dataSourceName); - try - { - return QueryTool.update(dataSource, query, parameters); - } catch (InvalidQueryException ex) - { - operationLog.error(ex.getCause().getMessage()); - throw ex; - } - } - - public int update(String dataSourceName, String query) throws IllegalArgumentException - { - return update(dataSourceName, query, new Object[0]); - } - - public long insert(String dataSourceName, String query, Object... parameters) - throws IllegalArgumentException - { - final DataSource dataSource = getDataSourceProvider().getDataSource(dataSourceName); - try - { - return QueryTool.insert(dataSource, query, parameters); - } catch (InvalidQueryException ex) - { - operationLog.error(ex.getCause().getMessage()); - throw ex; - } - } - - public long insert(String dataSourceName, String query) throws IllegalArgumentException - { - return insert(dataSourceName, query, new Object[0]); - } - - public Map<String, Object> insertMultiKeys(String dataSourceName, String[] generatedIdColumns, - String query, Object... parameters) throws IllegalArgumentException - { - final DataSource dataSource = getDataSourceProvider().getDataSource(dataSourceName); - try - { - return QueryTool.insertMultiKeys(dataSource, generatedIdColumns, query, parameters); - } catch (InvalidQueryException ex) - { - operationLog.error(ex.getCause().getMessage()); - throw ex; - } - } - - public Map<String, Object> insertMultiKeys(String dataSourceName, String[] generatedIdColumns, - String query) throws IllegalArgumentException - { - return insertMultiKeys(dataSourceName, generatedIdColumns, query, new Object[0]); - } - } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/IDataSourceQueryService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/IDataSourceQueryService.java index d392e769727dd40996384d3e73c9aee736472455..37925c0d936a326f54d5e4a3aed19e7f322c6fc7 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/IDataSourceQueryService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/internal/v1/IDataSourceQueryService.java @@ -44,14 +44,6 @@ import net.lemnik.eodsql.DataSet; * result.close() * </pre> * - * Use {@link #update(String, String, Object...)} for performing statements that don't return a - * result. - * <p> - * Use {@link #insert(String, String, Object...)} or - * {@link #insertMultiKeys(String, String[], String, Object...)} if you need to get an - * auto-generated key of an insert statement, that is if you have a key that is doing an - * <code>AUTO_INCREMENT</code> of some sort. - * * @author Chandrasekhar Ramakrishnan */ public interface IDataSourceQueryService @@ -88,100 +80,4 @@ public interface IDataSourceQueryService DataSet<Map<String, Object>> select(String dataSourceName, String query, Object... parameters) throws IllegalArgumentException; - /** - * Execute an update against the data source with the specified name. - * - * @param dataSourceName The name of the data source to query against, as declared in the - * service.properties file. - * @param query The SQL query to execute, possibly including parameters marked by '?{X}' where X - * is the parameter number. - * @return Either the row count (for <code>INSERT</code>, <code>UPDATE</code>, or - * <code>DELETE</code> statements) or 0 for SQL statements that return nothing - * @throw IllegalArgumentException Throws if there is no data source with the given name. - * @throw InvalidQueryException Thrown the given query string cannot be parsed, or doesn't match - * the given parameters. - */ - int update(String dataSourceName, String query) throws IllegalArgumentException; - - /** - * Execute an update against the data source with the specified name. - * - * @param dataSourceName The name of the data source to query against, as declared in the - * service.properties file. - * @param query The SQL query to execute, possibly including parameters marked by '?{X}' where X - * is the parameter number. - * @param parameters The values for filling in the query parameters. - * @return Either the row count (for <code>INSERT</code>, <code>UPDATE</code>, or - * <code>DELETE</code> statements) or 0 for SQL statements that return nothing - * @throw IllegalArgumentException Thrown if there is no data source with the given name. - * @throw InvalidQueryException Thrown the given query string cannot be parsed, or doesn't match - * the given parameters. - */ - int update(String dataSourceName, String query, Object... parameters) - throws IllegalArgumentException; - - /** - * Execute an insert against the data source with the specified name. - * - * @param dataSourceName The name of the data source to query against, as declared in the - * service.properties file. - * @param query The SQL query to execute, possibly including parameters marked by '?{X}' where X - * is the parameter number. - * @return The generated key of the insert statement, or -1, of no key was generated - * @throw IllegalArgumentException Throws if there is no data source with the given name. - * @throw InvalidQueryException Thrown the given query string cannot be parsed, or doesn't match - * the given parameters. - */ - long insert(String dataSourceName, String query) throws IllegalArgumentException; - - /** - * Execute an insert against the data source with the specified name. - * - * @param dataSourceName The name of the data source to query against, as declared in the - * service.properties file. - * @param query The SQL query to execute, possibly including parameters marked by '?{X}' where X - * is the parameter number. - * @param parameters The values for filling in the query parameters. - * @return The generated key of the insert statement, or -1, of no key was generated - * @throw IllegalArgumentException Thrown if there is no data source with the given name. - * @throw InvalidQueryException Thrown the given query string cannot be parsed, or doesn't match - * the given parameters. - */ - long insert(String dataSourceName, String query, Object... parameters) - throws IllegalArgumentException; - - /** - * Execute an insert against the data source with the specified name. - * - * @param dataSourceName The name of the data source to query against, as declared in the - * service.properties file. - * @param generatedIdColumns The column names of the auto-generated ids, or <code>null</code>, - * if the columns automatically detected by the driver should be used. - * @param query The SQL query to execute, possibly including parameters marked by '?{X}' where X - * is the parameter number. - * @return The generated key of the insert statement, or -1, of no key was generated - * @throw IllegalArgumentException Throws if there is no data source with the given name. - * @throw InvalidQueryException Thrown the given query string cannot be parsed, or doesn't match - * the given parameters. - */ - Map<String, Object> insertMultiKeys(String dataSourceName, String[] generatedIdColumns, - String query) throws IllegalArgumentException; - - /** - * Execute an insert against the data source with the specified name. - * - * @param dataSourceName The name of the data source to query against, as declared in the - * service.properties file. - * @param generatedIdColumns The column names of the auto-generated ids, or <code>null</code>, - * if the columns automatically detected by the driver should be used. - * @param query The SQL query to execute, possibly including parameters marked by '?{X}' where X - * is the parameter number. - * @param parameters The values for filling in the query parameters. - * @return The generated key of the insert statement, or -1, of no key was generated - * @throw IllegalArgumentException Thrown if there is no data source with the given name. - * @throw InvalidQueryException Thrown the given query string cannot be parsed, or doesn't match - * the given parameters. - */ - Map<String, Object> insertMultiKeys(String dataSourceName, String[] generatedIdColumns, - String query, Object... parameters) throws IllegalArgumentException; }