diff --git a/irodsext-data-profiler/src/main/java/org/irodsext/dataprofiler/IrodsextDataProfilerFactoryImpl.java b/irodsext-data-profiler/src/main/java/org/irodsext/dataprofiler/IrodsextDataProfilerFactoryImpl.java new file mode 100644 index 0000000..488f910 --- /dev/null +++ b/irodsext-data-profiler/src/main/java/org/irodsext/dataprofiler/IrodsextDataProfilerFactoryImpl.java @@ -0,0 +1,86 @@ +/** + * + */ +package org.irodsext.dataprofiler; + +import org.irods.jargon.core.connection.IRODSAccount; +import org.irods.jargon.core.exception.JargonRuntimeException; +import org.irods.jargon.core.pub.IRODSAccessObjectFactory; +import org.irods.jargon.extensions.dataprofiler.DataProfilerService; +import org.irods.jargon.extensions.dataprofiler.DataProfilerFactory; +import org.irods.jargon.extensions.dataprofiler.DataProfilerSettings; +import org.irods.jargon.extensions.datatyper.DataTypeResolutionServiceFactory; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Factory for {@link DataProfiler} implementation + * + * @author Mike Conway - NIEHS + * + */ +public class IrodsextDataProfilerFactoryImpl implements DataProfilerFactory { + + @Autowired + private IRODSAccessObjectFactory irodsAccessObjectFactory; + + @Autowired + private DataProfilerSettings dataProfilerSettings; + + @Autowired + private DataTypeResolutionServiceFactory dataTypeResolutionServiceFactory; + + /* (non-Javadoc) + * @see org.irodsext.dataprofiler.DataProfilerFactory#instanceDataProfilerService(org.irods.jargon.core.connection.IRODSAccount) + */ + @Override + public DataProfilerService instanceDataProfilerService(final IRODSAccount irodsAccount) { + validateDependencies(); + DataProfilerService dataProfilerService = new IrodsextDataProfilerService(dataProfilerSettings, + irodsAccessObjectFactory, irodsAccount); + dataProfilerService.setDataTypeResolutionService( + dataTypeResolutionServiceFactory.instanceDataTypeResolutionService(irodsAccount)); + return dataProfilerService; + } + + public IRODSAccessObjectFactory getIrodsAccessObjectFactory() { + return irodsAccessObjectFactory; + } + + public void setIrodsAccessObjectFactory(IRODSAccessObjectFactory irodsAccessObjectFactory) { + this.irodsAccessObjectFactory = irodsAccessObjectFactory; + } + + public DataProfilerSettings getDataProfilerSettings() { + return dataProfilerSettings; + } + + public void setDataProfilerSettings(DataProfilerSettings dataProfilerSettings) { + this.dataProfilerSettings = dataProfilerSettings; + } + + public DataTypeResolutionServiceFactory getDataTypeResolutionServiceFactory() { + return dataTypeResolutionServiceFactory; + } + + public void setDataTypeResolutionServiceFactory(DataTypeResolutionServiceFactory dataTypeResolutionServiceFactory) { + this.dataTypeResolutionServiceFactory = dataTypeResolutionServiceFactory; + } + + /** + * Just a sanity check + */ + private void validateDependencies() { + if (irodsAccessObjectFactory == null) { + throw new JargonRuntimeException("null irodsAccessObjectFactory"); + } + + if (dataProfilerSettings == null) { + throw new JargonRuntimeException("null dataProfilerSettings"); + } + + if (dataTypeResolutionServiceFactory == null) { + throw new IllegalArgumentException("null dataTypeResolutionServiceFactory"); + } + } + +} diff --git a/irodsext-data-profiler/src/main/java/org/irodsext/dataprofiler/IrodsextDataProfilerService.java b/irodsext-data-profiler/src/main/java/org/irodsext/dataprofiler/IrodsextDataProfilerService.java index 453bf6d..52881b2 100644 --- a/irodsext-data-profiler/src/main/java/org/irodsext/dataprofiler/IrodsextDataProfilerService.java +++ b/irodsext-data-profiler/src/main/java/org/irodsext/dataprofiler/IrodsextDataProfilerService.java @@ -9,7 +9,7 @@ import org.irods.jargon.core.pub.domain.Collection; import org.irods.jargon.core.pub.domain.DataObject; import org.irods.jargon.extensions.dataprofiler.DataProfile; -import org.irods.jargon.extensions.dataprofiler.DataProfileService; +import org.irods.jargon.extensions.dataprofiler.DataProfilerService; import org.irods.jargon.extensions.dataprofiler.DataProfilerSettings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -21,7 +21,7 @@ * @author Mike Conway - NIEHS * */ -public class IrodsextDataProfilerService extends DataProfileService { +public class IrodsextDataProfilerService extends DataProfilerService { public static final Logger log = LoggerFactory.getLogger(IrodsextDataProfilerService.class); diff --git a/irodsext-data-profiler/src/test/java/org/irodsext/dataprofiler/IrodsextDataProfilerServiceTest.java b/irodsext-data-profiler/src/test/java/org/irodsext/dataprofiler/IrodsextDataProfilerServiceTest.java index 8392b15..3373417 100644 --- a/irodsext-data-profiler/src/test/java/org/irodsext/dataprofiler/IrodsextDataProfilerServiceTest.java +++ b/irodsext-data-profiler/src/test/java/org/irodsext/dataprofiler/IrodsextDataProfilerServiceTest.java @@ -11,7 +11,7 @@ import org.irods.jargon.core.pub.IRODSAccessObjectFactory; import org.irods.jargon.core.pub.IRODSFileSystem; import org.irods.jargon.extensions.dataprofiler.DataProfile; -import org.irods.jargon.extensions.dataprofiler.DataProfileService; +import org.irods.jargon.extensions.dataprofiler.DataProfilerService; import org.irods.jargon.extensions.dataprofiler.DataProfilerSettings; import org.irods.jargon.extensions.datatyper.DataTypeResolutionService; import org.irods.jargon.extensions.datatyper.DataTyperSettings; @@ -96,7 +96,7 @@ public void testBasicDataProfileWithCollection() throws Exception { DataTypeResolutionService dataTyperService = new IrodsextDataTypeResolutionService(accessObjectFactory, irodsAccount, dataTyperSettings); - DataProfileService dataProfilerService = new IrodsextDataProfilerService(dataProfilerSettings, + DataProfilerService dataProfilerService = new IrodsextDataProfilerService(dataProfilerSettings, accessObjectFactory, irodsAccount); dataProfilerService.setDataTypeResolutionService(dataTyperService); @SuppressWarnings("rawtypes") diff --git a/irodsext-data-typer/src/main/java/org/irodsext/datatyper/IrodsextDataTypeResolutionServiceFactoryImpl.java b/irodsext-data-typer/src/main/java/org/irodsext/datatyper/IrodsextDataTypeResolutionServiceFactoryImpl.java new file mode 100644 index 0000000..3ac373e --- /dev/null +++ b/irodsext-data-typer/src/main/java/org/irodsext/datatyper/IrodsextDataTypeResolutionServiceFactoryImpl.java @@ -0,0 +1,68 @@ +/** + * + */ +package org.irodsext.datatyper; + +import org.irods.jargon.core.connection.IRODSAccount; +import org.irods.jargon.core.exception.JargonRuntimeException; +import org.irods.jargon.core.pub.IRODSAccessObjectFactory; +import org.irods.jargon.extensions.datatyper.DataTypeResolutionService; +import org.irods.jargon.extensions.datatyper.DataTypeResolutionServiceFactory; +import org.irods.jargon.extensions.datatyper.DataTyperSettings; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * Factory for {@link IrodsextDataTypeResolutionService} + * + * @author Mike Conway - NIEHS + * + */ +public class IrodsextDataTypeResolutionServiceFactoryImpl implements DataTypeResolutionServiceFactory { + + @Autowired + private IRODSAccessObjectFactory irodsAccessObjectFactory; + + @Autowired + private DataTyperSettings dataTyperSettings; + + public IRODSAccessObjectFactory getIrodsAccessObjectFactory() { + return irodsAccessObjectFactory; + } + + public void setIrodsAccessObjectFactory(IRODSAccessObjectFactory irodsAccessObjectFactory) { + this.irodsAccessObjectFactory = irodsAccessObjectFactory; + } + + public DataTyperSettings getDataTyperSettings() { + return dataTyperSettings; + } + + public void setDataTyperSettings(DataTyperSettings dataTyperSettings) { + this.dataTyperSettings = dataTyperSettings; + } + + /* (non-Javadoc) + * @see org.irodsext.datatyper.DataTypeResolutionServiceFactory#instanceDataTypeResolutionService(org.irods.jargon.core.connection.IRODSAccount) + */ + @Override + public DataTypeResolutionService instanceDataTypeResolutionService(final IRODSAccount irodsAccount) { + validateDependencies(); + DataTypeResolutionService dataTypeResolutionService = new IrodsextDataTypeResolutionService( + irodsAccessObjectFactory, irodsAccount, dataTyperSettings); + return dataTypeResolutionService; + } + + /** + * Just a sanity check + */ + private void validateDependencies() { + if (irodsAccessObjectFactory == null) { + throw new JargonRuntimeException("null irodsAccessObjectFactory"); + } + + if (dataTyperSettings == null) { + throw new JargonRuntimeException("null dataTyperSettings"); + } + } + +} diff --git a/pom.xml b/pom.xml index a57b871..00e2a9e 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,18 @@ jargon-extensions-if ${project.version} + + org.springframework + spring-beans + + + org.springframework + spring-context + + + org.springframework + spring-core + diff --git a/target/jargon-irods-ext-4.2.1.0-SNAPSHOT.jar b/target/jargon-irods-ext-4.2.1.0-SNAPSHOT.jar index d529165..bfd16ce 100644 Binary files a/target/jargon-irods-ext-4.2.1.0-SNAPSHOT.jar and b/target/jargon-irods-ext-4.2.1.0-SNAPSHOT.jar differ