2020-04-28 11:23:29 +02:00
|
|
|
|
2020-04-10 17:53:07 +02:00
|
|
|
package eu.dnetlib.dhp.oa.graph.raw;
|
2020-03-02 16:12:14 +01:00
|
|
|
|
2020-06-09 19:52:53 +02:00
|
|
|
import static eu.dnetlib.dhp.schema.common.ModelConstants.*;
|
2021-04-27 15:44:01 +02:00
|
|
|
import static eu.dnetlib.dhp.schema.oaf.utils.OafMapperUtils.*;
|
2020-05-22 10:08:02 +02:00
|
|
|
|
2020-11-19 14:34:54 +01:00
|
|
|
import java.util.*;
|
2020-10-30 10:56:42 +01:00
|
|
|
import java.util.stream.Collectors;
|
2020-04-28 11:23:29 +02:00
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.dom4j.Document;
|
|
|
|
import org.dom4j.Node;
|
|
|
|
|
2020-05-25 10:35:39 +02:00
|
|
|
import eu.dnetlib.dhp.common.PacePerson;
|
2021-01-25 15:43:04 +01:00
|
|
|
import eu.dnetlib.dhp.common.vocabulary.VocabularyGroup;
|
2021-05-26 18:20:23 +02:00
|
|
|
import eu.dnetlib.dhp.schema.common.ModelConstants;
|
2020-10-16 17:02:10 +02:00
|
|
|
import eu.dnetlib.dhp.schema.oaf.*;
|
2021-04-27 15:44:01 +02:00
|
|
|
import eu.dnetlib.dhp.schema.oaf.utils.CleaningFunctions;
|
2021-03-16 14:19:32 +01:00
|
|
|
import eu.dnetlib.dhp.schema.oaf.utils.IdentifierFactory;
|
2020-02-05 15:35:40 +01:00
|
|
|
|
2020-03-02 16:12:14 +01:00
|
|
|
public class OdfToOafMapper extends AbstractMdRecordToOafMapper {
|
2020-02-05 15:35:40 +01:00
|
|
|
|
2020-05-06 13:20:02 +02:00
|
|
|
public static final String HTTP_DX_DOI_PREIFX = "http://dx.doi.org/";
|
|
|
|
|
2021-07-19 15:56:55 +02:00
|
|
|
public OdfToOafMapper(final VocabularyGroup vocs, final boolean invisible, final boolean shouldHashId,
|
|
|
|
final boolean forceOrginalId) {
|
|
|
|
super(vocs, invisible, shouldHashId, forceOrginalId);
|
|
|
|
}
|
|
|
|
|
2020-11-30 12:00:38 +01:00
|
|
|
public OdfToOafMapper(final VocabularyGroup vocs, final boolean invisible, final boolean shouldHashId) {
|
|
|
|
super(vocs, invisible, shouldHashId);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<StructuredProperty> prepareTitles(final Document doc, final DataInfo info) {
|
2021-04-23 17:09:36 +02:00
|
|
|
return prepareListStructProps(
|
2021-05-20 16:13:06 +02:00
|
|
|
doc,
|
|
|
|
"//*[local-name()='titles']/*[local-name()='title']|//*[local-name()='resource']/*[local-name()='title']",
|
|
|
|
MAIN_TITLE_QUALIFIER, info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Author> prepareAuthors(final Document doc, final DataInfo info) {
|
|
|
|
final List<Author> res = new ArrayList<>();
|
|
|
|
int pos = 1;
|
2021-04-23 17:09:36 +02:00
|
|
|
for (final Object o : doc.selectNodes("//*[local-name()='creator']")) {
|
2020-04-28 11:23:29 +02:00
|
|
|
final Node n = (Node) o;
|
|
|
|
final Author author = new Author();
|
2021-04-23 17:09:36 +02:00
|
|
|
final String fullname = n.valueOf("./*[local-name()='creatorName']");
|
|
|
|
final String name = n.valueOf("./*[local-name()='givenName']");
|
|
|
|
final String surname = n.valueOf("./*[local-name()='familyName']");
|
2021-01-25 18:02:49 +01:00
|
|
|
if (StringUtils.isNotBlank(fullname) || StringUtils.isNotBlank(name) || StringUtils.isNotBlank(surname)) {
|
2021-01-25 17:57:51 +01:00
|
|
|
author.setFullname(fullname);
|
2020-05-14 15:07:24 +02:00
|
|
|
|
2021-01-25 17:57:51 +01:00
|
|
|
final PacePerson pp = new PacePerson(fullname, false);
|
2020-05-22 10:08:02 +02:00
|
|
|
|
2021-01-25 17:57:51 +01:00
|
|
|
if (StringUtils.isBlank(name) & pp.isAccurate()) {
|
|
|
|
author.setName(pp.getNormalisedFirstName());
|
|
|
|
} else {
|
|
|
|
author.setName(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(surname) & pp.isAccurate()) {
|
|
|
|
author.setSurname(pp.getNormalisedSurname());
|
|
|
|
} else {
|
|
|
|
author.setSurname(surname);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(author.getFullname())) {
|
|
|
|
author.setFullname(String.format("%s, %s", author.getSurname(), author.getName()));
|
|
|
|
}
|
|
|
|
|
2021-04-23 17:09:36 +02:00
|
|
|
author.setAffiliation(prepareListFields(n, "./*[local-name()='affiliation']", info));
|
2021-01-25 17:57:51 +01:00
|
|
|
author.setPid(preparePids(n, info));
|
|
|
|
author.setRank(pos++);
|
|
|
|
res.add(author);
|
|
|
|
}
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2020-05-15 12:26:16 +02:00
|
|
|
private List<StructuredProperty> preparePids(final Node n, final DataInfo info) {
|
2020-04-28 11:23:29 +02:00
|
|
|
final List<StructuredProperty> res = new ArrayList<>();
|
2021-04-23 17:09:36 +02:00
|
|
|
for (final Object o : n.selectNodes("./*[local-name()='nameIdentifier']")) {
|
2020-05-22 10:47:39 +02:00
|
|
|
|
|
|
|
final String id = ((Node) o).getText();
|
2020-05-22 12:34:00 +02:00
|
|
|
final String type = ((Node) o)
|
|
|
|
.valueOf("./@nameIdentifierScheme")
|
2020-05-22 10:47:39 +02:00
|
|
|
.trim()
|
|
|
|
.toUpperCase()
|
2020-05-22 11:00:27 +02:00
|
|
|
.replaceAll(" ", "")
|
|
|
|
.replaceAll("_", "");
|
2020-05-22 10:47:39 +02:00
|
|
|
|
2021-05-26 18:20:23 +02:00
|
|
|
if (type.toLowerCase().startsWith(ORCID)) {
|
2020-05-22 10:47:39 +02:00
|
|
|
final String cleanedId = id.replaceAll("http://orcid.org/", "").replaceAll("https://orcid.org/", "");
|
|
|
|
res.add(structuredProperty(cleanedId, ORCID_PID_TYPE, info));
|
|
|
|
} else if (type.startsWith("MAGID")) {
|
|
|
|
res.add(structuredProperty(id, MAG_PID_TYPE, info));
|
|
|
|
}
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Instance> prepareInstances(
|
|
|
|
final Document doc,
|
|
|
|
final DataInfo info,
|
|
|
|
final KeyValue collectedfrom,
|
|
|
|
final KeyValue hostedby) {
|
|
|
|
|
|
|
|
final Instance instance = new Instance();
|
|
|
|
instance
|
2020-05-27 11:34:13 +02:00
|
|
|
.setInstancetype(prepareQualifier(doc, "//dr:CobjCategory", DNET_PUBLICATION_RESOURCE));
|
2020-04-28 11:23:29 +02:00
|
|
|
instance.setCollectedfrom(collectedfrom);
|
|
|
|
instance.setHostedby(hostedby);
|
2021-03-16 14:19:32 +01:00
|
|
|
|
|
|
|
final List<StructuredProperty> alternateIdentifier = prepareResultPids(doc, info);
|
|
|
|
final List<StructuredProperty> pid = IdentifierFactory.getPids(alternateIdentifier, collectedfrom);
|
|
|
|
|
|
|
|
final Set<StructuredProperty> pids = pid.stream().collect(Collectors.toCollection(HashSet::new));
|
|
|
|
|
|
|
|
instance
|
|
|
|
.setAlternateIdentifier(
|
|
|
|
alternateIdentifier.stream().filter(i -> !pids.contains(i)).collect(Collectors.toList()));
|
|
|
|
instance.setPid(pid);
|
|
|
|
|
2020-04-28 11:23:29 +02:00
|
|
|
instance.setDateofacceptance(field(doc.valueOf("//oaf:dateAccepted"), info));
|
2021-05-05 16:36:15 +02:00
|
|
|
final String distributionlocation = doc.valueOf("//oaf:distributionlocation");
|
|
|
|
instance.setDistributionlocation(StringUtils.isNotBlank(distributionlocation) ? distributionlocation : null);
|
2020-04-28 11:23:29 +02:00
|
|
|
instance
|
2021-01-12 15:36:38 +01:00
|
|
|
.setAccessright(prepareAccessRight(doc, "//oaf:accessrights", DNET_ACCESS_MODES));
|
2020-04-28 11:23:29 +02:00
|
|
|
instance.setLicense(field(doc.valueOf("//oaf:license"), info));
|
2020-06-09 19:52:53 +02:00
|
|
|
instance.setRefereed(prepareQualifier(doc, "//oaf:refereed", DNET_REVIEW_LEVELS));
|
2020-04-28 11:23:29 +02:00
|
|
|
instance.setProcessingchargeamount(field(doc.valueOf("//oaf:processingchargeamount"), info));
|
|
|
|
instance
|
2020-05-22 10:08:02 +02:00
|
|
|
.setProcessingchargecurrency(field(doc.valueOf("//oaf:processingchargeamount/@currency"), info));
|
2020-04-28 11:23:29 +02:00
|
|
|
|
2020-05-14 15:07:24 +02:00
|
|
|
final Set<String> url = new HashSet<>();
|
2021-04-23 17:09:36 +02:00
|
|
|
for (final Object o : doc
|
|
|
|
.selectNodes("//*[local-name()='alternateIdentifier' and ./@alternateIdentifierType='URL']")) {
|
2020-05-08 09:43:26 +02:00
|
|
|
url.add(((Node) o).getText().trim());
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
2020-06-11 12:28:34 +02:00
|
|
|
for (final Object o : doc
|
2021-04-23 17:09:36 +02:00
|
|
|
.selectNodes("//*[local-name()='alternateIdentifier' and ./@alternateIdentifierType='landingPage']")) {
|
2020-06-11 12:28:34 +02:00
|
|
|
url.add(((Node) o).getText().trim());
|
|
|
|
}
|
2021-04-23 17:09:36 +02:00
|
|
|
for (final Object o : doc.selectNodes("//*[local-name()='identifier' and ./@identifierType='URL']")) {
|
2020-05-08 09:43:26 +02:00
|
|
|
url.add(((Node) o).getText().trim());
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
2021-04-23 17:09:36 +02:00
|
|
|
for (final Object o : doc.selectNodes("//*[local-name()='identifier' and ./@identifierType='landingPage']")) {
|
2020-06-11 12:28:34 +02:00
|
|
|
url.add(((Node) o).getText().trim());
|
|
|
|
}
|
2021-04-23 17:09:36 +02:00
|
|
|
for (final Object o : doc
|
|
|
|
.selectNodes("//*[local-name()='alternateIdentifier' and ./@alternateIdentifierType='DOI']")) {
|
2020-05-08 09:43:26 +02:00
|
|
|
url.add(HTTP_DX_DOI_PREIFX + ((Node) o).getText().trim());
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
2021-04-23 17:09:36 +02:00
|
|
|
for (final Object o : doc.selectNodes("//*[local-name()='identifier' and ./@identifierType='DOI']")) {
|
2020-05-08 09:43:26 +02:00
|
|
|
url.add(HTTP_DX_DOI_PREIFX + ((Node) o).getText().trim());
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
2020-05-14 15:07:24 +02:00
|
|
|
if (!url.isEmpty()) {
|
|
|
|
instance.setUrl(new ArrayList<>());
|
|
|
|
instance.getUrl().addAll(url);
|
|
|
|
}
|
2020-04-28 11:23:29 +02:00
|
|
|
return Arrays.asList(instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Field<String>> prepareSources(final Document doc, final DataInfo info) {
|
|
|
|
return new ArrayList<>(); // Not present in ODF ???
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<StructuredProperty> prepareRelevantDates(final Document doc, final DataInfo info) {
|
|
|
|
final List<StructuredProperty> res = new ArrayList<>();
|
2021-04-23 17:09:36 +02:00
|
|
|
for (final Object o : doc.selectNodes("//*[local-name()='date']")) {
|
2020-04-28 11:23:29 +02:00
|
|
|
final String dateType = ((Node) o).valueOf("@dateType");
|
|
|
|
if (StringUtils.isBlank(dateType)
|
2021-01-12 15:36:38 +01:00
|
|
|
|| (!dateType.equalsIgnoreCase("Accepted")
|
|
|
|
&& !dateType.equalsIgnoreCase("Issued")
|
|
|
|
&& !dateType.equalsIgnoreCase("Updated")
|
|
|
|
&& !dateType.equalsIgnoreCase("Available"))) {
|
2020-04-28 11:23:29 +02:00
|
|
|
res
|
2020-05-26 13:11:09 +02:00
|
|
|
.add(
|
|
|
|
structuredProperty(
|
2021-03-31 18:33:57 +02:00
|
|
|
((Node) o).getText(), UNKNOWN, UNKNOWN, DNET_DATACITE_DATE, DNET_DATACITE_DATE,
|
2021-01-12 15:36:38 +01:00
|
|
|
info));
|
|
|
|
} else {
|
|
|
|
res
|
|
|
|
.add(
|
|
|
|
structuredProperty(
|
|
|
|
((Node) o).getText(), dateType, dateType, DNET_DATACITE_DATE, DNET_DATACITE_DATE,
|
2020-05-26 13:11:09 +02:00
|
|
|
info));
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Field<String>> prepareCoverages(final Document doc, final DataInfo info) {
|
|
|
|
return new ArrayList<>(); // Not present in ODF ???
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Field<String>> prepareContributors(final Document doc, final DataInfo info) {
|
2021-04-23 17:09:36 +02:00
|
|
|
return prepareListFields(doc, "//*[local-name()='contributorName']", info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Field<String>> prepareFormats(final Document doc, final DataInfo info) {
|
2021-05-05 16:36:15 +02:00
|
|
|
return prepareListFields(doc, "//*[local-name()='format']", info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Field<String> preparePublisher(final Document doc, final DataInfo info) {
|
2021-05-05 16:36:15 +02:00
|
|
|
return prepareField(doc, "//*[local-name()='publisher']", info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Field<String>> prepareDescriptions(final Document doc, final DataInfo info) {
|
2021-04-23 17:09:36 +02:00
|
|
|
return prepareListFields(doc, "//*[local-name()='description' and ./@descriptionType='Abstract']", info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<StructuredProperty> prepareSubjects(final Document doc, final DataInfo info) {
|
2021-04-23 17:09:36 +02:00
|
|
|
return prepareListStructProps(doc, "//*[local-name()='subject']", info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Qualifier prepareLanguages(final Document doc) {
|
2021-05-05 16:36:15 +02:00
|
|
|
return prepareQualifier(doc, "//*[local-name()='language']", DNET_LANGUAGES);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Field<String>> prepareOtherResearchProductTools(
|
2020-05-22 10:08:02 +02:00
|
|
|
final Document doc,
|
|
|
|
final DataInfo info) {
|
2020-04-28 11:23:29 +02:00
|
|
|
return new ArrayList<>(); // Not present in ODF ???
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Field<String>> prepareOtherResearchProductContactGroups(
|
2020-05-22 10:08:02 +02:00
|
|
|
final Document doc,
|
|
|
|
final DataInfo info) {
|
2020-05-26 13:11:09 +02:00
|
|
|
return prepareListFields(
|
2021-04-23 17:09:36 +02:00
|
|
|
doc,
|
|
|
|
"//*[local-name()='contributor' and ./@contributorType='ContactGroup']/*[local-name()='contributorName']",
|
|
|
|
info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Field<String>> prepareOtherResearchProductContactPersons(
|
2020-05-22 10:08:02 +02:00
|
|
|
final Document doc,
|
|
|
|
final DataInfo info) {
|
2020-05-26 13:11:09 +02:00
|
|
|
return prepareListFields(
|
2021-04-23 17:09:36 +02:00
|
|
|
doc,
|
|
|
|
"//*[local-name()='contributor' and ./@contributorType='ContactPerson']/*[local-name()='contributorName']",
|
|
|
|
info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Qualifier prepareSoftwareProgrammingLanguage(final Document doc, final DataInfo info) {
|
2021-04-23 17:09:36 +02:00
|
|
|
return prepareQualifier(doc, "//*[local-name()='format']", DNET_PROGRAMMING_LANGUAGES);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Field<String> prepareSoftwareCodeRepositoryUrl(
|
2020-05-22 10:08:02 +02:00
|
|
|
final Document doc,
|
|
|
|
final DataInfo info) {
|
2020-04-28 11:23:29 +02:00
|
|
|
return null; // Not present in ODF ???
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<StructuredProperty> prepareSoftwareLicenses(
|
2020-05-22 10:08:02 +02:00
|
|
|
final Document doc,
|
|
|
|
final DataInfo info) {
|
2020-04-28 11:23:29 +02:00
|
|
|
return new ArrayList<>(); // Not present in ODF ???
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Field<String>> prepareSoftwareDocumentationUrls(
|
2020-05-22 10:08:02 +02:00
|
|
|
final Document doc,
|
|
|
|
final DataInfo info) {
|
2020-05-26 13:11:09 +02:00
|
|
|
return prepareListFields(
|
2021-04-23 17:09:36 +02:00
|
|
|
doc,
|
|
|
|
"//*[local-name()='relatedIdentifier' and ./@relatedIdentifierType='URL' and @relationType='IsDocumentedBy']",
|
|
|
|
info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// DATASETS
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<GeoLocation> prepareDatasetGeoLocations(final Document doc, final DataInfo info) {
|
|
|
|
final List<GeoLocation> res = new ArrayList<>();
|
|
|
|
|
2021-04-23 17:09:36 +02:00
|
|
|
for (final Object o : doc.selectNodes("//*[local-name()='geoLocation']")) {
|
2020-04-28 11:23:29 +02:00
|
|
|
final GeoLocation loc = new GeoLocation();
|
2021-05-05 16:36:15 +02:00
|
|
|
loc.setBox(((Node) o).valueOf("./*[local-name()='geoLocationBox']"));
|
|
|
|
loc.setPlace(((Node) o).valueOf("./*[local-name()='geoLocationPlace']"));
|
|
|
|
loc.setPoint(((Node) o).valueOf("./*[local-name()='geoLocationPoint']"));
|
2020-04-28 11:23:29 +02:00
|
|
|
res.add(loc);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Field<String> prepareDatasetMetadataVersionNumber(
|
2020-05-22 10:08:02 +02:00
|
|
|
final Document doc,
|
|
|
|
final DataInfo info) {
|
2020-04-28 11:23:29 +02:00
|
|
|
return null; // Not present in ODF ???
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Field<String> prepareDatasetLastMetadataUpdate(
|
2020-05-22 10:08:02 +02:00
|
|
|
final Document doc,
|
|
|
|
final DataInfo info) {
|
2021-04-23 17:09:36 +02:00
|
|
|
return prepareField(doc, "//*[local-name()='date' and ./@dateType='Updated']", info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Field<String> prepareDatasetVersion(final Document doc, final DataInfo info) {
|
2021-04-23 17:09:36 +02:00
|
|
|
return prepareField(doc, "//*[local-name()='version']", info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Field<String> prepareDatasetSize(final Document doc, final DataInfo info) {
|
2021-04-23 17:09:36 +02:00
|
|
|
return prepareField(doc, "//*[local-name()='size']", info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Field<String> prepareDatasetDevice(final Document doc, final DataInfo info) {
|
|
|
|
return null; // Not present in ODF ???
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Field<String> prepareDatasetStorageDate(final Document doc, final DataInfo info) {
|
2021-04-23 17:09:36 +02:00
|
|
|
return prepareField(doc, "//*[local-name()='date' and ./@dateType='Issued']", info);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<Oaf> addOtherResultRels(
|
2020-10-16 17:02:10 +02:00
|
|
|
final Document doc,
|
|
|
|
final OafEntity entity) {
|
2020-04-28 11:23:29 +02:00
|
|
|
|
2020-10-16 16:00:19 +02:00
|
|
|
final String docId = entity.getId();
|
2020-04-28 11:23:29 +02:00
|
|
|
|
|
|
|
final List<Oaf> res = new ArrayList<>();
|
|
|
|
|
2021-04-23 17:09:36 +02:00
|
|
|
for (final Object o : doc
|
|
|
|
.selectNodes("//*[local-name()='relatedIdentifier' and ./@relatedIdentifierType='OPENAIRE']")) {
|
2020-04-28 11:23:29 +02:00
|
|
|
|
|
|
|
final String originalId = ((Node) o).getText();
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(originalId)) {
|
|
|
|
final String otherId = createOpenaireId(50, originalId, false);
|
|
|
|
final String type = ((Node) o).valueOf("@relationType");
|
|
|
|
|
2020-10-16 16:00:19 +02:00
|
|
|
if (type.equalsIgnoreCase(IS_SUPPLEMENT_TO)) {
|
2020-04-28 11:23:29 +02:00
|
|
|
res
|
2020-05-26 13:11:09 +02:00
|
|
|
.add(
|
|
|
|
getRelation(
|
2020-10-16 16:00:19 +02:00
|
|
|
docId, otherId, RESULT_RESULT, SUPPLEMENT, IS_SUPPLEMENT_TO, entity));
|
2020-04-28 11:23:29 +02:00
|
|
|
res
|
2020-05-26 13:11:09 +02:00
|
|
|
.add(
|
|
|
|
getRelation(
|
2020-10-16 16:00:19 +02:00
|
|
|
otherId, docId, RESULT_RESULT, SUPPLEMENT, IS_SUPPLEMENTED_BY, entity));
|
|
|
|
} else if (type.equalsIgnoreCase(IS_PART_OF)) {
|
2020-04-28 11:23:29 +02:00
|
|
|
res
|
2020-05-26 13:11:09 +02:00
|
|
|
.add(
|
|
|
|
getRelation(
|
2020-10-16 16:00:19 +02:00
|
|
|
docId, otherId, RESULT_RESULT, PART, IS_PART_OF, entity));
|
2020-04-28 11:23:29 +02:00
|
|
|
res
|
2020-05-26 13:11:09 +02:00
|
|
|
.add(
|
|
|
|
getRelation(
|
2021-03-31 17:07:13 +02:00
|
|
|
otherId, docId, RESULT_RESULT, PART, HAS_PART, entity));
|
2020-05-26 13:11:09 +02:00
|
|
|
} else {
|
2020-10-16 16:00:19 +02:00
|
|
|
// TODO catch more semantics
|
2020-05-26 13:11:09 +02:00
|
|
|
}
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected Qualifier prepareResourceType(final Document doc, final DataInfo info) {
|
2020-05-26 13:11:09 +02:00
|
|
|
return prepareQualifier(
|
2020-05-27 11:34:13 +02:00
|
|
|
doc, "//*[local-name() = 'resource']//*[local-name() = 'resourceType']", DNET_DATA_CITE_RESOURCE);
|
2020-04-28 11:23:29 +02:00
|
|
|
}
|
2020-05-26 13:06:55 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<StructuredProperty> prepareResultPids(final Document doc, final DataInfo info) {
|
2020-08-04 12:52:14 +02:00
|
|
|
final Set<StructuredProperty> res = new HashSet();
|
2020-05-26 13:11:09 +02:00
|
|
|
res
|
|
|
|
.addAll(
|
2020-05-27 11:34:13 +02:00
|
|
|
prepareListStructPropsWithValidQualifier(
|
|
|
|
doc, "//oaf:identifier", "@identifierType", DNET_PID_TYPES, info));
|
2020-05-26 13:11:09 +02:00
|
|
|
res
|
|
|
|
.addAll(
|
2020-05-27 11:34:13 +02:00
|
|
|
prepareListStructPropsWithValidQualifier(
|
2021-04-23 17:09:36 +02:00
|
|
|
doc,
|
|
|
|
"//*[local-name()='identifier' and ./@identifierType != 'URL' and ./@identifierType != 'landingPage']",
|
2020-06-11 12:28:34 +02:00
|
|
|
"@identifierType", DNET_PID_TYPES, info));
|
2020-05-26 13:11:09 +02:00
|
|
|
res
|
|
|
|
.addAll(
|
2020-05-27 11:34:13 +02:00
|
|
|
prepareListStructPropsWithValidQualifier(
|
2020-06-11 12:28:34 +02:00
|
|
|
doc,
|
2021-04-23 17:09:36 +02:00
|
|
|
"//*[local-name()='alternateIdentifier' and ./@alternateIdentifierType != 'URL' and ./@alternateIdentifierType != 'landingPage']",
|
2020-05-27 11:34:13 +02:00
|
|
|
"@alternateIdentifierType", DNET_PID_TYPES, info));
|
2020-10-30 10:56:42 +01:00
|
|
|
|
|
|
|
return res
|
|
|
|
.stream()
|
2020-11-03 12:19:46 +01:00
|
|
|
.map(CleaningFunctions::normalizePidValue)
|
2020-10-30 10:56:42 +01:00
|
|
|
.collect(Collectors.toList());
|
2020-05-26 13:06:55 +02:00
|
|
|
}
|
|
|
|
|
2020-02-05 15:35:40 +01:00
|
|
|
}
|