[Graph Dump] fixed issue on extraction of relation between entities and contexts: the relationship name and type were swapped #176

Merged
miriam.baglioni merged 2 commits from dump into beta 2021-12-23 10:16:21 +01:00
2 changed files with 74 additions and 3 deletions

View File

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

View File

@ -9,6 +9,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.spark.SparkConf; import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD; import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext; 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.Encoders;
import org.apache.spark.sql.SparkSession; import org.apache.spark.sql.SparkSession;
import org.junit.jupiter.api.*; import org.junit.jupiter.api.*;
@ -96,6 +97,76 @@ public class ExtractRelationFromEntityTest {
9, 9,
verificationDataset.filter("source.id = '50|dedup_wf_001::15270b996fa8fd2fb5723daxab3685c3'").count()); 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());
} }
} }