Merge pull request '[Graph Dump] fixed issue on extraction of relation between entities and contexts: the relationship name and type were swapped' (#176) from dump into beta

Reviewed-on: #176
pull/177/head
Miriam Baglioni 2 years ago
commit 5c4fee3533

@ -89,7 +89,7 @@ public class Extractor implements Serializable {
value.getId(), contextId,
Constants.RESULT_ENTITY,
Constants.CONTEXT_ENTITY,
ModelConstants.RELATIONSHIP, ModelConstants.IS_RELATED_TO, provenance);
ModelConstants.IS_RELATED_TO, ModelConstants.RELATIONSHIP, provenance);
if (!hashCodes.contains(r.hashCode())) {
relationList
.add(r);
@ -99,8 +99,8 @@ public class Extractor implements Serializable {
contextId, value.getId(),
Constants.CONTEXT_ENTITY,
Constants.RESULT_ENTITY,
ModelConstants.RELATIONSHIP,
ModelConstants.IS_RELATED_TO, provenance);
ModelConstants.IS_RELATED_TO,
ModelConstants.RELATIONSHIP, provenance);
if (!hashCodes.contains(r.hashCode())) {
relationList
.add(

@ -9,6 +9,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.FilterFunction;
import org.apache.spark.sql.Encoders;
import org.apache.spark.sql.SparkSession;
import org.junit.jupiter.api.*;
@ -96,6 +97,76 @@ public class ExtractRelationFromEntityTest {
9,
verificationDataset.filter("source.id = '50|dedup_wf_001::15270b996fa8fd2fb5723daxab3685c3'").count());
Assertions
.assertEquals(
"IsRelatedTo", verificationDataset
.filter((FilterFunction<Relation>) row -> row.getSource().getId().startsWith("00"))
.collectAsList()
.get(0)
.getReltype()
.getName());
Assertions
.assertEquals(
"relationship", verificationDataset
.filter((FilterFunction<Relation>) row -> row.getSource().getId().startsWith("00"))
.collectAsList()
.get(0)
.getReltype()
.getType());
Assertions
.assertEquals(
"context", verificationDataset
.filter((FilterFunction<Relation>) row -> row.getSource().getId().startsWith("00"))
.collectAsList()
.get(0)
.getSource()
.getType());
Assertions
.assertEquals(
"result", verificationDataset
.filter((FilterFunction<Relation>) row -> row.getSource().getId().startsWith("00"))
.collectAsList()
.get(0)
.getTarget()
.getType());
Assertions
.assertEquals(
"IsRelatedTo", verificationDataset
.filter((FilterFunction<Relation>) row -> row.getTarget().getId().startsWith("00"))
.collectAsList()
.get(0)
.getReltype()
.getName());
Assertions
.assertEquals(
"relationship", verificationDataset
.filter((FilterFunction<Relation>) row -> row.getTarget().getId().startsWith("00"))
.collectAsList()
.get(0)
.getReltype()
.getType());
Assertions
.assertEquals(
"context", verificationDataset
.filter((FilterFunction<Relation>) row -> row.getTarget().getId().startsWith("00"))
.collectAsList()
.get(0)
.getTarget()
.getType());
Assertions
.assertEquals(
"result", verificationDataset
.filter((FilterFunction<Relation>) row -> row.getTarget().getId().startsWith("00"))
.collectAsList()
.get(0)
.getSource()
.getType());
}
}

Loading…
Cancel
Save