Skip to content
Snippets Groups Projects
Commit c031df2e authored by felmer's avatar felmer
Browse files

LMS-1622 IDataSourceProvider modified

SVN: 16917
parent 0bbd70e6
No related branches found
No related tags found
No related merge requests found
......@@ -35,7 +35,7 @@ import ch.systemsx.cisd.dbmigration.SimpleDatabaseConfigurationContext;
import ch.systemsx.cisd.openbis.generic.shared.dto.DataPE;
/**
*
* Data source provider based on configuration per Data Store Server.
*
* @author Franz-Josef Elmer
*/
......@@ -68,7 +68,9 @@ public class DataStoreServerBasedDataSourceProvider implements IDataSourceProvid
{
String key = sectionProperties.getKey().toUpperCase();
Properties properties = sectionProperties.getProperties();
dataSources.put(key, create(properties));
SimpleDatabaseConfigurationContext context =
new SimpleDatabaseConfigurationContext(properties);
dataSources.put(key, context.getDataSource());
}
}
......@@ -79,10 +81,10 @@ public class DataStoreServerBasedDataSourceProvider implements IDataSourceProvid
{
throw new UserFailureException("Unknown data set " + dataSetCode);
}
return getDataSource(dataSet.getDataStore().getCode());
return getDataSourceByDataSetCode(dataSet.getDataStore().getCode(), technology);
}
private DataSource getDataSource(String dssCode)
public DataSource getDataSourceByDataStoreServerCode(String dssCode, String technology)
{
DataSource dataSource = dataSources.get(dssCode);
if (dataSource == null)
......@@ -93,23 +95,4 @@ public class DataStoreServerBasedDataSourceProvider implements IDataSourceProvid
return dataSource;
}
private DataSource create(Properties properties)
{
return new SimpleDatabaseConfigurationContext(properties).getDataSource();
}
public DataSource getDataSourceByExperimentPermID(String experimentPermID, String technology)
{
throw new IllegalArgumentException(
"Getting data source by experiment permID is not supported for technology '"
+ technology + "'.");
}
public DataSource getDataSourceBySamplePermID(String samplePermID, String technology)
{
throw new IllegalArgumentException(
"Getting data source by sample permID is not supported for technology '"
+ technology + "'.");
}
}
......@@ -22,7 +22,7 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException;
/**
* Interface for providing a {@link DataSource} for a technology specific database based on data set
* code or epxeriment/sample permID.
* code or data store server code
*
* @author Franz-Josef Elmer
*/
......@@ -38,20 +38,11 @@ public interface IDataSourceProvider
public DataSource getDataSourceByDataSetCode(String dataSetCode, String technology);
/**
* Returns an appropriated data source for specified experiment permID and technology.
* Returns an appropriated data source for specified data store server code and technology.
*
* @throws IllegalArgumentException if getting data source by experiment permID isn't supported
* for the specified technology.
* @throws UserFailureException if the specified experiment doesn't exist.
* @throws IllegalArgumentException if getting data source by data store server code isn't
* supported for the specified technology.
* @throws UserFailureException if the specified data store server doesn't exist.
*/
public DataSource getDataSourceByExperimentPermID(String experimentPermID, String technology);
/**
* Returns an appropriated data source for specified sample permID and technology.
*
* @throws IllegalArgumentException if getting data source by sample permID isn't supported
* for the specified technology.
* @throws UserFailureException if the specified sample doesn't exist.
*/
public DataSource getDataSourceBySamplePermID(String samplePermID, String technology);
public DataSource getDataSourceByDataStoreServerCode(String dssCode, String technology);
}
......@@ -42,12 +42,7 @@ public class SingleDataSourceProvider implements IDataSourceProvider
return dataSource;
}
public DataSource getDataSourceByExperimentPermID(String experimentPermID, String technology)
{
return dataSource;
}
public DataSource getDataSourceBySamplePermID(String samplePermID, String technology)
public DataSource getDataSourceByDataStoreServerCode(String dssCode, String technology)
{
return dataSource;
}
......
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