Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #346 by adding system to support the different types of external …
…lobs Implemented the option to add filter modules in between import and export modules when running dbptk: DBPTK help now shows available filter module names; Using -help <filter name> displays the list of parameters received by that filter; Using --filter or -f with the name of one or more filters (separated by ',') injects these filters (in the same order they are written in) into the workflow; Passing parameters to the filters is done using --filter<n>-<param long name> or -f<n><param short name> (where 'n' is the position of the filter in the list [starting at 1]). Implemented base system to support different types of external lobs: Added filter module to support handling of external lobs which can be added to the workflow using '--filter external-lobs', this filter requires at least two parameters: '--filter<n>-column-list [path to file]' which points to the file containing the list of columns in the database that reference external lobs (this file follows the same syntax as the one exported from the 'list-tables' module; '--filter<n>-reference-type [reference type]' which defines the strategy used to fetch the external lobs (ex.: file-system); Implemented abstract class ExternalLOBSCellHandler to ease the development of solutions for different types of external lobs by simply initializing a implementation of this class and passing it to the ExternalLOBSFilter. Implemented solution for external lobs on local file system
- Loading branch information
1 parent
26ab591
commit 339fd5d
Showing
16 changed files
with
756 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
203 changes: 176 additions & 27 deletions
203
dbptk-core/src/main/java/com/databasepreservation/cli/CLI.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...l/src/main/java/com/databasepreservation/model/modules/filters/DatabaseFilterFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.databasepreservation.model.modules.filters; | ||
|
||
import java.util.Map; | ||
|
||
import com.databasepreservation.model.Reporter; | ||
import com.databasepreservation.model.exception.ModuleException; | ||
import com.databasepreservation.model.parameters.Parameter; | ||
import com.databasepreservation.model.parameters.Parameters; | ||
|
||
/** | ||
* Defines a factory used to create Filter Modules. This factory should also be | ||
* able to inform the parameters needed to create a new filter module. | ||
* | ||
* @author Tomás Ferreira <tferreira@keep.pt> | ||
*/ | ||
public interface DatabaseFilterFactory { | ||
String getFilterName(); | ||
|
||
boolean isEnabled(); | ||
|
||
Parameters getParameters(); | ||
|
||
Map<String, Parameter> getAllParameters(); | ||
|
||
DatabaseFilterModule buildFilterModule(Map<Parameter, String> parameters, Reporter reporter) throws ModuleException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>dbptk-modules</artifactId> | ||
<groupId>com.databasepreservation</groupId> | ||
<version>2.2.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<name>dbptk-filter-external-lobs</name> | ||
<groupId>com.databasepreservation</groupId> | ||
<artifactId>dbptk-filter-external-lobs</artifactId> | ||
<version>2.2.0-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<!-- internal dependencies --> | ||
<dependency> | ||
<groupId>com.databasepreservation</groupId> | ||
<artifactId>dbptk-model</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.databasepreservation</groupId> | ||
<artifactId>dbptk-module-list-tables</artifactId> | ||
</dependency> | ||
</dependencies> | ||
</project> |
44 changes: 44 additions & 0 deletions
44
...basepreservation/modules/externalLobs/CellHandlers/ExternalLOBSCellHandlerFileSystem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.databasepreservation.modules.externalLobs.CellHandlers; | ||
|
||
import com.databasepreservation.model.data.BinaryCell; | ||
import com.databasepreservation.model.data.Cell; | ||
import com.databasepreservation.model.exception.ModuleException; | ||
import com.databasepreservation.modules.externalLobs.ExternalLOBSCellHandler; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
public class ExternalLOBSCellHandlerFileSystem implements ExternalLOBSCellHandler { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(ExternalLOBSCellHandlerFileSystem.class); | ||
private Path basePath; | ||
|
||
public ExternalLOBSCellHandlerFileSystem() { | ||
basePath = null; | ||
} | ||
|
||
public ExternalLOBSCellHandlerFileSystem(Path basePath) { | ||
this.basePath = basePath; | ||
} | ||
|
||
@Override | ||
public BinaryCell handleCell(String cellId, String cellValue) throws ModuleException { | ||
Path blobPath = basePath.resolve(cellValue); | ||
BinaryCell newCell = null; | ||
|
||
try (InputStream stream = Files.newInputStream(blobPath)) { | ||
newCell = new BinaryCell(cellId, stream); | ||
} catch (IOException e) { | ||
LOGGER.debug("Could not open stream to file", e); | ||
} | ||
return newCell; | ||
} | ||
|
||
@Override | ||
public String handleTypeDescription(String originalTypeDescription) { | ||
return "Converted to LOB referenced by file system path (original description: '"+originalTypeDescription+"')"; | ||
} | ||
} |
Oops, something went wrong.