forked from D-Net/dnet-hadoop
Merge branch 'master' into dhp_oaf_model
This commit is contained in:
commit
631fef12a7
|
@ -140,7 +140,8 @@ public class GenerateEventsApplication {
|
||||||
final Dataset<Publication> publications = readPath(spark, graphPath + "/publication", Publication.class);
|
final Dataset<Publication> publications = readPath(spark, graphPath + "/publication", Publication.class);
|
||||||
|
|
||||||
final Dataset<Relation> rels = readPath(spark, graphPath + "/relation", Relation.class)
|
final Dataset<Relation> rels = readPath(spark, graphPath + "/relation", Relation.class)
|
||||||
.filter(r -> !r.getRelClass().equals(BrokerConstants.IS_MERGED_IN_CLASS));
|
.filter(r -> !r.getRelClass().equals(BrokerConstants.IS_MERGED_IN_CLASS))
|
||||||
|
.cache();
|
||||||
|
|
||||||
final Dataset<OpenaireBrokerResult> r0 = readPath(
|
final Dataset<OpenaireBrokerResult> r0 = readPath(
|
||||||
spark, graphPath + "/" + sourceClass.getSimpleName().toLowerCase(), Result.class)
|
spark, graphPath + "/" + sourceClass.getSimpleName().toLowerCase(), Result.class)
|
||||||
|
|
|
@ -68,6 +68,22 @@ public class ConversionUtils {
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static eu.dnetlib.broker.objects.Publication oafPublicationToBrokerPublication(final Publication p) {
|
||||||
|
return p != null ? new eu.dnetlib.broker.objects.Publication()
|
||||||
|
.setOriginalId(p.getOriginalId().get(0))
|
||||||
|
.setTitle(structPropValue(p.getTitle()))
|
||||||
|
.setPids(p.getPid().stream().map(ConversionUtils::oafPidToBrokerPid).collect(Collectors.toList()))
|
||||||
|
.setInstances(
|
||||||
|
p
|
||||||
|
.getInstance()
|
||||||
|
.stream()
|
||||||
|
.map(ConversionUtils::oafInstanceToBrokerInstances)
|
||||||
|
.flatMap(List::stream)
|
||||||
|
.collect(Collectors.toList()))
|
||||||
|
.setCollectedFrom(p.getCollectedfrom().stream().map(KeyValue::getValue).findFirst().orElse(null))
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
public static final OpenaireBrokerResult oafResultToBrokerResult(final Result result) {
|
public static final OpenaireBrokerResult oafResultToBrokerResult(final Result result) {
|
||||||
|
|
||||||
return result != null ? new OpenaireBrokerResult()
|
return result != null ? new OpenaireBrokerResult()
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
|
||||||
package eu.dnetlib.dhp.broker.oa.util.aggregators.withRels;
|
package eu.dnetlib.dhp.broker.oa.util.aggregators.withRels;
|
||||||
|
|
||||||
import eu.dnetlib.broker.objects.Dataset;
|
import eu.dnetlib.dhp.broker.oa.util.ConversionUtils;
|
||||||
import eu.dnetlib.broker.objects.Project;
|
import eu.dnetlib.dhp.schema.oaf.Dataset;
|
||||||
import eu.dnetlib.broker.objects.Publication;
|
import eu.dnetlib.dhp.schema.oaf.Project;
|
||||||
import eu.dnetlib.broker.objects.Software;
|
import eu.dnetlib.dhp.schema.oaf.Publication;
|
||||||
|
import eu.dnetlib.dhp.schema.oaf.Software;
|
||||||
|
|
||||||
public class RelatedEntityFactory {
|
public class RelatedEntityFactory {
|
||||||
|
|
||||||
|
@ -13,18 +14,21 @@ public class RelatedEntityFactory {
|
||||||
final String relType,
|
final String relType,
|
||||||
final T target,
|
final T target,
|
||||||
final Class<RT> clazz) {
|
final Class<RT> clazz) {
|
||||||
|
|
||||||
if (clazz == RelatedProject.class) {
|
if (clazz == RelatedProject.class) {
|
||||||
return (RT) new RelatedProject(sourceId, relType, (Project) target);
|
return (RT) new RelatedProject(sourceId, relType,
|
||||||
|
ConversionUtils.oafProjectToBrokerProject((Project) target));
|
||||||
|
} else if (clazz == RelatedSoftware.class) {
|
||||||
|
return (RT) new RelatedSoftware(sourceId, relType,
|
||||||
|
ConversionUtils.oafSoftwareToBrokerSoftware((Software) target));
|
||||||
|
} else if (clazz == RelatedDataset.class) {
|
||||||
|
return (RT) new RelatedDataset(sourceId, relType,
|
||||||
|
ConversionUtils.oafDatasetToBrokerDataset((Dataset) target));
|
||||||
|
} else if (clazz == RelatedPublication.class) {
|
||||||
|
return (RT) new RelatedPublication(sourceId, relType,
|
||||||
|
ConversionUtils.oafPublicationToBrokerPublication((Publication) target));
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
if (clazz == RelatedSoftware.class) {
|
|
||||||
return (RT) new RelatedSoftware(sourceId, relType, (Software) target);
|
|
||||||
}
|
|
||||||
if (clazz == RelatedDataset.class) {
|
|
||||||
return (RT) new RelatedDataset(sourceId, relType, (Dataset) target);
|
|
||||||
}
|
|
||||||
if (clazz == RelatedPublication.class) {
|
|
||||||
return (RT) new RelatedPublication(sourceId, relType, (Publication) target);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,9 +126,16 @@ public class OdfToOafMapper extends AbstractMdRecordToOafMapper {
|
||||||
for (final Object o : doc.selectNodes("//datacite:alternateIdentifier[@alternateIdentifierType='URL']")) {
|
for (final Object o : doc.selectNodes("//datacite:alternateIdentifier[@alternateIdentifierType='URL']")) {
|
||||||
url.add(((Node) o).getText().trim());
|
url.add(((Node) o).getText().trim());
|
||||||
}
|
}
|
||||||
|
for (final Object o : doc
|
||||||
|
.selectNodes("//datacite:alternateIdentifier[@alternateIdentifierType='landingPage']")) {
|
||||||
|
url.add(((Node) o).getText().trim());
|
||||||
|
}
|
||||||
for (final Object o : doc.selectNodes("//datacite:identifier[@identifierType='URL']")) {
|
for (final Object o : doc.selectNodes("//datacite:identifier[@identifierType='URL']")) {
|
||||||
url.add(((Node) o).getText().trim());
|
url.add(((Node) o).getText().trim());
|
||||||
}
|
}
|
||||||
|
for (final Object o : doc.selectNodes("//datacite:identifier[@identifierType='landingPage']")) {
|
||||||
|
url.add(((Node) o).getText().trim());
|
||||||
|
}
|
||||||
for (final Object o : doc.selectNodes("//datacite:alternateIdentifier[@alternateIdentifierType='DOI']")) {
|
for (final Object o : doc.selectNodes("//datacite:alternateIdentifier[@alternateIdentifierType='DOI']")) {
|
||||||
url.add(HTTP_DX_DOI_PREIFX + ((Node) o).getText().trim());
|
url.add(HTTP_DX_DOI_PREIFX + ((Node) o).getText().trim());
|
||||||
}
|
}
|
||||||
|
@ -367,11 +374,13 @@ public class OdfToOafMapper extends AbstractMdRecordToOafMapper {
|
||||||
res
|
res
|
||||||
.addAll(
|
.addAll(
|
||||||
prepareListStructPropsWithValidQualifier(
|
prepareListStructPropsWithValidQualifier(
|
||||||
doc, "//datacite:identifier[@identifierType != 'URL']", "@identifierType", DNET_PID_TYPES, info));
|
doc, "//datacite:identifier[@identifierType != 'URL' and @identifierType != 'landingPage']",
|
||||||
|
"@identifierType", DNET_PID_TYPES, info));
|
||||||
res
|
res
|
||||||
.addAll(
|
.addAll(
|
||||||
prepareListStructPropsWithValidQualifier(
|
prepareListStructPropsWithValidQualifier(
|
||||||
doc, "//datacite:alternateIdentifier[@alternateIdentifierType != 'URL']",
|
doc,
|
||||||
|
"//datacite:alternateIdentifier[@alternateIdentifierType != 'URL' and @alternateIdentifierType != 'landingPage']",
|
||||||
"@alternateIdentifierType", DNET_PID_TYPES, info));
|
"@alternateIdentifierType", DNET_PID_TYPES, info));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue