mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-07 01:54:22 +00:00
[CST-5587] Fixed tests
This commit is contained in:
@@ -51,7 +51,7 @@ public class OrcidFundingFieldMapping {
|
||||
|
||||
private String descriptionField;
|
||||
|
||||
private String organizationField;
|
||||
private String organizationRelationshipType;
|
||||
|
||||
private Map<String, FundingContributorRole> parseContributors(String contributors) {
|
||||
Map<String, String> contributorsMap = parseConfigurations(contributors);
|
||||
@@ -122,12 +122,12 @@ public class OrcidFundingFieldMapping {
|
||||
this.descriptionField = descriptionField;
|
||||
}
|
||||
|
||||
public String getOrganizationField() {
|
||||
return organizationField;
|
||||
public String getOrganizationRelationshipType() {
|
||||
return organizationRelationshipType;
|
||||
}
|
||||
|
||||
public void setOrganizationField(String organizationField) {
|
||||
this.organizationField = organizationField;
|
||||
public void setOrganizationRelationshipType(String organizationRelationshipType) {
|
||||
this.organizationRelationshipType = organizationRelationshipType;
|
||||
}
|
||||
|
||||
public String getTypeField() {
|
||||
|
@@ -39,13 +39,13 @@ public interface OrcidCommonObjectFactory {
|
||||
public Optional<FuzzyDate> createFuzzyDate(MetadataValue metadataValue);
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link Organization} from the given metadata value.
|
||||
* Creates an instance of {@link Organization} from the given orgUnit item.
|
||||
*
|
||||
* @param context the DSpace context
|
||||
* @param metadataValue the metadata value
|
||||
* @return the created Organization's instance, if any
|
||||
* @param context the DSpace context
|
||||
* @param orgUnit the orgUnit item
|
||||
* @return the created Organization's instance, if any
|
||||
*/
|
||||
public Optional<Organization> createOrganization(Context context, MetadataValue metadataValue);
|
||||
public Optional<Organization> createOrganization(Context context, Item orgUnit);
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link Contributor} from the given metadata value.
|
||||
|
@@ -17,14 +17,12 @@ import static org.dspace.app.orcid.model.factory.OrcidFactoryUtils.parseConfigur
|
||||
import static org.orcid.jaxb.model.common.SequenceType.ADDITIONAL;
|
||||
import static org.orcid.jaxb.model.common.SequenceType.FIRST;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.dspace.app.orcid.client.OrcidConfiguration;
|
||||
@@ -37,19 +35,15 @@ import org.dspace.core.Context;
|
||||
import org.dspace.handle.service.HandleService;
|
||||
import org.dspace.util.MultiFormatDateParser;
|
||||
import org.dspace.util.SimpleMapConverter;
|
||||
import org.dspace.util.UUIDUtils;
|
||||
import org.orcid.jaxb.model.common.ContributorRole;
|
||||
import org.orcid.jaxb.model.common.FundingContributorRole;
|
||||
import org.orcid.jaxb.model.common.Iso3166Country;
|
||||
import org.orcid.jaxb.model.v3.release.common.Contributor;
|
||||
import org.orcid.jaxb.model.v3.release.common.ContributorAttributes;
|
||||
import org.orcid.jaxb.model.v3.release.common.ContributorEmail;
|
||||
import org.orcid.jaxb.model.v3.release.common.ContributorOrcid;
|
||||
import org.orcid.jaxb.model.v3.release.common.Country;
|
||||
import org.orcid.jaxb.model.v3.release.common.CreditName;
|
||||
import org.orcid.jaxb.model.v3.release.common.DisambiguatedOrganization;
|
||||
import org.orcid.jaxb.model.v3.release.common.FuzzyDate;
|
||||
import org.orcid.jaxb.model.v3.release.common.OrcidIdBase;
|
||||
import org.orcid.jaxb.model.v3.release.common.Organization;
|
||||
import org.orcid.jaxb.model.v3.release.common.OrganizationAddress;
|
||||
import org.orcid.jaxb.model.v3.release.common.Url;
|
||||
@@ -76,6 +70,8 @@ public class OrcidCommonObjectFactoryImpl implements OrcidCommonObjectFactory {
|
||||
|
||||
private SimpleMapConverter countryConverter;
|
||||
|
||||
private String organizationTitleField;
|
||||
|
||||
private String organizationCityField;
|
||||
|
||||
private String organizationCountryField;
|
||||
@@ -103,21 +99,17 @@ public class OrcidCommonObjectFactoryImpl implements OrcidCommonObjectFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Organization> createOrganization(Context context, MetadataValue metadataValue) {
|
||||
public Optional<Organization> createOrganization(Context context, Item orgUnit) {
|
||||
|
||||
if (isUnprocessableValue(metadataValue)) {
|
||||
return empty();
|
||||
if (orgUnit == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
Organization organization = new Organization();
|
||||
|
||||
organization.setName(metadataValue.getValue());
|
||||
|
||||
Item organizationItem = findRelatedItem(context, metadataValue);
|
||||
if (organizationItem != null) {
|
||||
organization.setAddress(createOrganizationAddress(organizationItem));
|
||||
organization.setDisambiguatedOrganization(createDisambiguatedOrganization(organizationItem));
|
||||
}
|
||||
organization.setName(getMetadataValue(orgUnit, organizationTitleField));
|
||||
organization.setAddress(createOrganizationAddress(orgUnit));
|
||||
organization.setDisambiguatedOrganization(createDisambiguatedOrganization(orgUnit));
|
||||
|
||||
return of(organization);
|
||||
}
|
||||
@@ -132,12 +124,6 @@ public class OrcidCommonObjectFactoryImpl implements OrcidCommonObjectFactory {
|
||||
contributor.setCreditName(new CreditName(metadataValue.getValue()));
|
||||
contributor.setContributorAttributes(getContributorAttributes(metadataValue, role));
|
||||
|
||||
Item authorItem = findItem(context, UUIDUtils.fromString(metadataValue.getAuthority()));
|
||||
if (authorItem != null) {
|
||||
contributor.setContributorEmail(getContributorEmail(authorItem));
|
||||
contributor.setContributorOrcid(getContributorOrcid(authorItem));
|
||||
}
|
||||
|
||||
return of(contributor);
|
||||
}
|
||||
|
||||
@@ -153,12 +139,6 @@ public class OrcidCommonObjectFactoryImpl implements OrcidCommonObjectFactory {
|
||||
contributor.setCreditName(new CreditName(metadataValue.getValue()));
|
||||
contributor.setContributorAttributes(getFundingContributorAttributes(metadataValue, role));
|
||||
|
||||
Item authorItem = findItem(context, UUIDUtils.fromString(metadataValue.getAuthority()));
|
||||
if (authorItem != null) {
|
||||
contributor.setContributorEmail(getContributorEmail(authorItem));
|
||||
contributor.setContributorOrcid(getContributorOrcid(authorItem));
|
||||
}
|
||||
|
||||
return of(contributor);
|
||||
}
|
||||
|
||||
@@ -183,31 +163,6 @@ public class OrcidCommonObjectFactoryImpl implements OrcidCommonObjectFactory {
|
||||
.map(isoCountry -> new Country(isoCountry));
|
||||
}
|
||||
|
||||
private ContributorOrcid getContributorOrcid(Item authorItem) {
|
||||
String orcid = getMetadataValue(authorItem, contributorOrcidField);
|
||||
return isNotBlank(orcid) ? new ContributorOrcid(getOrcidIdBase(orcid)) : null;
|
||||
}
|
||||
|
||||
private OrcidIdBase getOrcidIdBase(String orcid) {
|
||||
|
||||
OrcidIdBase orcidBase = new OrcidIdBase();
|
||||
orcidBase.setPath(orcid);
|
||||
|
||||
String orcidDomain = orcidConfiguration.getDomainUrl();
|
||||
|
||||
if (StringUtils.isNotBlank(orcidDomain)) {
|
||||
orcidBase.setHost(orcidDomain);
|
||||
orcidBase.setUri(orcidDomain + "/" + orcid);
|
||||
}
|
||||
|
||||
return orcidBase;
|
||||
}
|
||||
|
||||
private ContributorEmail getContributorEmail(Item authorItem) {
|
||||
String email = getMetadataValue(authorItem, contributorEmailField);
|
||||
return isNotBlank(email) ? new ContributorEmail(email) : null;
|
||||
}
|
||||
|
||||
private ContributorAttributes getContributorAttributes(MetadataValue metadataValue, ContributorRole role) {
|
||||
ContributorAttributes attributes = new ContributorAttributes();
|
||||
attributes.setContributorRole(role != null ? role : null);
|
||||
@@ -259,14 +214,6 @@ public class OrcidCommonObjectFactoryImpl implements OrcidCommonObjectFactory {
|
||||
.map(value -> Iso3166Country.fromValue(value));
|
||||
}
|
||||
|
||||
private Item findRelatedItem(Context context, MetadataValue metadataValue) {
|
||||
try {
|
||||
return itemService.find(context, UUIDUtils.fromString(metadataValue.getAuthority()));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isUnprocessableValue(MetadataValue value) {
|
||||
return value == null || isBlank(value.getValue());
|
||||
}
|
||||
@@ -283,14 +230,6 @@ public class OrcidCommonObjectFactoryImpl implements OrcidCommonObjectFactory {
|
||||
return date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
}
|
||||
|
||||
private Item findItem(Context context, UUID uuid) {
|
||||
try {
|
||||
return itemService.find(context, uuid);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getOrganizationCityField() {
|
||||
return organizationCityField;
|
||||
}
|
||||
@@ -355,4 +294,12 @@ public class OrcidCommonObjectFactoryImpl implements OrcidCommonObjectFactory {
|
||||
this.countryConverter = countryConverter;
|
||||
}
|
||||
|
||||
public String getOrganizationTitleField() {
|
||||
return organizationTitleField;
|
||||
}
|
||||
|
||||
public void setOrganizationTitleField(String organizationTitleField) {
|
||||
this.organizationTitleField = organizationTitleField;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -10,11 +10,13 @@ package org.dspace.app.orcid.model.factory.impl;
|
||||
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.Currency;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.dspace.app.orcid.model.OrcidEntityType;
|
||||
import org.dspace.app.orcid.model.OrcidFundingFieldMapping;
|
||||
@@ -22,11 +24,14 @@ import org.dspace.app.orcid.model.factory.OrcidCommonObjectFactory;
|
||||
import org.dspace.app.orcid.model.factory.OrcidEntityFactory;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.MetadataValue;
|
||||
import org.dspace.content.Relationship;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.dspace.content.service.ItemService;
|
||||
import org.dspace.content.service.RelationshipService;
|
||||
import org.dspace.content.service.RelationshipTypeService;
|
||||
import org.dspace.core.Context;
|
||||
import org.orcid.jaxb.model.common.FundingContributorRole;
|
||||
import org.orcid.jaxb.model.common.FundingType;
|
||||
import org.orcid.jaxb.model.common.Relationship;
|
||||
import org.orcid.jaxb.model.v3.release.common.Amount;
|
||||
import org.orcid.jaxb.model.v3.release.common.FuzzyDate;
|
||||
import org.orcid.jaxb.model.v3.release.common.Organization;
|
||||
@@ -60,6 +65,12 @@ public class OrcidFundingFactory implements OrcidEntityFactory {
|
||||
@Autowired
|
||||
private OrcidCommonObjectFactory orcidCommonObjectFactory;
|
||||
|
||||
@Autowired
|
||||
private RelationshipTypeService relationshipTypeService;
|
||||
|
||||
@Autowired
|
||||
private RelationshipService relationshipService;
|
||||
|
||||
private OrcidFundingFieldMapping fieldMapping;
|
||||
|
||||
@Override
|
||||
@@ -131,14 +142,38 @@ public class OrcidFundingFactory implements OrcidEntityFactory {
|
||||
ExternalID externalID = new ExternalID();
|
||||
externalID.setType(type);
|
||||
externalID.setValue(value);
|
||||
externalID.setRelationship(Relationship.SELF);
|
||||
externalID.setRelationship(org.orcid.jaxb.model.common.Relationship.SELF);
|
||||
return externalID;
|
||||
}
|
||||
|
||||
private Organization getOrganization(Context context, Item item) {
|
||||
return getMetadataValue(context, item, fieldMapping.getOrganizationField())
|
||||
.flatMap(metadataValue -> orcidCommonObjectFactory.createOrganization(context, metadataValue))
|
||||
.orElse(null);
|
||||
|
||||
try {
|
||||
|
||||
return relationshipTypeService.findByLeftwardOrRightwardTypeName(context,
|
||||
fieldMapping.getOrganizationRelationshipType()).stream()
|
||||
.flatMap(relationshipType -> getRelationship(context, item, relationshipType))
|
||||
.map(relationship -> getRelatedItem(item, relationship))
|
||||
.flatMap(orgUnit -> orcidCommonObjectFactory.createOrganization(context, orgUnit).stream())
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Stream<Relationship> getRelationship(Context context, Item item, RelationshipType relationshipType) {
|
||||
try {
|
||||
return relationshipService.findByItemAndRelationshipType(context, item, relationshipType).stream();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Item getRelatedItem(Item item, Relationship relationship) {
|
||||
return item.equals(relationship.getLeftItem()) ? relationship.getRightItem() : relationship.getLeftItem();
|
||||
}
|
||||
|
||||
private FuzzyDate getStartDate(Context context, Item item) {
|
||||
|
@@ -11,14 +11,11 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static org.orcid.jaxb.model.common.Relationship.SELF;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.lang3.EnumUtils;
|
||||
@@ -161,10 +158,6 @@ public class OrcidWorkFactory implements OrcidEntityFactory {
|
||||
return selfExternalIds;
|
||||
}
|
||||
|
||||
private boolean isAuthoritySet(String authority) {
|
||||
return isNotBlank(authority);
|
||||
}
|
||||
|
||||
private ExternalID getSelfExternalId(MetadataValue metadataValue) {
|
||||
Map<String, String> externalIdentifierFields = fieldMapping.getExternalIdentifierFields();
|
||||
String metadataField = metadataValue.getMetadataField().toString('.');
|
||||
@@ -227,17 +220,6 @@ public class OrcidWorkFactory implements OrcidEntityFactory {
|
||||
return orcidCommonObjectFactory.createUrl(context, item).orElse(null);
|
||||
}
|
||||
|
||||
private List<MetadataValue> getMetadataValues(Context context, Item item, String metadataField) {
|
||||
if (isBlank(metadataField)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return itemService.getMetadataByMetadataString(item, metadataField);
|
||||
}
|
||||
|
||||
private boolean isNotPlaceholder(MetadataValue metadata) {
|
||||
return metadata != null && metadata.getValue() != null;
|
||||
}
|
||||
|
||||
private List<MetadataValue> getMetadataValues(Context context, Item item, Collection<String> metadataFields) {
|
||||
return metadataFields.stream()
|
||||
.flatMap(metadataField -> itemService.getMetadataByMetadataString(item, metadataField).stream())
|
||||
@@ -255,14 +237,6 @@ public class OrcidWorkFactory implements OrcidEntityFactory {
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
private Optional<Item> findItemById(Context context, UUID id) {
|
||||
try {
|
||||
return Optional.ofNullable(itemService.find(context, id));
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemService getItemService() {
|
||||
return itemService;
|
||||
}
|
||||
|
@@ -407,7 +407,7 @@ public class OrcidQueueConsumerIT extends AbstractIntegrationTestWithDatabase {
|
||||
|
||||
Item publication = ItemBuilder.createItem(context, publicationCollection)
|
||||
.withTitle("Test publication")
|
||||
.withAuthor("Test User", profile.getID().toString())
|
||||
.withAuthor("Test User")
|
||||
.build();
|
||||
|
||||
EntityType publicationType = EntityTypeBuilder.createEntityTypeBuilder(context, "Publication").build();
|
||||
@@ -489,9 +489,17 @@ public class OrcidQueueConsumerIT extends AbstractIntegrationTestWithDatabase {
|
||||
|
||||
Item publication = ItemBuilder.createItem(context, publicationCollection)
|
||||
.withTitle("Test publication")
|
||||
.withAuthor("Test User", profile.getID().toString())
|
||||
.withAuthor("Test User")
|
||||
.build();
|
||||
|
||||
EntityType publicationType = EntityTypeBuilder.createEntityTypeBuilder(context, "Publication").build();
|
||||
EntityType personType = EntityTypeBuilder.createEntityTypeBuilder(context, "Person").build();
|
||||
|
||||
RelationshipType isAuthorOfPublication = createRelationshipTypeBuilder(context, personType, publicationType,
|
||||
"isAuthorOfPublication", "isPublicationOfAuthor", 0, null, 0, null).build();
|
||||
|
||||
RelationshipBuilder.createRelationshipBuilder(context, profile, publication, isAuthorOfPublication).build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
context.commit();
|
||||
|
||||
@@ -555,11 +563,19 @@ public class OrcidQueueConsumerIT extends AbstractIntegrationTestWithDatabase {
|
||||
|
||||
Collection projectCollection = createCollection("Projects", "Project");
|
||||
|
||||
ItemBuilder.createItem(context, projectCollection)
|
||||
Item project = ItemBuilder.createItem(context, projectCollection)
|
||||
.withTitle("Test project")
|
||||
.withAuthor("Test User", profile.getID().toString())
|
||||
.withProjectInvestigator("Test User")
|
||||
.build();
|
||||
|
||||
EntityType projectType = EntityTypeBuilder.createEntityTypeBuilder(context, "Project").build();
|
||||
EntityType personType = EntityTypeBuilder.createEntityTypeBuilder(context, "Person").build();
|
||||
|
||||
RelationshipType isProjectOfPerson = createRelationshipTypeBuilder(context, projectType, personType,
|
||||
"isProjectOfPerson", "isPersonOfProject", 0, null, 0, null).build();
|
||||
|
||||
RelationshipBuilder.createRelationshipBuilder(context, project, profile, isProjectOfPerson).build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
context.commit();
|
||||
|
||||
|
@@ -10,6 +10,7 @@ package org.dspace.app.orcid.service;
|
||||
import static org.apache.commons.lang.StringUtils.endsWith;
|
||||
import static org.dspace.app.matcher.LambdaMatcher.has;
|
||||
import static org.dspace.app.matcher.LambdaMatcher.matches;
|
||||
import static org.dspace.builder.RelationshipTypeBuilder.createRelationshipTypeBuilder;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
@@ -19,7 +20,6 @@ import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.orcid.jaxb.model.common.ContributorRole.AUTHOR;
|
||||
import static org.orcid.jaxb.model.common.ContributorRole.EDITOR;
|
||||
import static org.orcid.jaxb.model.common.FundingContributorRole.CO_LEAD;
|
||||
import static org.orcid.jaxb.model.common.FundingContributorRole.LEAD;
|
||||
import static org.orcid.jaxb.model.common.SequenceType.ADDITIONAL;
|
||||
import static org.orcid.jaxb.model.common.SequenceType.FIRST;
|
||||
@@ -31,21 +31,22 @@ import org.dspace.AbstractIntegrationTestWithDatabase;
|
||||
import org.dspace.app.orcid.factory.OrcidServiceFactory;
|
||||
import org.dspace.builder.CollectionBuilder;
|
||||
import org.dspace.builder.CommunityBuilder;
|
||||
import org.dspace.builder.EntityTypeBuilder;
|
||||
import org.dspace.builder.ItemBuilder;
|
||||
import org.dspace.builder.RelationshipBuilder;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.orcid.jaxb.model.common.ContributorRole;
|
||||
import org.orcid.jaxb.model.common.FundingContributorRole;
|
||||
import org.orcid.jaxb.model.common.FundingType;
|
||||
import org.orcid.jaxb.model.common.Iso3166Country;
|
||||
import org.orcid.jaxb.model.common.Relationship;
|
||||
import org.orcid.jaxb.model.common.SequenceType;
|
||||
import org.orcid.jaxb.model.common.WorkType;
|
||||
import org.orcid.jaxb.model.v3.release.common.Contributor;
|
||||
import org.orcid.jaxb.model.v3.release.common.ContributorEmail;
|
||||
import org.orcid.jaxb.model.v3.release.common.ContributorOrcid;
|
||||
import org.orcid.jaxb.model.v3.release.common.FuzzyDate;
|
||||
import org.orcid.jaxb.model.v3.release.common.Organization;
|
||||
import org.orcid.jaxb.model.v3.release.common.Url;
|
||||
@@ -66,13 +67,11 @@ public class OrcidEntityFactoryServiceIT extends AbstractIntegrationTestWithData
|
||||
|
||||
private OrcidEntityFactoryService entityFactoryService;
|
||||
|
||||
private Collection persons;
|
||||
|
||||
private Collection orgUnits;
|
||||
|
||||
private Collection publications;
|
||||
|
||||
private Collection fundings;
|
||||
private Collection projects;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -85,11 +84,6 @@ public class OrcidEntityFactoryServiceIT extends AbstractIntegrationTestWithData
|
||||
.withTitle("Parent community")
|
||||
.build();
|
||||
|
||||
persons = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withName("Collection")
|
||||
.withEntityType("Person")
|
||||
.build();
|
||||
|
||||
orgUnits = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withName("Collection")
|
||||
.withEntityType("OrgUnit")
|
||||
@@ -100,9 +94,9 @@ public class OrcidEntityFactoryServiceIT extends AbstractIntegrationTestWithData
|
||||
.withEntityType("Publication")
|
||||
.build();
|
||||
|
||||
fundings = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
projects = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withName("Collection")
|
||||
.withEntityType("Funding")
|
||||
.withEntityType("Project")
|
||||
.build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
@@ -113,16 +107,10 @@ public class OrcidEntityFactoryServiceIT extends AbstractIntegrationTestWithData
|
||||
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
Item author = ItemBuilder.createItem(context, persons)
|
||||
.withTitle("Jesse Pinkman")
|
||||
.withOrcidIdentifier("0000-1111-2222-3333")
|
||||
.withPersonEmail("test@test.it")
|
||||
.build();
|
||||
|
||||
Item publication = ItemBuilder.createItem(context, publications)
|
||||
.withTitle("Test publication")
|
||||
.withAuthor("Walter White")
|
||||
.withAuthor("Jesse Pinkman", author.getID().toString())
|
||||
.withAuthor("Jesse Pinkman")
|
||||
.withEditor("Editor")
|
||||
.withIssueDate("2021-04-30")
|
||||
.withDescriptionAbstract("Publication description")
|
||||
@@ -156,8 +144,7 @@ public class OrcidEntityFactoryServiceIT extends AbstractIntegrationTestWithData
|
||||
assertThat(contributors, hasSize(3));
|
||||
assertThat(contributors, has(contributor("Walter White", AUTHOR, FIRST)));
|
||||
assertThat(contributors, has(contributor("Editor", EDITOR, FIRST)));
|
||||
assertThat(contributors, has(contributor("Jesse Pinkman", AUTHOR, ADDITIONAL,
|
||||
"0000-1111-2222-3333", "test@test.it")));
|
||||
assertThat(contributors, has(contributor("Jesse Pinkman", AUTHOR, ADDITIONAL)));
|
||||
|
||||
assertThat(work.getExternalIdentifiers(), notNullValue());
|
||||
|
||||
@@ -313,7 +300,6 @@ public class OrcidEntityFactoryServiceIT extends AbstractIntegrationTestWithData
|
||||
.withHandle("123456789/0001")
|
||||
.withTitle("Test funding")
|
||||
.withFundingIdentifier("987654")
|
||||
.withFundingAwardUrl("http://test-funding")
|
||||
.build();
|
||||
|
||||
Item publication = ItemBuilder.createItem(context, publications)
|
||||
@@ -372,38 +358,36 @@ public class OrcidEntityFactoryServiceIT extends AbstractIntegrationTestWithData
|
||||
public void testFundingCreation() {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
Item investigator = ItemBuilder.createItem(context, persons)
|
||||
.withTitle("Jesse Pinkman")
|
||||
.withPersonEmail("test@test.it")
|
||||
.build();
|
||||
|
||||
Item orgUnit = ItemBuilder.createItem(context, orgUnits)
|
||||
.withTitle("4Science")
|
||||
.withOrgUnitLegalName("4Science")
|
||||
.withOrgUnitCountry("IT")
|
||||
.withOrgUnitLocality("Milan")
|
||||
.withOrgUnitCrossrefIdentifier("12345")
|
||||
.build();
|
||||
|
||||
Item fundingItem = ItemBuilder.createItem(context, fundings)
|
||||
Item projectItem = ItemBuilder.createItem(context, projects)
|
||||
.withTitle("Test funding")
|
||||
.withType("Contract")
|
||||
.withFundingStartDate("2001-03")
|
||||
.withFundingEndDate("2010-03-25")
|
||||
.withFunder("4Science", orgUnit.getID().toString())
|
||||
.withFundingInvestigator("Walter White")
|
||||
.withFundingInvestigator("Jesse Pinkman", investigator.getID().toString())
|
||||
.withFundingCoInvestigator("Mario Rossi")
|
||||
.withProjectInvestigator("Walter White")
|
||||
.withProjectInvestigator("Jesse Pinkman")
|
||||
.withInternalId("888-666-444")
|
||||
.withFundingAwardUrl("www.test.com")
|
||||
.withFundingIdentifier("000-111-333")
|
||||
.withDescription("This is a funding to test orcid mapping")
|
||||
.withAmount("200000")
|
||||
.withAmountCurrency("Euro")
|
||||
.build();
|
||||
|
||||
EntityType projectType = EntityTypeBuilder.createEntityTypeBuilder(context, "Project").build();
|
||||
EntityType orgUnitType = EntityTypeBuilder.createEntityTypeBuilder(context, "OrgUnit").build();
|
||||
|
||||
RelationshipType isAuthorOfPublication = createRelationshipTypeBuilder(context, orgUnitType, projectType,
|
||||
"isOrgUnitOfProject", "isProjectOfOrgUnit", 0, null, 0, null).build();
|
||||
|
||||
RelationshipBuilder.createRelationshipBuilder(context, orgUnit, projectItem, isAuthorOfPublication).build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
Activity activity = entityFactoryService.createOrcidObject(context, fundingItem);
|
||||
Activity activity = entityFactoryService.createOrcidObject(context, projectItem);
|
||||
assertThat(activity, instanceOf(Funding.class));
|
||||
|
||||
Funding funding = (Funding) activity;
|
||||
@@ -413,11 +397,7 @@ public class OrcidEntityFactoryServiceIT extends AbstractIntegrationTestWithData
|
||||
assertThat(funding.getStartDate(), matches(date("2001", "03", "01")));
|
||||
assertThat(funding.getEndDate(), matches(date("2010", "03", "25")));
|
||||
assertThat(funding.getDescription(), is("This is a funding to test orcid mapping"));
|
||||
assertThat(funding.getType(), is(FundingType.CONTRACT));
|
||||
assertThat(funding.getUrl(), matches(urlEndsWith(fundingItem.getHandle())));
|
||||
assertThat(funding.getAmount(), notNullValue());
|
||||
assertThat(funding.getAmount().getContent(), is("200000"));
|
||||
assertThat(funding.getAmount().getCurrencyCode(), is("EUR"));
|
||||
assertThat(funding.getUrl(), matches(urlEndsWith(projectItem.getHandle())));
|
||||
|
||||
Organization organization = funding.getOrganization();
|
||||
assertThat(organization, notNullValue());
|
||||
@@ -433,61 +413,18 @@ public class OrcidEntityFactoryServiceIT extends AbstractIntegrationTestWithData
|
||||
assertThat(fundingContributors, notNullValue());
|
||||
|
||||
List<FundingContributor> contributors = fundingContributors.getContributor();
|
||||
assertThat(contributors, hasSize(3));
|
||||
assertThat(contributors, hasSize(2));
|
||||
assertThat(contributors, has(fundingContributor("Walter White", LEAD)));
|
||||
assertThat(contributors, has(fundingContributor("Jesse Pinkman", LEAD, "test@test.it")));
|
||||
assertThat(contributors, has(fundingContributor("Mario Rossi", CO_LEAD)));
|
||||
assertThat(contributors, has(fundingContributor("Jesse Pinkman", LEAD)));
|
||||
|
||||
assertThat(funding.getExternalIdentifiers(), notNullValue());
|
||||
|
||||
List<ExternalID> externalIds = funding.getExternalIdentifiers().getExternalIdentifier();
|
||||
assertThat(externalIds, hasSize(3));
|
||||
assertThat(externalIds, hasSize(2));
|
||||
assertThat(externalIds, has(selfExternalId("other-id", "888-666-444")));
|
||||
assertThat(externalIds, has(selfExternalId("uri", "www.test.com")));
|
||||
assertThat(externalIds, has(selfExternalId("grant_number", "000-111-333")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFundingCreationWithoutAmountCurrency() {
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
Item fundingItem = ItemBuilder.createItem(context, fundings)
|
||||
.withTitle("Test funding")
|
||||
.withType("Gift")
|
||||
.withFundingStartDate("2001-03")
|
||||
.withFundingEndDate("2010-03-25")
|
||||
.withFundingInvestigator("Walter White")
|
||||
.withAmount("200000")
|
||||
.build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
Activity activity = entityFactoryService.createOrcidObject(context, fundingItem);
|
||||
assertThat(activity, instanceOf(Funding.class));
|
||||
|
||||
Funding funding = (Funding) activity;
|
||||
assertThat(funding.getTitle(), notNullValue());
|
||||
assertThat(funding.getTitle().getTitle(), notNullValue());
|
||||
assertThat(funding.getTitle().getTitle().getContent(), is("Test funding"));
|
||||
assertThat(funding.getStartDate(), matches(date("2001", "03", "01")));
|
||||
assertThat(funding.getEndDate(), matches(date("2010", "03", "25")));
|
||||
assertThat(funding.getDescription(), nullValue());
|
||||
assertThat(funding.getType(), is(FundingType.GRANT));
|
||||
assertThat(funding.getUrl(), matches(urlEndsWith(fundingItem.getHandle())));
|
||||
assertThat(funding.getAmount(), nullValue());
|
||||
assertThat(funding.getOrganization(), nullValue());
|
||||
|
||||
FundingContributors fundingContributors = funding.getContributors();
|
||||
assertThat(fundingContributors, notNullValue());
|
||||
|
||||
List<FundingContributor> contributors = fundingContributors.getContributor();
|
||||
assertThat(contributors, hasSize(1));
|
||||
assertThat(contributors, has(fundingContributor("Walter White", LEAD)));
|
||||
|
||||
assertThat(funding.getExternalIdentifiers(), notNullValue());
|
||||
assertThat(funding.getExternalIdentifiers().getExternalIdentifier(), empty());
|
||||
}
|
||||
|
||||
private Predicate<ExternalID> selfExternalId(String type, String value) {
|
||||
return externalId(type, value, Relationship.SELF);
|
||||
}
|
||||
@@ -509,33 +446,6 @@ public class OrcidEntityFactoryServiceIT extends AbstractIntegrationTestWithData
|
||||
&& role.equals(contributor.getContributorAttributes().getContributorRole());
|
||||
}
|
||||
|
||||
private Predicate<FundingContributor> fundingContributor(String name, FundingContributorRole role, String email) {
|
||||
return fundingContributor(name, role)
|
||||
.and(fundingContributor -> sameEmail(fundingContributor.getContributorEmail(), email))
|
||||
.and(fundingContributor -> fundingContributor.getContributorOrcid() == null);
|
||||
}
|
||||
|
||||
private Predicate<Contributor> contributor(String orcid, String email) {
|
||||
return contributor -> sameEmail(contributor.getContributorEmail(), email)
|
||||
&& sameOrcid(contributor.getContributorOrcid(), orcid);
|
||||
}
|
||||
|
||||
private boolean sameEmail(ContributorEmail contributorEmail, String email) {
|
||||
return contributorEmail != null && email.equals(contributorEmail.getValue());
|
||||
}
|
||||
|
||||
private boolean sameOrcid(ContributorOrcid contributorOrcid, String orcid) {
|
||||
return contributorOrcid != null
|
||||
&& orcid.equals(contributorOrcid.getPath())
|
||||
&& "https://sandbox.orcid.org".equals(contributorOrcid.getHost())
|
||||
&& ("https://sandbox.orcid.org/" + orcid).equals(contributorOrcid.getUri());
|
||||
}
|
||||
|
||||
private Predicate<Contributor> contributor(String name, ContributorRole role, SequenceType sequence,
|
||||
String orcid, String email) {
|
||||
return contributor(name, role, sequence).and(contributor(orcid, email));
|
||||
}
|
||||
|
||||
private Predicate<? super FuzzyDate> date(String year, String month, String days) {
|
||||
return date -> date != null
|
||||
&& year.equals(date.getYear().getValue())
|
||||
|
@@ -70,7 +70,7 @@ public class PlainMetadataSignatureGeneratorIT extends AbstractIntegrationTestWi
|
||||
Item item = ItemBuilder.createItem(context, collection)
|
||||
.withTitle("Item title")
|
||||
.withIssueDate("2020-01-01")
|
||||
.withAuthor("Jesse Pinkman", "d285b110-e8fd-4f71-80b5-2e9267c27dfb")
|
||||
.withAuthor("Jesse Pinkman")
|
||||
.withAuthorAffiliation("Affiliation")
|
||||
.build();
|
||||
|
||||
@@ -82,7 +82,7 @@ public class PlainMetadataSignatureGeneratorIT extends AbstractIntegrationTestWi
|
||||
String signature = generator.generate(context, List.of(author, affiliation));
|
||||
assertThat(signature, notNullValue());
|
||||
|
||||
String expectedSignature = "dc.contributor.author::Jesse Pinkman::d285b110-e8fd-4f71-80b5-2e9267c27dfb§§"
|
||||
String expectedSignature = "dc.contributor.author::Jesse Pinkman§§"
|
||||
+ "oairecerif.author.affiliation::Affiliation";
|
||||
|
||||
assertThat(signature, equalTo(expectedSignature));
|
||||
|
@@ -83,10 +83,6 @@ public class ItemBuilder extends AbstractDSpaceObjectBuilder<Item> {
|
||||
return addMetadataValue(item, MetadataSchemaEnum.DC.getName(), "contributor", "author", authorName);
|
||||
}
|
||||
|
||||
public ItemBuilder withAuthor(final String authorName, final String authority) {
|
||||
return addMetadataValue(item, DC.getName(), "contributor", "author", null, authorName, authority, 600);
|
||||
}
|
||||
|
||||
public ItemBuilder withAuthor(final String authorName, final String authority, final int confidence) {
|
||||
return addMetadataValue(item, MetadataSchemaEnum.DC.getName(), "contributor", "author",
|
||||
null, authorName, authority, confidence);
|
||||
@@ -300,8 +296,8 @@ public class ItemBuilder extends AbstractDSpaceObjectBuilder<Item> {
|
||||
return addMetadataValue(item, "oairecerif", "funding", "identifier", identifier);
|
||||
}
|
||||
|
||||
public ItemBuilder withFundingAwardUrl(String url) {
|
||||
return addMetadataValue(item, "funding", "award", "url", url);
|
||||
public ItemBuilder withOrgUnitLegalName(String name) {
|
||||
return addMetadataValue(item, "organization", "legalName", null, name);
|
||||
}
|
||||
|
||||
public ItemBuilder withOrgUnitCountry(String addressCountry) {
|
||||
@@ -332,20 +328,8 @@ public class ItemBuilder extends AbstractDSpaceObjectBuilder<Item> {
|
||||
return addMetadataValue(item, "oairecerif", "funder", null, null, funder, authority, 600);
|
||||
}
|
||||
|
||||
public ItemBuilder withFundingInvestigator(String investigator) {
|
||||
return addMetadataValue(item, "funding", "investigators", null, investigator);
|
||||
}
|
||||
|
||||
public ItemBuilder withFundingInvestigator(String investigator, String authority) {
|
||||
return addMetadataValue(item, "funding", "investigators", null, null, investigator, authority, 600);
|
||||
}
|
||||
|
||||
public ItemBuilder withFundingCoInvestigator(String investigator) {
|
||||
return addMetadataValue(item, "funding", "coinvestigators", null, investigator);
|
||||
}
|
||||
|
||||
public ItemBuilder withFundingCoInvestigator(String investigator, String authority) {
|
||||
return addMetadataValue(item, "funding", "coinvestigators", null, null, investigator, authority, 600);
|
||||
public ItemBuilder withProjectInvestigator(String investigator) {
|
||||
return addMetadataValue(item, "project", "investigator", null, investigator);
|
||||
}
|
||||
|
||||
public ItemBuilder withInternalId(String internalId) {
|
||||
|
@@ -114,7 +114,7 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
|
||||
// check the first two rows
|
||||
.andExpect(jsonPath("$.rows[0].fields", contains(
|
||||
SubmissionFormFieldMatcher.matchFormFieldDefinition("name", "Author",
|
||||
null, true, "Add an author", null, "dc.contributor.author", "PersonAuthority"))))
|
||||
null, true,"Add an author", "dc.contributor.author"))))
|
||||
.andExpect(jsonPath("$.rows[1].fields", contains(
|
||||
SubmissionFormFieldMatcher.matchFormFieldDefinition("onebox", "Title",
|
||||
"You must enter a main title for this item.", false,
|
||||
@@ -145,7 +145,7 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
|
||||
.startsWith(REST_SERVER_URL + "config/submissionforms/traditionalpageone")))
|
||||
.andExpect(jsonPath("$.rows[0].fields", contains(
|
||||
SubmissionFormFieldMatcher.matchFormFieldDefinition("name", "Author",
|
||||
null, true, "Add an author", null, "dc.contributor.author", "PersonAuthority"))))
|
||||
null, true,"Add an author", "dc.contributor.author"))))
|
||||
.andExpect(jsonPath("$.rows[1].fields", contains(
|
||||
SubmissionFormFieldMatcher.matchFormFieldDefinition("onebox", "Title",
|
||||
"You must enter a main title for this item.", false,
|
||||
@@ -294,7 +294,7 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
|
||||
.andExpect(jsonPath("$.rows[0].fields", contains(
|
||||
SubmissionFormFieldMatcher.matchFormOpenRelationshipFieldDefinition("name",
|
||||
"Author", null, true,"Add an author",
|
||||
"dc.contributor.author", "PersonAuthority", "isAuthorOfPublication", null,
|
||||
"dc.contributor.author", "isAuthorOfPublication", null,
|
||||
"person", true))))
|
||||
;
|
||||
}
|
||||
@@ -353,7 +353,7 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
|
||||
.startsWith(REST_SERVER_URL + "config/submissionforms/languagetest")))
|
||||
.andExpect(jsonPath("$.rows[0].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("name", "Autore", "\u00C8" + " richiesto almeno un autore", true,
|
||||
"Aggiungi un autore", null, "dc.contributor.author", "PersonAuthority"))))
|
||||
"Aggiungi un autore", "dc.contributor.author"))))
|
||||
.andExpect(jsonPath("$.rows[1].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("onebox", "Titolo",
|
||||
"\u00C8" + " necessario inserire un titolo principale per questo item", false,
|
||||
@@ -377,7 +377,7 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
|
||||
.startsWith(REST_SERVER_URL + "config/submissionforms/languagetest")))
|
||||
.andExpect(jsonPath("$.rows[0].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("name", "Автор", "Потрібно ввести хочаб одного автора!",
|
||||
true, "Додати автора", null, "dc.contributor.author", "PersonAuthority"))))
|
||||
true, "Додати автора", "dc.contributor.author"))))
|
||||
.andExpect(jsonPath("$.rows[1].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("onebox", "Заголовок",
|
||||
"Заговолок файла обов'язковий !", false,
|
||||
@@ -432,7 +432,7 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
|
||||
.startsWith(REST_SERVER_URL + "config/submissionforms/languagetest")))
|
||||
.andExpect(jsonPath("$.rows[0].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("name", "Autore", "\u00C8" + " richiesto almeno un autore", true,
|
||||
"Aggiungi un autore", null, "dc.contributor.author", "PersonAuthority"))))
|
||||
"Aggiungi un autore", "dc.contributor.author"))))
|
||||
.andExpect(jsonPath("$.rows[1].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("onebox", "Titolo",
|
||||
"\u00C8" + " necessario inserire un titolo principale per questo item", false,
|
||||
@@ -456,7 +456,7 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
|
||||
.startsWith(REST_SERVER_URL + "config/submissionforms/languagetest")))
|
||||
.andExpect(jsonPath("$.rows[0].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("name", "Автор", "Потрібно ввести хочаб одного автора!",
|
||||
true, "Додати автора", null, "dc.contributor.author", "PersonAuthority"))))
|
||||
true, "Додати автора", "dc.contributor.author"))))
|
||||
.andExpect(jsonPath("$.rows[1].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("onebox", "Заголовок",
|
||||
"Заговолок файла обов'язковий !", false,
|
||||
@@ -506,7 +506,7 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
|
||||
.startsWith(REST_SERVER_URL + "config/submissionforms/languagetest")))
|
||||
.andExpect(jsonPath("$.rows[0].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("name", "Autore", "\u00C8" + " richiesto almeno un autore", true,
|
||||
"Aggiungi un autore", null, "dc.contributor.author", "PersonAuthority"))))
|
||||
"Aggiungi un autore", "dc.contributor.author"))))
|
||||
.andExpect(jsonPath("$.rows[1].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("onebox", "Titolo",
|
||||
"\u00C8" + " necessario inserire un titolo principale per questo item", false,
|
||||
@@ -548,7 +548,7 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
|
||||
.startsWith(REST_SERVER_URL + "config/submissionforms/languagetest")))
|
||||
.andExpect(jsonPath("$.rows[0].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("name", "Autore", "\u00C8 richiesto almeno un autore", true,
|
||||
"Aggiungi un autore", null, "dc.contributor.author", "PersonAuthority"))))
|
||||
"Aggiungi un autore", "dc.contributor.author"))))
|
||||
.andExpect(jsonPath("$.rows[1].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("onebox", "Titolo",
|
||||
"\u00C8 necessario inserire un titolo principale per questo item", false,
|
||||
@@ -583,7 +583,7 @@ public class SubmissionFormsControllerIT extends AbstractControllerIntegrationTe
|
||||
.startsWith(REST_SERVER_URL + "config/submissionforms/languagetest")))
|
||||
.andExpect(jsonPath("$.rows[0].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("name", "Autore", "\u00C8 richiesto almeno un autore", true,
|
||||
"Aggiungi un autore", null, "dc.contributor.author", "PersonAuthority"))))
|
||||
"Aggiungi un autore", "dc.contributor.author"))))
|
||||
.andExpect(jsonPath("$.rows[1].fields", contains(SubmissionFormFieldMatcher
|
||||
.matchFormFieldDefinition("onebox", "Titolo",
|
||||
"\u00C8 necessario inserire un titolo principale per questo item", false,
|
||||
|
@@ -142,8 +142,6 @@ public class SubmissionFormFieldMatcher {
|
||||
* the expected hints message
|
||||
* @param metadata
|
||||
* the expected metadata
|
||||
* @param controlledVocabulary
|
||||
* the expected controlledVocabulary
|
||||
* @param relationshipType
|
||||
* the type of relationship
|
||||
* @param filter
|
||||
@@ -159,7 +157,6 @@ public class SubmissionFormFieldMatcher {
|
||||
boolean repeatable,
|
||||
String hints,
|
||||
String metadata,
|
||||
String controlledVocabulary,
|
||||
String relationshipType,
|
||||
String filter,
|
||||
String searchConfiguration,
|
||||
@@ -169,8 +166,7 @@ public class SubmissionFormFieldMatcher {
|
||||
hasJsonPath("$.selectableRelationship.filter", is(filter)),
|
||||
hasJsonPath("$.selectableRelationship.searchConfiguration", is(searchConfiguration)),
|
||||
hasJsonPath("$.selectableRelationship.nameVariants", is(String.valueOf(nameVariants))),
|
||||
matchFormFieldDefinition(type, label, mandatoryMessage, repeatable, hints, null, metadata,
|
||||
controlledVocabulary));
|
||||
matchFormFieldDefinition(type, label, mandatoryMessage, repeatable, hints, metadata));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -11,6 +11,7 @@ import static com.jayway.jsonpath.JsonPath.read;
|
||||
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
|
||||
import static org.dspace.app.matcher.LambdaMatcher.matches;
|
||||
import static org.dspace.builder.OrcidQueueBuilder.createOrcidQueue;
|
||||
import static org.dspace.builder.RelationshipTypeBuilder.createRelationshipTypeBuilder;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
@@ -43,11 +44,15 @@ import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
|
||||
import org.dspace.builder.CollectionBuilder;
|
||||
import org.dspace.builder.CommunityBuilder;
|
||||
import org.dspace.builder.EPersonBuilder;
|
||||
import org.dspace.builder.EntityTypeBuilder;
|
||||
import org.dspace.builder.ItemBuilder;
|
||||
import org.dspace.builder.OrcidHistoryBuilder;
|
||||
import org.dspace.builder.OrcidQueueBuilder;
|
||||
import org.dspace.builder.RelationshipBuilder;
|
||||
import org.dspace.content.Collection;
|
||||
import org.dspace.content.EntityType;
|
||||
import org.dspace.content.Item;
|
||||
import org.dspace.content.RelationshipType;
|
||||
import org.dspace.eperson.EPerson;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
@@ -715,7 +720,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
Collection fundings = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withEntityType("Funding")
|
||||
.withEntityType("Project")
|
||||
.withName("Collection 3")
|
||||
.build();
|
||||
|
||||
@@ -725,7 +730,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
.build();
|
||||
|
||||
Item orgUnit = ItemBuilder.createItem(context, orgUnits)
|
||||
.withTitle("4Science")
|
||||
.withOrgUnitLegalName("4Science")
|
||||
.withOrgUnitCountry("IT")
|
||||
.withOrgUnitLocality("Milan")
|
||||
.withOrgUnitCrossrefIdentifier("12345")
|
||||
@@ -738,10 +743,18 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
.withFunder("4Science", orgUnit.getID().toString())
|
||||
.build();
|
||||
|
||||
EntityType fundingType = EntityTypeBuilder.createEntityTypeBuilder(context, "Project").build();
|
||||
EntityType orgUnitType = EntityTypeBuilder.createEntityTypeBuilder(context, "OrgUnit").build();
|
||||
|
||||
RelationshipType isAuthorOfPublication = createRelationshipTypeBuilder(context, orgUnitType, fundingType,
|
||||
"isOrgUnitOfProject", "isProjectOfOrgUnit", 0, null, 0, null).build();
|
||||
|
||||
RelationshipBuilder.createRelationshipBuilder(context, orgUnit, funding, isAuthorOfPublication).build();
|
||||
|
||||
OrcidQueue orcidQueue = OrcidQueueBuilder.createOrcidQueue(context, profile, funding)
|
||||
.withDescription("Test funding")
|
||||
.withOperation(OrcidOperation.INSERT)
|
||||
.withRecordType("Funding")
|
||||
.withRecordType("Project")
|
||||
.build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
@@ -797,7 +810,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
Collection fundings = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withEntityType("Funding")
|
||||
.withEntityType("Project")
|
||||
.withName("Collection 3")
|
||||
.build();
|
||||
|
||||
@@ -807,7 +820,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
.build();
|
||||
|
||||
Item orgUnit = ItemBuilder.createItem(context, orgUnits)
|
||||
.withTitle("4Science")
|
||||
.withOrgUnitLegalName("4Science")
|
||||
.withOrgUnitCountry("IT")
|
||||
.withOrgUnitLocality("Milan")
|
||||
.withOrgUnitCrossrefIdentifier("12345")
|
||||
@@ -823,9 +836,17 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
OrcidQueue orcidQueue = OrcidQueueBuilder.createOrcidQueue(context, profile, funding)
|
||||
.withDescription("Test funding")
|
||||
.withOperation(OrcidOperation.INSERT)
|
||||
.withRecordType("Funding")
|
||||
.withRecordType("Project")
|
||||
.build();
|
||||
|
||||
EntityType fundingType = EntityTypeBuilder.createEntityTypeBuilder(context, "Project").build();
|
||||
EntityType orgUnitType = EntityTypeBuilder.createEntityTypeBuilder(context, "OrgUnit").build();
|
||||
|
||||
RelationshipType isAuthorOfPublication = createRelationshipTypeBuilder(context, orgUnitType, fundingType,
|
||||
"isOrgUnitOfProject", "isProjectOfOrgUnit", 0, null, 0, null).build();
|
||||
|
||||
RelationshipBuilder.createRelationshipBuilder(context, orgUnit, funding, isAuthorOfPublication).build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
when(orcidClientMock.push(eq(ACCESS_TOKEN), eq(ORCID), any()))
|
||||
@@ -871,7 +892,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
Collection fundings = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withEntityType("Funding")
|
||||
.withEntityType("Project")
|
||||
.withName("Collection 3")
|
||||
.build();
|
||||
|
||||
@@ -881,7 +902,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
.build();
|
||||
|
||||
Item orgUnit = ItemBuilder.createItem(context, orgUnits)
|
||||
.withTitle("4Science")
|
||||
.withOrgUnitLegalName("4Science")
|
||||
.withOrgUnitCountry("IT")
|
||||
.withOrgUnitLocality("Milan")
|
||||
.withOrgUnitCrossrefIdentifier("12345")
|
||||
@@ -897,9 +918,17 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
OrcidQueue orcidQueue = OrcidQueueBuilder.createOrcidQueue(context, profile, funding)
|
||||
.withDescription("Test funding")
|
||||
.withOperation(OrcidOperation.INSERT)
|
||||
.withRecordType("Funding")
|
||||
.withRecordType("Project")
|
||||
.build();
|
||||
|
||||
EntityType fundingType = EntityTypeBuilder.createEntityTypeBuilder(context, "Project").build();
|
||||
EntityType orgUnitType = EntityTypeBuilder.createEntityTypeBuilder(context, "OrgUnit").build();
|
||||
|
||||
RelationshipType isAuthorOfPublication = createRelationshipTypeBuilder(context, orgUnitType, fundingType,
|
||||
"isOrgUnitOfProject", "isProjectOfOrgUnit", 0, null, 0, null).build();
|
||||
|
||||
RelationshipBuilder.createRelationshipBuilder(context, orgUnit, funding, isAuthorOfPublication).build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
when(orcidClientMock.push(eq(ACCESS_TOKEN), eq(ORCID), any()))
|
||||
@@ -945,7 +974,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
Collection fundings = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withEntityType("Funding")
|
||||
.withEntityType("Project")
|
||||
.withName("Collection 3")
|
||||
.build();
|
||||
|
||||
@@ -955,7 +984,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
.build();
|
||||
|
||||
Item orgUnit = ItemBuilder.createItem(context, orgUnits)
|
||||
.withTitle("4Science")
|
||||
.withOrgUnitLegalName("4Science")
|
||||
.withOrgUnitCountry("IT")
|
||||
.withOrgUnitLocality("Milan")
|
||||
.withOrgUnitCrossrefIdentifier("12345")
|
||||
@@ -971,10 +1000,18 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
OrcidQueue orcidQueue = OrcidQueueBuilder.createOrcidQueue(context, profile, funding)
|
||||
.withDescription("Test funding")
|
||||
.withOperation(OrcidOperation.UPDATE)
|
||||
.withRecordType("Funding")
|
||||
.withRecordType("Project")
|
||||
.withPutCode("12345")
|
||||
.build();
|
||||
|
||||
EntityType fundingType = EntityTypeBuilder.createEntityTypeBuilder(context, "Project").build();
|
||||
EntityType orgUnitType = EntityTypeBuilder.createEntityTypeBuilder(context, "OrgUnit").build();
|
||||
|
||||
RelationshipType isAuthorOfPublication = createRelationshipTypeBuilder(context, orgUnitType, fundingType,
|
||||
"isOrgUnitOfProject", "isProjectOfOrgUnit", 0, null, 0, null).build();
|
||||
|
||||
RelationshipBuilder.createRelationshipBuilder(context, orgUnit, funding, isAuthorOfPublication).build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
when(orcidClientMock.update(eq(ACCESS_TOKEN), eq(ORCID), any(), eq("12345")))
|
||||
@@ -1027,7 +1064,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
public void testCreationForFundingDeletion() throws Exception {
|
||||
|
||||
context.turnOffAuthorisationSystem();
|
||||
OrcidQueue orcidQueue = createOrcidQueue(context, profile, "Description", "Funding", "12345").build();
|
||||
OrcidQueue orcidQueue = createOrcidQueue(context, profile, "Description", "Project", "12345").build();
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
when(orcidClientMock.deleteByPutCode(ACCESS_TOKEN, ORCID, "12345", "/funding")).thenReturn(deletedResponse());
|
||||
@@ -1071,7 +1108,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
Collection fundings = CollectionBuilder.createCollection(context, parentCommunity)
|
||||
.withEntityType("Funding")
|
||||
.withEntityType("Project")
|
||||
.withName("Collection 3")
|
||||
.build();
|
||||
|
||||
@@ -1096,7 +1133,7 @@ public class OrcidHistoryRestRepositoryIT extends AbstractControllerIntegrationT
|
||||
OrcidQueue orcidQueue = OrcidQueueBuilder.createOrcidQueue(context, profile, funding)
|
||||
.withDescription("Test funding")
|
||||
.withOperation(OrcidOperation.INSERT)
|
||||
.withRecordType("Funding")
|
||||
.withRecordType("Project")
|
||||
.build();
|
||||
|
||||
context.restoreAuthSystemState();
|
||||
|
@@ -60,7 +60,7 @@ orcid.mapping.work.funding.url =
|
||||
|
||||
### Funding mapping ###
|
||||
orcid.mapping.funding.title = dc.title
|
||||
orcid.mapping.funding.type =
|
||||
orcid.mapping.funding.type = dc.type
|
||||
orcid.mapping.funding.type.converter = mapConverterDSpaceToOrcidFundingType
|
||||
##orcid.mapping.funding.external-ids syntax is <metadatafield>::<type>
|
||||
##The full list of available external identifiers is available here https://pub.orcid.org/v3.0/identifiers
|
||||
@@ -71,8 +71,7 @@ orcid.mapping.funding.start-date = oairecerif.funding.startDate
|
||||
orcid.mapping.funding.end-date = oairecerif.funding.endDate
|
||||
##orcid.mapping.funding.contributors syntax is <metadatafield>::<type>
|
||||
orcid.mapping.funding.contributors = project.investigator::lead
|
||||
orcid.mapping.funding.contributors =
|
||||
orcid.mapping.funding.organization = oairecerif.funder
|
||||
orcid.mapping.funding.organization-relationship-type = isOrgUnitOfProject
|
||||
orcid.mapping.funding.amount = oairecerif.amount
|
||||
orcid.mapping.funding.amount.currency = oairecerif.amount.currency
|
||||
orcid.mapping.funding.amount.currency.converter = mapConverterDSpaceToOrcidAmountCurrency
|
||||
@@ -97,6 +96,7 @@ orcid.mapping.person-external-ids = person.identifier.rid::RID
|
||||
orcid.mapping.researcher-urls = oairecerif.identifier.url
|
||||
|
||||
### Organization mapping ###
|
||||
orcid.mapping.organization.title = organization.legalName
|
||||
orcid.mapping.organization.country = organization.address.addressCountry
|
||||
orcid.mapping.organization.city = organization.address.addressLocality
|
||||
|
||||
|
@@ -79,12 +79,13 @@
|
||||
<property name="descriptionField" value="${orcid.mapping.funding.description}" />
|
||||
<property name="startDateField" value="${orcid.mapping.funding.start-date}" />
|
||||
<property name="endDateField" value="${orcid.mapping.funding.end-date}" />
|
||||
<property name="organizationField" value="${orcid.mapping.funding.organization}" />
|
||||
<property name="organizationRelationshipType" value="${orcid.mapping.funding.organization-relationship-type}" />
|
||||
</bean>
|
||||
|
||||
<bean class="org.dspace.app.orcid.model.factory.impl.OrcidCommonObjectFactoryImpl">
|
||||
<property name="contributorEmailField" value="${orcid.mapping.contributor.email}" />
|
||||
<property name="contributorOrcidField" value="${orcid.mapping.contributor.orcid}" />
|
||||
<property name="organizationTitleField" value="${orcid.mapping.organization.title}" />
|
||||
<property name="organizationCityField" value="${orcid.mapping.organization.city}" />
|
||||
<property name="organizationCountryField" value="${orcid.mapping.organization.country}" />
|
||||
<property name="disambiguatedOrganizationIdentifierFields" value="${orcid.mapping.organization.identifiers}" />
|
||||
|
Reference in New Issue
Block a user