Alignment API and Server 3.5

fr.inrialpes.exmo.align.service
Class QueryMediator

java.lang.Object
  extended by fr.inrialpes.exmo.align.service.QueryMediator
All Implemented Interfaces:
QueryProcessor

public class QueryMediator
extends Object
implements QueryProcessor

QueryMediator A query processor that mediates queries through an ontology alignment. This implementation rely on an embedded QueryProcessor. Another possible implementation would be to subclass a query processor. This would however provide few benefits (speed gained by no indirection) against loss in generality.

Author:
Arun Sharma, Jérôme Euzenat

Field Summary
private  Alignment alignment
           
private  QueryProcessor processor
           
 
Constructor Summary
QueryMediator(Alignment a)
           
QueryMediator(QueryProcessor proc, Alignment a)
           
QueryMediator(QueryProcessor proc, String alignmentURI)
           
QueryMediator(String alignmentURI)
           
 
Method Summary
 int getType(String query)
           
 void loadOntology(String uri)
           
 Result query(String query)
           
 Result query(String query, Type type)
           
 String queryWithStringResults(String query)
           
 String rewriteQuery(String aQuery)
           
static String rewriteSPARQLQuery(String aQuery, Alignment align)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alignment

private Alignment alignment

processor

private QueryProcessor processor
Constructor Detail

QueryMediator

public QueryMediator(QueryProcessor proc,
                     Alignment a)

QueryMediator

public QueryMediator(QueryProcessor proc,
                     String alignmentURI)
              throws SAXException,
                     ParserConfigurationException,
                     IOException
Throws:
SAXException
ParserConfigurationException
IOException

QueryMediator

public QueryMediator(Alignment a)

QueryMediator

public QueryMediator(String alignmentURI)
              throws SAXException,
                     ParserConfigurationException,
                     IOException
Throws:
SAXException
ParserConfigurationException
IOException
Method Detail

query

public Result query(String query,
                    Type type)
Specified by:
query in interface QueryProcessor
Parameters:
query - -- The query string
type - -- The query type, can be one of SELECT, ASK, CONSTRUCT, or DESCRIBE
Returns:
Result, result form depends on type

query

public Result query(String query)
Specified by:
query in interface QueryProcessor
Parameters:
query - -- The query string

queryWithStringResults

public String queryWithStringResults(String query)
Specified by:
queryWithStringResults in interface QueryProcessor
Parameters:
query - -- The query string
Returns:
query results as string

getType

public int getType(String query)
Specified by:
getType in interface QueryProcessor
Parameters:
query - -- the query string
Returns:
the type of the query

loadOntology

public void loadOntology(String uri)
Specified by:
loadOntology in interface QueryProcessor

rewriteQuery

public String rewriteQuery(String aQuery)
                    throws AlignmentException
Parameters:
aQuery - -- query to be re-written
Returns:
-- rewritten query: - replaces all the prefix namespaces, if present, in the query by actual IRIs - replaces all entity IRI by their counterpart in the ontology Caveats: - This does only work for alignments with = - This does not care for the *:x status of alignments - This does work from ontology1 to ontology2, not the otherway round (use invert() in this case).
Throws:
AlignmentException

rewriteSPARQLQuery

public static String rewriteSPARQLQuery(String aQuery,
                                        Alignment align)
                                 throws AlignmentException
Throws:
AlignmentException

Alignment API and Server 3.5

(C) INRIA & friends, 2003-2008