Index: Dev/branches/jos-branch/classes/master.php
===================================================================
--- Dev/branches/jos-branch/classes/master.php	(revision 212)
+++ Dev/branches/jos-branch/classes/master.php	(revision 212)
@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * Description of master
+ * 
+ * For autoloading of classes for example.
+ *
+ * @author fpvanagthoven
+ */
+// Determine our absolute document root
+define('DOC_ROOT', realpath(dirname(__FILE__) . '/../'));
+
+/* Session */
+session_name("cpsft");   // Set a session name
+session_start();  // Start the session
+
+function __autoload($class_name) {
+	if (file_exists('classes/' . $class_name . '.php'))
+		require 'classes/' . $class_name . '.php';
+	else if (file_exists('classes/models/' . $class_name . '.php'))
+		require 'classes/models/' . $class_name . '.php';
+}
+
+
+// Redirects user to $url
+function redirect($url = null)
+{
+	if (is_null($url))
+		$url = $_SERVER['PHP_SELF'];
+
+	header("Location: $url");
+	exit();
+}
+
+
+?>
Index: Dev/branches/jos-branch/classes/models/Application.php
===================================================================
--- Dev/branches/jos-branch/classes/models/Application.php	(revision 212)
+++ Dev/branches/jos-branch/classes/models/Application.php	(revision 212)
@@ -0,0 +1,117 @@
+<?php
+// Survey database interface class as intermediate for storing data from the site to the RDF database 
+require_once 'rdfConstants.php';
+// Include RAP Library to write RDF files
+include(RDFAPI_INCLUDE_DIR . "RDFAPI.php");
+/**
+ * Description of Application
+ *
+ * @author jkraaijeveld
+ */
+class Application extends ResearchToolObject{
+    
+	public static $filename = 'data/applications/applications.rdf';
+
+    public $title;
+    public $description;
+    public $style;
+
+	/**
+	 * Constructor for an Application object
+	 * @param type $uid : The uid of the Application object.
+	 * @param type $title: The title of the Application.
+	 * @param type $description: The description of the Application.
+	 * @param type $style: The style of the Application.
+	 */
+    public function __construct($uid = null, $title = null, $description = null, $style = null) 
+    {
+        if(!isset ($uid))
+        {
+            $uid = md5(uniqid(rand(), true));
+        }
+        $this->uid = $uid;
+        $this->title = $title;
+        $this->description = $description;
+		$this->style = $style;
+	}
+	
+	/**
+	 * function save()
+	 * Saves the current object into the database.
+	 */
+	public function save()
+	{
+		//Ensure the required folder exists.
+		if(!is_dir('data/applications/'))
+			mkdir('data/applications/');
+
+		$model = ResearchToolObject::load(Application::$filename);
+        $resourceApplication = new Resource(APPLICATION.'/'.$this->uid);
+        //Remove the old value stored with the given id
+        $model->subtract($model->find($resourceApplication, null, null));
+
+        //Add the new statements to the model
+        $resourceApplicationType = new Resource(APPLICATION);
+        $predicateRType = new Resource(RTYPE);
+        $model->add(new Statement($resourceApplication,$predicateRType,$resourceApplicationType));
+		
+        $literalApplicationID = new Literal($this->uid);
+        $predicateUniqueID = new Resource(UID);
+        $model->add(new Statement($resourceApplication,$predicateUniqueID,$literalApplicationID));
+
+        $applicationTitle = new Literal($this->title);
+        $predicateTitle = new Resource(TITLE);	
+        $model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle));
+
+        $applicationDescription = new Literal($this->description);
+        $predicateDescription = new Resource(DESCRIPTION);
+        $model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription));
+
+        $applicationStyle = new Literal($this->style);
+        $predicateStyle = new Resource(STYLE);
+        $model->add(new Statement($resourceApplication,$predicateStyle,$applicationStyle));
+		
+		$model->saveAs(Application::$filename, 'rdf');
+		return true;
+	}
+
+	/**
+	 * static function get($arguments)
+	 * Gets the array of Application objects belonging to arguments supplied.
+	 * @param type $arguments : An array containing zero or more of the following keys:
+	 * 							'uid', 'title', 'description', 'style'
+	 */
+	public static function get($arguments)
+	{
+		$model = ResearchToolObject::load(Application::$filename);
+		 //Create the querystring 
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT ?uid, ?title, ?description, ?style
+            WHERE 	
+            {
+                    _application	predicates:resource_type	resources:application ;
+					predicates:uid ?uid ;
+					predicates:title ?title ;
+					predicates:description ?description ;
+					predicates:style ?style ; '
+                    . ResearchToolObject::createArguments($arguments) . ' 
+            }';
+
+        //Query the model
+        $results = $model->sparqlQuery($querystring);
+        $applications = array();
+        if(!empty($results))
+        {
+            //Run over all results and create appropriate Application objets
+            foreach($results as $result)
+            { 
+                    $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label);
+            }
+        }
+        return $applications;
+	}
+}
+
+?>
Index: Dev/branches/jos-branch/classes/models/ResearchToolObject.php
===================================================================
--- Dev/branches/jos-branch/classes/models/ResearchToolObject.php	(revision 212)
+++ Dev/branches/jos-branch/classes/models/ResearchToolObject.php	(revision 212)
@@ -0,0 +1,73 @@
+<?php
+/**
+ * Description of ResearchToolObject
+ *
+ * @author jkraaijeveld
+ */
+abstract class ResearchToolObject {
+
+	public $uid;
+
+	public function evaluate()
+	{
+		return true;
+	}
+	
+	public static function load($filename)
+	{
+		$model = ModelFactory::getDefaultModel();
+		if(file_exists($filename))
+			$model->load($filename);
+		return $model;
+	}
+
+	/**
+	 * function createArguments()
+	 * @param type $arguments
+	 * Creates the arguments to be used in the query based on the
+	 * arguments specified in the incoming array.
+	 */
+	public static function createArguments($arguments)
+	{
+		$argumentString = "";
+		foreach(array_keys($arguments) as $key)
+		{
+			$addition = "";
+			switch($key)
+			{
+				case "uid" : $addition = "predicates:uid '" . $arguments[$key] . "'\n"; break;
+				case "question" : $addition = "predicates:question_code '" . $arguments[$key] . "'\n"; break;
+				case "values": foreach($arguments[$key] as $value) { $addition = $addition . "predicates:answered '" . $value . "'\n"; } break;
+				case "survey" : $addition = "predicates:for_survey '" . $arguments[$key] . "'\n"; break;
+				case "respondent" : $addition = "predicates:by_respondent '" . $arguments[$key] . "'\n"; break;
+				case "answers" : foreach($arguments[$key] as $answer) { $addition = $addition . "predicates:given_answer '" . $answer . "'\n"; } break;
+				case "title" : $addition = "predicates:title '" . $arguments[$key] . "'\n"; break;
+				case "description" : $addition = "predicates:description '" . $arguments[$key] . "'\n"; break;
+				case "style" : $addition = "predicates:style '" . $arguments[$key] . "'\n"; break;
+				case "code" : $addition = "predicates:question_code '" . $arguments[$key] . "'\n";break;
+				case "type" : $addition = "predicates:question_type '" . $arguments[$key] . "'\n"; break;	
+				case "category" : $addition = "predicates:question_category '" . $arguments[$key] . "'\n";
+				case "definedanswers" : foreach($arguments[$key] as $answer) { $addition = $addition . "predicates:has_answer '" . $answer . "'\n"; } break;
+				case "name" : $addition = "predicates:name '" . $arguments[$key] . "'\n"; break;
+				case "password" : $addition = "predicates:password '" . $arguments[$key] . "'\n"; break;
+				case "creator" : $addition = "predicates:creator '" . $arguments[$key] . "'\n"; break;
+				case "creationdate" : $addition = "predicates:creationdate '" . $arguments[$key] . "'\n"; break;
+				case "applications" : foreach($arguments[$key] as $application) { $addition = $addition . "predicates:has_application '" . $application . "'\n"; } break;
+				case "surveys" : foreach($arguments[$key] as $survey) { $addition = $addition . "predicates:has_survey '" . $survey . "'\n"; } break;
+				case "answersets" : foreach($arguments[$key] as $answerset) { $addition = $addition . "predicates:has_answerset '" . $answerset . "'\n"; } break;
+				case "questions" : foreach($arguments[$key] as $question) { $addition = $addition . "predicates:has_question '" . $question . "'\n"; } break;
+				case "location" : $addition = "predicates:location '" . $arguments[$key] . "\n"; break;
+				case "facilitator" : $addition = "predicates:facilitator '" . $arguments[$key] . "\n"; break;
+				case "starttime" : $addition = "predicates:starttime '" . $arguments[$key] . "\n"; break;
+				case "endtime" : $addition = "predicates:endtime '" . $arguments[$key] . "\n"; break;
+				case "session" : $addition = "predicates:of_session '" . $arguments[$key] . "\n"; break;
+				case "resultset" : $addition = "predciates:has_resultset '" . $arguments[$key] . "\n"; break;
+			}
+			$argumentString = $argumentString . $addition;
+		}
+		return $argumentString;
+	}
+
+}
+
+?>
Index: Dev/branches/jos-branch/classes/models/Respondent.php
===================================================================
--- Dev/branches/jos-branch/classes/models/Respondent.php	(revision 212)
+++ Dev/branches/jos-branch/classes/models/Respondent.php	(revision 212)
@@ -0,0 +1,114 @@
+<?php
+// Survey database interface class as intermediate for storing data from the site to the RDF database 
+require_once 'rdfConstants.php';
+// Include RAP Library to write RDF files
+include(RDFAPI_INCLUDE_DIR . "RDFAPI.php");
+
+/**
+ * Description of Respondent
+ *
+ * @author jkraaijeveld
+ */
+
+class Respondent extends ResearchToolObject {
+	//Static Database-related information.
+	private static $filename = 'data/users/respondents.rdf';
+
+	public $name;
+	public $password;
+
+	/**
+	 * Constructor for a Respondent object
+	 * @param type $uid
+	 * @param type $name
+	 * @param type password
+	 */
+	public function __construct($uid = null, $name = null, $password = null)
+	{
+      	if(!isset($uid))
+      	{
+            $uid = md5(uniqid(rand(), true));
+      	}
+      
+      	$this->uid = $uid;
+     	$this->name = $name;
+      	$this->password = $password;
+	}
+    /**
+	 * function save()
+	 * Saves the current object into the database
+     */
+    public function save()
+    {
+		//Ensure the required folder exists.
+		if(!is_dir('data/users/'))
+			mkdir('data/users/');
+
+		$model = ResearchToolObject::load(Respondent::$filename);
+
+        $resourceRespondent = new Resource(RESPONDENT . '/' . $this->uid);
+        //Remove the old value stored with the given id
+        $model->subtract($model->find($resourceRespondent, null, null));
+
+		//Set the new values
+        $resourceRespondentType = new Resource(RESPONDENT);
+        $predicateRType = new Resource(RTYPE);
+        $model->add(new Statement($resourceRespondent,$predicateRType,$resourceRespondentType));
+
+        $literalRespondentID = new Literal($this->uid);
+        $predicateUniqueID = new Resource(UID);
+        $model->add(new Statement($resourceRespondent,$predicateUniqueID,$literalRespondentID));
+        
+        $literalRespondentName = new Literal($this->name);
+        $predicateName = new Resource(NAME);
+        $model->add(new Statement($resourceRespondent,$predicateName,$literalRespondentName));			
+
+        $literalPassword = new Literal($this->password);
+        $predicatePassword = new Resource(PASSWORD);
+        $model->add(new Statement($resourceRespondent,$predicatePassword,$literalPassword));
+		$model->saveAs(Respondent::$filename, 'rdf');
+		return true;
+    }
+
+
+	/**
+	 * static function get($arguments)
+	 * Gets the array of Respondent objects belonging to arguments supplied.
+	 * @param type $arguments : An array containing zero or more of the following keys:
+	 							'uid', 'name', 'password'
+	 */
+    public static function get($arguments) {
+		$model = ResearchToolObject::load(Respondent::$filename);
+       
+        //Create the querystring 
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT ?uid, ?name, ?password
+            WHERE 	
+            {
+                    _respondent	predicates:resource_type	resources:respondent ;
+					predicates:uid ?uid ;
+					predicates:name ?name ;
+					predicates:password ?password ;
+					' . ResearchToolObject::createArguments($arguments) .  '
+            }';
+        //Query the model
+        $results = $model->sparqlQuery($querystring);
+		$respondents = array();
+        if(!empty($results))
+        {
+            //Run over all results and create appropriate Respondent objets
+            foreach($results as $result)
+            { 
+                    $respondents[] = new Respondent($result['?uid']->label, $result['?name']->label, $result['?password']->label);
+            }
+        }
+        return $respondents;
+	}
+}
+
+	
+
+
+
Index: Dev/branches/jos-branch/classes/models/User.php
===================================================================
--- Dev/branches/jos-branch/classes/models/User.php	(revision 212)
+++ Dev/branches/jos-branch/classes/models/User.php	(revision 212)
@@ -0,0 +1,110 @@
+<?php
+// Survey database interface class as intermediate for storing data from the site to the RDF database 
+require_once 'rdfConstants.php';
+// Include RAP Library to write RDF files
+include(RDFAPI_INCLUDE_DIR . "RDFAPI.php");
+
+/**
+ * Description of User
+ *
+ * @author jkraaijeveld
+ */
+
+class User extends ResearchToolObject {
+
+	//Static Database-related information.
+	private static $filename = 'data/users/users.rdf';
+    
+    public $name;
+    public $password;
+    
+    /**
+     * Constructor of User
+     * If the user does not yet exist in the database, call with null as first parameter
+     */
+    public function __construct($uid = null, $name = null, $password = null) {
+        if(!isset($uid))
+        {
+             $uid = md5(uniqid(rand(), true));
+        }
+        $this->uid = $uid;
+        $this->name = $name;
+        $this->password = $password;
+	}
+
+	/**
+	 * function save()
+	 * Saves the current object into the database.
+	 */
+	public function save()
+	{
+		//Ensure the required folder exists.
+		if(!is_dir('data/users/'))
+			mkdir('data/users/');
+
+		$model = ResearchToolObject::load(User::$filename);
+        $resourceUser = new Resource(USER . '/' . $this->uid);
+        //Remove the old value stored with the given id
+        $model->subtract($model->find($resourceUser, null, null));
+
+        $resourceUserType = new Resource(USER);
+        $predicateRType = new Resource(RTYPE);
+        $model->add(new Statement($resourceUser,$predicateRType,$resourceUserType));
+
+        $literalUserID = new Literal($this->uid);
+        $predicateUniqueID = new Resource(UID);
+        $model->add(new Statement($resourceUser,$predicateUniqueID,$literalUserID));
+        
+        $literalUserName = new Literal($this->name);
+        $predicateName = new Resource(NAME);
+        $model->add(new Statement($resourceUser,$predicateName,$literalUserName));			
+
+        $literalPassword = new Literal($this->password);
+        $predicatePassword = new Resource(PASSWORD);
+		$model->add(new Statement($resourceUser,$predicatePassword,$literalPassword));
+
+		$model->saveAs(User::$filename, 'rdf');
+		return true;
+	}
+
+
+	/**
+	 * static function get($arguments)
+	 * Gets the array of User objects belonging to arguments supplied.
+	 * @param type $arguments : An array containing zero or more of the following keys:
+	 * 							'uid', 'name', 'password'
+	 */
+	public static function get($arguments)
+	{
+	    $model = ResearchToolObject::load(User::$filename);
+        //Create the querystring 
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT ?uid, ?name, ?password
+            WHERE 	
+            {
+                    _user	predicates:resource_type	resources:user ;
+					predicates:uid ?uid ;
+					predicates:name ?name ;
+					predicates:password ?password ;
+					' . ResearchToolObject::createArguments($arguments) . '
+            }';
+        //Query the model
+		$results = $model->sparqlQuery($querystring);
+        $users = array();
+        if(!empty($results))
+        {
+            //Run over all results and create appropriate User objects
+            foreach($results as $result)
+            { 
+                    $users[] = new User($result['?uid']->label, $result['?name']->label, $result['?password']->label);
+            }
+        }
+        return $users;
+	}
+	
+	
+}
+
+?>
Index: Dev/branches/jos-branch/testpage.php
===================================================================
--- Dev/branches/jos-branch/testpage.php	(revision 211)
+++ Dev/branches/jos-branch/testpage.php	(revision 212)
@@ -1,12 +1,6 @@
 <?php
     require 'classes/master.php';
-
-	$db = new DatabaseInterface();
 	
-	$result = $db->get("Session");
-	$session = $result[0];
-	$session->title = "Changed title";
-	$db->set($session);
+	$result = Application::get(array());
 	print_r($result);
-
 ?>
