forked from D-Net/dnet-hadoop
Merge pull request 'BipInstance' (#185) from BipInstance into beta
Reviewed-on: D-Net/dnet-hadoop#185
This commit is contained in:
commit
7bf12ad24a
|
@ -18,6 +18,7 @@ import eu.dnetlib.dhp.schema.oaf.utils.OafMapperUtils;
|
|||
public class Constants {
|
||||
|
||||
public static final String DOI = "doi";
|
||||
public static final String DOI_CLASSNAME = "Digital Object Identifier";
|
||||
|
||||
public static final String DEFAULT_DELIMITER = ",";
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import eu.dnetlib.dhp.schema.oaf.Instance;
|
|||
import eu.dnetlib.dhp.schema.oaf.KeyValue;
|
||||
import eu.dnetlib.dhp.schema.oaf.Measure;
|
||||
import eu.dnetlib.dhp.schema.oaf.Result;
|
||||
import eu.dnetlib.dhp.schema.oaf.utils.CleaningFunctions;
|
||||
import eu.dnetlib.dhp.schema.oaf.utils.OafMapperUtils;
|
||||
import eu.dnetlib.dhp.utils.DHPUtils;
|
||||
|
||||
|
@ -95,11 +96,39 @@ public class PrepareBipFinder implements Serializable {
|
|||
}).collect(Collectors.toList()).iterator()).rdd(), Encoders.bean(BipScore.class))
|
||||
.map((MapFunction<BipScore, Result>) v -> {
|
||||
Result r = new Result();
|
||||
final String cleanedPid = CleaningFunctions.normalizePidValue(DOI, v.getId());
|
||||
|
||||
r.setId(DHPUtils.generateUnresolvedIdentifier(v.getId(), DOI));
|
||||
Instance inst = new Instance();
|
||||
inst.setMeasures(getMeasure(v));
|
||||
|
||||
inst
|
||||
.setPid(
|
||||
Arrays
|
||||
.asList(
|
||||
OafMapperUtils
|
||||
.structuredProperty(
|
||||
cleanedPid,
|
||||
OafMapperUtils
|
||||
.qualifier(
|
||||
DOI, DOI_CLASSNAME,
|
||||
ModelConstants.DNET_PID_TYPES,
|
||||
ModelConstants.DNET_PID_TYPES),
|
||||
null)));
|
||||
r.setInstance(Arrays.asList(inst));
|
||||
r
|
||||
.setDataInfo(
|
||||
OafMapperUtils
|
||||
.dataInfo(
|
||||
false, null, true,
|
||||
false,
|
||||
OafMapperUtils
|
||||
.qualifier(
|
||||
ModelConstants.PROVENANCE_ENRICH,
|
||||
null,
|
||||
ModelConstants.DNET_PROVENANCE_ACTIONS,
|
||||
ModelConstants.DNET_PROVENANCE_ACTIONS),
|
||||
null));
|
||||
return r;
|
||||
}, Encoders.bean(Result.class))
|
||||
.write()
|
||||
|
|
|
@ -245,6 +245,68 @@ public class ProduceTest {
|
|||
.get(0)
|
||||
.getValue());
|
||||
|
||||
Assertions
|
||||
.assertEquals(
|
||||
"10.3390/s18072310",
|
||||
tmp
|
||||
.filter(row -> row.getId().equals(doi))
|
||||
.collect()
|
||||
.get(0)
|
||||
.getInstance()
|
||||
.get(0)
|
||||
.getPid()
|
||||
.get(0)
|
||||
.getValue()
|
||||
.toLowerCase());
|
||||
|
||||
Assertions
|
||||
.assertEquals(
|
||||
"doi",
|
||||
tmp
|
||||
.filter(row -> row.getId().equals(doi))
|
||||
.collect()
|
||||
.get(0)
|
||||
.getInstance()
|
||||
.get(0)
|
||||
.getPid()
|
||||
.get(0)
|
||||
.getQualifier()
|
||||
.getClassid());
|
||||
|
||||
Assertions
|
||||
.assertEquals(
|
||||
"Digital Object Identifier",
|
||||
tmp
|
||||
.filter(row -> row.getId().equals(doi))
|
||||
.collect()
|
||||
.get(0)
|
||||
.getInstance()
|
||||
.get(0)
|
||||
.getPid()
|
||||
.get(0)
|
||||
.getQualifier()
|
||||
.getClassname());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void produceTestMeasures() throws Exception {
|
||||
final String doi = "unresolved::10.3390/s18072310::doi";
|
||||
JavaRDD<Result> tmp = getResultJavaRDD();
|
||||
|
||||
List<StructuredProperty> mes = tmp
|
||||
.filter(row -> row.getInstance() != null && row.getInstance().size() > 0)
|
||||
.flatMap(row -> row.getInstance().iterator())
|
||||
.flatMap(i -> i.getPid().iterator())
|
||||
.collect();
|
||||
|
||||
Assertions.assertEquals(86, mes.size());
|
||||
|
||||
tmp
|
||||
.filter(row -> row.getInstance() != null && row.getInstance().size() > 0)
|
||||
.foreach(
|
||||
e -> Assertions.assertEquals("sysimport:enrich", e.getDataInfo().getProvenanceaction().getClassid()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -797,7 +797,7 @@
|
|||
<mockito-core.version>3.3.3</mockito-core.version>
|
||||
<mongodb.driver.version>3.4.2</mongodb.driver.version>
|
||||
<vtd.version>[2.12,3.0)</vtd.version>
|
||||
<dhp-schemas.version>[2.9.24]</dhp-schemas.version>
|
||||
<dhp-schemas.version>[2.10.24]</dhp-schemas.version>
|
||||
<dnet-actionmanager-api.version>[4.0.3]</dnet-actionmanager-api.version>
|
||||
<dnet-actionmanager-common.version>[6.0.5]</dnet-actionmanager-common.version>
|
||||
<dnet-openaire-broker-common.version>[3.1.6]</dnet-openaire-broker-common.version>
|
||||
|
|
Loading…
Reference in New Issue