Miguel Azurin, Andrew Engroff, Ahmad Sadiq Jython SPARQL Miguel Azurin, Andrew Engroff, Ahmad Sadiq
Files that were modified Files that were modified include: build.xml - added Jena support: Jena is a Java framework for building Semantic Web applications. Jena provides a collection of tools and Java libraries to help develop semantic web and linked-data apps, tools and servers. Python.g - different types of sparql statements Tuple.java - Modified constructor PyTuple.java - added Name of Data Source CodeCompiler.java - Sparql query node
Sparql queries -how to // Initialize variables here. $sparql_stmt::prefixes = new ArrayList<com.MJJ.common.Pair<String, String>>(); $sparql_stmt::selectVars = new ArrayList<String>(); $sparql_stmt::fromClauses = new ArrayList<String>(); $sparql_stmt::orderBys = new ArrayList<com.MJJ.common.Pair<String, String>>(); $sparql_stmt::whereClauses = new ArrayList<com.MJJ.common.WhereClause>(); $sparql_stmt::limits = new ArrayList<String>(); $sparql_stmt::exprs = new ArrayList<expr>(); $sparql_stmt::queryType=""; $sparql_stmt::temp=""; $sparql_stmt::values = new ArrayList<String>(); $sparql_stmt::exprs = new ArrayList<com.MJJ.common.Pair<expr, String>>();
Demo - Part 1 # First we need to create an ARQ model SPARQL(CREATE family_demo) # Set the prefix we want to use SPARQL(PREFIX fam : <http://www.example.org/family/>) # Insert a little family into the database SPARQL(INSERT { fam:Dad fam:fatherOf fam:SomeGuy; }) SPARQL(INSERT { fam:Mom fam:motherOf fam:SomeGuy; }) SPARQL(INSERT { fam:Dad fam:fatherOf fam:SomeGirl; }) SPARQL(INSERT { fam:Mom fam:motherOf fam:SomeGirl; })
Demo - Part 2 SPARQL(INSERT { fam:Dad fam:fatherOf fam:AnotherGirl; }) SPARQL(INSERT { fam:Mom fam:motherOf fam:AnotherGirl; }) SPARQL(INSERT { fam:SomeGuy fam:sonOf fam:Dad. }) SPARQL(INSERT { fam:SomeGuy fam:sonOf fam:Mom. }) SPARQL(INSERT { fam:SomeGirl fam:daughterOf fam:Mom. }) SPARQL(INSERT { fam:SomeGirl fam:daughterOf fam:Dad. }) SPARQL(INSERT { fam:AnotherGirl fam:daughterOf fam:Mom. }) SPARQL(INSERT { fam:AnotherGirl fam:daughterOf fam:Dad. })
Demo - Part 3 # Get all the daughters of Mom from the database SPARQL(SELECT * WHERE { ?daughters fam:daughterOf fam:Mom. }) # Get all the sons of Dad from the database SPARQL(SELECT * WHERE { ?sons fam:sonOf fam:Dad. }) # Get all the parents of SomeGuy SPARQL(SELECT * WHERE { fam:SomeGuy fam:sonOf ?parents. }) # We're done, so let's drop the model. SPARQL(DROP GRAPH family_demo)
RDF Triple Store using INSERT With a bunch of INSERT statements we create a table SPARQL(INSERT { fam:Dad fam:fatherOf fam:AnotherGirl; })
SPARQL SELECT This SPARQL Select statement uses the WHERE clause to find all the "daughters" in the table
SPARQL MULTIPLE SELECTS This select statement shows all the "Parents" from the Table. It knows that Mom and Dad are both Parents.
SPARQL DELETE Delete a specific row from the table using WHERE clause.
SPARQL DROP TABLE Drops the entire table.
Pair.java added needed functionality to make select statement be more granular by the time we want to use it to query the db. modified the language to allow for SELECT * FROM ... case public class Pair<E, S> { protected E left; protected S right; public Pair(E left, S right){ this.left = left; this.right = right; } public E getLeft(){ return left; } public S getRight(){ return right;
WhereClause: subject, predicate, object Public class WhereClause { protected String subject; protected String predicate; protected String object; public WhereClause(String subject, String predicate, String object){ this.subject = subject; this.predicate = predicate; this.object = object; } public String getSubject(){ return subject;} public String getPredicate(){ return predicate;} public String getObject(){ return object; } public String toString(){ StringBuffer sb = new StringBuffer(); sb.append(subject == null ? "null" : subject); sb.append(predicate == null ? "null" : predicate); sb.append(object == null ? "null" : object); return sb.toString(); }}