diff --git a/dspace-api/pom.xml b/dspace-api/pom.xml
index fe07777d263e..c83141474d33 100644
--- a/dspace-api/pom.xml
+++ b/dspace-api/pom.xml
@@ -434,19 +434,14 @@
1.0
- gr.ekt
- biblio-transformation-engine
- 0.82
+ gr.ekt.bte
+ bte-core
+ 0.9
- net.sf.opencsv
- opencsv
- 2.3
-
-
- org.jbibtex
- jbibtex
- 1.0.0
+ gr.ekt.bte
+ bte-io
+ 0.9
org.apache.solr
diff --git a/dspace-api/src/main/java/org/dspace/app/itemimport/DataLoaderService.java b/dspace-api/src/main/java/org/dspace/app/itemimport/DataLoaderService.java
index 99cb0f9f95e1..30356c07994e 100644
--- a/dspace-api/src/main/java/org/dspace/app/itemimport/DataLoaderService.java
+++ b/dspace-api/src/main/java/org/dspace/app/itemimport/DataLoaderService.java
@@ -7,11 +7,11 @@
*/
package org.dspace.app.itemimport;
+import gr.ekt.bte.core.DataLoader;
+
import java.util.HashMap;
import java.util.Map;
-import gr.ekt.transformationengine.core.DataLoader;
-
@@ -22,6 +22,7 @@ public class DataLoaderService
{
Map dataLoaders = new HashMap();
+ Map outputMap = new HashMap();
/**
* Default constructor
@@ -48,5 +49,21 @@ public Map getDataLoaders()
{
return dataLoaders;
}
-
-}
+
+ /**
+ *
+ * @return the outputMapping
+ */
+ public Map getOutputMap() {
+ return outputMap;
+ }
+
+ /**
+ * Setter method for the outputMapping
+ * @param outputMapping
+ */
+ public void setOutputMap(Map outputMap) {
+ this.outputMap = outputMap;
+ }
+
+}
\ No newline at end of file
diff --git a/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImport.java b/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImport.java
index dce235d9497e..9f8bf4b75dfe 100644
--- a/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImport.java
+++ b/dspace-api/src/main/java/org/dspace/app/itemimport/ItemImport.java
@@ -7,13 +7,12 @@
*/
package org.dspace.app.itemimport;
-import gr.ekt.transformationengine.core.DataLoader;
-import gr.ekt.transformationengine.core.TransformationEngine;
-import gr.ekt.transformationengine.exceptions.UnimplementedAbstractMethod;
-import gr.ekt.transformationengine.exceptions.UnknownClassifierException;
-import gr.ekt.transformationengine.exceptions.UnknownInputFileType;
-import gr.ekt.transformationengine.exceptions.UnsupportedComparatorMode;
-import gr.ekt.transformationengine.exceptions.UnsupportedCriterion;
+import gr.ekt.bte.core.DataLoader;
+import gr.ekt.bte.core.TransformationEngine;
+import gr.ekt.bte.core.TransformationResult;
+import gr.ekt.bte.core.TransformationSpec;
+import gr.ekt.bte.dataloader.FileDataLoader;
+import gr.ekt.bteio.generators.DSpaceOutputGenerator;
import java.io.*;
import java.sql.SQLException;
@@ -54,6 +53,7 @@
import org.dspace.eperson.Group;
import org.dspace.handle.HandleManager;
import org.dspace.search.DSIndexer;
+import org.dspace.utils.DSpace;
import org.dspace.workflow.WorkflowManager;
import org.dspace.xmlworkflow.XmlWorkflowManager;
import org.w3c.dom.Document;
@@ -62,7 +62,6 @@
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
-import org.dspace.utils.DSpace;
/**
* Import items into DSpace. The conventional use is upload files by copying
@@ -206,7 +205,7 @@ public static void main(String[] argv) throws Exception
if (line.hasOption('i'))
{
- bteInputType = line.getOptionValue('i');;
+ bteInputType = line.getOptionValue('i');
}
if (line.hasOption('w'))
@@ -314,13 +313,7 @@ else if ("add".equals(command) || "replace".equals(command))
}
else if ("add-bte".equals(command))
{
- if (sourcedir == null)
- {
- System.out
- .println("Error - a source file containing items must be set");
- System.out.println(" (run with -h flag for details)");
- System.exit(1);
- }
+ //Source dir can be null, the user can specify the parameters for his loader in the Spring XML configuration file
if (mapfile == null)
{
@@ -638,36 +631,51 @@ private void addBTEItems(Context c, Collection[] mycollections,
DataLoaderService dls = new DSpace().getSingletonService(DataLoaderService.class);
DataLoader dataLoader = dls.getDataLoaders().get(inputType);
+ Map outputMap = dls.getOutputMap();
+ if (dataLoader==null){
+ System.out.println("ERROR: The key used in -i parameter must match a valid DataLoader in the BTE Spring XML configuration file!");
+ return;
+ }
+
+ if (outputMap==null){
+ System.out.println("ERROR: The key used in -i parameter must match a valid outputMapping in the BTE Spring XML configuration file!");
+ return;
+ }
+
+ if (dataLoader instanceof FileDataLoader){
+ FileDataLoader fdl = (FileDataLoader) dataLoader;
+ if (!"".equals(sourceDir)){
+ System.out.println("INFO: Dataloader will load data from the file specified in the command prompt (and not from the Spring XML configuration file)");
+ fdl.setFilename(sourceDir);
+ }
+ }
+
if (dataLoader!=null){
- System.out.println("INFO: Dataloader " + dataLoader.toString()+" will be used for the import!");
-
- dataLoader.setFileName(sourceDir);
- te.setDataLoader(dataLoader);
+ System.out.println("INFO: Dataloader " + dataLoader.toString()+" will be used for the import!");
- try {
- te.transform();
- } catch (UnknownClassifierException e) {
- e.printStackTrace();
- } catch (UnknownInputFileType e) {
- e.printStackTrace();
- } catch (UnimplementedAbstractMethod e) {
- e.printStackTrace();
- } catch (UnsupportedComparatorMode e) {
- e.printStackTrace();
- } catch (UnsupportedCriterion e) {
- e.printStackTrace();
- }
+ te.setDataLoader(dataLoader);
+
+ DSpaceOutputGenerator outputGenerator = new DSpaceOutputGenerator(outputMap);
+ outputGenerator.setOutputDirectory("./.bte_output_dspace");
+
+ te.setOutputGenerator(outputGenerator);
- ItemImport myloader = new ItemImport();
- myloader.addItems(c, mycollections, "./bte_output_dspace", mapFile, template);
- //remove files from output generator
- deleteDirectory(new File("./bte_output_dspace"));
- }
- else {
- System.out.println("Error: The key used in -i parameter must match a valid DataLoader in the BTE Spring XML configuration file!");
- return;
+ try {
+ TransformationResult res = te.transform(new TransformationSpec());
+ List output = res.getOutput();
+ outputGenerator.writeOutput(output);
+ } catch (Exception e) {
+ System.err.println("Exception");
+ e.printStackTrace();
+ }
+
+ ItemImport myloader = new ItemImport();
+ myloader.addItems(c, mycollections, "./.bte_output_dspace", mapFile, template);
+
+ //remove files from output generator
+ deleteDirectory(new File("./.bte_output_dspace"));
}
}
@@ -1546,7 +1554,7 @@ private void registerBitstream(Context c, Item i, int assetstore,
// find the bundle
Bundle[] bundles = i.getBundles(newBundleName);
Bundle targetBundle = null;
-
+
if( bundles.length < 1 )
{
// not found, create a new one
@@ -1557,19 +1565,19 @@ private void registerBitstream(Context c, Item i, int assetstore,
// put bitstreams into first bundle
targetBundle = bundles[0];
}
-
+
// now add the bitstream
bs = targetBundle.registerBitstream(assetstore, bitstreamPath);
-
+
// set the name to just the filename
int iLastSlash = bitstreamPath.lastIndexOf('/');
bs.setName(bitstreamPath.substring(iLastSlash + 1));
-
+
// Identify the format
// FIXME - guessing format guesses license.txt incorrectly as a text file format!
BitstreamFormat bf = FormatIdentifier.guessFormat(c, bs);
bs.setFormat(bf);
-
+
bs.update();
}
}
@@ -1876,4 +1884,4 @@ private static boolean deleteDirectory(File path)
boolean pathDeleted = path.delete();
return (pathDeleted);
}
-}
+}
\ No newline at end of file
diff --git a/dspace/config/spring/api/bte.xml b/dspace/config/spring/api/bte.xml
index dc714f83f510..b061df680c6f 100644
--- a/dspace/config/spring/api/bte.xml
+++ b/dspace/config/spring/api/bte.xml
@@ -3,175 +3,189 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
-
-
-
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
-
-
-
+
+
+
+
+
+
-
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file