mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
Comment and minor improvements
This commit is contained in:
@@ -19,9 +19,10 @@ import org.dspace.importer.external.service.components.dto.PlainMetadataKeyValue
|
||||
import org.dspace.importer.external.service.components.dto.PlainMetadataSourceDto;
|
||||
|
||||
/**
|
||||
* Metadata contributor that takes an PlainMetadataSourceDto instance and turns it into a metadatum
|
||||
* Metadata contributor that takes an PlainMetadataSourceDto instance and turns it into a
|
||||
* collection of metadatum
|
||||
*
|
||||
* @author Roeland Dillen (roeland at atmire dot com)
|
||||
* @author Pasquale Cavallo (pasquale.cavallo at 4science dot it)
|
||||
*/
|
||||
public class SimpleMetadataContributor implements MetadataContributor<PlainMetadataSourceDto> {
|
||||
|
||||
@@ -57,25 +58,21 @@ public class SimpleMetadataContributor implements MetadataContributor<PlainMetad
|
||||
* In case of success, new metadatum is constructer (using field elements and PlainMetadataSourceDto value)
|
||||
* and added to the list.
|
||||
*
|
||||
* @param t A class to retrieve metadata and key to match from.
|
||||
* @param t A class to retrieve metadata and key to match from. t and contained list "metadata" MUST be not null.
|
||||
* @return a collection of import records. Only the identifier of the found records may be put in the record.
|
||||
*/
|
||||
@Override
|
||||
public Collection<MetadatumDTO> contributeMetadata(PlainMetadataSourceDto t) {
|
||||
List<MetadatumDTO> values = new LinkedList<>();
|
||||
try {
|
||||
for (PlainMetadataKeyValueItem metadatum : t.getMetadata()) {
|
||||
if (metadatum.getKey().equals(key)) {
|
||||
MetadatumDTO dcValue = new MetadatumDTO();
|
||||
dcValue.setValue(metadatum.getValue());
|
||||
dcValue.setElement(field.getElement());
|
||||
dcValue.setQualifier(field.getQualifier());
|
||||
dcValue.setSchema(field.getSchema());
|
||||
values.add(dcValue);
|
||||
}
|
||||
for (PlainMetadataKeyValueItem metadatum : t.getMetadata()) {
|
||||
if (key.equals(metadatum.getKey())) {
|
||||
MetadatumDTO dcValue = new MetadatumDTO();
|
||||
dcValue.setValue(metadatum.getValue());
|
||||
dcValue.setElement(field.getElement());
|
||||
dcValue.setQualifier(field.getQualifier());
|
||||
dcValue.setSchema(field.getSchema());
|
||||
values.add(dcValue);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
@@ -28,7 +28,8 @@ import org.springframework.beans.factory.annotation.Required;
|
||||
*
|
||||
* @author Roeland Dillen (roeland at atmire dot com)
|
||||
*/
|
||||
public abstract class AbstractImportMetadataSourceService<RecordType> extends AbstractRemoteMetadataSource {
|
||||
public abstract class AbstractImportMetadataSourceService<RecordType> extends AbstractRemoteMetadataSource
|
||||
implements MetadataSource {
|
||||
private GenerateQueryService generateQueryForItem = null;
|
||||
private MetadataFieldMapping<RecordType, MetadataContributor<RecordType>> metadataFieldMapping;
|
||||
|
||||
|
@@ -12,24 +12,37 @@ package org.dspace.importer.external.service.components.dto;
|
||||
*
|
||||
* @author Pasquale Cavallo (pasquale.cavallo at 4science dot it)
|
||||
*/
|
||||
|
||||
public class PlainMetadataKeyValueItem {
|
||||
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
/*
|
||||
* In a key-value items, like PlainMetadata, this method get the item's key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/*
|
||||
* In a key-value items, like PlainMetadata, this method set the item's key.
|
||||
* Never set or leave this field to null
|
||||
*
|
||||
*/
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/*
|
||||
* In key-value items, like PlainMetadata, this method get the item's value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* In key-value items, like PlainMetadata, this method set the item's value
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
@@ -21,10 +21,16 @@ public class PlainMetadataSourceDto {
|
||||
|
||||
private List<PlainMetadataKeyValueItem> metadata;
|
||||
|
||||
/*
|
||||
* Method used to get the Metadata list
|
||||
*/
|
||||
public List<PlainMetadataKeyValueItem> getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/*
|
||||
* Method used to set the metadata list
|
||||
*/
|
||||
public void setMetadata(List<PlainMetadataKeyValueItem> metadata) {
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
@@ -53,13 +53,6 @@
|
||||
<!-- <property name="metadataFieldMapping" ref="BibtexMetadataFieldMapping"/> -->
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
<bean id="BibtexMetadataFieldMapping"
|
||||
class="org.dspace.importer.external.bibtex.service.BibtexFieldMapping">
|
||||
</bean>
|
||||
-->
|
||||
|
||||
|
||||
<!-- Metadatafield used to check against if it's already imported or not during the JSONLookupSearcher-->
|
||||
<bean id="lookupID" class="org.dspace.importer.external.metadatamapping.MetadataFieldConfig">
|
||||
<constructor-arg value="dc.identifier.other"/>
|
||||
|
@@ -900,7 +900,7 @@ public class WorkspaceItemRestRepositoryIT extends AbstractControllerIntegration
|
||||
String authToken = getAuthToken(eperson.getEmail(), password);
|
||||
// bulk create workspaceitems in the default collection (col1)
|
||||
getClient(authToken).perform(fileUpload("/api/submission/workspaceitems")
|
||||
.file(bibtexFile).param("owningCollection", col1.getID().toString()))
|
||||
.file(bibtexFile).param("projection", "full"))
|
||||
// bulk create should return 200, 201 (created) is better for single resource
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$._embedded.workspaceitems[0].sections.traditionalpageone['dc.title'][0].value",
|
||||
|
Reference in New Issue
Block a user