Skip to content
Snippets Groups Projects
Commit d7ff7d32 authored by brinn's avatar brinn
Browse files

remove: IDataSourceQueryService.update() and select() methods

add: IDataSetRegistrationTransaction.getDatabaseQuery() (to be completed by Sekhar)

SVN: 22308
parent b541811c
No related branches found
No related tags found
No related merge requests found
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package ch.systemsx.cisd.etlserver.registrator.api.v1; 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.IDataSetImmutable;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IExperimentImmutable; import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IExperimentImmutable;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IMaterialImmutable; import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.IMaterialImmutable;
...@@ -209,5 +211,17 @@ public interface IDataSetRegistrationTransaction ...@@ -209,5 +211,17 @@ public interface IDataSetRegistrationTransaction
* @return The search service for this transaction. * @return The search service for this transaction.
*/ */
ISearchService getSearchService(); 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;
} }
...@@ -21,6 +21,9 @@ import java.io.FilenameFilter; ...@@ -21,6 +21,9 @@ import java.io.FilenameFilter;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import net.lemnik.eodsql.DynamicTransactionQuery;
import net.lemnik.eodsql.QueryTool;
import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
...@@ -446,4 +449,10 @@ public class DataSetRegistrationTransaction<T extends DataSetInformation> implem ...@@ -446,4 +449,10 @@ public class DataSetRegistrationTransaction<T extends DataSetInformation> implem
{ {
return new SearchService(openBisService); return new SearchService(openBisService);
} }
public DynamicTransactionQuery getDatabaseQuery(String dataSourceName)
throws IllegalArgumentException
{
return QueryTool.getQuery(DynamicTransactionQuery.class);
}
} }
...@@ -65,62 +65,4 @@ public class DataSourceQueryService implements IDataSourceQueryService ...@@ -65,62 +65,4 @@ public class DataSourceQueryService implements IDataSourceQueryService
return select(dataSourceName, query, new Object[0]); 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]);
}
} }
...@@ -44,14 +44,6 @@ import net.lemnik.eodsql.DataSet; ...@@ -44,14 +44,6 @@ import net.lemnik.eodsql.DataSet;
* result.close() * result.close()
* </pre> * </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 * @author Chandrasekhar Ramakrishnan
*/ */
public interface IDataSourceQueryService public interface IDataSourceQueryService
...@@ -88,100 +80,4 @@ public interface IDataSourceQueryService ...@@ -88,100 +80,4 @@ public interface IDataSourceQueryService
DataSet<Map<String, Object>> select(String dataSourceName, String query, Object... parameters) DataSet<Map<String, Object>> select(String dataSourceName, String query, Object... parameters)
throws IllegalArgumentException; 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;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment