Class CharacterSeparatedImportMetadataSourceServiceImpl
java.lang.Object
org.dspace.importer.external.metadatamapping.AbstractMetadataFieldMapping<PlainMetadataSourceDto>
org.dspace.importer.external.service.components.AbstractPlainMetadataSource
org.dspace.importer.external.csv.service.CharacterSeparatedImportMetadataSourceServiceImpl
- All Implemented Interfaces:
MetadataFieldMapping<PlainMetadataSourceDto,,MetadataContributor<PlainMetadataSourceDto>> FileSource,MetadataSource
This class is an implementation of
MetadataSource which extends AbstractPlainMetadataSource
in order to parse "character separated" files like csv, tsv, etc using the Live Import framework.- Author:
- Pasquale Cavallo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionThe string that identifies this import implementation.protected List<PlainMetadataSourceDto>readData(InputStream inputStream) The method process any kind of "character separated" files, like CSV, TSV, and so on.voidsetEscapeCharacter(char escapeCharacter) Method to inject the escape character, usually \.voidsetImportSource(String importSource) Method to set the name of the sourcevoidsetMetadataFieldMap(Map<MetadataFieldConfig, MetadataContributor<PlainMetadataSourceDto>> metadataFieldMap) Defines which metadatum is mapped on which metadatum.voidsetQuoteCharacter(char quoteCharacter) Method to inject the escape character, usually ".voidsetSeparator(char separator) Method to inject the separator This must be the ASCII integer related to the char.voidsetSkipLines(Integer skipLines) Set the number of lines to skip at the start of the file.Methods inherited from class org.dspace.importer.external.service.components.AbstractPlainMetadataSource
getRecord, getRecords, getSupportedExtensions, setSupportedExtensionsMethods inherited from class org.dspace.importer.external.metadatamapping.AbstractMetadataFieldMapping
getMetadataFieldMap, getMetadataProcessor, resultToDCValueMapping, setMetadataProcessorMap, toDCValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.dspace.importer.external.service.components.FileSource
isValidSourceForFile
-
Constructor Details
-
CharacterSeparatedImportMetadataSourceServiceImpl
public CharacterSeparatedImportMetadataSourceServiceImpl()
-
-
Method Details
-
setSkipLines
Set the number of lines to skip at the start of the file. This method is suitable, for example, to skip file headers.- Parameters:
skipLines- number of the line at the start of the file to skip.
-
getSkipLines
- Returns:
- the number of the lines to skip
-
setSeparator
public void setSeparator(char separator) Method to inject the separator This must be the ASCII integer related to the char. In example, 9 for tab, 44 for comma -
setQuoteCharacter
public void setQuoteCharacter(char quoteCharacter) Method to inject the escape character, usually ". This must be the ASCII integer related to the char. In example, 9 for tab, 44 for comma -
setEscapeCharacter
public void setEscapeCharacter(char escapeCharacter) Method to inject the escape character, usually \. This must be the ASCII integer related to the char. In example, 9 for tab, 44 for comma -
getImportSource
Description copied from interface:MetadataSourceThe string that identifies this import implementation. Preferable a URI- Returns:
- the identifying uri
-
setImportSource
Method to set the name of the source -
readData
The method process any kind of "character separated" files, like CSV, TSV, and so on. It return a List of PlainMetadataSourceDto. Using the superclass methods AbstractPlainMetadataSource.getRecord(s), any of this element will then be converted in anImportRecord. Columns will be identified by their position, zero based notation. Separator character and escape character MUST be defined at class level. Number of lines to skip (headers) could also be defined in the field skipLines.- Specified by:
readDatain classAbstractPlainMetadataSource- Parameters:
InputStream- The inputStream of the file- Returns:
- A list of PlainMetadataSourceDto
- Throws:
FileSourceException- if, for any reason, the file is not parsable
-
setMetadataFieldMap
public void setMetadataFieldMap(Map<MetadataFieldConfig, MetadataContributor<PlainMetadataSourceDto>> metadataFieldMap) Description copied from class:AbstractMetadataFieldMappingDefines which metadatum is mapped on which metadatum. Note that while the key must be unique it only matters here for postprocessing of the value. The mapped MetadatumContributor has full control over what metadatafield is generated.- Overrides:
setMetadataFieldMapin classAbstractMetadataFieldMapping<PlainMetadataSourceDto>- Parameters:
metadataFieldMap- The map containing the link between retrieve metadata and metadata that will be set to the item.
-