Jena and Complex SPARQL query

Gabriela Medina <[email protected]>
Newsgroups gmane.comp.misc.ontology.protege.general
Message-ID <[email protected]>
Hello,

I've been recently using Jena and SPARQL and I have one question. I
tried to make a query in which ONE variable (in my case named “Process”) is linked to TWO
other variables (both are variables of the same class. In my case this class is
called Symptoms). I need to describe some characteristics or some relations
that Process have with other classes and at the same time I have to describe characteristics
or some relations that each of the Symptoms have.

To perform this query I
have tried two alternatives but I have no success. Here I present the two
alternatives:
1.     The first alternative is a SELECT
Query written as follow:

String queryString = 
"PREFIX ONTO: http://www.owl-ontologies.com/Ontology1326704817.owl#
 PREFIX owl:
<http://www.w3.org/2002/07/owl#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
 
SELECT ?Symptome1 ?Symptome2 ?Deviation1 ?Deviation2 ?Flux1 ?Flux2
?Propriete1 ?Propriete2 ?Process
{{?Process rdf:type ONTO:MoteurDiesel . 
?Process ONTO:presente ?Symptome1 . 
?Symptome1 rdf:type ONTO:Symptome . 
?Symptome1 ONTO:possedeCaracteristiqueDeviation  ?Deviation1 .  
FILTER regex(str(?Deviation1),
'http://www.owl-ontologies.com/Ontology1326704817.owl#Moins') . 
?Symptome1 ONTO:possedeCaracteristiqueFlux  ?Flux1 . 
?Flux1 rdf:type ONTO:Huile . 
?Symptome1 ONTO:possedeCaracteristiquePropriete ?Propriete1 . 
?Propriete1 rdf:type ONTO:PressionFonctionnement} . 
 
{?Process ONTO:presente ?Symptome2. 
?Symptome2 rdf:type ONTO:Symptome . 
?Symptome2 ONTO:possedeCaracteristiqueDeviation  ?Deviation2 .  
FILTER regex(str(?Deviation),
'http://www.owl-ontologies.com/Ontology1326704817.owl#Plus') . 
?Symptome2 ONTO:possedeCaracteristiqueFlux  ?Flux2 . 
?Flux2 rdf:type ONTO:Huile . 
?Symptome2 ONTO:possedeCaracteristiquePropriete ?Propriete2 . 
?Propriete2 rdf:type ONTO:Temperature}}"; 
 
try{
                  
      Query
query = QueryFactory.create(queryString);
QueryExecution qexecRule = QueryExecutionFactory.create(query,
infmodel);
      ResultSet resultset =
qexecRule.execSelect();
      Model result =
qexecRule.execConstruct();
      for(; resultset.hasNext() ; ) {
                  
            QuerySolution soln=
resultset.nextSolution();
            RDFNode x =
soln.getResource("Process");
            RDFNode
y = soln.getResource("Symptome1");
            RDFNode z = soln.getResource("Symptome2");
System.out.println(x.toString()  + " "+
y.toString()  + " "+ z.toString());
            } 
The result of this query is
an error saying: “Insufficient memory…” 
          
2.     The second alternative is a
CONSTRUCT Query:
String queryString = 
"PREFIX ONTO:
<http://www.owl-ontologies.com/Ontology1326704817.owl#> PREFIX owl:
<http://www.w3.org/2002/07/owl#> 
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
CONSTRUCT {?Process ONTO:presente ?Symptome1; ONTO:presente
?Symptome2}
WHERE{
{?Process rdf:type ONTO:MoteurDiesel . 

?Process ONTO:presente
?Symptome1 . 

?Symptome1 rdf:type ONTO:Symptome . 

?Symptome1 ONTO:possedeCaracteristiqueDeviation  ?Deviation1 .  

FILTER regex(str(?Deviation1),
'http://www.owl-ontologies.com/Ontology1326704817.owl#Moins') . 

?Symptome1 ONTO:possedeCaracteristiqueFlux  ?Flux1 . 

?Flux1 rdf:type ONTO:Huile . 

?Symptome1 ONTO:possedeCaracteristiquePropriete ?Propriete1 . 

?Propriete1
rdf:type ONTO:PressionFonctionnement} . 

{?Process ONTO:presente ?Symptome2. 

?Symptome2 rdf:type ONTO:Symptome . 

?Symptome2 ONTO:possedeCaracteristiqueDeviation  ?Deviation2 .  

FILTER regex(str(?Deviation),
'http://www.owl-ontologies.com/Ontology1326704817.owl#Plus') . 

?Symptome2 ONTO:possedeCaracteristiqueFlux  ?Flux2 . 

?Flux2 rdf:type ONTO:Huile . 

?Symptome2 ONTO:possedeCaracteristiquePropriete ?Propriete2 . 

?Propriete2 rdf:type
ONTO:Temperature}}"; 
      
try{     
      Query
query = QueryFactory.create(queryString);      
      QueryExecution qexecRule = QueryExecutionFactory.create(query,
infmodel);
      Model result =
qexecRule.execConstruct();
      {result.write(System.out, "Result");
            }     
 
The result of this query is:  “Attempt
to have ResultSet from a CONSTRUCT query”        
 
Do you have any suggestion to
obtain the correct query for ONE VARIABLE link to TWO OTHERS each one with
their relations? 

Thanks in advanced for your reply and for your help,
Kind regards,
Gabriela

_______________________________________________
protege-discussion mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/protege-discussion

Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.