Request Path Resolution

FIXME

IGNORE THE FOLLOWING NOTES FOR NOW, AND JUST TAKE A LOOK AT THE SAMPLE CODE !!

Request Path resolution / URL space 
  notfound 
  error 
  baseuri 
  _parent for URL generation 
  .href() 
  hrefSkin, hrefFunction, hrefRootPrototype

demoObjectModelling.zip: collections, parent, object-reference

### mysql.sql ### 
 
CREATE DATABASE demoObjectModelling; 
USE demoObjectModelling; 
 
GRANT ALL ON demoObjectModelling.* TO helma@localhost IDENTIFIED BY 'secret'; 
 
CREATE TABLE tb_person ( 
  person_id MEDIUMINT(10) NOT NULL, 
  person_name TINYTEXT, 
  person_height TINYINT unsigned, 
  person_dateofbirth DATETIME, 
  person_org_id MEDIUMINT(10) unsigned 
  PRIMARY KEY (person_id) 
); 
 
CREATE TABLE tb_organisation ( 
   org_id MEDIUMINT(10) unsigned NOT NULL, 
   org_name TINYTEXT, 
   org_country TINYTEXT, 
   PRIMARY KEY (org_id) 
); 
 
CREATE INDEX idx_pers_org ON tb_person (person_org_id); 
 
INSERT INTO tb_organisation values (1, "knallgrau", "at"); 
INSERT INTO tb_organisation values (2, "helma", "at"); 
INSERT INTO tb_organisation values (3, "amazon", "us"); 
INSERT INTO tb_organisation values (4, "ebay", "us"); 
INSERT INTO tb_organisation values (5, "yahoo", "us"); 
 
INSERT INTO tb_person values (1, "michi", 180, "1978-05-24", 1); 
INSERT INTO tb_person values (2, "matthias", 179, "1976-06-22", 1); 
INSERT INTO tb_person values (3, "dieter", null, "1978-06-13", 1); 
INSERT INTO tb_person values (4, "hannes", null, null, 2); 
INSERT INTO tb_person values (5, "weirdo", 185, null, null); 
 
 
### db.properties ### 
 
jad.url      = jdbc:mysql://localhost/demoObjectModelling 
jad.driver   = com.mysql.jdbc.Driver 
jad.user     = helma 
jad.password = secret 
 
 
### Root/type.properties ### 
 
_children = collection(Organisation) 
_children.accessname = org_name 
 
tallPeople = collection(Person) 
tallPeople.order = person_height desc 
tallPeople.filter = person_height IS NOT NULL 
# tallPeople.maxsize = 5 
 
allPeople = collection(Person) 
 
 
### Root/functions.js ### 
 
function main_action() { 
   // list all Organisation and their Persons 
   for (var i=0; i<root.count(); i++) { 
      var o = root.get(i); 
      res.write("<h3>" + o.name + " (" + o.country + ")</h3>"); 
      for (var j=0; j<o.count(); j++) { 
         var p = o.get(j); 
         res.write("<li>"); 
         res.write(p.name + " " + (j+1) + " of " + p.organisation.count()); 
         res.write(" <a href=" + p.href("info") + ">info</a>"); 
      } 
   } 
   res.write("<br /><a href=" + root.href("tallPeople") + ">tall People</a>"); 
} 
 
 
function tallPeople_action() { 
   // list the tallest people 
   for (var i=0; i<root.tallPeople.count(); i++) { 
      var p = root.tallPeople.get(i); 
      res.write("<li>" + p.name + " " + p.height + " " + 
          p.href("info") + " " + root.get("knallgrau").contains(p)); 
   } 
} 
 
### Organisation/type.properties ### 
 
_db = jad 
_table = tb_organisation 
 
_id = org_id 
_parent = root 
 
_children = collection(Person) 
_children.local = org_id 
_children.foreign = person_org_id 
_children.accessname = person_name 
_children.order = person_name 
 
name = org_name 
country = org_country 
 
 
### Person/type.properties ### 
 
_db = jad 
_table = tb_person 
 
_id = person_id 
_parent = organisation, root.allPeople 
 
name = person_name 
height = person_height 
dateOfBirth = person_dateofbirth 
 
organisation = object(Organisation) 
organisation.local = person_org_id 
organisation.foreign = org_id

demoGrouping.zip

### mysql.sql ### 
 
CREATE DATABASE demoGrouping; 
USE demoGrouping; 
 
GRANT ALL ON demoGrouping.* TO helma@localhost IDENTIFIED BY 'secret'; 
 
