The TripleQuery Javadoc page shows the available functions for a TripleQuery. Using these functions you can select data from a TripleStore as you see fit.
This example SiDIF has id='ex1'. It shows the 27 possible combinations of subject1-3, predicate1-3 and object1-3
subject1 predicate1 object1
subject1 predicate1 object2
subject1 predicate1 object3
subject2 predicate1 object1
subject2 predicate1 object2
subject2 predicate1 object3
subject3 predicate1 object1
subject3 predicate1 object2
subject3 predicate1 object3
subject1 predicate2 object1
subject1 predicate2 object2
subject1 predicate2 object3
subject2 predicate2 object1
subject2 predicate2 object2
subject2 predicate2 object3
subject3 predicate2 object1
subject3 predicate2 object2
subject3 predicate2 object3
subject1 predicate3 object1
subject1 predicate3 object2
subject1 predicate3 object3
subject2 predicate3 object1
subject2 predicate3 object2
subject2 predicate3 object3
subject3 predicate3 object1
subject3 predicate3 object2
subject3 predicate3 object3
The statement:
<#assign query=tripleStore.query()/>
gets the default query for the tripleStore. This query selects all triples of the tripleStore. The triples of a query are accessible with query.getTriples().
The following template with the id='query1' shows how all triples of the tripleStore are selected:
<#assign query=tripleStore.query()/>
<#list query.getTriples() as triple>
${triple_index+1} subject: ${triple.subject} predicate: ${triple.predicate} object: ${triple.object}<br>
</#list>
{{wikitask|cmd=runtemplate|input=ex1|template=query1|targetpage=WikiTask Tutorial/query1 result}}
runtemplate -> WikiTask Tutorial/query1 result
1 subject: subject1 predicate: predicate1 object: object1
2 subject: subject1 predicate: predicate1 object: object2
3 subject: subject1 predicate: predicate1 object: object3
4 subject: subject1 predicate: predicate2 object: object1
5 subject: subject1 predicate: predicate2 object: object2
...
The statement:
<#assign query=tripleStore.query()/>
<#assign qSubjects=query.query(null,"predicate1","object1")/>
<#list qSubjects.getTriples() as triple>
${triple_index+1} subject: ${triple.subject} predicate: ${triple.predicate} object: ${triple.object}<br>
</#list>
gets a specific query for the tripleStore. This query selects all triples of the tripleStore, which contain "predicate1" and "object1". The triples of this query are accessible with qSubjects.getTriples().
{{wikitask|cmd=runtemplate|input=ex1|template=query2|targetpage=WikiTask Tutorial/query2 result}}
runtemplate -> WikiTask Tutorial/query2 result
1 subject: subject1 predicate: predicate1 object: object1
2 subject: subject2 predicate: predicate1 object: object1
3 subject: subject3 predicate: predicate1 object: object1
The statement:
<#assign query=tripleStore.query()/>
<#assign qSubjects1=query.query(null,"predicate1","object1")/>
<#assign qSubjects2=query.query(null,"predicate2","object1")/>
<#assign qSubjects3=query.query(null,"predicate3","object1")/>
<#assign qAllSubjects=qSubjects1.union(qSubjects2).union(qSubjects3)/>
<#list qAllSubjects.getTriples() as triple>
${triple_index+1} subject: ${triple.subject} predicate: ${triple.predicate} object: ${triple.object}<br>
</#list>
gets a specific query for the tripleStore. This query selects all triples of the tripleStore, which contain "predicate1","predicate2","predicate3" and "object1". To make an union of two different queries, you can use the method union() e.g. queryAll=query1.union(query2) The triples of this query are accessible with qAllSubjects.getTriples().
{{wikitask|cmd=runtemplate|input=ex1|template=query3|targetpage=WikiTask Tutorial/query3 result}}
runtemplate -> WikiTask Tutorial/query3 result
1 subject: subject1 predicate: predicate1 object: object1
2 subject: subject2 predicate: predicate1 object: object1
3 subject: subject3 predicate: predicate1 object: object1
4 subject: subject1 predicate: predicate2 object: object1
5 subject: subject2 predicate: predicate2 object: object1
6 subject: subject3 predicate: predicate2 object: object1
7 subject: subject1 predicate: predicate3 object: object1
8 subject: subject2 predicate: predicate3 object: object1
9 subject: subject3 predicate: predicate3 object: object1