Skip to content

Commit

Permalink
Fix to GH issue 882 (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
crapo authored Feb 11, 2022
1 parent 19c6b18 commit ccc9919
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2632,17 +2632,9 @@ else if (realArg instanceof Junction) {
throw new TranslationException("Unexpected real argument");
}
}
else { // argNode is not null, but still make sure we don't have a remaining null object in a triple
else { // argNode is not null, add to retiredProxyNodes and set the arg to the argNode
((ProxyNode)arg).setReplacementNode(SadlModelProcessor.nodeCheck(argNode));
if (realArg instanceof GraphPatternElement) {
if (realArg instanceof TripleElement && ((TripleElement)realArg).getObject() == null) {
VariableNode v = getVariableNode(((TripleElement)realArg).getSubject(),
((TripleElement)realArg).getPredicate(), null, false);
if (v != null) {
((TripleElement) realArg).setObject(v);
argNode = v;
}
}
retiredProxyNodes.put((GraphPatternElement) realArg, (ProxyNode)arg);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ class ExtendedIFTest extends AbstractSADLModelProcessorTest {
}
var idx = 0
for (t:forTest) {
processor.compareTranslations(results.get(idx++).toString, t.toString)
assertTrue(processor.compareTranslations(results.get(idx++).toString, t.toString))
}
]
}
Expand Down Expand Up @@ -1529,4 +1529,133 @@ class ExtendedIFTest extends AbstractSADLModelProcessorTest {
]
}

@Test
def void testGH_882() {
val forTest = "Rule Test: if rdf(inst, rdf:type, test:Class1) and rdf(inst, test:xyz, xyz1) and rdf(xyz1, rdf:type, abc) and rdf(abc, rdfs:subClassOf, test:XYZ) and rdf(abc, test:new1, v0) and rdf(abc, test:new1, z1) and rdf(z1, test:ccc1Val, someName1) and rdf(obj1, rdf:type, test:Object) and rdf(obj1, test:objProp, obj2) and rdf(obj2, rdf:type, test:Object2) and rdf(obj2, test:someProp3, inst) and rdf(obj2, someName1, v1) and rdf(v1, sadlimplicitmodel:value, z2) and rdf(xyz1, test:new3, v2) and >=(z2,v2) and rdf(obj3, rdf:type, test:Object2) and rdf(obj3, someName1, v3) and rdf(v3, sadlimplicitmodel:value, z3) and >=(z3,v2) then print(\"in Test *********************************************************************************************\")."

val rdfmodel ='''
uri "http://www.w3.org/2000/01/rdf-schema" alias rdfs.
^type is a property.
rdfs:domain is a property.
rdfs:range is a property.
rdfs:subClassOf is a property.
rdfs:subPropertyOf is a property.
rdfs:subTypeOf is a property.
rdfs:onProperty is a property.
rdfs:allValuesFrom is a property.
rdfs:onClass is a property.
'''.sadl
'''
uri "http://kdl.ge.com/Test.sadl" alias test.
import "http://www.w3.org/2000/01/rdf-schema".
Object is a class
described by objProp with values of type Object2.
Object2 is a class
described by someProp1 with values of type UnittedQuantity
described by someProp2 with values of type UnittedQuantity
described by someProp3 with values of type Class1.
Class1 is a class,
described by xyz with values of type XYZ.
CCC1 is a class,
described by ccc1Val with values of type class.
XYZ is a class
described by new1 with a single value of type CCC1
described by new2 with a single value of type CCC1
described by new3 with a single value of type float.
ABC is a type of XYZ.
new1 of ABC is (a CCC1 with ccc1Val someProp1).
new2 of ABC is (a CCC1 with ccc1Val someProp2).
Rule Test
if inst is a Class1
and xyz of inst is xyz1
and xyz1 is a abc
and abc rdfs:subClassOf XYZ
and new1 of abc is a CCC1
and new1 of abc is z1
and z1 has ccc1Val someName1
and obj1 is a Object
and obj2 is objProp of obj1
and obj2 is a Object2
and inst is someProp3 of obj2
and ^value of someName1 of obj2 is z2
and z2 >= new3 of xyz1
and obj3 is a Object2
and ^value of someName1 of obj3 is z3
and z3 >= new3 of xyz1
then print("in Test *********************************************************************************************").
mx is a Class1
has xyz (a ABC with new3 0.0).
p1 is a Object
with objProp (a Object2
with someProp3 mx
with someProp1 (a UnittedQuantity with ^value 3.2 with unit "xxx1")
with someProp2 (a UnittedQuantity with ^value 8.3 with unit "xxx2")
).
Ask: "select * where {?x ?y ?z} limit 2".
'''.assertValidatesTo[jenaModel, rules, cmds, issues, processor |
if (issues !== null) {
for (issue:issues) {
println(issue.message)
}
}
assertTrue(rules.size==1)
for (rule:rules) {
println(rule.toString)
}
assertTrue(processor.compareTranslations(rules.get(0).toString, forTest))
// var idx = 0
// for (t:forTest) {
// assertEquals(rules.get(idx++).toString, t.toString)
// }
]
}

}

0 comments on commit ccc9919

Please sign in to comment.