From ccc99195bb558203741b2fc3ab492f0119fe2654 Mon Sep 17 00:00:00 2001 From: Andrew Crapo Date: Fri, 11 Feb 2022 12:50:11 -0500 Subject: [PATCH] Fix to GH issue 882 (#883) --- .../sadl/jena/IntermediateFormTranslator.java | 10 +- .../sadl/tests/model/ExtendedIFTest.xtend | 131 +++++++++++++++++- 2 files changed, 131 insertions(+), 10 deletions(-) diff --git a/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.jena/src/com/ge/research/sadl/jena/IntermediateFormTranslator.java b/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.jena/src/com/ge/research/sadl/jena/IntermediateFormTranslator.java index 7763c3201..f8ed42d5e 100644 --- a/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.jena/src/com/ge/research/sadl/jena/IntermediateFormTranslator.java +++ b/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.jena/src/com/ge/research/sadl/jena/IntermediateFormTranslator.java @@ -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 { diff --git a/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.tests/src/com/ge/research/sadl/tests/model/ExtendedIFTest.xtend b/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.tests/src/com/ge/research/sadl/tests/model/ExtendedIFTest.xtend index 379357e01..60f795272 100644 --- a/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.tests/src/com/ge/research/sadl/tests/model/ExtendedIFTest.xtend +++ b/sadl3/com.ge.research.sadl.parent/com.ge.research.sadl.tests/src/com/ge/research/sadl/tests/model/ExtendedIFTest.xtend @@ -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)) } ] } @@ -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) +// } + ] + } + }