From 33185fd0b7e923c36e0f0a451dd1412910f3dcbb Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Wed, 19 Feb 2020 16:56:38 +0100 Subject: [PATCH 1/2] ISLookupClientFactory moved in dhp-common --- dhp-common/pom.xml | 12 ++++++++++++ .../eu/dnetlib/dhp}/utils/ISLookupClientFactory.java | 2 +- dhp-workflows/dhp-graph-provision/pom.xml | 8 -------- .../eu/dnetlib/dhp/graph/SparkXmlIndexingJob.java | 2 +- .../eu/dnetlib/dhp/graph/utils/ContextMapper.java | 1 + pom.xml | 7 +++++++ 6 files changed, 22 insertions(+), 10 deletions(-) rename {dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph => dhp-common/src/main/java/eu/dnetlib/dhp}/utils/ISLookupClientFactory.java (96%) diff --git a/dhp-common/pom.xml b/dhp-common/pom.xml index 4416bd4ff..a9fb39ea0 100644 --- a/dhp-common/pom.xml +++ b/dhp-common/pom.xml @@ -46,6 +46,18 @@ net.sf.saxon Saxon-HE + + org.slf4j + jcl-over-slf4j + + + org.apache.cxf + cxf-rt-transports-http + + + eu.dnetlib + cnr-rmi-api + diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph/utils/ISLookupClientFactory.java b/dhp-common/src/main/java/eu/dnetlib/dhp/utils/ISLookupClientFactory.java similarity index 96% rename from dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph/utils/ISLookupClientFactory.java rename to dhp-common/src/main/java/eu/dnetlib/dhp/utils/ISLookupClientFactory.java index d87f29452..c74cf3c11 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph/utils/ISLookupClientFactory.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/utils/ISLookupClientFactory.java @@ -1,4 +1,4 @@ -package eu.dnetlib.dhp.graph.utils; +package eu.dnetlib.dhp.utils; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; import org.apache.commons.logging.Log; diff --git a/dhp-workflows/dhp-graph-provision/pom.xml b/dhp-workflows/dhp-graph-provision/pom.xml index f74c9b666..ac4e01d21 100644 --- a/dhp-workflows/dhp-graph-provision/pom.xml +++ b/dhp-workflows/dhp-graph-provision/pom.xml @@ -66,14 +66,6 @@ zookeeper - - org.apache.cxf - cxf-rt-transports-http - - - eu.dnetlib - cnr-rmi-api - eu.dnetlib.dhp diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph/SparkXmlIndexingJob.java b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph/SparkXmlIndexingJob.java index 2775d93b4..63ff8fb31 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph/SparkXmlIndexingJob.java +++ b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph/SparkXmlIndexingJob.java @@ -2,8 +2,8 @@ package eu.dnetlib.dhp.graph; import com.lucidworks.spark.util.SolrSupport; import eu.dnetlib.dhp.application.ArgumentApplicationParser; -import eu.dnetlib.dhp.graph.utils.ISLookupClientFactory; import eu.dnetlib.dhp.graph.utils.StreamingInputDocumentFactory; +import eu.dnetlib.dhp.utils.ISLookupClientFactory; import eu.dnetlib.dhp.utils.saxon.SaxonTransformerFactory; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpDocumentNotFoundException; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; diff --git a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph/utils/ContextMapper.java b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph/utils/ContextMapper.java index 0c3a481d0..ad9e7dfad 100644 --- a/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph/utils/ContextMapper.java +++ b/dhp-workflows/dhp-graph-provision/src/main/java/eu/dnetlib/dhp/graph/utils/ContextMapper.java @@ -1,6 +1,7 @@ package eu.dnetlib.dhp.graph.utils; import com.google.common.base.Joiner; +import eu.dnetlib.dhp.utils.ISLookupClientFactory; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpException; import eu.dnetlib.enabling.is.lookup.rmi.ISLookUpService; import org.dom4j.Document; diff --git a/pom.xml b/pom.xml index 7f5e1e3dc..faed1db35 100644 --- a/pom.xml +++ b/pom.xml @@ -129,6 +129,13 @@ provided + + org.slf4j + jcl-over-slf4j + 1.7.25 + provided + + org.apache.commons commons-lang3 From d42dde52baff933c5bac8141fdf21668c846a247 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Wed, 19 Feb 2020 17:29:05 +0100 Subject: [PATCH 2/2] implemented method to merge relations --- .../eu/dnetlib/dhp/schema/oaf/Relation.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java index 5cf0883be..d404981f4 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java @@ -1,6 +1,11 @@ package eu.dnetlib.dhp.schema.oaf; +import org.junit.Assert; + +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; public class Relation extends Oaf { @@ -14,7 +19,7 @@ public class Relation extends Oaf { private String target; - private List collectedFrom; + private List collectedFrom = new ArrayList<>(); public String getRelType() { return relType; @@ -63,4 +68,19 @@ public class Relation extends Oaf { public void setCollectedFrom(List collectedFrom) { this.collectedFrom = collectedFrom; } + + public void mergeFrom(final Relation r) { + Assert.assertEquals("source ids must be equal", getSource(), r.getSource()); + Assert.assertEquals("target ids must be equal", getTarget(), r.getTarget()); + Assert.assertEquals("relType(s) must be equal", getRelType(), r.getRelType()); + Assert.assertEquals("subRelType(s) must be equal", getSubRelType(), r.getSubRelType()); + Assert.assertEquals("relClass(es) must be equal", getRelClass(), r.getRelClass()); + setCollectedFrom( + Stream.concat( + getCollectedFrom().stream(), + r.getCollectedFrom().stream()) + .distinct() // relies on KeyValue.equals + .collect(Collectors.toList())); + } + }