fixed organization id created when mapping APC affiliations. Factored out ROR constants in dhp-common
This commit is contained in:
parent
d8882c4481
commit
8a463cc3e8
|
@ -10,6 +10,12 @@ public class Constants {
|
|||
public static final Map<String, String> accessRightsCoarMap = Maps.newHashMap();
|
||||
public static final Map<String, String> coarCodeLabelMap = Maps.newHashMap();
|
||||
|
||||
public static final String ROR_NS_PREFIX = "ror_________";
|
||||
|
||||
public static final String ROR_OPENAIRE_ID = "10|openaire____::993a7ae7a863813cf95028b50708e222";
|
||||
|
||||
public static final String ROR_DATASOURCE_NAME = "Research Organization Registry (ROR)";
|
||||
|
||||
public static String COAR_ACCESS_RIGHT_SCHEMA = "http://vocabularies.coar-repositories.org/documentation/access_rights/";
|
||||
|
||||
private Constants() {
|
||||
|
|
|
@ -40,6 +40,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import eu.dnetlib.dhp.actionmanager.ror.model.ExternalIdType;
|
||||
import eu.dnetlib.dhp.actionmanager.ror.model.RorOrganization;
|
||||
import eu.dnetlib.dhp.application.ArgumentApplicationParser;
|
||||
import eu.dnetlib.dhp.common.Constants;
|
||||
import eu.dnetlib.dhp.common.HdfsSupport;
|
||||
import eu.dnetlib.dhp.schema.action.AtomicAction;
|
||||
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
||||
|
@ -59,10 +60,8 @@ public class GenerateRorActionSetJob {
|
|||
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
||||
private static final String ROR_NS_PREFIX = "ror_________";
|
||||
|
||||
private static final List<KeyValue> ROR_COLLECTED_FROM = listKeyValues(
|
||||
"10|openaire____::993a7ae7a863813cf95028b50708e222", "ROR");
|
||||
Constants.ROR_OPENAIRE_ID, Constants.ROR_DATASOURCE_NAME);
|
||||
|
||||
private static final DataInfo ROR_DATA_INFO = dataInfo(
|
||||
false, "", false, false, ENTITYREGISTRY_PROVENANCE_ACTION, "0.92");
|
||||
|
@ -126,7 +125,7 @@ public class GenerateRorActionSetJob {
|
|||
final Organization o = new Organization();
|
||||
|
||||
o.setId(calculateOpenaireId(r.getId()));
|
||||
o.setOriginalId(Arrays.asList(String.format("%s::%s", ROR_NS_PREFIX, r.getId())));
|
||||
o.setOriginalId(Arrays.asList(String.format("%s::%s", Constants.ROR_NS_PREFIX, r.getId())));
|
||||
o.setCollectedfrom(ROR_COLLECTED_FROM);
|
||||
o.setPid(pids(r));
|
||||
o.setDateofcollection(now.toString());
|
||||
|
@ -170,7 +169,7 @@ public class GenerateRorActionSetJob {
|
|||
}
|
||||
|
||||
private static String calculateOpenaireId(final String rorId) {
|
||||
return String.format("20|%s::%s", ROR_NS_PREFIX, DHPUtils.md5(rorId));
|
||||
return String.format("20|%s::%s", Constants.ROR_NS_PREFIX, DHPUtils.md5(rorId));
|
||||
}
|
||||
|
||||
private static List<StructuredProperty> pids(final RorOrganization r) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import eu.dnetlib.dhp.common.Constants;
|
||||
import eu.dnetlib.dhp.common.vocabulary.VocabularyGroup;
|
||||
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
||||
import eu.dnetlib.dhp.schema.common.ModelSupport;
|
||||
|
@ -326,8 +327,10 @@ public abstract class AbstractMdRecordToOafMapper {
|
|||
String rorId = element.attributeValue("affiliationIdentifier");
|
||||
if (StringUtils.isNotBlank(rorId)) {
|
||||
|
||||
String fullRorId = Constants.ROR_NS_PREFIX + "::" + rorId;
|
||||
|
||||
String resultId = entity.getId();
|
||||
String orgId = createOpenaireId("organization", rorId, true);
|
||||
String orgId = createOpenaireId("organization", fullRorId, true);
|
||||
|
||||
List<KeyValue> properties = Lists.newArrayList();
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
|||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import eu.dnetlib.dhp.common.Constants;
|
||||
import eu.dnetlib.dhp.common.vocabulary.VocabularyGroup;
|
||||
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
||||
import eu.dnetlib.dhp.schema.oaf.*;
|
||||
|
@ -922,7 +923,7 @@ class MappersTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void testOpenAPC() throws IOException, DocumentException {
|
||||
void testOpenAPC() throws IOException {
|
||||
final String xml = IOUtils.toString(Objects.requireNonNull(getClass().getResourceAsStream("oaf_openapc.xml")));
|
||||
final List<Oaf> list = new OafToOafMapper(vocs, true, true).processMdRecord(xml);
|
||||
|
||||
|
@ -955,6 +956,8 @@ class MappersTest {
|
|||
if (StringUtils.startsWith(source, "50")) {
|
||||
assertEquals(ModelConstants.HAS_AUTHOR_INSTITUTION, r.getRelClass());
|
||||
} else if (StringUtils.startsWith(source, "20")) {
|
||||
assertTrue(StringUtils.contains(source, "::"));
|
||||
assertEquals("20|" + Constants.ROR_NS_PREFIX, StringUtils.substringBefore(source, "::"));
|
||||
assertEquals(ModelConstants.IS_AUTHOR_INSTITUTION_OF, r.getRelClass());
|
||||
} else {
|
||||
throw new IllegalArgumentException("invalid source / target prefixes for affiliation relations");
|
||||
|
|
Loading…
Reference in New Issue