forked from D-Net/dnet-hadoop
Now it compiles
This commit is contained in:
parent
ba380f5826
commit
706631586b
|
@ -320,7 +320,7 @@ public class CreateOpenCitationsASTest {
|
|||
check.foreach(r -> {
|
||||
if (r.getSource().equals(doi2) || r.getSource().equals(doi3) || r.getSource().equals(doi4) ||
|
||||
r.getSource().equals(doi5) || r.getSource().equals(doi6)) {
|
||||
assertEquals(ModelConstants.IS_CITED_BY, r.getRelClass());
|
||||
assertEquals(Relation.RELCLASS.IsCitedBy, r.getRelClass());
|
||||
assertEquals(doi1, r.getTarget());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -25,7 +25,9 @@ public class BlacklistRelationTest {
|
|||
"resultProject_outcome_isProducedBy");
|
||||
|
||||
rels.forEach(r -> {
|
||||
RelationLabel inverse = ModelSupport.relationInverseMap.get(r);
|
||||
RelationLabel inverse =
|
||||
|
||||
ModelSupport.unRel(r);
|
||||
Assertions.assertNotNull(inverse);
|
||||
Assertions.assertNotNull(inverse.getRelType());
|
||||
Assertions.assertNotNull(inverse.getSubReltype());
|
||||
|
|
|
@ -297,7 +297,7 @@ public class SparkDedupTest implements Serializable {
|
|||
.read()
|
||||
.load(testOutputBasePath + "/" + testActionSetId + "/organization_mergerel")
|
||||
.as(Encoders.bean(Relation.class))
|
||||
.filter((FilterFunction<Relation>) r -> r.getRelClass().equalsIgnoreCase("merges"))
|
||||
.filter((FilterFunction<Relation>) r -> Relation.RELCLASS.merges == r.getRelClass())
|
||||
.groupBy("source")
|
||||
.agg(count("target").alias("cnt"))
|
||||
.select("source", "cnt")
|
||||
|
@ -308,7 +308,7 @@ public class SparkDedupTest implements Serializable {
|
|||
.read()
|
||||
.load(testOutputBasePath + "/" + testActionSetId + "/publication_mergerel")
|
||||
.as(Encoders.bean(Relation.class))
|
||||
.filter((FilterFunction<Relation>) r -> r.getRelClass().equalsIgnoreCase("merges"))
|
||||
.filter((FilterFunction<Relation>) r -> Relation.RELCLASS.merges == r.getRelClass())
|
||||
.groupBy("source")
|
||||
.agg(count("target").alias("cnt"))
|
||||
.select("source", "cnt")
|
||||
|
@ -318,7 +318,7 @@ public class SparkDedupTest implements Serializable {
|
|||
.read()
|
||||
.load(testOutputBasePath + "/" + testActionSetId + "/software_mergerel")
|
||||
.as(Encoders.bean(Relation.class))
|
||||
.filter((FilterFunction<Relation>) r -> r.getRelClass().equalsIgnoreCase("merges"))
|
||||
.filter((FilterFunction<Relation>) r ->Relation.RELCLASS.merges == r.getRelClass())
|
||||
.groupBy("source")
|
||||
.agg(count("target").alias("cnt"))
|
||||
.select("source", "cnt")
|
||||
|
@ -329,7 +329,7 @@ public class SparkDedupTest implements Serializable {
|
|||
.read()
|
||||
.load(testOutputBasePath + "/" + testActionSetId + "/dataset_mergerel")
|
||||
.as(Encoders.bean(Relation.class))
|
||||
.filter((FilterFunction<Relation>) r -> r.getRelClass().equalsIgnoreCase("merges"))
|
||||
.filter((FilterFunction<Relation>) r -> Relation.RELCLASS.merges == r.getRelClass())
|
||||
.groupBy("source")
|
||||
.agg(count("target").alias("cnt"))
|
||||
.select("source", "cnt")
|
||||
|
@ -340,7 +340,7 @@ public class SparkDedupTest implements Serializable {
|
|||
.read()
|
||||
.load(testOutputBasePath + "/" + testActionSetId + "/otherresearchproduct_mergerel")
|
||||
.as(Encoders.bean(Relation.class))
|
||||
.filter((FilterFunction<Relation>) r -> r.getRelClass().equalsIgnoreCase("merges"))
|
||||
.filter((FilterFunction<Relation>) r -> Relation.RELCLASS.merges == r.getRelClass())
|
||||
.groupBy("source")
|
||||
.agg(count("target").alias("cnt"))
|
||||
.select("source", "cnt")
|
||||
|
|
|
@ -150,7 +150,7 @@ public class SparkPublicationRootsTest implements Serializable {
|
|||
.read()
|
||||
.load(workingPath + "/" + testActionSetId + "/publication_mergerel")
|
||||
.as(Encoders.bean(Relation.class))
|
||||
.filter((FilterFunction<Relation>) r -> r.getRelClass().equalsIgnoreCase("merges"))
|
||||
.filter((FilterFunction<Relation>) r -> Relation.RELCLASS.merges == r.getRelClass())
|
||||
.groupBy("source")
|
||||
.agg(count("target").alias("cnt"))
|
||||
.select("source", "cnt")
|
||||
|
|
|
@ -61,9 +61,9 @@ class CrossrefMappingTest {
|
|||
assertNotNull(relation.getSource, s"Source of relation null $relJson")
|
||||
assertNotNull(relation.getTarget, s"Target of relation null $relJson")
|
||||
assertFalse(relation.getTarget.isEmpty, s"Target is empty: $relJson")
|
||||
assertFalse(relation.getRelClass.isEmpty, s"RelClass is empty: $relJson")
|
||||
assertFalse(relation.getRelType.isEmpty, s"RelType is empty: $relJson")
|
||||
assertFalse(relation.getSubRelType.isEmpty, s"SubRelType is empty: $relJson")
|
||||
assertNotNull(relation.getRelClass, s"RelClass is empty: $relJson")
|
||||
assertNotNull(relation.getRelType, s"RelType is empty: $relJson")
|
||||
assertNotNull(relation.getSubRelType, s"SubRelType is empty: $relJson")
|
||||
|
||||
})
|
||||
|
||||
|
@ -144,7 +144,7 @@ class CrossrefMappingTest {
|
|||
val relationList: List[Relation] = result
|
||||
.filter(s => s.isInstanceOf[Relation])
|
||||
.map(r => r.asInstanceOf[Relation])
|
||||
.filter(r => r.getSubRelType.equalsIgnoreCase(Relation.SUBRELTYPE.citation))
|
||||
.filter(r => Relation.SUBRELTYPE.citation.equals(r.getSubRelType))
|
||||
|
||||
assertNotNull(relationList)
|
||||
assertFalse(relationList.isEmpty)
|
||||
|
@ -497,9 +497,9 @@ class CrossrefMappingTest {
|
|||
assertNotNull(relation)
|
||||
assertFalse(relation.getSource.isEmpty)
|
||||
assertFalse(relation.getTarget.isEmpty)
|
||||
assertFalse(relation.getRelClass.isEmpty)
|
||||
assertFalse(relation.getRelType.isEmpty)
|
||||
assertFalse(relation.getSubRelType.isEmpty)
|
||||
assertNotNull(relation.getRelClass)
|
||||
assertNotNull(relation.getRelType)
|
||||
assertNotNull(relation.getSubRelType)
|
||||
|
||||
})
|
||||
|
||||
|
|
|
@ -487,7 +487,9 @@ public class MigrateDbEntitiesApplication extends AbstractMigrationApplication i
|
|||
rel = setRelationSemantic(rel, Relation.RELTYPE.resultProject, Relation.SUBRELTYPE.outcome, Relation.RELCLASS.produces);
|
||||
break;
|
||||
case "resultResult_publicationDataset_isRelatedTo":
|
||||
rel = setRelationSemantic(rel, Relation.RELTYPE.resultResult, PUBLICATION_DATASET, IS_RELATED_TO);
|
||||
//TODO THIS METHOD HAS BEEN REPLACE TO MAKE IT COMPILABLE
|
||||
// rel = setRelationSemantic(rel, Relation.RELTYPE.resultResult, PUBLICATION_DATASET, Relation.RELCLASS.IsRelatedTo);
|
||||
rel = setRelationSemantic(rel, Relation.RELTYPE.resultResult, Relation.SUBRELTYPE.relationship, Relation.RELCLASS.IsRelatedTo);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("claim semantics not managed: " + semantics);
|
||||
|
|
|
@ -130,13 +130,13 @@ public class GroupEntitiesSparkJobTest {
|
|||
assertEquals(
|
||||
2,
|
||||
output
|
||||
.map((MapFunction<Result, String>) r -> r.getResulttype(), Encoders.STRING())
|
||||
.map((MapFunction<Result, String>) r -> r.getResulttype().toString(), Encoders.STRING())
|
||||
.filter((FilterFunction<String>) s -> s.equals("publication"))
|
||||
.count());
|
||||
assertEquals(
|
||||
1,
|
||||
output
|
||||
.map((MapFunction<Result, String>) r -> r.getResulttype(), Encoders.STRING())
|
||||
.map((MapFunction<Result, String>) r -> r.getResulttype().toString(), Encoders.STRING())
|
||||
.filter((FilterFunction<String>) s -> s.equals("dataset"))
|
||||
.count());
|
||||
}
|
||||
|
|
|
@ -51,27 +51,28 @@ class GenerateEntitiesApplicationTest {
|
|||
Result software = getResult("odf_software.xml", Software.class);
|
||||
Result orp = getResult("oaf_orp.xml", OtherResearchProduct.class);
|
||||
|
||||
verifyMerge(publication, dataset, Dataset.class, ModelConstants.DATASET_RESULTTYPE_CLASSID);
|
||||
verifyMerge(dataset, publication, Dataset.class, ModelConstants.DATASET_RESULTTYPE_CLASSID);
|
||||
|
||||
verifyMerge(publication, dataset, Dataset.class, Result.RESULTTYPE.dataset);
|
||||
verifyMerge(dataset, publication, Dataset.class, Result.RESULTTYPE.dataset);
|
||||
|
||||
verifyMerge(publication, software, Publication.class, ModelConstants.PUBLICATION_RESULTTYPE_CLASSID);
|
||||
verifyMerge(software, publication, Publication.class, ModelConstants.PUBLICATION_RESULTTYPE_CLASSID);
|
||||
verifyMerge(publication, software, Publication.class, Result.RESULTTYPE.publication);
|
||||
verifyMerge(software, publication, Publication.class, Result.RESULTTYPE.publication);
|
||||
|
||||
verifyMerge(publication, orp, Publication.class, ModelConstants.PUBLICATION_RESULTTYPE_CLASSID);
|
||||
verifyMerge(orp, publication, Publication.class, ModelConstants.PUBLICATION_RESULTTYPE_CLASSID);
|
||||
verifyMerge(publication, orp, Publication.class, Result.RESULTTYPE.publication);
|
||||
verifyMerge(orp, publication, Publication.class, Result.RESULTTYPE.publication);
|
||||
|
||||
verifyMerge(dataset, software, Dataset.class, ModelConstants.DATASET_RESULTTYPE_CLASSID);
|
||||
verifyMerge(software, dataset, Dataset.class, ModelConstants.DATASET_RESULTTYPE_CLASSID);
|
||||
verifyMerge(dataset, software, Dataset.class, Result.RESULTTYPE.dataset);
|
||||
verifyMerge(software, dataset, Dataset.class, Result.RESULTTYPE.dataset);
|
||||
|
||||
verifyMerge(dataset, orp, Dataset.class, ModelConstants.DATASET_RESULTTYPE_CLASSID);
|
||||
verifyMerge(orp, dataset, Dataset.class, ModelConstants.DATASET_RESULTTYPE_CLASSID);
|
||||
verifyMerge(dataset, orp, Dataset.class, Result.RESULTTYPE.dataset);
|
||||
verifyMerge(orp, dataset, Dataset.class, Result.RESULTTYPE.dataset);
|
||||
|
||||
verifyMerge(software, orp, Software.class, ModelConstants.SOFTWARE_RESULTTYPE_CLASSID);
|
||||
verifyMerge(orp, software, Software.class, ModelConstants.SOFTWARE_RESULTTYPE_CLASSID);
|
||||
verifyMerge(software, orp, Software.class, Result.RESULTTYPE.software);
|
||||
verifyMerge(orp, software, Software.class, Result.RESULTTYPE.software);
|
||||
}
|
||||
|
||||
protected <T extends Result> void verifyMerge(Result publication, Result dataset, Class<T> clazz,
|
||||
String resultType) {
|
||||
Result.RESULTTYPE resultType) {
|
||||
final Result merge = MergeUtils.merge(publication, dataset);
|
||||
assertTrue(clazz.isAssignableFrom(merge.getClass()));
|
||||
assertEquals(resultType, merge.getResulttype());
|
||||
|
|
|
@ -172,8 +172,8 @@ class MappersTest {
|
|||
assertNotNull(p.getDataInfo());
|
||||
assertNotNull(p.getDataInfo().getTrust());
|
||||
}
|
||||
assertTrue(StringUtils.isNotBlank(r.getRelClass()));
|
||||
assertTrue(StringUtils.isNotBlank(r.getRelType()));
|
||||
assertNotNull(r.getRelClass());
|
||||
assertNotNull(r.getRelType());
|
||||
|
||||
}
|
||||
|
||||
|
@ -373,10 +373,10 @@ class MappersTest {
|
|||
assertNotNull(r2.getProvenance().get(0).getDataInfo().getTrust());
|
||||
assertEquals(r1.getSource(), r2.getTarget());
|
||||
assertEquals(r2.getSource(), r1.getTarget());
|
||||
assertTrue(StringUtils.isNotBlank(r1.getRelClass()));
|
||||
assertTrue(StringUtils.isNotBlank(r2.getRelClass()));
|
||||
assertTrue(StringUtils.isNotBlank(r1.getRelType()));
|
||||
assertTrue(StringUtils.isNotBlank(r2.getRelType()));
|
||||
assertNotNull(r1.getRelClass());
|
||||
assertNotNull(r2.getRelClass());
|
||||
assertNotNull(r1.getRelType());
|
||||
assertNotNull(r2.getRelType());
|
||||
assertTrue(r1.getValidated());
|
||||
assertTrue(r2.getValidated());
|
||||
assertEquals("2020-01-01", r1.getValidationDate());
|
||||
|
|
|
@ -243,14 +243,15 @@ class MigrateDbEntitiesApplicationTest {
|
|||
assertTrue(r1.getSource().startsWith("10|"));
|
||||
assertTrue(r1.getTarget().startsWith("20|"));
|
||||
|
||||
assertEquals(ModelConstants.DATASOURCE_ORGANIZATION, r1.getRelType());
|
||||
assertEquals(ModelConstants.DATASOURCE_ORGANIZATION, r2.getRelType());
|
||||
|
||||
assertEquals(Relation.RELTYPE.datasourceOrganization, r1.getRelType());
|
||||
assertEquals(Relation.RELTYPE.datasourceOrganization, r2.getRelType());
|
||||
|
||||
assertEquals(Relation.SUBRELTYPE.provision, r1.getSubRelType());
|
||||
assertEquals(Relation.SUBRELTYPE.provision, r2.getSubRelType());
|
||||
|
||||
assertEquals(Relation.RELCLASS.isProvidedBy, r1.getRelClass());
|
||||
assertEquals(ModelConstants.PROVIDES, r2.getRelClass());
|
||||
assertEquals(Relation.RELCLASS.provides, r2.getRelClass());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -271,9 +272,9 @@ class MigrateDbEntitiesApplicationTest {
|
|||
assertFalse(rel.getProvenance().isEmpty());
|
||||
assertValidId(rel.getProvenance().get(0).getCollectedfrom().getKey());
|
||||
|
||||
assertEquals(ModelConstants.PROJECT_ORGANIZATION, rel.getRelType());
|
||||
assertEquals(Relation.RELTYPE.projectOrganization, rel.getRelType());
|
||||
assertEquals(Relation.SUBRELTYPE.participation, rel.getSubRelType());
|
||||
assertEquals(ModelConstants.IS_PARTICIPANT, rel.getRelClass());
|
||||
assertEquals(Relation.RELCLASS.isParticipant, rel.getRelClass());
|
||||
|
||||
assertNotNull(rel.getProperties());
|
||||
checkProperty(rel, "contribution", "436754.0");
|
||||
|
@ -338,10 +339,10 @@ class MigrateDbEntitiesApplicationTest {
|
|||
|
||||
assertEquals(r1.getSource(), r2.getTarget());
|
||||
assertEquals(r2.getSource(), r1.getTarget());
|
||||
assertTrue(StringUtils.isNotBlank(r1.getRelClass()));
|
||||
assertTrue(StringUtils.isNotBlank(r2.getRelClass()));
|
||||
assertTrue(StringUtils.isNotBlank(r1.getRelType()));
|
||||
assertTrue(StringUtils.isNotBlank(r2.getRelType()));
|
||||
assertNotNull(r1.getRelClass());
|
||||
assertNotNull(r2.getRelClass());
|
||||
assertNotNull(r1.getRelType());
|
||||
assertNotNull(r2.getRelType());
|
||||
|
||||
assertValidId(r1.getProvenance().get(0).getCollectedfrom().getKey());
|
||||
assertValidId(r2.getProvenance().get(0).getCollectedfrom().getKey());
|
||||
|
|
|
@ -82,22 +82,4 @@ class ScholixGraphTest extends AbstractVocabularyTest {
|
|||
println(mapper.writeValueAsString(scholix.head))
|
||||
}
|
||||
|
||||
@Test
|
||||
def testScholixRelationshipsClean(): Unit = {
|
||||
val inputRelations = Source
|
||||
.fromInputStream(
|
||||
getClass.getResourceAsStream("/eu/dnetlib/dhp/sx/graph/relation_transform.json")
|
||||
)
|
||||
.mkString
|
||||
implicit lazy val formats: DefaultFormats.type = org.json4s.DefaultFormats
|
||||
|
||||
lazy val json: json4s.JValue = parse(inputRelations)
|
||||
val l: List[String] = json.extract[List[String]]
|
||||
assertNotNull(l)
|
||||
assertTrue(l.nonEmpty)
|
||||
val relVocbaulary = ScholixUtils.relations
|
||||
l.foreach(r => assertTrue(relVocbaulary.contains(r.toLowerCase)))
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ public class SortableRelation extends Relation implements Comparable<SortableRel
|
|||
weights.put(Relation.SUBRELTYPE.citation, 3);
|
||||
weights.put(Relation.SUBRELTYPE.affiliation, 4);
|
||||
weights.put(Relation.SUBRELTYPE.relationship, 5);
|
||||
//weights.put(ModelConstants.PUBLICATION_RESULTTYPE_CLASSID, 6);
|
||||
//weights.put(Result.RESULTTYPE.publication, 6);
|
||||
weights.put(Relation.SUBRELTYPE.similarity, 7);
|
||||
|
||||
weights.put(Relation.SUBRELTYPE.provision, 8);
|
||||
|
|
|
@ -22,7 +22,8 @@ public class SortableRelationKey implements Comparable<SortableRelationKey>, Ser
|
|||
weights.put(Relation.SUBRELTYPE.outcome, 1);
|
||||
weights.put(Relation.SUBRELTYPE.affiliation, 2);
|
||||
weights.put(Relation.SUBRELTYPE.dedup, 3);
|
||||
weights.put(ModelConstants.PUBLICATION_DATASET, 4);
|
||||
//TODO COMMENTED BUT SHOULD BE REPLACED WITH RELATIONSHIPS??
|
||||
// weights.put(ModelConstants.PUBLICATION_DATASET, 4);
|
||||
weights.put(Relation.SUBRELTYPE.supplement, 5);
|
||||
weights.put(Relation.SUBRELTYPE.review, 6);
|
||||
weights.put(Relation.SUBRELTYPE.relationship, 7);
|
||||
|
@ -37,7 +38,7 @@ public class SortableRelationKey implements Comparable<SortableRelationKey>, Ser
|
|||
|
||||
private String groupingKey;
|
||||
|
||||
private String subRelType;
|
||||
private Relation.SUBRELTYPE subRelType;
|
||||
|
||||
public static SortableRelationKey create(Relation r, String groupingKey) {
|
||||
SortableRelationKey sr = new SortableRelationKey();
|
||||
|
@ -74,11 +75,11 @@ public class SortableRelationKey implements Comparable<SortableRelationKey>, Ser
|
|||
return Optional.ofNullable(weights.get(o.getSubRelType())).orElse(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public String getSubRelType() {
|
||||
public Relation.SUBRELTYPE getSubRelType() {
|
||||
return subRelType;
|
||||
}
|
||||
|
||||
public void setSubRelType(String subRelType) {
|
||||
public void setSubRelType(Relation.SUBRELTYPE subRelType) {
|
||||
this.subRelType = subRelType;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue