Merge pull request 'enrichment' (#9) from enrichment into master

Reviewed-on: #9
This commit is contained in:
Claudio Atzori 2022-01-14 09:48:53 +01:00
commit fa4cd3963b
4 changed files with 724 additions and 8 deletions

View File

@ -2,246 +2,703 @@
package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import java.util.stream.Collectors;
import eu.dnetlib.dhp.schema.common.AccessRightComparator;
import eu.dnetlib.dhp.schema.common.ModelConstants;
import eu.dnetlib.dhp.schema.oaf.utils.CleaningFunctions;
import scala.Tuple2;
/**
* The type Result.
*/
public class Result extends OafEntity implements Serializable {
/**
* The Measures.
*/
private List<Measure> measures;
/**
* The Author.
*/
private List<Author> author;
// resulttype allows subclassing results into publications | datasets | software
/**
* The Resulttype.
*/
// resulttype allows subclassing results into publications | datasets | software
private Qualifier resulttype;
// common fields
/**
* The Language.
*/
// common fields
private Qualifier language;
/**
* The Country.
*/
private List<Country> country;
/**
* The Subject.
*/
private List<StructuredProperty> subject;
/**
* The Title.
*/
private List<StructuredProperty> title;
/**
* The Relevantdate.
*/
private List<StructuredProperty> relevantdate;
/**
* The Description.
*/
private List<Field<String>> description;
/**
* The Dateofacceptance.
*/
private Field<String> dateofacceptance;
/**
* The Publisher.
*/
private Field<String> publisher;
/**
* The Embargoenddate.
*/
private Field<String> embargoenddate;
/**
* The Source.
*/
private List<Field<String>> source;
/**
* The Fulltext.
*/
private List<Field<String>> fulltext; // remove candidate
/**
* The Format.
*/
private List<Field<String>> format;
/**
* The Contributor.
*/
private List<Field<String>> contributor;
/**
* The Resourcetype.
*/
private Qualifier resourcetype;
/**
* The Coverage.
*/
private List<Field<String>> coverage;
/**
* The Bestaccessright.
*/
private Qualifier bestaccessright;
/**
* The Context.
*/
private List<Context> context;
/**
* The External reference.
*/
private List<ExternalReference> externalReference;
/**
* The Instance.
*/
private List<Instance> instance;
/**
* Gets measures.
*
* @return the measures
*/
public List<Measure> getMeasures() {
return measures;
}
/**
* Sets measures.
*
* @param measures the measures
*/
public void setMeasures(List<Measure> measures) {
this.measures = measures;
}
/**
* Gets author.
*
* @return the author
*/
public List<Author> getAuthor() {
return author;
}
/**
* Sets author.
*
* @param author the author
*/
public void setAuthor(List<Author> author) {
this.author = author;
}
/**
* Gets resulttype.
*
* @return the resulttype
*/
public Qualifier getResulttype() {
return resulttype;
}
/**
* Sets resulttype.
*
* @param resulttype the resulttype
*/
public void setResulttype(Qualifier resulttype) {
this.resulttype = resulttype;
}
/**
* Gets language.
*
* @return the language
*/
public Qualifier getLanguage() {
return language;
}
/**
* Sets language.
*
* @param language the language
*/
public void setLanguage(Qualifier language) {
this.language = language;
}
/**
* Gets country.
*
* @return the country
*/
public List<Country> getCountry() {
return country;
}
/**
* Sets country.
*
* @param country the country
*/
public void setCountry(List<Country> country) {
this.country = country;
}
/**
* Gets subject.
*
* @return the subject
*/
public List<StructuredProperty> getSubject() {
return subject;
}
/**
* Sets subject.
*
* @param subject the subject
*/
public void setSubject(List<StructuredProperty> subject) {
this.subject = subject;
}
/**
* Gets title.
*
* @return the title
*/
public List<StructuredProperty> getTitle() {
return title;
}
/**
* Sets title.
*
* @param title the title
*/
public void setTitle(List<StructuredProperty> title) {
this.title = title;
}
/**
* Gets relevantdate.
*
* @return the relevantdate
*/
public List<StructuredProperty> getRelevantdate() {
return relevantdate;
}
/**
* Sets relevantdate.
*
* @param relevantdate the relevantdate
*/
public void setRelevantdate(List<StructuredProperty> relevantdate) {
this.relevantdate = relevantdate;
}
/**
* Gets description.
*
* @return the description
*/
public List<Field<String>> getDescription() {
return description;
}
/**
* Sets description.
*
* @param description the description
*/
public void setDescription(List<Field<String>> description) {
this.description = description;
}
/**
* Gets dateofacceptance.
*
* @return the dateofacceptance
*/
public Field<String> getDateofacceptance() {
return dateofacceptance;
}
/**
* Sets dateofacceptance.
*
* @param dateofacceptance the dateofacceptance
*/
public void setDateofacceptance(Field<String> dateofacceptance) {
this.dateofacceptance = dateofacceptance;
}
/**
* Gets publisher.
*
* @return the publisher
*/
public Field<String> getPublisher() {
return publisher;
}
/**
* Sets publisher.
*
* @param publisher the publisher
*/
public void setPublisher(Field<String> publisher) {
this.publisher = publisher;
}
/**
* Gets embargoenddate.
*
* @return the embargoenddate
*/
public Field<String> getEmbargoenddate() {
return embargoenddate;
}
/**
* Sets embargoenddate.
*
* @param embargoenddate the embargoenddate
*/
public void setEmbargoenddate(Field<String> embargoenddate) {
this.embargoenddate = embargoenddate;
}
/**
* Gets source.
*
* @return the source
*/
public List<Field<String>> getSource() {
return source;
}
/**
* Sets source.
*
* @param source the source
*/
public void setSource(List<Field<String>> source) {
this.source = source;
}
/**
* Gets fulltext.
*
* @return the fulltext
*/
public List<Field<String>> getFulltext() {
return fulltext;
}
/**
* Sets fulltext.
*
* @param fulltext the fulltext
*/
public void setFulltext(List<Field<String>> fulltext) {
this.fulltext = fulltext;
}
/**
* Gets format.
*
* @return the format
*/
public List<Field<String>> getFormat() {
return format;
}
/**
* Sets format.
*
* @param format the format
*/
public void setFormat(List<Field<String>> format) {
this.format = format;
}
/**
* Gets contributor.
*
* @return the contributor
*/
public List<Field<String>> getContributor() {
return contributor;
}
/**
* Sets contributor.
*
* @param contributor the contributor
*/
public void setContributor(List<Field<String>> contributor) {
this.contributor = contributor;
}
/**
* Gets resourcetype.
*
* @return the resourcetype
*/
public Qualifier getResourcetype() {
return resourcetype;
}
/**
* Sets resourcetype.
*
* @param resourcetype the resourcetype
*/
public void setResourcetype(Qualifier resourcetype) {
this.resourcetype = resourcetype;
}
/**
* Gets coverage.
*
* @return the coverage
*/
public List<Field<String>> getCoverage() {
return coverage;
}
/**
* Sets coverage.
*
* @param coverage the coverage
*/
public void setCoverage(List<Field<String>> coverage) {
this.coverage = coverage;
}
/**
* Gets bestaccessright.
*
* @return the bestaccessright
*/
public Qualifier getBestaccessright() {
return bestaccessright;
}
/**
* Sets bestaccessright.
*
* @param bestaccessright the bestaccessright
*/
public void setBestaccessright(Qualifier bestaccessright) {
this.bestaccessright = bestaccessright;
}
/**
* Gets context.
*
* @return the context
*/
public List<Context> getContext() {
return context;
}
/**
* Sets context.
*
* @param context the context
*/
public void setContext(List<Context> context) {
this.context = context;
}
/**
* Gets external reference.
*
* @return the external reference
*/
public List<ExternalReference> getExternalReference() {
return externalReference;
}
/**
* Sets external reference.
*
* @param externalReference the external reference
*/
public void setExternalReference(List<ExternalReference> externalReference) {
this.externalReference = externalReference;
}
/**
* Gets instance.
*
* @return the instance
*/
public List<Instance> getInstance() {
return instance;
}
/**
* Sets instance.
*
* @param instance the instance
*/
public void setInstance(List<Instance> instance) {
this.instance = instance;
}
private static boolean isAnEnrichment(OafEntity e) {
/**
* Is an enrichment boolean.
*
* @param e the e
* @return the boolean
*/
public static boolean isAnEnrichment(OafEntity e) {
return e.getDataInfo()!= null &&
e.getDataInfo().getProvenanceaction()!= null
&& ModelConstants.PROVENANCE_ENRICH.equalsIgnoreCase(e.getDataInfo().getProvenanceaction().getClassid());
}
/**
* Normalize pid string.
*
* @param pid the pid
* @return the string
*/
private static String extractKeyFromPid(final StructuredProperty pid) {
if (pid == null)
return null;
final StructuredProperty normalizedPid = CleaningFunctions.normalizePidValue(pid);
return String.format("%s::%s", normalizedPid.getQualifier().getClassid(), normalizedPid.getValue());
}
/**
* Valid pid boolean.
*
* @param p the p
* @return the boolean
*/
private static boolean validPid(final StructuredProperty p) {
return p.getValue()!= null && p.getQualifier()!= null && p.getQualifier().getClassid()!=null;
}
/**
* This method converts the list of instance enrichments
* into a Map where the key is the normalized identifier
* and the value is the instance itself
*
* @param ri the list of enrichment instances
* @return the result map
*/
public static Map<String, Instance> toInstanceMap(final List<Instance> ri) {
return ri
.stream()
.filter(i -> i.getPid() != null || i.getAlternateIdentifier() != null)
.flatMap(i -> {
final List<Tuple2<String, Instance>> result = new ArrayList<>();
if (i.getPid() != null)
i.getPid().stream().filter(Result::validPid).forEach(p -> result.add(new Tuple2<>(extractKeyFromPid(p), i)));
if (i.getAlternateIdentifier() != null)
i.getAlternateIdentifier().stream().filter(Result::validPid).forEach(p -> result.add(new Tuple2<>(extractKeyFromPid(p), i)));
return result.stream();
}).collect(Collectors.toMap(
Tuple2::_1,
Tuple2::_2,
(a, b) -> a
));
}
/**
* This utility method finds the list of enrichment instances
* that match one or more PIDs in the input list
*
* @param pids the list of PIDs
* @param enrichments the List of enrichment instances having the same pid
* @return the list
*/
private static List<Instance> findEnrichmentsByPID(final List<StructuredProperty> pids, final Map<String,Instance> enrichments) {
if (pids == null || enrichments == null)
return null;
return pids
.stream()
.map(Result::extractKeyFromPid)
.map(enrichments::get)
.filter(Objects::nonNull)
.collect(Collectors.toList());
}
/**
* This method apply enrichment on a single instance
* The enrichment consists of replacing values on
* single attribute only if in the current instance is missing
* The only repeatable field enriched is measures
*
* @param currentInstance the current instance
* @param enrichment the enrichment instance
*/
private static void applyEnrichment(final Instance currentInstance, final Instance enrichment) {
if (currentInstance == null || enrichment == null)
return;
//ENRICH accessright
if (enrichment.getAccessright()!=null && currentInstance.getAccessright() == null)
currentInstance.setAccessright(enrichment.getAccessright());
//ENRICH license
if (enrichment.getLicense()!=null && currentInstance.getLicense() == null)
currentInstance.setLicense(enrichment.getLicense());
//ENRICH instanceType
if (enrichment.getInstancetype()!=null && currentInstance.getInstancetype() == null)
currentInstance.setInstancetype(enrichment.getInstancetype());
//ENRICH hostedby
if (enrichment.getHostedby()!=null && currentInstance.getHostedby() == null)
currentInstance.setHostedby(enrichment.getHostedby());
//ENRICH distributionlocation
if (enrichment.getDistributionlocation()!=null && currentInstance.getDistributionlocation() == null)
currentInstance.setDistributionlocation(enrichment.getDistributionlocation());
//ENRICH collectedfrom
if (enrichment.getCollectedfrom()!=null && currentInstance.getCollectedfrom() == null)
currentInstance.setCollectedfrom(enrichment.getCollectedfrom());
//ENRICH dateofacceptance
if (enrichment.getDateofacceptance()!=null && currentInstance.getDateofacceptance() == null)
currentInstance.setDateofacceptance(enrichment.getDateofacceptance());
//ENRICH processingchargeamount
if (enrichment.getProcessingchargeamount()!=null && currentInstance.getProcessingchargeamount() == null)
currentInstance.setProcessingchargeamount(enrichment.getProcessingchargeamount());
//ENRICH refereed
if (enrichment.getRefereed()!=null && currentInstance.getRefereed() == null)
currentInstance.setRefereed(enrichment.getRefereed());
//ENRICH measures
if (enrichment.getMeasures()!=null)
if (currentInstance.getMeasures() == null)
currentInstance.setMeasures(enrichment.getMeasures());
else
enrichment.getMeasures().forEach(currentInstance.getMeasures()::add);
}
/**
* This main method apply the enrichment of the instances
*
* @param toEnrichInstances the instances that could be enriched
* @param enrichmentInstances the enrichment instances
* @return list of instances possibly enriched
*/
private static List<Instance> enrichInstances(final List<Instance> toEnrichInstances,final List<Instance> enrichmentInstances) {
final List<Instance> enrichmentResult = new ArrayList<>();
if (toEnrichInstances == null) {
return enrichmentResult;
}
if (enrichmentInstances == null) {
return enrichmentResult;
}
Map<String, Instance> ri = toInstanceMap(enrichmentInstances);
toEnrichInstances.forEach(i -> {
final List<Instance> e = findEnrichmentsByPID(i.getPid(), ri);
if (e!= null && e.size()> 0) {
e.forEach(enr -> applyEnrichment(i, enr));
} else {
final List<Instance> a = findEnrichmentsByPID(i.getAlternateIdentifier(), ri);
if (a!= null && a.size()> 0) {
a.forEach(enr -> applyEnrichment(i, enr));
}
}
enrichmentResult.add(i);
});
return enrichmentResult;
}
@Override
public void mergeFrom(OafEntity e) {
super.mergeFrom(e);
@ -254,7 +711,15 @@ public class Result extends OafEntity implements Serializable {
measures = mergeLists(measures, r.getMeasures());
instance = mergeLists(instance, r.getInstance());
if( !isAnEnrichment(this) && !isAnEnrichment(e))
instance = mergeLists(instance, r.getInstance());
else {
final List<Instance> enrichmentInstances = isAnEnrichment(this) ? instance : r.getInstance();
final List<Instance> enrichedInstances= isAnEnrichment(this) ? r.getInstance(): instance;
if (isAnEnrichment(this))
setDataInfo(e.getDataInfo());
instance = enrichInstances(enrichedInstances,enrichmentInstances);
}
if (r.getBestaccessright() != null
&& new AccessRightComparator().compare(r.getBestaccessright(), bestaccessright) < 0)
@ -334,6 +799,13 @@ public class Result extends OafEntity implements Serializable {
externalReference = mergeLists(externalReference, r.getExternalReference());
}
/**
* Longest lists list.
*
* @param a the a
* @param b the b
* @return the list
*/
private List<Field<String>> longestLists(List<Field<String>> a, List<Field<String>> b) {
if (a == null || b == null)
return a == null ? b : a;
@ -355,6 +827,12 @@ public class Result extends OafEntity implements Serializable {
return a.size() > b.size() ? a : b;
}
/**
* Gets main title.
*
* @param titles the titles
* @return the main title
*/
private StructuredProperty getMainTitle(List<StructuredProperty> titles) {
// need to check if the list of titles contains more than 1 main title? (in that case, we should chose which
// main title select in the list)

View File

@ -3,22 +3,42 @@ package eu.dnetlib.dhp.schema.oaf;
import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException;
import java.io.InputStream;
import java.time.format.DateTimeParseException;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* The type Merge test.
*/
class MergeTest {
/**
* The Oaf.
*/
OafEntity oaf;
/**
* Sets up.
*/
@BeforeEach
public void setUp() {
oaf = new Publication();
}
/**
* Merge lists test.
*/
@Test
@SuppressWarnings("unchecked")
void mergeListsTest() {
@ -35,6 +55,9 @@ class MergeTest {
System.out.println("merge result 3 = " + oaf.mergeLists(c, c));
}
/**
* Merge publication collected from test.
*/
@Test
void mergePublicationCollectedFromTest() {
@ -50,6 +73,118 @@ class MergeTest {
assertEquals(3, a.getCollectedfrom().size());
}
/**
* Load resource result list.
*
* @param <T> the type parameter
* @param path the path
* @param clazz the clazz
* @return the list
* @throws Exception the exception
*/
private <T extends Result> List<Result> loadResourceResult(final String path, final Class<T> clazz ) throws Exception {
final ObjectMapper mapper = new ObjectMapper();
final InputStream str = Objects.requireNonNull(getClass().getResourceAsStream(path));
// LOAD test publications
return IOUtils.readLines(str).stream().map(s -> {
try {
return mapper.readValue(s, clazz);
} catch (IOException e) {
return null;
}
}).filter(Objects::nonNull).collect(Collectors.toList());
}
/**
* Apply to any test list result the same pid of the enrichment instance
*
* @param source the source
* @param enrichment the enrichment
* @param overrideAlternateIdentifier the override alternate identifier
*/
private void updatePidIntoPublicationInstance(final List<Result> source, final List<Result>enrichment, final boolean overrideAlternateIdentifier) {
for(int i = 0 ; i< source.size(); i++) {
final Result currentPub = source.get(i);
final Result currentEnrichment = enrichment.get(i);
final Instance currentInstance = Objects.requireNonNull(currentPub.getInstance()).get(0);
if (overrideAlternateIdentifier)
currentInstance.setAlternateIdentifier(Objects.requireNonNull(currentEnrichment.getInstance()).get(0).getPid());
else
currentInstance.setPid(Objects.requireNonNull(currentEnrichment.getInstance()).get(0).getPid());
}
}
private void applyAndVerifyEnrichment(final List<Result> l1, final List<Result> l2) {
// Apply Merge and verify that enrichments works
for(int i = 0 ; i< l1.size(); i++) {
final Result currentPub = l2.get(i);
final Result currentEnrichment = l1.get(i);
currentPub.mergeFrom(currentEnrichment);
assertEquals(1, currentPub.getInstance().size());
final Instance currentInstance = Objects.requireNonNull(currentPub.getInstance()).get(0);
assertNotNull(currentInstance.getMeasures());
assertNotNull(currentPub.getTitle());
assertFalse(Result.isAnEnrichment(currentPub));
}
}
/**
* Test enrichment function.
*
* @throws Exception the exception
*/
@Test
void testEnrichment() throws Exception {
// 1 TEST UPDATING PID INSTANCE AND MERGE CURRENT PUBLICATION WITH ENRICHMENT
// LOAD test publications
List<Result> publications = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/publications.json", Publication.class);
// Assert that each publication has only one instance and inside that all the measure field is empty
publications.forEach(p -> {
assertEquals(1, p.getInstance().size());
final Instance currentInstance = Objects.requireNonNull(p.getInstance()).get(0);
assertNull(currentInstance.getMeasures());
});
// LOAD test enrichments
List<Result> enrichment = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/enrichment.json", Result.class);
updatePidIntoPublicationInstance(publications, enrichment, false);
applyAndVerifyEnrichment(publications, enrichment);
// 2 TEST UPDATING ALTERNATE ID INSTANCE AND MERGE CURRENT PUBLICATION WITH ENRICHMENT
publications = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/publications.json", Publication.class);
enrichment = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/enrichment.json", Result.class);
updatePidIntoPublicationInstance(publications, enrichment, true);
applyAndVerifyEnrichment(publications, enrichment);
// 3 TEST UPDATING PID INSTANCE AND MERGE ENRICHMENT WITH CURRENT PUBLICATION
publications = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/publications.json", Publication.class);
enrichment = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/enrichment.json", Result.class);
updatePidIntoPublicationInstance(publications, enrichment, false);
applyAndVerifyEnrichment( enrichment, publications);
// 4 TEST UPDATING ALTERNATE ID INSTANCE AND MERGE ENRICHMENT WITH CURRENT PUBLICATION
publications = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/publications.json", Publication.class);
enrichment = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/enrichment.json", Result.class);
updatePidIntoPublicationInstance(publications, enrichment, true);
applyAndVerifyEnrichment( enrichment, publications);
}
/**
* Merge publication date of acceptance test both present.
*/
@Test
void mergePublicationDateOfAcceptanceTest_bothPresent() {
@ -65,6 +200,9 @@ class MergeTest {
assertEquals("2021-06-18", a.getDateofacceptance().getValue());
}
/**
* Merge publication date of acceptance test both present 1.
*/
@Test
void mergePublicationDateOfAcceptanceTest_bothPresent_1() {
@ -80,6 +218,9 @@ class MergeTest {
assertEquals("2021-06-19", a.getDateofacceptance().getValue());
}
/**
* Merge publication date of acceptance test both present 2.
*/
@Test
void mergePublicationDateOfAcceptanceTest_bothPresent_2() {
@ -95,6 +236,9 @@ class MergeTest {
assertEquals("2021-06-18", a.getDateofacceptance().getValue());
}
/**
* Merge publication date of acceptance test left missing.
*/
@Test
void mergePublicationDateOfAcceptanceTest_leftMissing() {
@ -109,6 +253,9 @@ class MergeTest {
assertEquals("2021-06-19", a.getDateofacceptance().getValue());
}
/**
* Merge publication date of acceptance test left missing 1.
*/
@Test
void mergePublicationDateOfAcceptanceTest_leftMissing_1() {
@ -123,6 +270,9 @@ class MergeTest {
assertEquals("2021-06-19", a.getDateofacceptance().getValue());
}
/**
* Merge publication date of acceptance test left missing 2.
*/
@Test
void mergePublicationDateOfAcceptanceTest_leftMissing_2() {
@ -137,6 +287,9 @@ class MergeTest {
assertEquals("2021-06-19", a.getDateofacceptance().getValue());
}
/**
* Merge publication date of acceptance test right missing.
*/
@Test
void mergePublicationDateOfAcceptanceTest_rightMissing() {
@ -151,6 +304,9 @@ class MergeTest {
assertEquals("2021-06-19", a.getDateofacceptance().getValue());
}
/**
* Merge publication date of acceptance test right missing 1.
*/
@Test
void mergePublicationDateOfAcceptanceTest_rightMissing_1() {
@ -165,6 +321,9 @@ class MergeTest {
assertEquals("2021-06-19", a.getDateofacceptance().getValue());
}
/**
* Merge publication date of acceptance test right missing 2.
*/
@Test
void mergePublicationDateOfAcceptanceTest_rightMissing_2() {
@ -179,6 +338,9 @@ class MergeTest {
assertEquals("2021-06-19", a.getDateofacceptance().getValue());
}
/**
* Merge publication subject test.
*/
@Test
void mergePublicationSubjectTest() {
@ -194,6 +356,9 @@ class MergeTest {
assertEquals(3, a.getSubject().size());
}
/**
* Merge relation test.
*/
@Test
void mergeRelationTest() {
@ -235,6 +400,9 @@ class MergeTest {
}
/**
* Merge relation test parse exception.
*/
@Test
void mergeRelationTestParseException() {
assertThrows(DateTimeParseException.class, () -> {
@ -244,6 +412,13 @@ class MergeTest {
});
}
/**
* Create rel relation.
*
* @param validated the validated
* @param validationDate the validation date
* @return the relation
*/
private Relation createRel(Boolean validated, String validationDate) {
Relation rel = new Relation();
rel.setSource("1");
@ -256,6 +431,13 @@ class MergeTest {
return rel;
}
/**
* Sets kv.
*
* @param key the key
* @param value the value
* @return the kv
*/
private KeyValue setKV(final String key, final String value) {
KeyValue k = new KeyValue();
@ -266,6 +448,14 @@ class MergeTest {
return k;
}
/**
* Sets sp.
*
* @param value the value
* @param schema the schema
* @param classname the classname
* @return the sp
*/
private StructuredProperty setSP(
final String value, final String schema, final String classname) {
StructuredProperty s = new StructuredProperty();
@ -279,24 +469,48 @@ class MergeTest {
return s;
}
/**
* Field field.
*
* @param <T> the type parameter
* @param value the value
* @return the field
*/
private <T> Field<T> field(T value) {
Field<T> f = new Field();
f.setValue(value);
return f;
}
/**
* Publication publication.
*
* @return the publication
*/
private Publication publication() {
Publication p = new Publication();
p.setDataInfo(df("0.9"));
return p;
}
/**
* Publication publication.
*
* @param trust the trust
* @return the publication
*/
private Publication publication(String trust) {
Publication p = new Publication();
p.setDataInfo(df(trust));
return p;
}
/**
* Df data info.
*
* @param trust the trust
* @return the data info
*/
private DataInfo df(String trust) {
DataInfo d = new DataInfo();
d.setTrust(trust);

View File

@ -0,0 +1,12 @@
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0000/ra.v2i3.114::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.91019644836e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.0"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"4.65008652949e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0000/ra.v2i3.114"}]}]}
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0001/(aj).v3i6.458::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.91019644836e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.0"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"4.01810569717e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0001/(aj).v3i6.458"}]}]}
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0001/1587::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.91019644836e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.0"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.39172290649e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0001/1587"}]}]}
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0001/462::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"6.33235333753e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.36"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.00285265116e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0001/462"}]}]}
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0001/731::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.91019644836e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.0"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"4.01810569717e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0001/731"}]}]}
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0001/ijllis.v9i4.2066.g2482::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.91019644836e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.0"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"8.48190886761e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0001/ijllis.v9i4.2066.g2482"}]}]}
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0118/alfahim.v3i1.140::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.91019644836e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.0"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"9.88840807598e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0118/alfahim.v3i1.140"}]}]}
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0166/fk2.stagefigshare.6442896.v3::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.91019644836e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.0"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"7.28336930301e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0166/fk2.stagefigshare.6442896.v3"}]}]}
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0301/jttb.v2i1.64::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.91019644836e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.0"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"7.28336930301e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0301/jttb.v2i1.64"}]}]}
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0809/seruni.v1i1.567::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.91019644836e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.0"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"2.62959564033e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0809/seruni.v1i1.567"}]}]}
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0809/seruni.v2i1.765::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"9.40178571921e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.0559872"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"3.67659957614e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0809/seruni.v2i1.765"}]}]}
{"dataInfo":{"deletedbyinference":false,"inferred":true,"invisible":false,"provenanceaction":{"classid":"sysimport:enrich","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"}},"id":"unresolved::10.0901/jkip.v7i3.485::doi","instance":[{"measures":[{"id":"influence","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"5.91019644836e-09"}]},{"id":"popularity_alt","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"0.0"}]},{"id":"popularity","unit":[{"dataInfo":{"deletedbyinference":false,"inferenceprovenance":"update","inferred":true,"invisible":false,"provenanceaction":{"classid":"measure:bip","classname":"Inferred by OpenAIRE","schemeid":"dnet:provenanceActions","schemename":"dnet:provenanceActions"},"trust":""},"key":"score","value":"6.26204125721e-09"}]}],"pid":[{"qualifier":{"classid":"doi","classname":"Digital Object Identifier","schemeid":"dnet:pid_types","schemename":"dnet:pid_types"},"value":"10.0901/jkip.v7i3.485"}]}]}

File diff suppressed because one or more lines are too long