CREATE TABLE tb_person ( 
  person_id MEDIUMINT(10) NOT NULL, 
  person_name TINYTEXT, 
  person_height TINYINT unsigned, 
  person_dateofbirth DATETIME, 
  person_org_id MEDIUMINT(10) unsigned 
  PRIMARY KEY (person_id) 
); 
 
 
CREATE TABLE tb_organisation ( 
   org_id MEDIUMINT(10) unsigned NOT NULL, 
   org_name TINYTEXT, 
   org_country TINYTEXT, 
   PRIMARY KEY (org_id) 
); 
 
CREATE INDEX idx_pers_org ON tb_person (person_org_id); 
 
INSERT INTO tb_organisation values (1, "knallgrau", "at"); 
INSERT INTO tb_organisation values (2, "helma", "at"); 
INSERT INTO tb_organisation values (3, "amazon", "us"); 
INSERT INTO tb_organisation values (4, "ebay", "us"); 
INSERT INTO tb_organisation values (5, "yahoo", "us"); 
 
INSERT INTO tb_person values (1, "michi", 180, "1978-05-24", 1); 
INSERT INTO tb_person values (2, "matthias", 179, "1976-06-22", 1); 
INSERT INTO tb_person values (3, "dieter", null, "1978-06-13", 1); 
INSERT INTO tb_person values (4, "hannes", null, null, 2); 
INSERT INTO tb_person values (5, "weirdo", 185, null, null); 
 
 
### db.properties ### 
 
jad.url      = jdbc:mysql://localhost/demoGrouping 
jad.driver   = com.mysql.jdbc.Driver 
jad.user     = helma 
jad.password = secret 
 
 
### Root/type.properties ### 
 
_children = collection(Organisation) 
_children.accessname = org_name 
 
countries = collection(Organisation) 
countries.group = org_country 
countries.group.prototype = Country 
countries.group.order = org_country desc 
 
 
### Root/functions.js ### 
 
function main_action() { 
   // list all Countries and their Organisations 
   for (var i=0; i<root.countries.count(); i++) { 
      var c = root.countries.get(i); 
      res.write("<h3>" + c.getName() + " <a href=" + c.href("info") + ">info</a></h3>"); 
      res.write(""); 
      for (var j=0; j<c.count(); j++) { 
         var o = c.get(j); 
         res.write("<li>"); 
         res.write(o.name + " " + o.count()); 
         res.write(" <a href=" + o.href("info") + ">info</a>"); 
      } 
   } 
} 
 
 
### Organisation/type.properties ### 
 
_db = jad 
_table = tb_organisation 
 
_id = org_id 
_parent = root 
 
_children = collection(Person) 
_children.local = org_id 
_children.foreign = person_org_id 
_children.accessname = person_name 
_children.order = person_name 
 
name = org_name 
country = org_country 
 
 
### Person/type.properties ### 
 
_db = jad 
_table = tb_person 
 
_id = person_id 
_parent = organisation, root.allPeople 
 
name = person_name 
height = person_height 
dateOfBirth = person_dateofbirth 
 
organisation = object(Organisation) 
organisation.local = person_org_id 
organisation.foreign = org_id 
 
 
### Country/functions.js ### 
 
function getName() { 
   if (this.groupname == "at")  
      return "Austria"; 
   else if (this.groupname == "us")  
      return "USA"; 
}

demoMNRelation.zip

### mysql.sql ### 
 
CREATE DATABASE demoMNRelation; 
USE demoMNRelation; 
 
GRANT ALL ON demoMNRelation.* TO helma@localhost IDENTIFIED BY 'secret'; 
 
CREATE TABLE tb_person ( 
  person_id MEDIUMINT(10) NOT NULL, 
  person_name TINYTEXT, 
  PRIMARY KEY (person_id) 
); 
 
CREATE TABLE tb_relationship ( 
   rel_id MEDIUMINT(10) unsigned NOT NULL, 
   rel_person01_id MEDIUMINT(10) unsigned, 
   rel_person02_id MEDIUMINT(10) unsigned, 
   PRIMARY KEY (rel_id) 
); 
 
CREATE INDEX idx_rel_pers01 ON tb_relationship (rel_person01_id); 
CREATE INDEX idx_rel_pers02 ON tb_relationship (rel_person02_id); 
 
INSERT INTO tb_person values (1, "michi"); 
INSERT INTO tb_person values (2, "matthias"); 
INSERT INTO tb_person values (3, "dieter"); 
INSERT INTO tb_person values (4, "hannes"); 
 
INSERT INTO tb_relationship values (1, 1, 2); 
INSERT INTO tb_relationship values (2, 2, 1); 
INSERT INTO tb_relationship values (3, 1, 3); 
INSERT INTO tb_relationship values (4, 1, 4); 
INSERT INTO tb_relationship values (5, 4, 3); 
 
 
### db.properties ### 
 
