diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/AbstractTransactionState.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/AbstractTransactionState.java index 219582632e38c346de589f7e119f1d3f9406427b..ab19d50b9f04b3337f7243774f5e591d2c8acc9e 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/AbstractTransactionState.java +++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/registrator/api/v1/impl/AbstractTransactionState.java @@ -181,31 +181,17 @@ abstract class AbstractTransactionState<T extends DataSetInformation> public IDataSet createNewDataSet() { - // Create registration details for the new data set - DataSetRegistrationDetails<T> registrationDetails = - registrationDetailsFactory.createDataSetRegistrationDetails(); - - return createNewDataSet(registrationDetails); + return createNewDataSet(registrationDetailsFactory, null, null); } public IDataSet createNewDataSet(String dataSetType) { - // Create registration details for the new data set - DataSetRegistrationDetails<T> registrationDetails = - registrationDetailsFactory.createDataSetRegistrationDetails(); - registrationDetails.setDataSetType(dataSetType); - - return createNewDataSet(registrationDetails); + return createNewDataSet(registrationDetailsFactory, dataSetType, null); } public IDataSet createNewDataSet(String dataSetType, String dataSetCode) { - // Create registration details for the new data set - DataSetRegistrationDetails<T> registrationDetails = - registrationDetailsFactory.createDataSetRegistrationDetails(); - registrationDetails.setDataSetType(dataSetType); - - return createNewDataSet(registrationDetails, dataSetCode); + return createNewDataSet(registrationDetailsFactory, dataSetType, dataSetCode); } public IDataSet createNewDataSet(DataSetRegistrationDetails<? extends T> registrationDetails) @@ -216,16 +202,37 @@ abstract class AbstractTransactionState<T extends DataSetInformation> } public IDataSet createNewDataSet( - DataSetRegistrationDetails<? extends T> registrationDetails, String specifiedCode) + DataSetRegistrationDetails<? extends T> registrationDetails, + String specifiedCodeOrNull) { + return createNewDataSet(registrationDetails, null, specifiedCodeOrNull); + } + + public IDataSet createNewDataSet(IDataSetRegistrationDetailsFactory<? extends T> factory, + String dataSetTypeOrNull, String dataSetCodeOrNull) + { + // Create registration details for the new data set + DataSetRegistrationDetails<? extends T> registrationDetails = + factory.createDataSetRegistrationDetails(); + return createNewDataSet(registrationDetails, dataSetTypeOrNull, dataSetCodeOrNull); + } + + private IDataSet createNewDataSet( + DataSetRegistrationDetails<? extends T> registrationDetails, + String dataSetTypeOrNull, String specifiedCodeOrNull) + { + if (null != dataSetTypeOrNull) + { + registrationDetails.setDataSetType(dataSetTypeOrNull); + } final String dataSetCode; - if (null == specifiedCode) + if (null == specifiedCodeOrNull) { dataSetCode = generateDataSetCode(registrationDetails); registrationDetails.getDataSetInformation().setDataSetCode(dataSetCode); } else { - dataSetCode = specifiedCode.toUpperCase(); + dataSetCode = specifiedCodeOrNull.toUpperCase(); } registrationDetails.getDataSetInformation().setDataSetCode(dataSetCode); 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 fbdb336a1c020da6384dd7667438c1bae98b79aa..ea1b2c8327cdc38bcfd3459cded6179566fb3839 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 @@ -213,6 +213,12 @@ public class DataSetRegistrationTransaction<T extends DataSetInformation> implem return getStateAsLiveState().createNewDataSet(registrationDetails); } + public IDataSet createNewDataSet(IDataSetRegistrationDetailsFactory<? extends T> factory, + String dataSetType) + { + return getStateAsLiveState().createNewDataSet(factory, dataSetType, null); + } + public IDataSetImmutable getDataSet(String dataSetCode) { return getStateAsLiveState().getDataSet(dataSetCode);