Hi,
I am trying to build the following query using ARQ

PREFIX  ldp:  <http://www.w3.org/ns/ldp#>
CONSTRUCT
  {
    ?a ldp:member ?b .
  }
WHERE {
    SELECT ?b WHERE {
       GRAPH ?d {
           ?b  ldp:memberOf  ?a
       }
       GRAPH ?b {
           ?r  ldp:memberOf  ?s
       }
    }
}

I was able to create the patterns and Ops necessary for the building
But when it comes to building the construct operation, which I created with
OpAsQuery and then setting the construct type, I was not able to add the
inner select since there is no OpSelect for that purpose.
My code in Scala

val resourceVar = Var.alloc("b")
val provenanceVar = Var.alloc("d")

val containerVar = Var.alloc("a")
val memberOf = NodeFactory.createLiteral("ldp:memberOf")
val member = NodeFactory.createLiteral("ldp:member")

val provenanceGraphPattern = new BasicPattern()
provenanceGraphPattern.add(new Triple(resourceVar, memberOf, containerVar))
val provenanceBGP = new OpBGP(provenanceGraphPattern)

val resourceGraphPattern = new BasicPattern()
resourceGraphPattern.add(new Triple(Var.alloc("r"),
NodeFactory.createLiteral("ldp:memberOf"), Var.alloc("s")))
val resourceBGP = new OpBGP(resourceGraphPattern)
val provenanceGraph = new OpGraph(provenanceVar, provenanceBGP)
val resourceGraph = new OpGraph(resourceVar, resourceBGP)
val join = OpJoin.create(provenanceGraph, resourceGraph)

val innerSelect = OpAsQuery.asQuery(join)
innerSelect.addResultVar(resourceVar)
val subQuery = new ElementSubQuery(innerSelect)
val constructPattern = new BasicPattern()
constructPattern.add(new Triple(containerVar,
  member,
  resourceVar
))
val op = Algebra.compile(subQuery)
val result = OpAsQuery.asQuery(op)
result.setConstructTemplate(new Template(constructPattern))
result.setQueryConstructType()
result.getPrefixMapping
  .setNsPrefix("ldp", "http://www.w3.org/ns/ldp#";)
result

*This creates the following query, which lacks of the inner SELECT clause*

PREFIX  ldp:  <http://www.w3.org/ns/ldp#>

CONSTRUCT
  {
    ?a "ldp:member" ?b .
  }
WHERE
  { GRAPH ?d
      { ?b  "ldp:memberOf"  ?a }
    GRAPH ?resource
      { ?r  "doc:encodes"  ?s }
  }


Any help is appreciated
*PS*: Also, which is the way to create a prefix reference Node in the
Triple. NodeFactory.createLiteral seems to add "" always and
NodeFactory.createURI always adds <>
Regards,
Guillermo.

-- 
<https://www.mulesoft.com/>
Guillermo Coscarelli, Principal Software Engineer

PARQUE AUSTRAL - Av. Cayetano Beliera 3025
Edificio M4 - Pilar (B1629HVK)
Provincia de Buenos Aires - Argentina

O + <555.555.5555>54 (230) 438-4933  M +54 (911) 5956-6026

<https://www.linkedin.com/company/mulesoft>   <https://twitter.com/mulesoft>
   <https://www.facebook.com/MuleSoft>   <https://videos.mulesoft.com/> We're
hiring! <https://www.mulesoft.com/careers>

*NOTICE: This e-mail may contain confidential information. Any pricing
information contained in this communication is confidential MuleSoft
information. If you are not the addressee or the intended recipient please
do not read this e-mail and please immediately delete this e-mail message
and any attachments from your network mail system. If you are the addressee
or the intended recipient and you save or print a copy of this e-mail,
please place it in an appropriate file, depending on whether confidential
information is contained in the message, and please treat all MuleSoft
confidential information with heightened protection.*

Reply via email to