diff --git a/src/fr/inrialpes/exmo/QueryProcessor/QueryProcessor.java b/src/fr/inrialpes/exmo/QueryProcessor/QueryProcessor.java deleted file mode 100644 index 063e170a97acb8177fc9fa75cdd79b5e19248cc1..0000000000000000000000000000000000000000 --- a/src/fr/inrialpes/exmo/QueryProcessor/QueryProcessor.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * QueryProcessor.java - * - * Created on March 20, 2006, 10:29 AM - * - */ - -package fr.inrialpes.exmo.QueryProcessor; - -/** - * - * @author Arun Sharma - */ -public interface QueryProcessor { - /** - * @param query -- The query string - * @param type -- The query type, can be one of SELECT, ASK, CONSTRUCT, or DESCRIBE - * @returns Result, result form depends on type - */ - public Result query(String query, Type type); - - /** - *@param query -- The query string - */ - public Result query(String query); - - /** - *@param query -- The query string - *@returns query results as string - */ - public String queryWithStringResults(String query); - - /** - *@param query -- the query string - *@returns the type of the query - */ - public int getType(String query); - - public void loadOntology(String uri); - -} diff --git a/src/fr/inrialpes/exmo/QueryProcessor/QueryTypeMismatchException.java b/src/fr/inrialpes/exmo/QueryProcessor/QueryTypeMismatchException.java deleted file mode 100644 index 99acb79925b2e312e9365079dd58a981fdc599d2..0000000000000000000000000000000000000000 --- a/src/fr/inrialpes/exmo/QueryProcessor/QueryTypeMismatchException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * QueryTypeMismatchException.java - * - * Created on March 20, 2006, 11:03 AM - * - */ - -package fr.inrialpes.exmo.QueryProcessor; - -/** - * - * @author Arun Sharma - */ -public class QueryTypeMismatchException extends Exception { - /** - * Create a new <code>QueryTypeMismatchException</code> with no - * detail mesage. - */ - public QueryTypeMismatchException() { - super(); - } - - /** - * Create a new <code>QueryTypeMismatchException</code> with - * the <code>String</code> specified as an error message. - * - * @param message The error message for the exception. - */ - public QueryTypeMismatchException(String message) { - super(message); - } - - /** - * Create a new <code>QueryTypeMismatchException</code> with - * the <code>String</code> specified as an error message and the - * <code>Throwable</code> that caused this exception to be raised. - * @param message The error message for the exception - * @param cause The cause of the exception - */ - public QueryTypeMismatchException(String message, Throwable cause) { - super(message, cause); - } -} diff --git a/src/fr/inrialpes/exmo/QueryProcessor/RDFGraph.java b/src/fr/inrialpes/exmo/QueryProcessor/RDFGraph.java deleted file mode 100644 index 3cdf2ea9a4d4be877a445f508270b9aa0d3cc50d..0000000000000000000000000000000000000000 --- a/src/fr/inrialpes/exmo/QueryProcessor/RDFGraph.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * RDFGraph.java - * - * Created on March 20, 2006, 11:10 AM - * - */ - -package fr.inrialpes.exmo.QueryProcessor; - -/** - * - * @author Arun Sharma - */ -public interface RDFGraph { - /** - *@returns RDF/XML representation of the graph - */ - public String getXML(); - - /**@returns rdf triples - */ - public Triple[] getTriples(); - - //TODO: getN3(); - //TODO: some JenaRepresentation -} diff --git a/src/fr/inrialpes/exmo/QueryProcessor/Result.java b/src/fr/inrialpes/exmo/QueryProcessor/Result.java deleted file mode 100644 index bd130438efa63063c12be4864bc159a3d4dfc3a4..0000000000000000000000000000000000000000 --- a/src/fr/inrialpes/exmo/QueryProcessor/Result.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Result.java - * - * Created on March 20, 2006, 10:55 AM - * - */ - -package fr.inrialpes.exmo.QueryProcessor; - -import java.util.Collection; - -/** - * - * @author Arun Sharma - */ -public interface Result { - /**@returns the type of the result set - */ - public int getType(); - - /**@returns the reslut for ASK type queries - */ - public boolean getAskResult() throws QueryTypeMismatchException; - - /** - *@returns the RDF graph for construct queries - */ - public RDFGraph getConstructResult() throws QueryTypeMismatchException; - - /**@returns a collection set for SELECT queries - */ - public Collection getSelectResult() throws QueryTypeMismatchException; - - /**@returns an XML string for the SELECT queries - */ - public String getSelectResultasXML() throws QueryTypeMismatchException; - -} diff --git a/src/fr/inrialpes/exmo/QueryProcessor/Triple.java b/src/fr/inrialpes/exmo/QueryProcessor/Triple.java deleted file mode 100644 index 8cd0e88555ce797777ab23a3c5f2f5576344d865..0000000000000000000000000000000000000000 --- a/src/fr/inrialpes/exmo/QueryProcessor/Triple.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Triple.java - * - * Created on March 20, 2006, 11:12 AM - * - */ - -package fr.inrialpes.exmo.QueryProcessor; - -/** - * - * @author Arun Sharma - */ -public interface Triple { - - public String subject = ""; - public String object = ""; - public String predicate = ""; - - public String getObject(); - - public void setObject(String obj); - - public String getPredicate() ; - - public void setPredicate(String pred); - - public String getSubject(); - - public void setSubject(String sub); -} diff --git a/src/fr/inrialpes/exmo/QueryProcessor/Type.java b/src/fr/inrialpes/exmo/QueryProcessor/Type.java deleted file mode 100644 index 9fb06c5e6eef46a2bbe7f20ca7c50a15f6a7c956..0000000000000000000000000000000000000000 --- a/src/fr/inrialpes/exmo/QueryProcessor/Type.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Type.java - * - * Created on March 20, 2006, 11:20 AM - * - * - */ - -package fr.inrialpes.exmo.QueryProcessor; - -/** - * - * @author Arun Sharma - */ -public class Type { - - public static int SELECT = 1; - public static int ASK = 2; - public static int CONSTRUCT = 3; - public static int DESCRIBE = 4; - - /** Creates a new instance of Type */ - public Type() { - } - -} diff --git a/src/fr/inrialpes/exmo/QueryProcessor/impl/QueryProcessorImpl.java b/src/fr/inrialpes/exmo/QueryProcessor/impl/QueryProcessorImpl.java deleted file mode 100644 index 71309df485ae2d2e7ae484a929afc6fcbdaa08c9..0000000000000000000000000000000000000000 --- a/src/fr/inrialpes/exmo/QueryProcessor/impl/QueryProcessorImpl.java +++ /dev/null @@ -1,233 +0,0 @@ -package fr.inrialpes.exmo.QueryProcessor.impl; - -/** - * @author Arun Sharma - */ - -import java.util.Set; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Vector; -import java.net.URL; -import java.io.File; -import java.io.FileInputStream; -import java.io.DataInputStream; -import java.io.PrintStream; -import java.io.FileOutputStream; -import java.io.StringWriter; - -import org.mindswap.pellet.output.TableData; -import org.mindswap.pellet.output.OutputFormatter; -import fr.inrialpes.exmo.elster.picster.markup.Razor; -import fr.inrialpes.exmo.elster.picster.markup.MarkupModel; -import org.mindswap.pellet.output.ATermAbstractSyntaxRenderer; -import fr.inrialpes.exmo.elster.picster.*; -import org.mindswap.pellet.output.ATermRenderer; - -import com.hp.hpl.jena.query.ARQ; -import com.hp.hpl.jena.query.Query; -import com.hp.hpl.jena.query.QuerySolution; -import com.hp.hpl.jena.query.QueryExecutionFactory; -import com.hp.hpl.jena.query.ResultSet; -import com.hp.hpl.jena.query.QueryFactory; -import com.hp.hpl.jena.query.QueryExecution; -import com.hp.hpl.jena.query.ResultSetFormatter; - -import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.rdf.model.Property; -import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.rdf.model.StmtIterator; -import com.hp.hpl.jena.rdf.model.Resource; -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.RDFNode; -import com.hp.hpl.jena.graph.Node; -import com.hp.hpl.jena.rdf.model.ModelFactory; -import org.mindswap.markup.media.MarkupImageModel; - -import fr.inrialpes.exmo.QueryProcessor.Result; -import fr.inrialpes.exmo.QueryProcessor.Type; -import fr.inrialpes.exmo.QueryProcessor.QueryProcessor; -import fr.inrialpes.exmo.QueryProcessor.impl.ResultImpl; -/** - * - * @author Arun Sharma - */ -public class QueryProcessorImpl implements QueryProcessor { - - String query; - Model aModel; - ResultSet aResultSet; - Set aResults = new HashSet(); - Hashtable annotation = new Hashtable(); - - public QueryProcessorImpl() { - - } - public QueryProcessorImpl(Model m) { - aModel = m; - } - - public Result query(String aQuery) { - query = aQuery; - Query myquery = QueryFactory.create(query); - QueryExecution qe = QueryExecutionFactory.create(myquery, aModel); - System.err.println("Executing query: " + query); - aResultSet = qe.execSelect(); - - while (aResultSet.hasNext()) - { - QuerySolution aSolution = aResultSet.nextSolution(); - Resource aRes = (Resource)aSolution.get("uri"); - aResults.add(aRes.getURI()); - getAnnotations(aRes, aRes.getURI()); - Property p = aModel.getProperty("http://www.mindswap.org/~glapizco/technical.owl#", "depiction"); - StmtIterator stmtr = aRes.listProperties(p); - //String imguri = ""; - String imaAnnos = ""; - while(stmtr.hasNext()) { - Statement st = stmtr.nextStatement(); - String imguri = st.getObject().toString(); - System.out.println("Depiction URI = " + imguri); - if(!aResults.contains(imguri)) - aResults.add(imguri); - String thisImgAnno = getAnnotations(aRes, imguri); - imaAnnos = imaAnnos + thisImgAnno + "<image>"; - } - //getAnnotations(aRes, imguri); - annotation.put(aRes.getURI(), imaAnnos); - } - - qe.close(); - ResultImpl res = new ResultImpl(aResults); - return res; - } - - - public ResultSet performQuery() { - Query myquery = QueryFactory.create(query); - QueryExecution qe = QueryExecutionFactory.create(myquery, aModel); - System.err.println("Executing query: " + query); - aResultSet = qe.execSelect(); - - while (aResultSet.hasNext()) - { - QuerySolution aSolution = aResultSet.nextSolution(); - Resource aRes = (Resource)aSolution.get("uri"); - aResults.add(aRes.getURI()); - getAnnotations(aRes, aRes.getURI()); - Property p = aModel.getProperty("http://www.mindswap.org/~glapizco/technical.owl#", "depiction"); - StmtIterator stmtr = aRes.listProperties(p); - //String imguri = ""; - String imaAnnos = ""; - while(stmtr.hasNext()) { - Statement st = stmtr.nextStatement(); - String imguri = st.getObject().toString(); - System.out.println("Depiction URI = " + imguri); - if(!aResults.contains(imguri)) - aResults.add(imguri); - String thisImgAnno = getAnnotations(aRes, imguri); - imaAnnos = imaAnnos + thisImgAnno + "<image>"; - } - //getAnnotations(aRes, imguri); - annotation.put(aRes.getURI(), imaAnnos); - } - - qe.close(); - return aResultSet; - } - - public String getAnnotations(Resource res, String mediaUri) { - String queryAnno = ""; - String uri = res.getURI(); - String instanceFileName = uri.substring(uri.lastIndexOf('/')+1, uri.lastIndexOf('.')) + ".rdf"; - String annoFileName = ""; - if(!uri.equals(mediaUri)) { - if(mediaUri.contains("region")) { - String temp = mediaUri.substring(0, mediaUri.indexOf("region")-1); - annoFileName = temp.substring(temp.lastIndexOf('/')+1, temp.length() ) + ".rdf"; - } - else - annoFileName = mediaUri.substring(mediaUri.lastIndexOf('/')+1, mediaUri.length()) + ".rdf"; - } - System.out.println("\n\n\nInstanceFileName = " + instanceFileName); - System.out.println("\n\n\nAnnotationFileName = " + annoFileName); - - try { - FileInputStream in = new FileInputStream(new File("annotations/" + annoFileName)); - DataInputStream ds = new DataInputStream(in); - String annotations = ""; - while(ds.available() != 0) { - annotations = annotations + ds.readLine(); - annotations = annotations + "\n"; - } - OntModel m = ModelFactory.createOntologyModel(); - StmtIterator stms = res.listProperties(); - m.add(stms); - StringWriter sr = new StringWriter(); - m.write(sr, "RDF/XML-ABBREV"); - String instance = sr.toString(); - /* queryAnno = "<" + annoFileName + ">" + annotations + "</" + annoFileName + ">" - + "<" + instanceFileName + ">" + instance + "</" + instanceFileName + ">"; - */ - queryAnno = annoFileName + "<divider>" +annotations + "<divider>"+ instanceFileName + "<divider>" + instance; - } catch(Exception e) { - System.err.println("Annotation found not found"); - } - //annotation.put(mediaUri, queryAnno); - return queryAnno; - } - - public String getAnnotationforUri(String uri) { - String aAnno = (String) annotation.get(uri); - return aAnno; - } - - public Set getResourceUrisAsSet(ResultSet aResultSet) { - /* Set aResults = new HashSet(); - while (aResultSet.hasNext()) - { - }*/ - return aResults; - } - - public void showImages(Set mResults, Razor myApp) { - System.out.println("Reached show Images"); - Vector imgUrls = new Vector(); - Iterator itr = mResults.iterator(); - while(itr.hasNext()) { - String uri = (String) itr.next(); - String imageLocation = (String)MarkupImageModel.getUriMap().get(uri); - if(imageLocation == null) - imageLocation = (String)MarkupImageModel.getRegUriMap().get(uri); - imgUrls.add(imageLocation); - } - - for(int j = 0; j < imgUrls.size(); j++) { - try { - String url = (String) imgUrls.get(j); - System.out.println("Image Location = " + url); - URL aUrl = new URL(url); - myApp.loadURL(aUrl); - } catch(Exception e) { - System.out.println("Error in image location"); - } - } - } - - public Result query(String query, Type type) { - return null; - } - - public String queryWithStringResults(String query) { - return null; - } - - public int getType(String query) { - return 0; - } - - public void loadOntology(String uri) { - - } -} diff --git a/src/fr/inrialpes/exmo/QueryProcessor/impl/ResultImpl.java b/src/fr/inrialpes/exmo/QueryProcessor/impl/ResultImpl.java deleted file mode 100644 index d61356b74c0979e24281e0c0fa2166a235547cdc..0000000000000000000000000000000000000000 --- a/src/fr/inrialpes/exmo/QueryProcessor/impl/ResultImpl.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * ResultImpl.java - * - * Created on May 21, 2006, 10:49 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ - -package fr.inrialpes.exmo.QueryProcessor.impl; - -import fr.inrialpes.exmo.QueryProcessor.*; -import java.util.*; -/** - * - * @author Arun Sharma - */ -public class ResultImpl implements Result{ - - Set aSet = new HashSet(); - - public ResultImpl(Set set) { - aSet = set; - } - - /**@returns a collection set for SELECT queries - */ - public Collection getSelectResult() throws QueryTypeMismatchException { - return aSet; - } - - public int getType() { - return 0; - } - public boolean getAskResult() throws QueryTypeMismatchException { - return false; - } - public RDFGraph getConstructResult() throws QueryTypeMismatchException { - return null; - } - public String getSelectResultasXML() throws QueryTypeMismatchException { - return null; - } -} \ No newline at end of file