--- a/directmapping-webapp/src/main/resources/queries/1table0rows Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-CREATE TABLE Student (
- Name VARCHAR(50)
-);
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/1table0rows.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,3 @@
+CREATE TABLE Student (
+ Name VARCHAR(50)
+);
\ No newline at end of file
--- a/directmapping-webapp/src/main/resources/queries/1table1compositeprimarykey3columns1row Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-CREATE TABLE Student (
- ID integer,
- Name varchar(50),
- Sport varchar (50),
- PRIMARY KEY (ID,Name)
-);
-INSERT INTO Student (ID, Name,Sport) VALUES(10,"Venus Williams","Tennis");
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/1table1compositeprimarykey3columns1row.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,7 @@
+CREATE TABLE Student (
+ ID integer,
+ Name varchar(50),
+ Sport varchar (50),
+ PRIMARY KEY (ID,Name)
+);
+INSERT INTO Student (ID, Name,Sport) VALUES(10,"Venus Williams","Tennis");
\ No newline at end of file
--- a/directmapping-webapp/src/main/resources/queries/1table1primarykey1column1row Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-CREATE TABLE Student (
-Name varchar(50) PRIMARY KEY
-);
-INSERT INTO Student (Name) VALUES ("Venus");
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/1table1primarykey1column1row.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,4 @@
+CREATE TABLE Student (
+Name varchar(50) PRIMARY KEY
+);
+INSERT INTO Student (Name) VALUES ("Venus");
\ No newline at end of file
--- a/directmapping-webapp/src/main/resources/queries/1table1row Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-CREATE TABLE Student (
- Name VARCHAR(50)
-);
-INSERT INTO Student (Name) VALUES ("Venus");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/1table1row.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,4 @@
+CREATE TABLE Student (
+ Name VARCHAR(50)
+);
+INSERT INTO Student (Name) VALUES ("Venus");
--- a/directmapping-webapp/src/main/resources/queries/1table2columns1row Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-CREATE TABLE Student (
- ID INT,
- Name VARCHAR(50)
-);
-INSERT INTO Student (ID, Name) VALUES(10,"Venus");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/1table2columns1row.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,5 @@
+CREATE TABLE Student (
+ ID INT,
+ Name VARCHAR(50)
+);
+INSERT INTO Student (ID, Name) VALUES(10,"Venus");
--- a/directmapping-webapp/src/main/resources/queries/1table3columns1row Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-CREATE TABLE Student (
- ID INT,
- FirstName VARCHAR(50),
- LastName VARCHAR(50)
-);
-INSERT INTO Student (ID, FirstName, LastName) VALUES (10,"Venus", "Williams");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/1table3columns1row.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,6 @@
+CREATE TABLE Student (
+ ID INT,
+ FirstName VARCHAR(50),
+ LastName VARCHAR(50)
+);
+INSERT INTO Student (ID, FirstName, LastName) VALUES (10,"Venus", "Williams");
--- a/directmapping-webapp/src/main/resources/queries/2duplicates0nulls Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-CREATE TABLE IOUs (
- fname CHAR(20),
- lname CHAR(20),
- amount FLOAT);
-INSERT INTO IOUs (fname, lname, amount) VALUES ("Bob", "Smith", 30);
-INSERT INTO IOUs (fname, lname, amount) VALUES ("Sue", "Jones", 20);
-INSERT INTO IOUs (fname, lname, amount) VALUES ("Bob", "Smith", 30);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/2duplicates0nulls.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,7 @@
+CREATE TABLE IOUs (
+ fname CHAR(20),
+ lname CHAR(20),
+ amount FLOAT);
+INSERT INTO IOUs (fname, lname, amount) VALUES ("Bob", "Smith", 30);
+INSERT INTO IOUs (fname, lname, amount) VALUES ("Sue", "Jones", 20);
+INSERT INTO IOUs (fname, lname, amount) VALUES ("Bob", "Smith", 30);
--- a/directmapping-webapp/src/main/resources/queries/2tables1primarykey1foreingkey Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,17 +0,0 @@
-CREATE TABLE Student (
-ID integer,
-Name varchar(50),
-Sport integer,
-PRIMARY KEY (ID),
-FOREIGN KEY(Sport) REFERENCES Sport(ID)
-);
-
-CREATE TABLE Sport (
-ID integer,
-Name varchar (50),
-PRIMARY KEY (ID)
-);
-
-INSERT INTO Student (ID, Name, Sport) VALUES (10,"Venus Williams", 100);
-INSERT INTO Student (ID, Name, Sport) VALUES (20,"Demi Moore", NULL);
-INSERT INTO Sport (ID, Name) VALUES (100,"Tennis");
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/2tables1primarykey1foreingkey.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,17 @@
+CREATE TABLE Student (
+ID integer,
+Name varchar(50),
+Sport integer,
+PRIMARY KEY (ID),
+FOREIGN KEY(Sport) REFERENCES Sport(ID)
+);
+
+CREATE TABLE Sport (
+ID integer,
+Name varchar (50),
+PRIMARY KEY (ID)
+);
+
+INSERT INTO Student (ID, Name, Sport) VALUES (10,"Venus Williams", 100);
+INSERT INTO Student (ID, Name, Sport) VALUES (20,"Demi Moore", NULL);
+INSERT INTO Sport (ID, Name) VALUES (100,"Tennis");
\ No newline at end of file
--- a/directmapping-webapp/src/main/resources/queries/defaultSQL Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID));
-INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
-INSERT INTO People (ID, fname, addr) VALUES (8, "Sue", NULL);
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/defaultSQL.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,5 @@
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID));
+INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
+INSERT INTO People (ID, fname, addr) VALUES (8, "Sue", NULL);
\ No newline at end of file
--- a/directmapping-webapp/src/main/resources/queries/emp_addr Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID));
-INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
-INSERT INTO People (ID, fname, addr) VALUES (8, "Sue", NULL);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/emp_addr.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,5 @@
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID));
+INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
+INSERT INTO People (ID, fname, addr) VALUES (8, "Sue", NULL);
--- a/directmapping-webapp/src/main/resources/queries/hier_tabl_proto Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
- FOREIGN KEY (addr) REFERENCES Addresses(ID));
-INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
-CREATE TABLE Offices (ID INT PRIMARY KEY,
- building INT, ofcNumber STRING,
- FOREIGN KEY (ID) REFERENCES Addresses(ID));
-INSERT INTO Offices (ID, building, ofcNumber) VALUES (18, 32, "G528");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/hier_tabl_proto.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,9 @@
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
+ FOREIGN KEY (addr) REFERENCES Addresses(ID));
+INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
+CREATE TABLE Offices (ID INT PRIMARY KEY,
+ building INT, ofcNumber STRING,
+ FOREIGN KEY (ID) REFERENCES Addresses(ID));
+INSERT INTO Offices (ID, building, ofcNumber) VALUES (18, 32, "G528");
--- a/directmapping-webapp/src/main/resources/queries/hier_table Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
- FOREIGN KEY (addr) REFERENCES Addresses(ID));
-INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
-CREATE TABLE Offices (ID INT PRIMARY KEY,
- building INT, ofcNumber STRING,
- FOREIGN KEY (ID) REFERENCES Addresses(ID));
-INSERT INTO Offices (ID, building, ofcNumber) VALUES (18, 32, "G528");
-CREATE TABLE ExecutiveOffices (ID INT PRIMARY KEY,
- desk STRING,
- FOREIGN KEY (ID) REFERENCES Offices(ID));
-INSERT INTO ExecutiveOffices (ID, desk) VALUES (18, "oak");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/hier_table.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,13 @@
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
+ FOREIGN KEY (addr) REFERENCES Addresses(ID));
+INSERT INTO People (ID, fname, addr) VALUES (7, "Bob", 18);
+CREATE TABLE Offices (ID INT PRIMARY KEY,
+ building INT, ofcNumber STRING,
+ FOREIGN KEY (ID) REFERENCES Addresses(ID));
+INSERT INTO Offices (ID, building, ofcNumber) VALUES (18, 32, "G528");
+CREATE TABLE ExecutiveOffices (ID INT PRIMARY KEY,
+ desk STRING,
+ FOREIGN KEY (ID) REFERENCES Offices(ID));
+INSERT INTO ExecutiveOffices (ID, desk) VALUES (18, "oak");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/identity.construct Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,5 @@
+CONSTRUCT {
+ ?s ?p ?o .
+} WHERE {
+ ?s ?p ?o .
+}
\ No newline at end of file
--- a/directmapping-webapp/src/main/resources/queries/multi_key Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE Department (ID INT PRIMARY KEY, name STRING, city STRING,
- manager INT, FOREIGN KEY (manager) REFERENCES People(ID), UNIQUE (name, city));
-INSERT INTO Department (ID, name, city, manager) VALUES (23, "accounting", "Cambridge", 8);
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING,
- addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID),
- deptName STRING, deptCity STRING, FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
-INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (7, "Bob", 18, "accounting", "Cambridge");
-INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (8, "Sue", NULL, NULL, NULL);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/multi_key.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,10 @@
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE Department (ID INT PRIMARY KEY, name STRING, city STRING,
+ manager INT, FOREIGN KEY (manager) REFERENCES People(ID), UNIQUE (name, city));
+INSERT INTO Department (ID, name, city, manager) VALUES (23, "accounting", "Cambridge", 8);
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING,
+ addr INT, FOREIGN KEY (addr) REFERENCES Addresses(ID),
+ deptName STRING, deptCity STRING, FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
+INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (7, "Bob", 18, "accounting", "Cambridge");
+INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (8, "Sue", NULL, NULL, NULL);
--- a/directmapping-webapp/src/main/resources/queries/ref_no_pk Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
-INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
-CREATE TABLE Department (ID INT PRIMARY KEY, name STRING, city STRING, manager INT,
- FOREIGN KEY (manager) REFERENCES People(ID),
- UNIQUE (name, city));
-INSERT INTO Department (ID, name, city, manager) VALUES (23, "accounting", "Cambridge", 8);
-CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
- FOREIGN KEY (addr) REFERENCES Addresses(ID),
- deptName STRING, deptCity STRING,
- FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
-INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (7, "Bob", 18, "accounting", "Cambridge");
-INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (8, "Sue", NULL, NULL, NULL);
-CREATE TABLE Projects (lead INT,
- FOREIGN KEY (lead) REFERENCES People(ID),
- name STRING, UNIQUE (lead, name),
- deptName STRING, deptCity STRING,
- UNIQUE (name, deptName, deptCity),
- FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
-INSERT INTO Projects (lead, name, deptName, deptCity) VALUES (8, "pencil survey", "accounting", "Cambridge");
-INSERT INTO Projects (lead, name, deptName, deptCity) VALUES (8, "eraser survey", "accounting", "Cambridge");
-CREATE TABLE TaskAssignments (worker INT,
- FOREIGN KEY (worker) REFERENCES People(ID),
- project STRING, PRIMARY KEY (worker, project),
- deptName STRING, deptCity STRING,
- FOREIGN KEY (worker) REFERENCES People(ID),
- FOREIGN KEY (project, deptName, deptCity) REFERENCES Projects(name, deptName, deptCity),
- FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
-INSERT INTO TaskAssignments (worker, project, deptName, deptCity) VALUES (7, "pencil survey", "accounting", "Cambridge");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/ref_no_pk.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,28 @@
+CREATE TABLE Addresses (ID INT PRIMARY KEY, city STRING, state STRING);
+INSERT INTO Addresses (ID, city, state) VALUES (18, "Cambridge", "MA");
+CREATE TABLE Department (ID INT PRIMARY KEY, name STRING, city STRING, manager INT,
+ FOREIGN KEY (manager) REFERENCES People(ID),
+ UNIQUE (name, city));
+INSERT INTO Department (ID, name, city, manager) VALUES (23, "accounting", "Cambridge", 8);
+CREATE TABLE People (ID INT PRIMARY KEY, fname STRING, addr INT,
+ FOREIGN KEY (addr) REFERENCES Addresses(ID),
+ deptName STRING, deptCity STRING,
+ FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
+INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (7, "Bob", 18, "accounting", "Cambridge");
+INSERT INTO People (ID, fname, addr, deptName, deptCity) VALUES (8, "Sue", NULL, NULL, NULL);
+CREATE TABLE Projects (lead INT,
+ FOREIGN KEY (lead) REFERENCES People(ID),
+ name STRING, UNIQUE (lead, name),
+ deptName STRING, deptCity STRING,
+ UNIQUE (name, deptName, deptCity),
+ FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
+INSERT INTO Projects (lead, name, deptName, deptCity) VALUES (8, "pencil survey", "accounting", "Cambridge");
+INSERT INTO Projects (lead, name, deptName, deptCity) VALUES (8, "eraser survey", "accounting", "Cambridge");
+CREATE TABLE TaskAssignments (worker INT,
+ FOREIGN KEY (worker) REFERENCES People(ID),
+ project STRING, PRIMARY KEY (worker, project),
+ deptName STRING, deptCity STRING,
+ FOREIGN KEY (worker) REFERENCES People(ID),
+ FOREIGN KEY (project, deptName, deptCity) REFERENCES Projects(name, deptName, deptCity),
+ FOREIGN KEY (deptName, deptCity) REFERENCES Department(name, city));
+INSERT INTO TaskAssignments (worker, project, deptName, deptCity) VALUES (7, "pencil survey", "accounting", "Cambridge");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/reverse.construct Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,5 @@
+CONSTRUCT {
+ ?o ?p ?s .
+} WHERE {
+ ?s ?p ?o .
+}
\ No newline at end of file
--- a/directmapping-webapp/src/main/resources/queries/varchar_varchar_1row Wed May 04 15:35:48 2011 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-CREATE TABLE Student_Sport(
- Student VARCHAR(50),
- Sport VARCHAR(50)
-);
-INSERT INTO Student_Sport (Student,Sport) VALUES ("Venus", "Tennis");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/varchar_varchar_1row.ddl Thu May 05 16:59:13 2011 -0400
@@ -0,0 +1,5 @@
+CREATE TABLE Student_Sport(
+ Student VARCHAR(50),
+ Sport VARCHAR(50)
+);
+INSERT INTO Student_Sport (Student,Sport) VALUES ("Venus", "Tennis");
--- a/directmapping-webapp/src/main/scala/code/snippet/HelloWorld.scala Wed May 04 15:35:48 2011 -0400
+++ b/directmapping-webapp/src/main/scala/code/snippet/HelloWorld.scala Thu May 05 16:59:13 2011 -0400
@@ -31,11 +31,17 @@
object Services extends RestHelper with RDF2RDFModule with DirectMappingModule {
serve {
- case "ddl" :: ddl :: Nil Get _ => JsonResponse(JsRaw(QueryManager.getQueries(ddl)))
+ case "ddl" :: ddl :: Nil Get _ => JsonResponse(JsRaw(QueryManager.embeddedDDLs(ddl)))
case "ddls" :: Nil Get _ => {
val current = S.param("q").openOr("")
val limit = S.param("limit").flatMap(asInt).openOr(10)
- PlainTextResponse(QueryManager.getQueries.keys filter { _ contains current } take limit map (s => s+"|"+s) mkString "\n")
+ PlainTextResponse(QueryManager.embeddedDDLs.keys filter { _ contains current } take limit map (s => s+"|"+s) mkString "\n")
+ }
+ case "construct" :: construct :: Nil Get _ => JsonResponse(JsRaw(QueryManager.embeddedCONSTRUCTs(construct)))
+ case "constructs" :: Nil Get _ => {
+ val current = S.param("q").openOr("")
+ val limit = S.param("limit").flatMap(asInt).openOr(10)
+ PlainTextResponse(QueryManager.embeddedCONSTRUCTs.keys filter { _ contains current } take limit map (s => s+"|"+s) mkString "\n")
}
case "parse-ddl" :: Nil Post _ => {
try {
@@ -56,20 +62,26 @@
}
case "dm-then-construct" :: Nil Post _ => {
try {
- import DirectMapping._
- val SQLParser = sql.SqlParser()
- val db = SQLParser.toDB(S.param("ddl").openOr(""))
- DirectMapping.MinEncode = false
- val computedGraph:Graph = databaseSemantics(db)
- val construct = Construct(S.param("construct").openOr(""))
- val resultGraph = RDF2RDF(computedGraph) | construct
- PlainTextResponse(this.toString(resultGraph))
+ val ddl = S.param("ddl").openOr("")
+ val construct = S.param("construct").openOr("")
+ PlainTextResponse(dmThenConstruct(ddl, construct))
} catch {
case e => PlainTextResponse(e.getMessage, 500)
}
}
+ }
+ def dmThenConstruct(ddl:String, construct:String):String = {
+ import DirectMapping._
+ val SQLParser = sql.SqlParser()
+ val db = SQLParser.toDB(ddl)
+ DirectMapping.MinEncode = false
+ val computedGraph:Graph = databaseSemantics(db)
+ val construc = Construct(construct)
+ val resultGraph = RDF2RDF(computedGraph) | construc
+ this.toString(resultGraph)
}
+
}
@@ -80,28 +92,43 @@
val SQLParser = sql.SqlParser()
val defaultDDL = "ref_no_pk"
+ val defaultCONSTRUCT = "identity"
def render = {
val (ddlName, ddl, ddlMessage) = S.param("ddl") match {
- case Full(name) if QueryManager.getQueries contains name => {
- (name, QueryManager.getQueries(name), "DDL successfully loaded")
+ case Full(name) if QueryManager.embeddedDDLs contains name => {
+ (name, QueryManager.embeddedDDLs(name), "DDL successfully loaded")
}
case Full(name) => {
- (defaultDDL, QueryManager.getQueries(defaultDDL), name + "not found: default DDL used instead")
+ (defaultDDL, QueryManager.embeddedDDLs(defaultDDL), name + "not found: default DDL used instead")
}
case _ => {
- (defaultDDL, QueryManager.getQueries(defaultDDL), "Default DDL used")
+ (defaultDDL, QueryManager.embeddedDDLs(defaultDDL), "Default DDL used")
}
}
- "#ddl-name [value]" #> ddlName &
+ val (constructName, construct, constructMessage) = S.param("construct") match {
+ case Full(name) if QueryManager.embeddedCONSTRUCTs contains name => {
+ (name, QueryManager.embeddedCONSTRUCTs(name), "SPARQL CONSTRUCT successfully loaded")
+ }
+ case Full(name) => {
+ (defaultCONSTRUCT, QueryManager.embeddedCONSTRUCTs(defaultCONSTRUCT), name + "not found: default SPARQL CONSTRUCT used instead")
+ }
+ case _ => {
+ (defaultCONSTRUCT, QueryManager.embeddedCONSTRUCTs(defaultCONSTRUCT), "Default SPARQL CONSTRUCT used")
+ }
+ }
+
+ "#ddl-name [value]" #> "" &
"#ddl *" #> ddl &
- "#ddl-message *" #> ddlMessage
+ "#ddl-message *" #> ddlMessage &
+ "#construct-name [value]" #> "" &
+ "#construct *" #> construct &
+ "#construct-message *" #> constructMessage &
+ "#result *" #> Services.dmThenConstruct(ddl, construct)
+
}
-
-
-
}
object QueryManager {
@@ -112,17 +139,19 @@
import scala.collection.JavaConversions._
import scala.io.Source
+ val clazz:Class[_] = this.getClass
+ val classloader = this.getClass.getClassLoader
+
/** http://www.uofr.net/~greg/java/get-resource-listing.html */
def getResourceListing(path:String):List[String] = {
- val clazz:Class[_] = this.getClass
- var dirURL:URL = clazz.getClassLoader().getResource(path)
+ var dirURL:URL = classloader.getResource(path)
if (dirURL != null && dirURL.getProtocol == "file") {
/* A file path: easy enough */
new File(dirURL.toURI).list.toList
} else {
if (dirURL == null) {
val me = clazz.getName().replace(".", "/")+".class"
- dirURL = clazz.getClassLoader().getResource(me)
+ dirURL = classloader.getResource(me)
}
if (dirURL.getProtocol == "jar") {
val jarPath = dirURL.getPath.substring(5, dirURL.getPath().indexOf("!"))
@@ -140,101 +169,26 @@
}
}
- lazy val getQueries:Map[String, String] = {
- val classloader = this.getClass.getClassLoader
- val entries = getResourceListing("queries/")
- val queries = entries map { entry => {
- val url = classloader.getResource("queries/" + entry)
+ import scala.collection.mutable.LinkedHashMap
+
+ def embeddedFiles(extension:String):LinkedHashMap[String, String] = {
+ val pattern = extension.replaceAll("\\.", "\\.") + "$"
+ val files = getResourceListing("queries/") filter { _.endsWith(extension) }
+ val queries = files map { file => {
+ val url = classloader.getResource("queries/" + file)
val query = Source.fromURL(url, "UTF-8").getLines.mkString("\n")
- (entry, query)
- } } toMap
-
- queries
+ (file.replaceAll(pattern, ""), query)
+ } }
+ LinkedHashMap[String, String]() ++ queries
}
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-class DirectMapping extends JenaModel with RDF2RDFModule with DirectMappingModule with TurtleModule {
-
- import DirectMapping._
-
- val SQLParser = sql.SqlParser()
-
- val turtleParser = new TurtleParser { }
-
- def jenaSerializer(g:Graph):String = {
- val m = com.hp.hpl.jena.rdf.model.ModelFactory.createModelForGraph(g.jenaGraph)
- val s = new java.io.StringWriter
- m.write(s, "TURTLE")
- s.toString
- }
-
- def getSQL = Run("""jQuery.get('/sql/'+formatted, function(data) { jQuery("#sql-query").val(data); });""")
-
- def queryArea = {
- ".query *" #> QueryManager.getQueries("defaultSQL") &
- ".load-query" #> SHtml.ajaxButton(Text("load"), () => SetHtml("sql-query", Text(QueryManager.getQueries("")))) &
- ".query-box *" #> AutoComplete("", buildQuery _, getSQL)
- }
-
-
- private def buildQuery(current: String, limit: Int): Seq[String] = {
- QueryManager.getQueries.keys.toSeq filter { _ contains current } take limit
- }
-
-
- private var sqlValue = QueryManager.getQueries("defaultSQL")
-
- // private val resultValue = sqlValue.lift { (s:String) => {
- // try {
- // val db = SQLParser.toDB(s)
- // DirectMapping.MinEncode = false
- // val computedGraph:Graph = databaseSemantics(db)
- // jenaSerializer(computedGraph)
- // } catch {
- // case e => e.getMessage
- // }
- // }}
-
- def sqlAjaxTextArea = {
- "#sql" #> SHtml.ajaxTextarea(
- sqlValue,
- v => { println("new v"); sqlValue = v; Noop })
- }
-
-
+ lazy val embeddedDDLs = embeddedFiles(".ddl")
+ lazy val embeddedCONSTRUCTs = embeddedFiles(".construct")
}
}
+
}
--- a/directmapping-webapp/src/main/webapp/index.html Wed May 04 15:35:48 2011 -0400
+++ b/directmapping-webapp/src/main/webapp/index.html Thu May 05 16:59:13 2011 -0400
@@ -34,7 +34,7 @@
})
}
- jQuery("#ddl").watermark(jQuery("#ddl").val());
+ // jQuery("#ddl").watermark(jQuery("#ddl").val());
jQuery("#ddl-name").autocomplete("/ddls", {minChars:0,matchContains:true}).result(function(event, dt, ddlname) {
jQuery("#ddl-name").val(ddlname);
@@ -43,6 +43,13 @@
});
});
+ jQuery("#construct-name").autocomplete("/constructs", {minChars:0,matchContains:true}).result(function(event, dt, constructname) {
+ jQuery("#construct-name").val(constructname);
+ jQuery.ajax({url: '/construct/'+constructname,
+ success: function(data) { jQuery("#construct").val(data); jQuery("#construct-message").val("CONSTRUCT successfully loaded"); dmThenConstruct(); }
+ });
+ });
+
jQuery("#ddl").typeWatch({
callback: function() {
jQuery.ajax({type: "POST",
@@ -119,7 +126,7 @@
<input type="text" value="" id="construct-name" class="ac_input"/>
</div>
<div class="message">
- <textarea id="construct-message" class="error" rows="5" cols="40" disabled="disabled"></textarea>
+ <textarea id="construct-message" rows="5" cols="40" disabled="disabled"></textarea>
</div>
</div>
</div>