jad.url      = jdbc:mysql://localhost/demoMNRelation 
jad.driver   = com.mysql.jdbc.Driver 
jad.user     = helma 
jad.password = secret 
 
 
### Root/type.properties ### 
 
allPeople = collection(Person) 
allPeople.accessname = person_name 
 
 
### Root/functions.js ### 
 
function main_action() { 
   // list all People and their friends 
   for (var i=0; i<root.allPeople.count(); i++) { 
      var p = root.allPeople.get(i); 
      res.write("<h3>" + p.name + "</h3>"); 
      res.write(p.relations.count() + " Friend(s)"); 
      for (var j=0; j<p.relations.count(); j++) { 
         var rel = p.relations.get(j); 
         var f = rel.person02; 
         res.write(" " + f.name); 
      } 
      res.write("<br />Friend of " + p.backrelations.count() + " Person(s)"); 
      for (var j=0; j<p.backrelations.count(); j++) { 
         var rel = p.backrelations.get(j); 
         var f = rel.person01; 
         res.write(" " + f.name); 
      } 
   } 
 
   var michi = root.allPeople.get("michi"); 
   var matthias = root.allPeople.get("matthias"); 
   var dieter = root.allPeople.get("dieter"); 
   res.write("<hr><b>Is matthias a friend of michi?</b> "); 
   res.write(michi.isFriendOf(matthias) ? "yes" : "no"); 
   res.write("<hr><b>Is matthias a friend of dieter?</b> "); 
   res.write(dieter.isFriendOf(matthias) ? "yes" : "no"); 
} 
 

 
### Person/type.properties ### 
 
_db = jad 
_table = tb_person 
 
_id = person_id 
_parent = root.allPeople 
 
name = person_name 
 
relations = collection(Relationship) 
relations.local = person_id 
relations.foreign = rel_person01_id 
relations.accessname = rel_person02_id 
 
backrelations = collection(Relationship) 
backrelations.local = person_id 
backrelations.foreign = rel_person02_id 
backrelations.accessname = rel_person01_id 
 
 
### Person/functions.js ### 
 
function isFriendOf(p) { 
   if (!p) return false; 
   // determine whether we have a relation to that person 
   /* 
   // the clumsy way 
   for (var i=0; i<this.relations.count(); i++) { 
      if (this.relations.get(i).person02 == p) return true; 
   } 
   return false; 
   */ 
   // the smart way 
   if (this.relations.get(p._id+"") != null)  
      return true; 
   else 
      return false; 
} 
 
 
### Relationship/type.properties ### 
 
_db = jad 
_table = tb_relationship 
 
_id = rel_id 
_parent = person01.relations 
 
person01 = object(Person) 
person01.local = rel_person01_id 
person01.foreign = person_id 
 
person02 = object(Person) 
person02.local = rel_person02_id 
person02.foreign = person_id

demoMountpoint.zip

### mysql.sql ### 
 
CREATE DATABASE demoMountpoint; 
USE demoMountpoint; 
 
GRANT ALL ON demoMountpoint.* TO helma@localhost IDENTIFIED BY 'secret'; 
 
CREATE TABLE tb_person ( 
  person_id MEDIUMINT(10) NOT NULL, 
  person_name TINYTEXT, 
  PRIMARY KEY (person_id) 
); 
 
INSERT INTO tb_person values (1, "michi"); 
INSERT INTO tb_person values (2, "matthias"); 
INSERT INTO tb_person values (3, "dieter"); 
INSERT INTO tb_person values (4, "hannes"); 
 
 
### db.properties ### 
 
jad.url      = jdbc:mysql://localhost/demoMountpoint 
jad.driver   = com.mysql.jdbc.Driver 
jad.user     = helma 
jad.password = secret 
 
 
### Root/type.properties ### 
 
allPeople = collection(Person) 
 
manage = mountpoint(SysMgr) 
 
 
### Root/functions.js ### 
 
function main_action() { 
   res.writeln("HELLO WORLD!"); 
   res.writeln("<a href=" + root.manage.href("main") + ">SysMgr</a>"); 
   for (var i=0; i<root.allPeople.count(); i++) { 
      var p = root.allPeople.get(i); 
      res.writeln("<a href=" + p.manage.href("main") + ">SysMgr of " + p.name + "</a>"); 
   } 
} 
 
 
### Person/type.properties ### 
 
_db = jad 
_table = tb_person 
 
_id = person_id 
_parent = root.allPeople 
 
name = person_name 
 
manage = mountpoint(SysMgr) 
 
  
### SysMgr/type.properties ### 
 
_children = collection(Person) 
 
 
### SysMgr/functions.js ### 
 
function main_action() { 
   res.writeln("TOP SECRET STUFF"); 
   res.writeln("this: " + this); 
   res.writeln("parent: " + this._parent); 
   res.writeln("children: " + this.count()); 
}