changeset 361:277fe8b0313d

+ default query
author Alexandre Bertails <bertails@gmail.com>
date Sun, 13 Mar 2011 18:13:21 -0400
parents 1420a9d575b8
children 6aa359632373
files directmapping-webapp/src/main/resources/queries/default directmapping-webapp/src/main/scala/Servlet.scala
diffstat 2 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/directmapping-webapp/src/main/resources/queries/default	Sun Mar 13 18:13:21 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/scala/Servlet.scala	Sun Mar 13 18:06:23 2011 -0400
+++ b/directmapping-webapp/src/main/scala/Servlet.scala	Sun Mar 13 18:13:21 2011 -0400
@@ -17,13 +17,7 @@
 
 object DirectMappingWebapp {
 
-  val defaultSQL = 
-"""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);
-"""
+  val defaultSQL = QueryManager.getQueries("default")
 
   val encoding = "utf-8"
 
@@ -203,7 +197,7 @@
     }
   }
 
-  def getQueries:Map[String, String] = {
+  lazy val getQueries:Map[String, String] = {
     val classloader = this.getClass.getClassLoader
     val entries = getResourceListing("queries/")
     val queries = entries map { entry => {
Set up and maintained by W3C Systems Team, please report bugs to sysreq@w3.org.

W3C would like to thank Microsoft who donated the server that allows us to run this service.