Skip to content

Commit

Permalink
#1 add factories
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Dec 29, 2017
1 parent 7938beb commit d153360
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}
}

}
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@
<artifactId>jargon-extensions-if</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Binary file modified target/jargon-irods-ext-4.2.1.0-SNAPSHOT.jar
Binary file not shown.

0 comments on commit d153360

Please sign in to comment.