forked from DSpace/DSpace
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged in task/dspace-cris-2023_02_x/DSC-1935 (pull request DSpace#2789)
[DSC-1935] Update Datacite schema Approved-by: Stefano Maffei
- Loading branch information
Showing
8 changed files
with
244 additions
and
22 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...ain/java/org/dspace/content/integration/crosswalks/virtualfields/VirtualFieldAtPlace.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,49 @@ | ||
/** | ||
* 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.content.integration.crosswalks.virtualfields; | ||
|
||
import java.util.List; | ||
|
||
import org.apache.commons.collections4.CollectionUtils; | ||
import org.dspace.content.Item; | ||
import org.dspace.content.MetadataValue; | ||
import org.dspace.content.service.ItemService; | ||
import org.dspace.core.Context; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
/** | ||
* Builds the values at specific place. | ||
* | ||
* @author Mohamed Eskander (mohamed.eskander at 4science.com) | ||
*/ | ||
public class VirtualFieldAtPlace implements VirtualField { | ||
|
||
private final ItemService itemService; | ||
|
||
@Autowired | ||
public VirtualFieldAtPlace(ItemService itemService) { | ||
this.itemService = itemService; | ||
} | ||
|
||
public String[] getMetadata(Context context, Item item, String fieldName) { | ||
String[] virtualFieldName = fieldName.split("\\.", 4); | ||
if (virtualFieldName.length != 4) { | ||
return new String[] {}; | ||
} | ||
|
||
String metadataField = virtualFieldName[2].replaceAll("-", "."); | ||
int place = Integer.parseInt(virtualFieldName[3]); | ||
List<MetadataValue> values = itemService.getMetadataByMetadataString(item, metadataField); | ||
if (CollectionUtils.isEmpty(values)) { | ||
return null; | ||
} | ||
|
||
return new String[] { values.get(place).getValue() }; | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...pi/src/test/data/dspaceFolder/assetstore/crosswalk/publication-virtual-place-datacite.xml
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,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<resource | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://datacite.org/schema/kernel-4" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4/metadata.xsd"> | ||
<creators> | ||
<creator> | ||
<creatorName>(:unav)</creatorName> | ||
</creator> | ||
</creators> | ||
<titles> | ||
<title>Publication title</title> | ||
</titles> | ||
<publisher | ||
publisherIdentifier="rorID2" publisherIdentifierScheme="ROR" schemeURI="https://ror.org/" | ||
>Publisher</publisher> | ||
<publicationYear>2023</publicationYear> | ||
<dates> | ||
<date dateType="Issued">2023</date> | ||
<date dateType="Available">2023-10-20</date> | ||
</dates> | ||
<language>it</language> | ||
<resourceType resourceTypeGeneral="Other"> | ||
Unknown | ||
</resourceType> | ||
<alternateIdentifiers> | ||
<alternateIdentifier alternateIdentifierType="url">http://localhost:4000/handle/123456789/99999</alternateIdentifier> | ||
</alternateIdentifiers> | ||
<rightsList> | ||
</rightsList> | ||
<descriptions> | ||
</descriptions> | ||
</resource> |
31 changes: 31 additions & 0 deletions
31
.../data/dspaceFolder/assetstore/crosswalk/publication-without-authors-and-type-datacite.xml
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,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<resource | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://datacite.org/schema/kernel-4" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4/metadata.xsd"> | ||
<creators> | ||
<creator> | ||
<creatorName>(:unav)</creatorName> | ||
</creator> | ||
</creators> | ||
<titles> | ||
<title>Publication title</title> | ||
</titles> | ||
<publisher | ||
publisherIdentifier="rorID2" publisherIdentifierScheme="ROR" schemeURI="https://ror.org/" | ||
>Publisher</publisher> | ||
<publicationYear>2023</publicationYear> | ||
<dates> | ||
<date dateType="Issued">2023</date> | ||
<date dateType="Available">2023-10-20</date> | ||
</dates> | ||
<resourceType resourceTypeGeneral="Other"> | ||
Unknown | ||
</resourceType> | ||
<alternateIdentifiers> | ||
<alternateIdentifier alternateIdentifierType="url">http://localhost:4000/handle/123456789/99999</alternateIdentifier> | ||
</alternateIdentifiers> | ||
<rightsList> | ||
</rightsList> | ||
<descriptions> | ||
</descriptions> | ||
</resource> |
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
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