@@ -44,24 +44,25 @@ fun PrimitiveConstraint.toSparql(cb: ConstructBuilder): Expr {
4444 " @type" -> { p = RDF .type.asNode(); pvar = " Metatype" }
4545 else -> { p = SYSMLV2 .prop(property).asNode() }
4646 }
47- when (value) {
47+ val firstVal = value.get(0 ) // TODO what if value is empty list??? or > 1 value
48+ when (firstVal) {
4849 is JsonObject -> {
49- if (value .containsKey(" @id" )) {
50- v = SYSMLV2 .element(value .jsonObject[" @id" ]!! .jsonPrimitive.content).asNode()
50+ if (firstVal .containsKey(" @id" )) {
51+ v = SYSMLV2 .element(firstVal .jsonObject[" @id" ]!! .jsonPrimitive.content).asNode()
5152 } else {
5253 throw BadRequestException (" PrimitiveConstraint value object must contain @id" )
5354 }
5455 }
5556 is JsonPrimitive -> {
56- if (value == JsonNull ) {
57+ if (firstVal == JsonNull ) {
5758 v = RDF .nil.asNode()
5859 } else {
59- v = if (property == " @type" ) SYSMLV2 .type(value .content).asNode() else value .toRdfLiteralNode()
60+ v = if (property == " @type" ) SYSMLV2 .type(firstVal .content).asNode() else firstVal .toRdfLiteralNode()
6061 }
6162 }
6263 is JsonArray -> {throw BadRequestException (" PrimitiveConstraint value cannot be array" )}
6364 }
64- if (value == JsonNull ) {
65+ if (firstVal == JsonNull ) {
6566 cb.addOptional(" ?e" , p, " ?$pvar " )
6667 } else {
6768 cb.addWhere(" ?e" , p, " ?$pvar " )
@@ -78,9 +79,15 @@ fun PrimitiveConstraint.toSparql(cb: ConstructBuilder): Expr {
7879 PrimitiveConstraint .Operator .Less_Than -> {
7980 ef.lt(" ?$pvar " , v)
8081 }
82+ PrimitiveConstraint .Operator .Less_Than_Equal -> {
83+ ef.le(" ?$pvar " , v)
84+ }
8185 PrimitiveConstraint .Operator .Greater_Than -> {
8286 ef.gt(" ?$pvar " , v)
8387 }
88+ PrimitiveConstraint .Operator .Greater_Than_Equal -> {
89+ ef.ge(" ?$pvar " , v)
90+ }
8491 }
8592 return if (inverse) ef.not (expr) else expr
8693}
0 commit comments