mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Update from DSpace master
This commit is contained in:
@@ -332,6 +332,21 @@
|
||||
<artifactId>rome-modules</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>gr.ekt</groupId>
|
||||
<artifactId>biblio-transformation-engine</artifactId>
|
||||
<version>0.81</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.opencsv</groupId>
|
||||
<artifactId>opencsv</artifactId>
|
||||
<version>2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbibtex</groupId>
|
||||
<artifactId>jbibtex</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* The contents of this file are subject to the license and copyright
|
||||
* detailed in the LICENSE and NOTICE files at the root of the source
|
||||
* tree and available online at
|
||||
*
|
||||
* http://www.dspace.org/license/
|
||||
*/
|
||||
package org.dspace.app.itemimport;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import gr.ekt.transformationengine.core.DataLoader;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class acts as a Service in the procedure ot batch import using the Biblio-Transformation-Engine
|
||||
*/
|
||||
public class DataLoaderService
|
||||
{
|
||||
|
||||
Map<String, DataLoader> dataLoaders = new HashMap<String, DataLoader>();
|
||||
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public DataLoaderService()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter method for dataLoaders parameter
|
||||
* @param dataLoaders
|
||||
*/
|
||||
public void setDataLoaders(Map<String, DataLoader> dataLoaders)
|
||||
{
|
||||
this.dataLoaders = dataLoaders;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the map of DataLoaders
|
||||
*/
|
||||
public Map<String, DataLoader> getDataLoaders()
|
||||
{
|
||||
return dataLoaders;
|
||||
}
|
||||
|
||||
}
|
@@ -7,6 +7,14 @@
|
||||
*/
|
||||
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 java.io.*;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
@@ -54,6 +62,8 @@ import org.w3c.dom.Node;
|
||||
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
|
||||
* them. DSpace writes the item's bitstreams into its assetstore. Metadata is
|
||||
@@ -122,9 +132,11 @@ public class ItemImport
|
||||
Options options = new Options();
|
||||
|
||||
options.addOption("a", "add", false, "add items to DSpace");
|
||||
options.addOption("b", "add-bte", false, "add items to DSpace via Biblio-Transformation-Engine (BTE)");
|
||||
options.addOption("r", "replace", false, "replace items in mapfile");
|
||||
options.addOption("d", "delete", false,
|
||||
"delete items listed in mapfile");
|
||||
options.addOption("i", "inputtype", true, "input type in case of BTE import");
|
||||
options.addOption("s", "source", true, "source of items (directory)");
|
||||
options.addOption("z", "zip", true, "name of zip file");
|
||||
options.addOption("c", "collection", true,
|
||||
@@ -148,6 +160,7 @@ public class ItemImport
|
||||
CommandLine line = parser.parse(options, argv);
|
||||
|
||||
String command = null; // add replace remove, etc
|
||||
String bteInputType = null; //ris, endnote, tsv, csv, bibtex
|
||||
String sourcedir = null;
|
||||
String mapfile = null;
|
||||
String eperson = null; // db ID or email
|
||||
@@ -185,6 +198,16 @@ public class ItemImport
|
||||
{
|
||||
command = "delete";
|
||||
}
|
||||
|
||||
if (line.hasOption('b'))
|
||||
{
|
||||
command = "add-bte";
|
||||
}
|
||||
|
||||
if (line.hasOption('i'))
|
||||
{
|
||||
bteInputType = line.getOptionValue('i');;
|
||||
}
|
||||
|
||||
if (line.hasOption('w'))
|
||||
{
|
||||
@@ -289,6 +312,48 @@ public class ItemImport
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
if (mapfile == null)
|
||||
{
|
||||
System.out
|
||||
.println("Error - a map file to hold importing results must be specified");
|
||||
System.out.println(" (run with -h flag for details)");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (eperson == null)
|
||||
{
|
||||
System.out
|
||||
.println("Error - an eperson to do the importing must be specified");
|
||||
System.out.println(" (run with -h flag for details)");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (collections == null)
|
||||
{
|
||||
System.out
|
||||
.println("Error - at least one destination collection must be specified");
|
||||
System.out.println(" (run with -h flag for details)");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
if (bteInputType == null)
|
||||
{
|
||||
System.out
|
||||
.println("Error - an input type (tsv, csv, ris, endnote, bibtex or any other type you have specified in BTE Spring XML configuration file) must be specified");
|
||||
System.out.println(" (run with -h flag for details)");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
else if ("delete".equals(command))
|
||||
{
|
||||
if (eperson == null)
|
||||
@@ -505,6 +570,10 @@ public class ItemImport
|
||||
{
|
||||
myloader.deleteItems(c, mapfile);
|
||||
}
|
||||
else if ("add-bte".equals(command))
|
||||
{
|
||||
myloader.addBTEItems(c, mycollections, sourcedir, mapfile, template, bteInputType);
|
||||
}
|
||||
|
||||
// complete all transactions
|
||||
c.complete();
|
||||
@@ -562,6 +631,47 @@ public class ItemImport
|
||||
System.exit(status);
|
||||
}
|
||||
|
||||
private void addBTEItems(Context c, Collection[] mycollections,
|
||||
String sourceDir, String mapFile, boolean template, String inputType) throws Exception
|
||||
{
|
||||
TransformationEngine te = new DSpace().getSingletonService(TransformationEngine.class);
|
||||
|
||||
DataLoaderService dls = new DSpace().getSingletonService(DataLoaderService.class);
|
||||
DataLoader dataLoader = dls.getDataLoaders().get(inputType);
|
||||
|
||||
if (dataLoader!=null){
|
||||
System.out.println("INFO: Dataloader " + dataLoader.toString()+" will be used for the import!");
|
||||
|
||||
dataLoader.setFileName(sourceDir);
|
||||
te.setDataLoader(dataLoader);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addItems(Context c, Collection[] mycollections,
|
||||
String sourceDir, String mapFile, boolean template) throws Exception
|
||||
{
|
||||
@@ -746,7 +856,7 @@ public class ItemImport
|
||||
+ File.separatorChar);
|
||||
|
||||
// and the bitstreams from the contents file
|
||||
// process contents file, add bitstreams and bundles, return any
|
||||
// process contents file, add bistreams and bundles, return any
|
||||
// non-standard permissions
|
||||
List<String> options = processContentsFile(c, myitem, path
|
||||
+ File.separatorChar + itemname, "contents");
|
||||
|
@@ -1403,6 +1403,15 @@ webui.bitstream.order.field = bitstream_order
|
||||
google-metadata.config = ${dspace.dir}/config/crosswalks/google-metadata.properties
|
||||
google-metadata.enable = true
|
||||
|
||||
|
||||
#### DSpace services configuration ####
|
||||
#
|
||||
# Declare the Spirng xml resources for the SpringServiceManager
|
||||
# (currently, only bibliotransformation-engine xml file)
|
||||
#
|
||||
service.manager.spring.configs=spring/bte/bte.xml
|
||||
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
#--------------JSPUI SPECIFIC CONFIGURATIONS--------------------#
|
||||
#---------------------------------------------------------------#
|
||||
|
177
dspace/config/spring/bte/bte.xml
Normal file
177
dspace/config/spring/bte/bte.xml
Normal file
@@ -0,0 +1,177 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!-- TEST-SPRING.XML -->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
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">
|
||||
|
||||
<bean id="org.dspace.app.itemimport.DataLoaderService" class="org.dspace.app.itemimport.DataLoaderService">
|
||||
<property name="dataLoaders">
|
||||
<map>
|
||||
<entry>
|
||||
<key><value>bibtex</value></key>
|
||||
<ref bean="gr.ekt.transformationengine.dataloaders.dspace.BibTexDataLoader"/>
|
||||
</entry>
|
||||
<entry>
|
||||
<key><value>csv</value></key>
|
||||
<ref bean="gr.ekt.transformationengine.dataloaders.dspace.CSVDataLoader"/>
|
||||
</entry>
|
||||
<entry>
|
||||
<key><value>tsv</value></key>
|
||||
<ref bean="gr.ekt.transformationengine.dataloaders.dspace.TSVDataLoader"/>
|
||||
</entry>
|
||||
<entry>
|
||||
<key><value>endnote</value></key>
|
||||
<ref bean="gr.ekt.transformationengine.dataloaders.dspace.EndnoteDataLoader"/>
|
||||
</entry>
|
||||
<entry>
|
||||
<key><value>ris</value></key>
|
||||
<ref bean="gr.ekt.transformationengine.dataloaders.dspace.RISDataLoader"/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="gr.ekt.transformationengine.core.TransformationEngine" class="gr.ekt.transformationengine.core.TransformationEngine">
|
||||
<property name="workflow" ref="conjunctionTransformationWorkflow"/>
|
||||
<property name="outputGenerator" ref="outputGenerator" />
|
||||
</bean>
|
||||
|
||||
<bean id="gr.ekt.transformationengine.dataloaders.dspace.BibTexDataLoader"
|
||||
class="gr.ekt.transformationengine.dataloaders.dspace.BibTexDataLoader"/>
|
||||
|
||||
<bean id="gr.ekt.transformationengine.dataloaders.dspace.CSVDataLoader"
|
||||
class="gr.ekt.transformationengine.dataloaders.dspace.CSVDataLoader"/>
|
||||
|
||||
<bean id="gr.ekt.transformationengine.dataloaders.dspace.EndnoteDataLoader"
|
||||
class="gr.ekt.transformationengine.dataloaders.dspace.EndnoteDataLoader"/>
|
||||
|
||||
<bean id="gr.ekt.transformationengine.dataloaders.dspace.RISDataLoader"
|
||||
class="gr.ekt.transformationengine.dataloaders.dspace.RISDataLoader"/>
|
||||
|
||||
<bean id="gr.ekt.transformationengine.dataloaders.dspace.TSVDataLoader"
|
||||
class="gr.ekt.transformationengine.dataloaders.dspace.TSVDataLoader"/>
|
||||
|
||||
|
||||
<bean id="conjunctionTransformationWorkflow"
|
||||
class="gr.ekt.transformationengine.core.ConjunctionTransformationWorkflow">
|
||||
<property name="steps">
|
||||
<list>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="dcMap" class="java.util.HashMap">
|
||||
<constructor-arg>
|
||||
<map>
|
||||
<entry>
|
||||
<key>
|
||||
<value>Title</value>
|
||||
</key>
|
||||
<ref bean="titleDSpaceMetadata" />
|
||||
</entry>
|
||||
<entry>
|
||||
<key>
|
||||
<value>Type</value>
|
||||
</key>
|
||||
<ref bean="typeDSpaceMetadata" />
|
||||
</entry>
|
||||
<entry>
|
||||
<key>
|
||||
<value>Author</value>
|
||||
</key>
|
||||
<ref bean="authorDSpaceMetadata" />
|
||||
</entry>
|
||||
<entry>
|
||||
<key>
|
||||
<value>Journal</value>
|
||||
</key>
|
||||
<ref bean="sourceDSpaceMetadata" />
|
||||
</entry>
|
||||
<entry>
|
||||
<key>
|
||||
<value>Year</value>
|
||||
</key>
|
||||
<ref bean="dateDSpaceMetadata" />
|
||||
</entry>
|
||||
<entry>
|
||||
<key>
|
||||
<value>ISSN</value>
|
||||
</key>
|
||||
<ref bean="issnDSpaceMetadata" />
|
||||
</entry>
|
||||
</map>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="ektMap" class="java.util.HashMap">
|
||||
<constructor-arg>
|
||||
<map>
|
||||
<entry>
|
||||
<key>
|
||||
<value>Title</value>
|
||||
</key>
|
||||
<ref bean="titleDSpaceMetadata" />
|
||||
</entry>
|
||||
<entry>
|
||||
<key>
|
||||
<value>Type</value>
|
||||
</key>
|
||||
<ref bean="typeDSpaceMetadata" />
|
||||
</entry>
|
||||
</map>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="outputGenerator"
|
||||
class="gr.ekt.transformationengine.outputGenerators.DSpaceOutputGenerator">
|
||||
<property name="mappings">
|
||||
<map>
|
||||
<entry>
|
||||
<key>
|
||||
<value>dc</value>
|
||||
</key>
|
||||
<ref bean="dcMap" />
|
||||
</entry>
|
||||
<entry>
|
||||
<key>
|
||||
<value>ekt</value>
|
||||
</key>
|
||||
<ref bean="ektMap" />
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
<bean id="titleDSpaceMetadata" class="gr.ekt.transformationengine.dspace.DSpaceMetadata">
|
||||
<property name="schema" value="dc" />
|
||||
<property name="element" value="title" />
|
||||
</bean>
|
||||
<bean id="typeDSpaceMetadata" class="gr.ekt.transformationengine.dspace.DSpaceMetadata">
|
||||
<property name="schema" value="dc" />
|
||||
<property name="element" value="type" />
|
||||
</bean>
|
||||
<bean id="authorDSpaceMetadata" class="gr.ekt.transformationengine.dspace.DSpaceMetadata">
|
||||
<property name="schema" value="dc" />
|
||||
<property name="element" value="contributor" />
|
||||
<property name="qualifier" value="author" />
|
||||
</bean>
|
||||
<bean id="abstractDSpaceMetadata" class="gr.ekt.transformationengine.dspace.DSpaceMetadata">
|
||||
<property name="schema" value="dc" />
|
||||
<property name="element" value="description" />
|
||||
<property name="qualifier" value="abstract" />
|
||||
</bean>
|
||||
<bean id="sourceDSpaceMetadata" class="gr.ekt.transformationengine.dspace.DSpaceMetadata">
|
||||
<property name="schema" value="dc" />
|
||||
<property name="element" value="source" />
|
||||
</bean>
|
||||
<bean id="dateDSpaceMetadata" class="gr.ekt.transformationengine.dspace.DSpaceMetadata">
|
||||
<property name="schema" value="dc" />
|
||||
<property name="element" value="date" />
|
||||
</bean>
|
||||
<bean id="issnDSpaceMetadata" class="gr.ekt.transformationengine.dspace.DSpaceMetadata">
|
||||
<property name="schema" value="dc" />
|
||||
<property name="element" value="identifier" />
|
||||
</bean>
|
||||
</beans>
|
Reference in New Issue
Block a user