forked from D-Net/dnet-hadoop
Merge pull request 'fix APC affiliation links' (#294) from apc_affiliation into beta
Reviewed-on: D-Net/dnet-hadoop#294
This commit is contained in:
commit
e309688711
|
@ -10,6 +10,12 @@ public class Constants {
|
||||||
public static final Map<String, String> accessRightsCoarMap = Maps.newHashMap();
|
public static final Map<String, String> accessRightsCoarMap = Maps.newHashMap();
|
||||||
public static final Map<String, String> coarCodeLabelMap = 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/";
|
public static String COAR_ACCESS_RIGHT_SCHEMA = "http://vocabularies.coar-repositories.org/documentation/access_rights/";
|
||||||
|
|
||||||
private Constants() {
|
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.ExternalIdType;
|
||||||
import eu.dnetlib.dhp.actionmanager.ror.model.RorOrganization;
|
import eu.dnetlib.dhp.actionmanager.ror.model.RorOrganization;
|
||||||
import eu.dnetlib.dhp.application.ArgumentApplicationParser;
|
import eu.dnetlib.dhp.application.ArgumentApplicationParser;
|
||||||
|
import eu.dnetlib.dhp.common.Constants;
|
||||||
import eu.dnetlib.dhp.common.HdfsSupport;
|
import eu.dnetlib.dhp.common.HdfsSupport;
|
||||||
import eu.dnetlib.dhp.schema.action.AtomicAction;
|
import eu.dnetlib.dhp.schema.action.AtomicAction;
|
||||||
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
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 ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||||
|
|
||||||
private static final String ROR_NS_PREFIX = "ror_________";
|
|
||||||
|
|
||||||
private static final List<KeyValue> ROR_COLLECTED_FROM = listKeyValues(
|
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(
|
private static final DataInfo ROR_DATA_INFO = dataInfo(
|
||||||
false, "", false, false, ENTITYREGISTRY_PROVENANCE_ACTION, "0.92");
|
false, "", false, false, ENTITYREGISTRY_PROVENANCE_ACTION, "0.92");
|
||||||
|
@ -126,7 +125,7 @@ public class GenerateRorActionSetJob {
|
||||||
final Organization o = new Organization();
|
final Organization o = new Organization();
|
||||||
|
|
||||||
o.setId(calculateOpenaireId(r.getId()));
|
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.setCollectedfrom(ROR_COLLECTED_FROM);
|
||||||
o.setPid(pids(r));
|
o.setPid(pids(r));
|
||||||
o.setDateofcollection(now.toString());
|
o.setDateofcollection(now.toString());
|
||||||
|
@ -170,7 +169,7 @@ public class GenerateRorActionSetJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String calculateOpenaireId(final String rorId) {
|
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) {
|
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.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
|
import eu.dnetlib.dhp.common.Constants;
|
||||||
import eu.dnetlib.dhp.common.vocabulary.VocabularyGroup;
|
import eu.dnetlib.dhp.common.vocabulary.VocabularyGroup;
|
||||||
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
||||||
import eu.dnetlib.dhp.schema.common.ModelSupport;
|
import eu.dnetlib.dhp.schema.common.ModelSupport;
|
||||||
|
@ -326,8 +327,10 @@ public abstract class AbstractMdRecordToOafMapper {
|
||||||
String rorId = element.attributeValue("affiliationIdentifier");
|
String rorId = element.attributeValue("affiliationIdentifier");
|
||||||
if (StringUtils.isNotBlank(rorId)) {
|
if (StringUtils.isNotBlank(rorId)) {
|
||||||
|
|
||||||
|
String fullRorId = Constants.ROR_NS_PREFIX + "::" + rorId;
|
||||||
|
|
||||||
String resultId = entity.getId();
|
String resultId = entity.getId();
|
||||||
String orgId = createOpenaireId("organization", rorId, true);
|
String orgId = createOpenaireId("organization", fullRorId, true);
|
||||||
|
|
||||||
List<KeyValue> properties = Lists.newArrayList();
|
List<KeyValue> properties = Lists.newArrayList();
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import eu.dnetlib.dhp.common.Constants;
|
||||||
import eu.dnetlib.dhp.common.vocabulary.VocabularyGroup;
|
import eu.dnetlib.dhp.common.vocabulary.VocabularyGroup;
|
||||||
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
||||||
import eu.dnetlib.dhp.schema.oaf.*;
|
import eu.dnetlib.dhp.schema.oaf.*;
|
||||||
|
@ -922,7 +923,7 @@ class MappersTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testOpenAPC() throws IOException, DocumentException {
|
void testOpenAPC() throws IOException {
|
||||||
final String xml = IOUtils.toString(Objects.requireNonNull(getClass().getResourceAsStream("oaf_openapc.xml")));
|
final String xml = IOUtils.toString(Objects.requireNonNull(getClass().getResourceAsStream("oaf_openapc.xml")));
|
||||||
final List<Oaf> list = new OafToOafMapper(vocs, true, true).processMdRecord(xml);
|
final List<Oaf> list = new OafToOafMapper(vocs, true, true).processMdRecord(xml);
|
||||||
|
|
||||||
|
@ -955,6 +956,8 @@ class MappersTest {
|
||||||
if (StringUtils.startsWith(source, "50")) {
|
if (StringUtils.startsWith(source, "50")) {
|
||||||
assertEquals(ModelConstants.HAS_AUTHOR_INSTITUTION, r.getRelClass());
|
assertEquals(ModelConstants.HAS_AUTHOR_INSTITUTION, r.getRelClass());
|
||||||
} else if (StringUtils.startsWith(source, "20")) {
|
} 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());
|
assertEquals(ModelConstants.IS_AUTHOR_INSTITUTION_OF, r.getRelClass());
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("invalid source / target prefixes for affiliation relations");
|
throw new IllegalArgumentException("invalid source / target prefixes for affiliation relations");
|
||||||
|
|
Loading…
Reference in New Issue