Index: Dev/branches/jos-branch/classes_old/Answer.php
===================================================================
--- Dev/branches/jos-branch/classes_old/Answer.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/Answer.php	(revision 210)
@@ -0,0 +1,47 @@
+<?php
+
+/**
+ * Description of Answer
+ *
+ * @author jkraaijeveld
+ */
+class Answer extends ResearchToolObject {
+    public $question;
+	public $values;
+    
+    /**
+     * Constructor for an Answer object
+     * @param type $uid : The uid of the Answer object.
+     * @param type $question : The Question object this Answer answers.
+     * @param type $values : An array of strings, containing the answers.
+     */
+    public function __construct($uid = null, $question = null, $values = null) {
+      if(!isset($uid))
+      {
+            $uid = md5(uniqid(rand(), true));
+      }
+      $this->uid = $uid;
+      $this->question = $question;
+      $this->values = $values;
+	}
+	
+	/**
+	 * function evaluate()
+	 * Evaluates the references and fills in the objects for them instead.
+	 */
+	public function evaluate()
+	{
+		if(is_string($this->question))
+		{
+			$dbi = new DatabaseInterface();
+			$result = $dbi->get("question", array("code" => $this->question));
+			if(!isset($result[0]))
+				return false;
+			$this->question = $result[0];
+		}
+		return true;
+
+	}
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/AnswerConnector.php
===================================================================
--- Dev/branches/jos-branch/classes_old/AnswerConnector.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/AnswerConnector.php	(revision 210)
@@ -0,0 +1,120 @@
+<?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 AnswerConnector
+ *
+ * @author jkraaijeveld
+ */
+class AnswerConnector extends Connector{
+    
+    /**
+     * Constructor for AnswerConnector
+     */
+    public function __construct() {
+        //Ensure the required folder for this connector exists
+        if (!is_dir('data/answers/'))
+			mkdir('data/answers/');
+		$this->fileName = 'data/answers/answers.rdf';
+    }
+    
+	/**
+	 * function get()
+	 * @param type $arguments: An array having one or more of the following elements:
+	 * 'uid', 'question', 'values'.
+	 */
+    public function get($arguments)
+	{
+		$this->load();
+		//Create the querystring
+		$querystring = '
+			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+			SELECT DISTINCT ?uid, ?question_code
+			WHERE
+			{
+				_answer predicates:resource_type resources:answer;
+
+				predicates:uid ?uid ;
+				predicates:question_code ?question_code ;
+				' . $this->createArguments($arguments) . '
+			}';
+
+		//Query the model
+		$results = $this->model->sparqlQuery($querystring);	
+		//An answer can have multiple values, get all these values for the answer instances found.
+		$answers = array();
+		if(!empty($results))
+		{
+			foreach($results as $result)
+			{
+				$answers[] = new Answer($result['?uid']->label, $result['?question_code']->label, $this->getValues($result['?uid']->label));
+			}
+		}
+		return $answers;
+	}
+
+	/**
+	 * function getValues()
+	 * @param type $uid : The uid of the Answer for which the values should be gotten.
+	 */
+	private function getValues($uid)
+	{
+		$result = $this->model->findRegex("[(".$uid.")]", "[(answered)]", null);
+		$iterator = $result->getStatementIterator();
+		$values = array();
+		while($iterator->hasNext())
+		{
+			$element = $iterator->next();
+			$values[] = $element->getLabelObject();
+		}
+		return $values;
+	} 
+
+    /**
+	 * function set()
+     * @param type $rToolObject : The ResearchToolObject to be saved.
+     */
+    public function set($rToolObject)
+    {
+		$this->load();
+		//If evaluation fails, some references are incorrect.
+		//We shouldn't save in this case. Instead - let the user know. This function returns false if the evaluation has failed.
+		//TODO: Decide how to fix invalid references graciously.
+		if(!$rToolObject->evaluate()) 
+			return false;
+        $resourceAnswer = new Resource(ANSWER.'/'.$rToolObject->uid);        
+        //Remove the old value stored with the given id
+        $this->model->subtract($this->model->find($resourceAnswer, null, null));
+        
+        //Save all the new values
+        $resourceAnswerType = new Resource(ANSWER);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceAnswer,$predicateRType,$resourceAnswerType));
+        
+		$answerId = new Literal($rToolObject->uid);
+		$predicateId = new Resource(UID);
+		$this->model->add(new Statement($resourceAnswer, $predicateId, $answerId));
+
+		$questionId = new Literal($rToolObject->question->uid);
+		$predicateQId = new Resource(QCODE);
+		$this->model->add(new Statement($resourceAnswer, $predicateQId, $questionId));
+
+		if(isset($rToolObject->values))
+		{
+			foreach($rToolObject->values as $value)
+			{
+				$answerValue = new Literal($value);
+				$predicateAnswer = new Resource(ANSWERED);
+				$this->model->add(new Statement($resourceAnswer, $predicateAnswer, $answerValue));
+			}
+		}
+		$this->save();
+		return true;
+    }
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/AnswerSet.php
===================================================================
--- Dev/branches/jos-branch/classes_old/AnswerSet.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/AnswerSet.php	(revision 210)
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * AnswerSet is a collection of answers corresponding to a Session
+ *
+ */
+class AnswerSet extends ResearchToolObject{
+	public $survey;
+	public $respondent;
+	public $answers;
+
+	/**
+	 * Constructor for an AnswerSet object
+	 * @param type $uid
+	 * @param type $survey
+	 * @param type $respondent
+	 * @param type $answers
+	 */
+	public function __construct($uid=null, $survey=null, $respondent=null, $answers=null)
+	{
+		if(!isset($uid))
+		{
+			$uid = md5(uniqid(rand(), true));
+		}
+		$this->uid = $uid;
+		$this->survey = $survey;
+		$this->respondent = $respondent;
+		$this->answers = $answers;
+	}
+
+	/**
+	 * function evaluate()
+	 * evaluates the references of survey, respondent and answers.
+	 */
+	public function evaluate()
+	{
+		$dbi = new DatabaseInterface();
+		if(is_string($this->survey))
+		{
+			$result = $dbi->get("survey", array("uid" => $this->survey));
+			if(!isset($result[0]))
+				return false;
+			$this->survey = $result[0];
+		}
+		if(is_string($this->respondent))
+		{
+			$result = $dbi->get("respondent", array("uid" => $this->respondent));
+			if(!isset($result[0]))
+				return false;
+			$this->respondent = $result[0];
+		}
+		if(!empty($this->answers) && is_string($this->answers[0]))
+		{
+			$newanswers = array();
+			foreach($this->answers as $answer)
+			{
+				$result = $dbi->get("answer", array("uid" => $answer));
+				if(!isset($result[0]))
+					return false;
+				$newanswers[] = $result[0];
+			}
+			$this->answers = $newanswers;
+		}
+		return true;
+	}
+}
+
Index: Dev/branches/jos-branch/classes_old/AnswerSetConnector.php
===================================================================
--- Dev/branches/jos-branch/classes_old/AnswerSetConnector.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/AnswerSetConnector.php	(revision 210)
@@ -0,0 +1,124 @@
+<?php
+
+/**
+ * Description of AnswerSetConnector
+ *
+ * @author jkraaijeveld
+ */
+class AnswerSetConnector extends Connector{
+    protected $db;
+
+	/**
+	 * Constructor for the AnswerSetConnector
+	 */
+	public function __construct()
+	{
+		$this->fileName = 'data/answers/answersets.rdf';
+		//Ensure the required folder for this connector exists
+		if(!is_dir('data/answers'))
+			mkdir('data/answers');
+	}
+
+	/**
+	 * function get()
+	 * @param type $arguments : An array having one ore more of the following elements:
+	 * 'uid', 'survey', 'respondent', 'answers'.
+	 */
+	public function get($arguments)
+	{
+		$this->load();
+
+		//Build the query string
+		$querystring = '
+			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+			SELECT DISTINCT ?uid, ?for_survey, ?by_respondent
+			WHERE
+			{
+				_answerset	predicates:resource_type	resources:answerset ;
+				predicates:uid ?uid ;
+				predicates:for_survey ?for_survey ;
+				predicates:by_respondent ?by_respondent ;
+				' . $this->createArguments($arguments) . '
+			}';
+		//Query the model
+		$results = $this->model->sparqlQuery($querystring);
+		$answerSets = array();
+		if(!empty($results))
+		{
+			$this->db = new DatabaseInterface();
+			foreach($results as $result)
+			{
+				$survey = $result['?for_survey']->label;
+				$respondent = $result['?by_respondent']->label;
+				$answers = 	$this->getAnswers($result['?uid']->label);
+				$answerSets[] = new AnswerSet($result['?uid']->label, $survey[0], $respondent[0], $answers);
+			}
+		}
+		return $answerSets;
+	}
+
+	/**
+	 * function getAnswers()
+	 * @param type $uid : the uid for which the answers should be retrieved.
+	 */
+	private function getAnswers($uid)
+	{
+		$result = $this->model->findRegex("[(".$uid.")]", "[(given_answer)]", null);
+		$iterator = $result->getStatementIterator();
+		$answers = array();
+		while($iterator->hasNext())
+		{
+			$element = $iterator->next();
+			$answers[] = $element->getLabelObject();
+		}
+		return $answers;
+	}
+
+	/**
+	 * function set()
+	 * @param type $rToolObject : The ResearchToolObject to be saved.
+	 */
+	public function set($rToolObject)
+	{
+		$this->load();
+		//If evaluation fails, some references are incorrect.
+		//We shouldn't save in this case. Instead - let the user know. This function returns false if the evaluation has failed.
+		//TODO: Decide how to fix invalid references graciously.
+		if(!$rToolObject->evaluate()) 
+			return false;
+
+		$resourceAnswerSet = new Resource(ANSWERSET . '/' . $rToolObject->uid);
+		//Remove the old value stored with the given id
+		$this->model->subtract($this->model->find($resourceAnswerSet, null, null));
+
+		//Set the new values
+		$resourceAnswerSetType = new Resource(ANSWERSET);
+		$predicateRType = new Resource(RTYPE);
+		$this->model->add(new Statement($resourceAnswerSet, $predicateRType, $resourceAnswerSetType));
+
+		$answerSetId = new Literal($rToolObject->uid);
+		$predicateId = new Resource(UID);
+		$this->model->add(new Statement($resourceAnswerSet, $predicateId, $answerSetId));
+
+		$surveyId = new Literal($rToolObject->survey->uid);
+		$predicateSurvey = new Resource(FOR_SURVEY);
+		$this->model->add(new Statement($resourceAnswerSet, $predicateSurvey, $surveyId));
+
+		$respondentId = new Literal($rToolObject->respondent->uid);
+		$predicateRespondent = new Resource(BY_RESPONDENT);
+		$this->model->add(new Statement($resourceAnswerSet, $predicateRespondent, $respondentId));
+		
+		if(isset($rToolObject->answers))
+		{
+			foreach($rToolObject->answers as $answer)
+			{
+				$answerId = new Literal($answer->uid);
+				$predicateAnswer = new Resource(GIVEN_ANSWER);
+				$this->model->add(new Statement($resourceAnswerSet, $predicateAnswer, $answerId));
+			}
+		}
+		$this->save();
+		return true;
+	}
+}
Index: Dev/branches/jos-branch/classes_old/Application.php
===================================================================
--- Dev/branches/jos-branch/classes_old/Application.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/Application.php	(revision 210)
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * Description of Application
+ *
+ * @author jkraaijeveld
+ */
+class Application extends ResearchToolObject{
+    
+    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;
+	}
+	
+	public function evaluate()
+	{
+		//Do nothing, there are no references in application.
+		return true;
+	}
+}
+?>
Index: Dev/branches/jos-branch/classes_old/ApplicationConnector.php
===================================================================
--- Dev/branches/jos-branch/classes_old/ApplicationConnector.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/ApplicationConnector.php	(revision 210)
@@ -0,0 +1,101 @@
+<?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 ApplicationConnector
+ *
+ * @author jkraaijeveld
+ */
+class ApplicationConnector extends Connector{
+    
+    /**
+     * Constructor for ApplicationConnector.
+     */
+    public function __construct()
+    {
+		$this->fileName = 'data/applications/applications.rdf';
+        //Ensure the required folder for this connector exists
+        if (!is_dir('data/applications/'))
+            mkdir('data/applications/');	
+    }
+    
+    /**
+     * function get($arguments)
+     * @param type $arguments : An array containing zero or more of the following keys:
+     * 'uid', 'title', 'description', 'style'
+     */
+    public function get($arguments) {
+        $this->load();
+
+        //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 ; '
+                    . $this->createArguments($arguments) . ' 
+            }';
+
+        //Query the model
+        $results = $this->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;
+    }
+    
+    /**
+     * function set()
+     * Finds the required databaseentry matching the given object and removes
+     * it from the rdf file. Then adds the new RDF entry matching the object.
+     * @param type $rToolObject: The ResearchToolObject to be saved. 
+     */
+    public function set($rToolObject)
+    {
+        $this->load();
+        $resourceApplication = new Resource(APPLICATION.'/'.$rToolObject->uid);
+        //Remove the old value stored with the given id
+        $this->model->subtract($this->model->find($resourceApplication, null, null));
+
+        //Add the new statements to the model
+        $resourceApplicationType = new Resource(APPLICATION);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceApplication,$predicateRType,$resourceApplicationType));
+		
+        $literalApplicationID = new Literal($rToolObject->uid);
+        $predicateUniqueID = new Resource(UID);
+        $this->model->add(new Statement($resourceApplication,$predicateUniqueID,$literalApplicationID));
+
+        $applicationTitle = new Literal($rToolObject->title);
+        $predicateTitle = new Resource(TITLE);	
+        $this->model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle));
+
+        $applicationDescription = new Literal($rToolObject->description);
+        $predicateDescription = new Resource(DESCRIPTION);
+        $this->model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription));
+
+        $applicationStyle = new Literal($rToolObject->style);
+        $predicateStyle = new Resource(STYLE);
+        $this->model->add(new Statement($resourceApplication,$predicateStyle,$applicationStyle));
+		
+		$this->save();
+    }
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/Connector.php
===================================================================
--- Dev/branches/jos-branch/classes_old/Connector.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/Connector.php	(revision 210)
@@ -0,0 +1,89 @@
+<?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");
+
+/**
+ * Connector
+ *
+ * @author jkraaijeveld
+ */
+
+abstract class Connector implements IConnector
+{
+	protected $model;
+	protected $fileName;
+
+	/**
+	 * function load()
+	 * Loads the file into the standard MemModel
+	 */
+	public function load()
+	{
+		$this->model = ModelFactory::getDefaultModel();
+		if(file_exists($this->fileName))
+			$this->model->load($this->fileName);
+	}
+
+	/**
+	 * function save()
+	 * Saves the MemModel into the given file.
+	 */
+	public function save()
+	{
+		$this->model->saveAs($this->fileName, 'rdf');
+	}
+
+	/**
+	 * function createArguments()
+	 * @param type $arguments
+	 * Creates the arguments to be used in the query based on the
+	 * arguments specified in the incoming array.
+	 */
+	public 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_old/DatabaseInterface.php
===================================================================
--- Dev/branches/jos-branch/classes_old/DatabaseInterface.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/DatabaseInterface.php	(revision 210)
@@ -0,0 +1,141 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of DatabaseInterface
+ * Initializes all the connectors, serves as only entrance and exit point
+ * for the frontend
+ * @author jkraaijeveld
+ */
+class DatabaseInterface {
+    
+    /**
+     * Constructor for the DatabaseInterface class
+     */
+    private $applicationConnector;
+    private $questionConnector;
+    private $userConnector;
+    private $surveyConnector;
+    private $respondentConnector;
+	private $answerConnector;
+	private $answerSetConnector;
+	private $sessionConnector;
+	private $sessionInstanceConnector;
+    
+    /**
+     * Constructor for DatabaseInterface.
+     * Initializes all the connectors.
+     */
+    public function __construct() {
+        $this->applicationConnector = new ApplicationConnector();
+        $this->questionConnector = new QuestionConnector();
+        $this->userConnector = new UserConnector();
+        $this->surveyConnector = new SurveyConnector();
+        $this->respondentConnector = new RespondentConnector();
+		$this->answerConnector = new AnswerConnector();
+		$this->answerSetConnector = new AnswerSetConnector();
+		$this->sessionConnector = new SessionConnector();
+		$this->sessionInstanceConnector = new SessionInstanceConnector();
+    }
+    
+    /**
+     * Get the data corresponding to the given type and arguments
+     * @param type $type
+     * @param type $arguments
+     * @return type 
+     */
+    public function get($type, $arguments = array())
+    {
+        switch(strtolower($type))
+        {
+            case "application":
+                return $this->applicationConnector->get($arguments);
+                break;
+            case "question":
+                return $this->questionConnector->get($arguments);
+                break;
+            case "user":
+                return $this->userConnector->get($arguments);
+                break;
+            case "survey":
+                return $this->surveyConnector->get($arguments);
+                break;
+            case "respondent":
+                return $this->respondentConnector->get($arguments);
+                break;
+            case "answer":
+                return $this->answerConnector->get($arguments);
+				break;
+			case "answerset":
+				return $this->answerSetConnector->get($arguments);
+				break;
+			case "session":
+				return $this->sessionConnector->get($arguments);
+				break;
+			case "sessioninstance":
+				return $this->sessionInstanceConnector->get($arguments);
+				break;
+        }
+    }
+	
+    /**
+     * Saves the given object based on its class.
+     * @param type $rToolObject 
+     */
+    public function set($rToolObject)
+    {
+        switch(get_class($rToolObject))
+        {
+            case "Application":
+                return $this->applicationConnector->set($rToolObject);
+                break;
+            case "Question":
+                return $this->questionConnector->set($rToolObject);
+                break;
+            case "User":
+                return $this->userConnector->set($rToolObject);
+                break;
+            case "Survey":
+				return $this->surveyConnector->set($rToolObject);
+				break;
+            case "Respondent":
+				return $this->respondentConnector->set($rToolObject);
+				break;
+            case "Answer":
+				return $this->answerConnector->set($rToolObject);
+				break;
+			case "AnswerSet":
+				return $this->answerSetConnector->set($rToolObject);
+				break;
+			case "Session":
+				return $this->sessionConnector->set($rToolObject);
+				break;
+			case "SessionInstance":
+				return $this->sessionInstanceConnector->set($rToolObject);
+				break;
+        }
+    }
+    
+    /**
+     * Saves all the objects in the given array, assuming they are 
+     * valid ResearchToolObjects.
+     * @param type $rToolObjects 
+     */
+    public function batchSet($rToolObjects)
+    {
+        foreach ($rToolObjects as $rToolObject)
+        {
+			if(!$this->set($rToolObject))
+				return false;
+		}
+		return true;
+    }
+
+	
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/IConnector.php
===================================================================
--- Dev/branches/jos-branch/classes_old/IConnector.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/IConnector.php	(revision 210)
@@ -0,0 +1,21 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of Connector
+ *
+ * @author jkraaijeveld
+ */
+interface IConnector {
+    //This class will outline everything a Connector needs to operate within the system
+    public function get($arguments);
+    public function set($rToolObject);
+    public function load();
+    public function save();
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/Logo.php
===================================================================
--- Dev/branches/jos-branch/classes_old/Logo.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/Logo.php	(revision 210)
@@ -0,0 +1,28 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of Logo
+ *
+ * @author tschipper
+ */
+class Logo {
+    
+    // hardcoded logo div, image is defined in stylesheet. (#logo background:"";)
+    public function __construct() {
+        echo '<div id="logo"><a href="index.php">Research Tool</a>';
+        if (isset($_SESSION['username'])) {
+            echo '<a href="index.php" onClick="savePipeline(true);" style="display:block; font-size: 12px;">Log out</a>';
+        }
+        echo '</div>';
+    
+    }
+    
+    
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/PipelineInfoPanel.php
===================================================================
--- Dev/branches/jos-branch/classes_old/PipelineInfoPanel.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/PipelineInfoPanel.php	(revision 210)
@@ -0,0 +1,32 @@
+<?php
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Info panel, to the side of the Toolbox, showing various stats and links for the current pipeline.
+ *
+ * @author Thijs Schipper
+ */
+class PipelineInfoPanel {
+
+    private $linkedSequencer;
+
+    public function __construct() {
+        ?>
+        <div>
+            <div id="infoPanel" class="largeFrame">
+                <div class="largeTitle">
+                    Info
+                </div>
+                <div id="infoPanelContent" class="content">
+                    
+                </div>
+            </fieldset>
+        </div>
+        <?php
+    }
+
+}
+?>
Index: Dev/branches/jos-branch/classes_old/Question.php
===================================================================
--- Dev/branches/jos-branch/classes_old/Question.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/Question.php	(revision 210)
@@ -0,0 +1,45 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of Question
+ *
+ * @author fpvanagthoven
+ */
+class Question extends ResearchToolObject{    
+    public $title;
+    public $type;
+    public $description;
+    public $category;
+    public $answers; // format answers['#']
+    
+    /**
+     * Constructor for a Question. $uid equals the corresponding code.
+     * @param type $uid
+     * @param type $title
+     * @param type $type
+     * @param type $description
+     * @param type $category
+     * @param type $answers 
+     */
+    public function __construct($uid, $title = null, $type = null, $description = null, $category = null, $answers = null)
+    {
+		if(!isset($uid))
+		{
+			$uid = md5(uniqid(rand(), true));
+		}
+        $this->uid = $uid;
+        $this->title = $title;
+        $this->type = $type;
+        $this->description = $description;
+        $this->category =  $category;
+        $this->answers = $answers;
+	}
+
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/QuestionConnector.php
===================================================================
--- Dev/branches/jos-branch/classes_old/QuestionConnector.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/QuestionConnector.php	(revision 210)
@@ -0,0 +1,137 @@
+<?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 QuestionConnector
+ *
+ * @author jkraaijeveld
+ */
+class QuestionConnector extends Connector {
+    
+    
+    /**
+     * Constructor for QuestionConnector
+     */
+    public function __construct()
+    {
+		$this->fileName = 'data/questions/questions.rdf';
+        //Ensure the required folder for this connector exists
+        if (!is_dir('data/questions/'))
+            mkdir('data/questions/');	
+    }
+    
+    /**
+     * Get the questions corresponding to the arguments.
+	 * @param type $arguments : An array having one ore more of the following elements:
+	 * 'code', 'title', 'type', 'description', 'category', 'definedanswers'.
+     */
+    public function get($arguments)
+    {
+        $this->load();
+           
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT DISTINCT ?uid, ?title, ?type, ?description, ?category
+            WHERE 	
+            {
+                _question	predicates:resource_type	resources:question ;                
+                predicates:question_code ?uid ;
+                predicates:title ?title ;
+                predicates:question_type ?type ;
+                predicates:description ?description ;
+                predicates:question_category ?category ;
+				'. $this->createArguments($arguments) . '
+	}';
+
+		
+        //Create the querystring 
+        $results = $this->model->sparqlQuery($querystring);
+
+        
+        $questions = array();
+        if(!empty($results))
+        {
+            foreach($results as $result)
+            {
+                $answers = $this->getAnswers($result['?uid']->label);
+                $questions[] = new Question($result['?uid']->label, $result['?title']->label, $result['?type']->label, $result['?description']->label, $result['?category']->label, $answers);
+            }
+        }
+        return $questions;
+    }
+    
+    /**
+     * Gets the answers belonging to the given uid.
+     * @param type $uid : The uid of the Question in question (haha, pun).
+     */
+    private function getAnswers($uid)
+    {
+		$result = $this->model->findRegex("[(".$uid.")]", "[(has_answer)]", null);
+		$iterator = $result->getStatementIterator();
+		$answers = array();
+		while($iterator->hasNext())
+		{
+			$element = $iterator->next();
+			$answers[] = $element->getLabelObject();
+		}
+		return $answers;
+
+	}
+    
+    /**
+     * Save the given ResearchTool object
+     * @param type $rToolObject : The ResearchToolObject to be saved.
+     */
+    public function set($rToolObject)
+    {
+        $this->load();
+        
+        $resourceQuestion = new Resource(QUESTION.'/'.$rToolObject->uid);        
+        //Remove the old value stored with the given id
+        $this->model->subtract($this->model->find($resourceQuestion, null, null));
+        
+        //Save all the new values
+        $resourceQuestionType = new Resource(QUESTION);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType));
+        
+        $questionQCode = new Literal($rToolObject->uid);
+        $predicateQCode = new Resource(QCODE);
+        $this->model->add(new Statement($resourceQuestion,$predicateQCode,$questionQCode));
+        
+        $questionTitle = new Literal($rToolObject->title);
+        $predicateTitle = new Resource(TITLE);		
+        $this->model->add(new Statement($resourceQuestion,$predicateTitle,$questionTitle));	
+
+        $questionDescription = new Literal($rToolObject->description);
+        $predicateDescription = new Resource(DESCRIPTION);
+        $this->model->add(new Statement($resourceQuestion,$predicateDescription,$questionDescription));		
+
+        $resourceQuestionType = new Literal($rToolObject->type);
+        $predicateQType = new Resource(QTYPE);
+        $this->model->add(new Statement($resourceQuestion,$predicateQType,$resourceQuestionType));
+        
+        $questionQCategory = new Literal($rToolObject->category);
+        $predicateQCategory = new Resource(QCATEGORY);
+        $this->model->add(new Statement($resourceQuestion,$predicateQCategory,$questionQCategory));
+
+        if(isset($rToolObject->answers))
+        {
+            foreach($rToolObject->answers as $answer)
+            {		
+                $answerValue = new Literal($answer);
+                $predicateAnswer = new Resource(HAS_ANSWER);	
+                $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$answerValue));
+            }
+        }
+        $this->save();
+    }
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/ResearchToolObject.php
===================================================================
--- Dev/branches/jos-branch/classes_old/ResearchToolObject.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/ResearchToolObject.php	(revision 210)
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Description of ResearchToolObject
+ *
+ * @author jkraaijeveld
+ */
+abstract class ResearchToolObject {
+	public $uid;
+//Uncomment when done with creating all evaluation methods \o/////
+	public function evaluate()
+	{
+		return true;
+	}
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/Respondent.php
===================================================================
--- Dev/branches/jos-branch/classes_old/Respondent.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/Respondent.php	(revision 210)
@@ -0,0 +1,31 @@
+<?php
+
+/**
+ * Description of Respondent
+ *
+ * @author jkraaijeveld
+ */
+class Respondent {
+   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;
+   }
+
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/RespondentConnector.php
===================================================================
--- Dev/branches/jos-branch/classes_old/RespondentConnector.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/RespondentConnector.php	(revision 210)
@@ -0,0 +1,91 @@
+<?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 RespondentConnector
+ *
+ * @author jkraaijeveld
+ */
+class RespondentConnector extends Connector{
+    
+    /**
+     * Constructor for RespondentConnector.
+     */
+    public function __construct()
+    {
+		$this->fileName = 'data/users/respondents.rdf';
+        if (!is_dir('data/users/'))
+            mkdir('data/users/');	
+    }
+    
+    /**
+     * function get()
+     * 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 function get($arguments) {
+        $this->load();
+       
+        //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 ;
+					' . $this->createArguments($arguments) .  '
+            }';
+        //Query the model
+        $results = $this->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;
+    }
+    
+    /**
+	 * function set()
+     * @param type $rToolObject : The ResearchToolObject to be saved.
+     */
+    public function set($rToolObject)
+    {
+        $this->load();
+        $resourceRespondent = new Resource(RESPONDENT . '/' . $rToolObject->uid);
+        //Remove the old value stored with the given id
+        $this->model->subtract($this->model->find($resourceRespondent, null, null));
+
+		//Set the new values
+        $resourceRespondentType = new Resource(RESPONDENT);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceRespondent,$predicateRType,$resourceRespondentType));
+
+        $literalRespondentID = new Literal($rToolObject->uid);
+        $predicateUniqueID = new Resource(UID);
+        $this->model->add(new Statement($resourceRespondent,$predicateUniqueID,$literalRespondentID));
+        
+        $literalRespondentName = new Literal($rToolObject->name);
+        $predicateName = new Resource(NAME);
+        $this->model->add(new Statement($resourceRespondent,$predicateName,$literalRespondentName));			
+
+        $literalPassword = new Literal($rToolObject->password);
+        $predicatePassword = new Resource(PASSWORD);
+        $this->model->add(new Statement($resourceRespondent,$predicatePassword,$literalPassword));
+        $this->save();
+    }
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/Session.php
===================================================================
--- Dev/branches/jos-branch/classes_old/Session.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/Session.php	(revision 210)
@@ -0,0 +1,189 @@
+<?php
+/**
+ * Description of Session
+ *
+ * @author jkraaijeveld
+ */
+
+class Session extends ResearchToolObject
+{
+	public $title;
+	public $creator;
+	public $creationdate;
+	public $pipeline;
+
+	
+	/**
+	 * Constructor for a Session object
+	 * @param type $uid
+	 * @param type $title
+	 * @param type $creator
+	 * @param type $datetime
+	 * @param type $pipeline
+	 */
+	public function __construct($uid = null, $title = null, $creator = null, $datetime = null, $pipeline = null)
+	{
+		if(!isset($uid))
+		{
+			$uid = md5(uniqid(rand(), true));
+		}
+		$this->uid = $uid;
+		$this->title = $title;
+		$this->creator = $creator;
+		$this->creationdate = $datetime;
+		$this->pipeline = $pipeline;
+	}
+
+	/*
+	 * function evaluate(()
+	 * Evaluates all the references of this object.
+	 */
+	public function evaluate()
+	{
+		$dbi = new DatabaseInterface();
+		if(is_string($this->creator))
+		{
+			$result = $dbi->get("user", array("uid" => $this->creator));
+			if(!isset($result[0]))
+				return false;
+			$this->creator = $result[0];
+		}
+		if(!empty($this->pipeline) && is_string($this->pipeline[0]))
+		{
+			$newPipeline = array();
+			foreach($this->pipeline as $element)
+			{
+				//Check if the element's UID can be found in surveys, if not: 
+				//Check applications. If it isn't in either: invalid reference.
+				$result = $dbi->get("survey", array("uid" => $element));
+				if(!isset($result[0]))
+					$result = $dbi->get("application", array("uid" => $element));
+				if(!isset($result[0]))
+					return false;
+				$newPipeline[] = $result[0];
+			}
+			$this->pipeline = $newPipeline;
+		}
+		return true;
+	}
+
+	/**
+	 * function toSPSS
+	 * @param type $location
+	 * Writes an SPSS parseable file at the given location, named '$datetime_$title.txt'
+	 * One big note about toSPSS: If this session contains multiple instances of THE SAME Survey,
+	 * the world burns, people die, etcetera. (or, in a more fortunate case, the latest values
+	 * are written to the file whilst the others get lost.
+	 */
+	//DO NOT USE - BROKEN AS OF 23/12/2011
+	public function toSPSS($location)
+	{
+		$this->evaluate();
+		if(!is_dir($location))
+		{
+			mkdir($location);
+		}
+		//Create the filename, open the file at the given location
+		$fileName = $this->datetime->format("d-m-Y") . "_" . $this->title . ".txt";
+
+		//Make a list of all 'column headers', e.g. "respondent" and all the question codes.
+		$headers = array();
+		$headers[] = "respondent";
+		foreach ($this->pipeline as $element)
+		{
+			if(get_class($element) == "Survey")
+			{
+				$element->evaluate();
+				foreach($element->questions as $question)
+				{
+					//TODO: This might need fixing after lazy initialization refactoring.
+					$headers[] = $element->title . '_' . $question->uid;
+				}
+			}
+		}
+		//Return if there are no surveys.
+		if(count($headers) < 2)
+			return;
+		
+		//Get the answers for all respondents
+		$answers = $this->getAnswers($headers);
+
+		//Create the strings and write to file.
+		$headerString = "";
+		foreach($headers as $headerElement)
+		{
+			$headerString = $headerString . $headerElement . "\t";
+		}
+		$fileHandler = fopen($location . '/' . $fileName, 'w') or die("File in use");
+		fwrite($fileHandler, $headerString . "\n");
+		foreach($answers as $entry)
+		{
+			$entryString = "";
+			//PHP doesn't automatically sort the indices so I have to do it myself
+			//Entry elements can now be printed in order to match the headers
+			for ($i = 0; $i < count($headers); $i++)
+			{
+				if(in_array($i, array_keys($entry)))
+					$entryString = $entryString . $entry[$i] . "\t";	
+				else
+					$entryString = $entryString . "\t";
+			}
+			fwrite($fileHandler, $entryString . "\n");	
+		}
+	}
+
+	/*
+	 * function getAnswers
+	 * @param type $headers
+	 * Based on the questions specified in the headers array, matches the answers of every
+	 * respondent to the correct questions and returns an array containing a list of answers per 
+	 * respondent
+	 */
+	private function getAnswers($headers)
+	{
+		//Add the answers per survey per respondent. Requires some extra looping to assure proper ordering.
+		//Keeps a list of respondents which have already been used. If an answerset exists for a respondent which
+		//already exists within the answers-array, use the index of the respondent. Else: make a new row.
+		$respondentsUsed = array();
+		$answers = array();
+		foreach($this->answersets as $answerset)
+		{
+			$entryIndex;
+			if(in_array($answerset->respondent->name, $respondentsUsed))
+			{
+				$entryIndex = array_search($answerset->respondent->name, $respondentsUsed);
+				$entry = $answers[$entryIndex];
+			}
+			else
+			{
+				$entry = array();
+				$entry[0] = $answerset->respondent->name;
+				$entryIndex = count($respondentsUsed);
+				$respondentsUsed[] = $answerset->respondent->name;
+			}
+			foreach ($answerset->answers as $answer)
+			{
+				$index = array_search($answerset->survey->title . '_' . $answer->question->uid, $headers);
+				//Index has to be a good number, else the answer doesn't belong in this session
+				//Causes might be a missing question or having a wrong survey
+				if($index != 0)
+				{
+					$value = "";
+					foreach ($answer->values as $val)
+					{
+						$value = $value . $val . ",";
+					}
+					//We all hate trailing commas
+					if (strlen($value) > 0) { $value = substr($value, 0, strlen($value)-1); }
+					$entry[$index] = $value;
+				}
+			}
+			$answers[$entryIndex] = $entry;
+		}
+		return $answers;
+	}
+
+}	
+
+
+?>
Index: Dev/branches/jos-branch/classes_old/SessionConnector.php
===================================================================
--- Dev/branches/jos-branch/classes_old/SessionConnector.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/SessionConnector.php	(revision 210)
@@ -0,0 +1,172 @@
+<?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 SessionConnector
+ *
+ * @author jkraaijeveld
+ */
+class SessionConnector extends Connector  
+{
+	protected $db;
+
+	/**
+	 * Constructor for the SessionConnector
+	 */
+	public function __construct()
+	{
+		$this->fileName = 'data/sessions/sessions.rdf';
+		//Ensure the required folder for this connector exists
+		if(!is_dir('data/sessions'))
+			mkdir('data/sessions');
+	}
+
+	/**
+	 * function get()
+	 * @param type $arguments : An array containing one or more of the following elements:
+	 * 'uid', 'title', 'creationdate', 'applications', 'surveys'
+	 */
+	public function get($arguments)
+	{
+		$this->load();
+	
+		//Build the query string
+		$querystring = '
+			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+			SELECT DISTINCT ?uid, ?title, ?creator, ?creationdate
+			WHERE
+			{
+				_session predicates:resource_type resources:session ;
+				predicates:uid ?uid ;
+				predicates:title ?title ;
+				predicates:creator ?creator ;
+				predicates:creationdate ?creationdate ;
+				' . $this->createArguments($arguments) . '
+			}';
+		//Query the model
+		$results = $this->model->sparqlQuery($querystring);
+		$sessions = array();
+		if(!empty($results))
+		{
+			$this->db = new DatabaseInterface();
+			foreach($results as $result)
+			{
+				//Create a session object out of every result, get all required fields as well.
+				$pipeline = $this->getPipeline($result['?uid']->label);
+				$creator = $result['?creator']->label;
+				$creationdate = new DateTime();
+				$creationdate->setTimestamp(intval($result['?creationdate']->label));
+				$sessions[] = new Session($result['?uid']->label, $result['?title']->label, $creator, $creationdate, $pipeline);
+			}
+		}
+		return $sessions;
+	}
+	/**
+	 * function getPipeline()
+	 * param type $uid : The Session uid for which the pipeline should be retrieved.
+	 */
+	private function getPipeline($uid)
+	{
+		$result = $this->model->findRegex("[(".$uid.")]", "[(has_application)|(has_survey)]" ,null);
+		$iterator = $result->getStatementIterator();
+		$pipeline = array();
+		while($iterator->hasNext())
+		{
+			$element = $iterator->next();
+			$pipeline[] = $element->getLabelObject();
+		}
+		return $pipeline;
+	}
+
+	/**
+	 * function getAnswerSets()
+	 * @param type $uid : The Session uid for which the answerSets should be retrieved.
+	 */
+	private function getAnswerSets($uid)
+	{
+		$result = $this->model->findRegex("[(".$uid.")]", "[(has_answerset)]" ,null);
+		$iterator = $result->getStatementIterator();
+		$answersets = array();
+		while($iterator->hasNext())
+		{
+			$element = $iterator->next();
+			$answersets[] = $element->getLabelObject();
+		}
+		return $answersets;
+	}
+
+	/**
+	 * function set()
+	 * @param type $rToolObjects : The ResearchToolObject to be saved.
+	 */
+	public function set($rToolObject)
+	{
+		$this->load();
+		//If evaluation fails, some references are incorrect.
+		//We shouldn't save in this case. Instead - let the user know. This function returns false if the evaluation has failed.
+		//TODO: Decide how to fix invalid references graciously.
+		if(!$rToolObject->evaluate()) 
+			return false;
+
+		$resourceSession = new Resource(SESSION . '/' . $rToolObject->uid);
+		//Remove the old value stored with the given id
+		$this->model->subtract($this->model->find($resourceSession, null, null));
+
+		//Set the new values
+		$resourceSessionType = new Resource(SESSION);
+		$predicateType = new Resource(RTYPE);
+		$this->model->add(new Statement($resourceSession, $predicateType, $resourceSessionType));
+
+		$sessionId = new Literal($rToolObject->uid);
+		$predicateId = new Resource(UID);
+		$this->model->add(new Statement($resourceSession, $predicateId, $sessionId));
+
+		$sessionTitle = new Literal($rToolObject->title);
+		$predicateTitle = new Resource(TITLE);
+		$this->model->add(new Statement($resourceSession, $predicateTitle, $sessionTitle));
+
+		$sessionCreator = new Literal($rToolObject->creator->uid);
+		$predicateCreator = new Resource(CREATOR);
+		$this->model->add(new Statement($resourceSession, $predicateCreator, $sessionCreator));
+
+		$sessionTimestamp = new Literal($rToolObject->creationdate->getTimestamp());
+        //      $sessionTimestamp = new Literal($rToolObject->datetime);    // Edit of above function, allows for creation of session, but still results in errors...
+        $predicateTimestamp = new Resource(CREATIONDATE);
+		$this->model->add(new Statement($resourceSession, $predicateTimestamp, $sessionTimestamp));
+
+		//Create a sequence to store the different applications and surveys.
+		if(isset($rToolObject->pipeline))
+		{
+			foreach($rToolObject->pipeline as $element)
+			{
+				$sessionObject = new Literal($element->uid);
+				$predicateObject = null;
+				if(get_class($element) == "Application")
+					$predicateObject = new Resource(HAS_APPLICATION);
+				else if(get_class($element) == "Survey")
+					$predicateObject = new Resource(HAS_SURVEY);
+				if(isset($predicateObject))
+					$this->model->add(new Statement($resourceSession, $predicateObject, $sessionObject));
+			}
+		}
+
+		if(isset($rToolObject->answersets))
+		{
+			foreach($rToolObject->answersets as $answerset)
+			{
+				$sessionAnswerSet = new Literal($answerset->uid);
+				$predicateAnswerSet = new Resource(HAS_ANSWERSET);
+				$this->model->add(new Statement($resourceSession, $predicateAnswerSet, $sessionAnswerSet));
+			}
+		}
+
+		$this->save();
+		return true;
+	}
+}
+?>
+
Index: Dev/branches/jos-branch/classes_old/SessionEditorWidget.php
===================================================================
--- Dev/branches/jos-branch/classes_old/SessionEditorWidget.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/SessionEditorWidget.php	(revision 210)
@@ -0,0 +1,113 @@
+<?php
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * A visual interface object for editing and viewing a session's pipeline.
+ *
+ * @author Tschipper
+ */
+class SessionEditorWidget {
+
+    // properties
+    private $loadedSession;
+    private $selectedStep;
+    private $dbi;
+
+    public function __construct() {
+        $this->dbi = new DatabaseInterface();
+    }
+
+    public function init() {
+        $stringPipeline = "";
+        $stringPipelineType = "";
+        $stringPipelineUpdated = "";
+        $numberOfSteps = 0;
+
+        if (is_array($this->loadedSession->pipeline)) {
+            foreach ($this->loadedSession->pipeline as $object) {
+                $stringPipeline .= "$object->uid,";
+                $stringPipelineType .= get_class($object) . ",";
+                $stringPipelineUpdated .= "0,";
+                $numberOfSteps++;
+            }
+        } else {
+            $stringPipeline = $this->loadedSession->pipeline;
+            $stringPipelineType = $_POST['pipelineTypes'];
+            $stringPipelineUpdated = $_POST['pipelineUpdatedField'];
+        }
+        ?>
+        <br />
+
+        <div id="sequencer" class="largeFrame">
+            <div class="largeTitle">Name <?php echo $this->loadedSession->title; ?></div>
+            
+            <div id="seqContent" class="innerLargeFrame">
+                <div id="seqContentWrapper"></div>
+            </div>
+
+            <div class="controls">
+                <input type="button" id="moveSelectedL" value="< Move" class="smallButton"  onClick="moveStep(-1);" />
+                <input type="button" id="moveSelectedR" value="Move >" class="smallButton"  onClick="moveStep(1);" />
+                <input type="button" id="editSelected" value="Edit step" class="smallButton" onClick="editStep();" />
+                <input type="button" id="deleteSelected" value="Delete step" class="smallButton" onClick="deleteStep();" />
+                <input type="submit" id ="clearPipeline" name="clearPipeline" value="Clear pipeline" class="smallButton dis" disabled="true"/>
+                <input type="checkbox" id="confirmClear" name="confirmClear" onChange="IsCheckEnabled(this, document.getElementById('clearPipeline'));" />Really clear?
+                <input type="button" value="debug_save" onClick="savePipeline(true);" />
+            </div>
+            
+            <div id="hiddenInputs">
+                <input type="hidden" id="selectedStepField" value="" />
+                <input type="hidden" id="pipelineStringField" value="<?php echo $stringPipeline; ?>" />
+                <input type="hidden" id="pipelineTypeField" value="<?php echo $stringPipelineType; ?>" />
+                <input type="hidden" id="pipelineUpdatedField" value="<?php echo $stringPipelineUpdated; ?>" />
+                <input type="hidden" id="numSteps" value="<?php echo $numberOfSteps; ?>" />
+                <input type="hidden" id="sessionField" value="<?php echo $this->loadedSession->uid; ?>" />
+                <input type="hidden" id="sessionTitleField" value="<?php echo $this->loadedSession->title; ?>" />
+            </div>
+        </div>
+
+        
+        <?php
+    }
+
+    public function Javascript() {
+        ?>
+        <script type="text/javascript" src="js/generalScripts.js"></script>
+        <script type="text/javascript" src="js/sequencerScripts.js"></script>
+        <script type="text/javascript" src="js/jquery.js"></script>
+        <script type="text/javascript">
+            $(document).ready(function() {
+                loadSequencer();
+            });
+        </script>
+        <?php
+    }
+
+    public function LoadSession() {   // Initialize variables on page load.
+		// Redirect if no session is set
+        if (!isset($_SESSION['currentSession'])) {
+            redirect("selectSession.php");
+        }
+        // Store the current session in internal variable
+        $results = $this->dbi->get("Session", array("uid"=> $_SESSION['currentSession']));
+		print_r($results);
+        if (!empty($results)) {
+            if ($results[0]->evaluate()) {
+                $this->loadedSession = $results[0];
+            }
+        }
+        else {
+            // Throw error and quit if no results found
+            die("No session with that UID found!");
+        }
+    }
+
+    public function HandlePostData() {
+                
+    }
+
+}
+?>
Index: Dev/branches/jos-branch/classes_old/SessionInstance.php
===================================================================
--- Dev/branches/jos-branch/classes_old/SessionInstance.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/SessionInstance.php	(revision 210)
@@ -0,0 +1,82 @@
+<?php
+/**
+ * Description of SessionInstance
+ *
+ * @author jkraaijeveld
+ */
+
+class SessionInstance extends ResearchToolObject
+{
+	public $title;
+	public $location;
+	public $facilitator;
+	public $starttime;
+	public $endtime;
+	public $notes;
+	public $session;
+	public $resultset;
+
+	/**
+	 * Constructor for a SessionInstance object
+	 * @param type $uid
+	 * @param type $title
+	 * @param type $location
+	 * @param type $facilitator
+	 * @param type $starttime
+	 * @param type $endtime
+	 * @param type $notes
+	 * @param type $session
+	 * @param type $resultset
+	 */
+	public function __construct($uid = null, $title = null, $location = null, $facilitator = null, $starttime = null, $endtime = null, $notes = null, $session = null, $resultset = null)
+	{
+		if(!isset($uid))
+		{
+			$uid = md5(uniqid(rand(), true));
+		}
+		$this->uid = $uid;
+		$this->title = $title;
+		$this->location = $location;
+		$this->facilitator = $facilitator;
+		$this->starttime = $starttime;
+		$this->endtime = $endtime;
+		$this->notes = $notes;
+		$this->session = $session;
+		$this->resultset = $resultset;
+	}
+
+	/*
+	 * function evaluate()
+	 * Evaluates all the references of this object.
+	 */
+	public function evaluate()
+	{
+		$dbi = new DatabaseInterface();
+		if(is_string($this->facilitator))
+		{
+			$result = $dbi->get("user", array("uid" => $this->facilitator));
+			if(!isset($result[0]))
+				return false;
+			$this->facilitator = $result[0];
+		}
+
+		if(is_string($this->session))
+		{
+			$result = $dbi->get("session", array("uid" => $this->session));
+			if(!isset($result[0]))
+				return false;
+			$this->session = $result[0]; 
+		}
+
+		if(is_string($this->resultset))
+		{
+			$result = $dbi->get("resultset", array("uid" => $this->resultset));
+			if(!isset($result[0]))
+				return true;
+			$newResultSets[] = $result[0];
+		}
+		return true;
+	}
+			
+
+}
Index: Dev/branches/jos-branch/classes_old/SessionInstanceConnector.php
===================================================================
--- Dev/branches/jos-branch/classes_old/SessionInstanceConnector.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/SessionInstanceConnector.php	(revision 210)
@@ -0,0 +1,182 @@
+<?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 SessionInstanceConnector
+ *
+ * @author jkraaijeveld
+ */
+class SessionInstanceConnector extends Connector  
+{
+	protected $db;
+
+	/**
+	 * Constructor for the SessionInstanceConnector.
+	 */
+
+	public function __construct()
+	{
+		$this->fileName = 'data/sessions/sessioninstances.rdf';
+		//Ensure the required folder for this connector exists.
+		if(!is_dir('data/sessions'))
+			mkdir('data/sessions');
+	}
+
+	/**
+	 * function get()
+	 * @param type $arguments : An array containing one or more of the following elements:
+	 * 'uid', 'title', 'location', 'facilitator', 'starttime', 'endtime' 'notes', 'session', 'resultset'
+	 */
+	public function get($arguments)
+	{
+		$this->load();
+
+		//Build the query string
+		$querystring = '
+			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+			SELECT DISTINCT ?uid, ?title, ?location, ?facilitator, ?starttime, ?endtime, ?of_session, ?has_resultset 
+			WHERE
+			{
+				_sessioninstance predicates:resource_type resources:sessioninstance ;
+				predicates:uid ?uid ;
+				predicates:title ?title ;
+				predicates:location ?location ;
+				predicates:facilitator ?facilitator ;
+				predicates:starttime ?starttime ;
+				predicates:endtime ?endtime ;
+				predicates:of_session ?of_session ;
+				' . $this->createArguments($arguments) . '
+	}';
+		//Query the model
+		$results = $this->model->sparqlQuery($querystring);
+		$sessioninstances = array();
+		if(!empty($results))
+		{	
+			$this->db = new DatabaseInterface();
+			foreach($results as $result)
+			{
+				//Create a SessionInstance object out of every result. Get all the required fields as well.
+				$notes = $this->getNotes($result['?uid']->label);
+				$resultset = $this->getResultSet($result['?uid']->label);
+				$starttime = new DateTime();
+				$starttime->setTimestamp(intval($result['?starttime']->label));
+				$endtime = new DateTime();
+				$endtime->setTimestamp(intval($result['?endtime']->label));
+				$sessioninstances[] = new SessionInstance(  
+					$result['?uid']->label,
+					$result['?title']->label,
+					$result['?location']->label,
+					$result['?facilitator']->label,
+					$starttime,
+					$endtime,
+					$notes,
+					$result['?of_session'],
+					$resultset
+				);
+			}
+		}
+		return $sessioninstances;
+	}
+	
+	/**
+	 * function getNotes()
+	 * param type $uid : The SessionInstance uid for which the notes should be retrieved.
+	 */
+	public function getNotes($uid)
+	{
+		$result = $this->model->findRegex("[(".$uid.")]", "[(has_note)]", null);
+		$iterator = $result->getStatementIterator();
+		$notes = array();
+		while($iterator->hasNext())
+		{
+			$element = $iterator->next();
+			$notes[] = $element->getLabelObject();
+		}
+		return $notes;
+	}
+
+	/**
+	 * function getResultSet($uid)
+	 * param type $uid : The SessionInstance uid for which the ResultSet should be gotten.
+	 */
+	public function getResultSet($udi)
+	{
+		//TODO: Implement when ResultSet is in.
+		return null;
+	}
+
+	/**
+	 * function set()
+	 * @param type $rToolObject: The ResearchToolObject to be saved.
+	 */
+	public function set($rToolObject)
+	{
+		$this->load();
+		//If evaluation fails, some references are incorrect.
+		//We shouldn't save in this case. Instead - let the user know. This function returns false if the evaluation has failed.
+		//TODO: Decide how to fix invalid references graciously.
+		if(!$rToolObject->evaluate()) 
+			return false;
+		$resourceSInstance = new Resource(SESSIONINSTANCE . '/' . $rToolObject->uid);
+		//Remove the old value stored with the given id
+		$this->model->subtract($this->model->find($resourceSInstance, null, null));
+
+		//Set the new values
+		$resourceSInstanceType = new Resource(SESSIONINSTANCE);
+		$predicateType = new Resource(RTYPE);
+		$this->model->add(new Statement($resourceSInstance, $predicateType, $resourceSInstanceType));
+
+		$sInstanceId = new Literal($rToolObject->uid);
+		$predicateId = new Resource(UID);
+		$this->model->add(new Statement($resourceSInstance, $predicateId, $sInstanceId));
+
+		$sInstanceTitle = new Literal($rToolObject->title);
+		$predicateTitle = new Resource(TITLE);
+		$this->model->add(new Statement($resourceSInstance, $predicateTitle, $sInstanceTitle));
+
+		$sInstanceLocation = new Literal($rToolObject->location);
+		$predicateLocation = new Resource(LOCATION);
+		$this->model->add(new Statement($resourceSInstance, $predicateLocation, $sInstanceLocation));
+
+		$sInstanceFacilitator = new Literal($rToolObject->facilitator->uid);
+		$predicateFacilitator = new Resource(FACILITATOR);
+		$this->model->add(new Statement($resourceSInstance, $predicateFacilitator, $sInstanceFacilitator));
+
+		$sInstanceStartTime = new Literal($rToolObject->starttime->getTimestamp());
+		$predicateStartTime = new Resource(STARTTIME);
+		$this->model->add(new Statement($resourceSInstance, $predicateStartTime, $sInstanceStartTime));
+
+		$sInstanceEndTime = new Literal($rToolObject->endtime->getTimestamp());
+		$predicateEndTime = new Resource(ENDTIME);
+		$this->model->add(new Statement($resourceSInstance, $predicateEndTime, $sInstanceEndTime));
+
+		if(isset($rToolObject->notes))
+		{
+			foreach($rToolObject->notes as $note)
+			{
+				$sInstanceNote = new Literal($note);
+				$predicateNote = new Resource(HAS_NOTE);
+				$this->model->add(new Statement($resourceSInstance, $predicateNote, $sInstanceNote));
+			}
+		}
+
+		$sInstanceSession = new Literal($rToolObject->session->uid);
+		$predicateSession = new Resource(OF_SESSION);
+		$this->model->add(new Statement($resourceSInstance, $predicateSession, $sInstanceSession));
+
+		if(isset($rToolObject->resultset))
+		{
+			//$sInstanceResultSet = new Literal($rToolObject->resultset->uid);
+			$sInstanceResultSet = new Literal($rToolObject->resultset);
+			$predicateResultSet = new Resource(HAS_RESULTSET);
+			$this->model->add(new Statement($resourceSInstance, $predicateResultSet, $sInstanceResultSet));
+		}
+		$this->save();
+		return true;
+	}
+}
+?>
Index: Dev/branches/jos-branch/classes_old/StyleSheet.php
===================================================================
--- Dev/branches/jos-branch/classes_old/StyleSheet.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/StyleSheet.php	(revision 210)
@@ -0,0 +1,34 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Standard stylesheet class
+ *
+ * @author tschipper
+ */
+class StyleSheet {
+
+    public $filename; // includes path
+
+    public function __construct($styleName) {
+
+        // call new StyleSheet("standard") to load css/standard.css
+        $this->path = "css/" . $styleName . ".css";
+
+        echo '<link rel="Stylesheet" type="text/css" href="css/resetstyle.css" />';
+        echo '<link rel="Stylesheet" type="text/css" href="' . $this->path . '"/>';
+        
+        echo "\n";
+    }
+
+    public function ChangeStyle($styleName) {
+        $this->path = "css/" . $styleName . ".css";
+    }
+
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/Survey.php
===================================================================
--- Dev/branches/jos-branch/classes_old/Survey.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/Survey.php	(revision 210)
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * Description of Survey
+ *
+ * @author jkraaijeveld
+ */
+class Survey extends ResearchToolObject{
+    public $title;
+    public $description;
+    public $creator;
+    public $questions;
+    
+    public function __construct($uid = null, $title = null, $description = null, $creator = null, $questions = null) {
+        if(!isset($uid))
+        {
+            $uid = md5(uniqid(rand(), true));
+        }
+        $this->uid = $uid;
+        $this->title = $title;
+		$this->description = $description;
+		$this->creator = $creator;
+        $this->questions = $questions;
+	}
+
+	/**
+	 * function evaluate()
+	 * Evaluates the references
+	 */
+	public function evaluate()
+	{
+		$dbi = new DatabaseInterface();
+		if(is_string($this->creator))
+		{
+			$result = $dbi->get("user", array("uid" => $this->creator));	
+			if(!isset($result[0]))
+				return false;
+			$this->creator = $result[0];
+		}
+
+		if(!empty($this->questions) && is_string($this->questions[0]))
+		{
+			$newQuestions = array();
+			foreach($this->questions as $question)
+			{
+				$result = $dbi->get("question", array("uid" => $question));
+				if(!isset($result[0]))
+					return false;
+				$newQuestions[] = $result[0];			
+			}
+			$this->questions = newQuestions;
+		}
+		return true;
+	}
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/SurveyConnector.php
===================================================================
--- Dev/branches/jos-branch/classes_old/SurveyConnector.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/SurveyConnector.php	(revision 210)
@@ -0,0 +1,135 @@
+<?php
+
+/**
+ * Description of SurveyConnector
+ *
+ * @author jkraaijeveld
+ */
+class SurveyConnector extends Connector{
+    protected $db;
+
+    /**
+     * Constructor for ApplicationConnector.
+     */
+    public function __construct()
+    {
+		$this->fileName = 'data/surveys/surveys.rdf';
+        //Ensure the required folder for this connector exists
+        if (!is_dir('data/surveys/'))
+            mkdir('data/surveys/');	
+    }
+    
+    /**
+     * function get($arguments)
+     * Gets the array of Survey objects belonging to arguments supplied.
+     * @param type $arguments : An array containing zero or more of the following keys:
+     *                          'uid', 'title', 'description', 'questions'
+     * Note: questions has to be an array of question IDs (codes) for this filter to work.
+     */
+    public function get($arguments)
+    {
+        $this->load();
+        
+        //Build the query string
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT DISTINCT ?uid, ?title, ?description, ?creator
+            WHERE
+            {
+                _survey     predicates:resource_type    resources:survey ;
+                predicates:uid ?uid ;
+                predicates:title ?title ;
+				predicates:description ?description ;
+				predicates:creator ?creator ;
+				' . $this->createArguments($arguments) . '
+            }';
+        
+        //Query the model
+        $results = $this->model->sparqlQuery($querystring);
+        
+        //Create the corresponding Survey objects
+        $surveys = array();
+        if(!empty($results))
+        {
+            $this->db = new DatabaseInterface();
+            foreach($results as $result)
+            {
+				$questions = $this->getQuestions($result['?uid']->label);
+				$creator = $result['?creator']->label;
+                $surveys[] = new Survey($result['?uid']->label, $result['?title']->label, $result['?description']->label, $creator[0], $questions);
+            }
+        }
+        return $surveys;
+    }
+    
+    /**
+     * Gets the questions corresponding to the survey
+     * @param type $uid : The uid for which the questions should be gotten.
+     */
+    private function getQuestions($uid)
+    {
+		$result = $this->model->findRegex("[(".$uid.")]", "[(has_question)]", null);
+		$iterator = $result->getStatementIterator();
+		$questions = array();
+		while($iterator->hasNext())
+		{
+			$element = $iterator->next();
+			$questions[] = $element->getLabelObject();
+		}
+		return $questions;
+    }
+    
+    /**
+     * Saves the given Survey object.
+     * @param type $rToolObject : The ResearchToolObject to be saved.
+     */
+    public function set($rToolObject)
+    {
+        $this->load();
+        
+		//If evaluation fails, some references are incorrect.
+		//We shouldn't save in this case. Instead - let the user know. This function returns false if the evaluation has failed.
+		//TODO: Decide how to fix invalid references graciously.
+		if(!$rToolObject->evaluate()) 
+			return false;
+
+        $resourceSurvey = new Resource(SURVEY.'/'.$rToolObject->uid);
+        //Remove the old value stored with the given id
+        $this->model->subtract($this->model->find($resourceSurvey, null, null));
+        
+        $resourceSurveyType = new Resource(SURVEY);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceSurvey,$predicateRType,$resourceSurveyType));
+
+        $predicateUniqueID = new Resource(UID);
+        $literalSurveyID = new Literal($rToolObject->uid);
+        $this->model->add(new Statement($resourceSurvey,$predicateUniqueID,$literalSurveyID));
+
+        $predicateTitle = new Resource(TITLE);		
+        $surveyTitle = new Literal($rToolObject->title);
+        $this->model->add(new Statement($resourceSurvey,$predicateTitle,$surveyTitle));		
+
+        $predicateDescription = new Resource(DESCRIPTION);
+        $surveyDescription = new Literal($rToolObject->description);
+        $this->model->add(new Statement($resourceSurvey,$predicateDescription,$surveyDescription));
+        
+		$predicateCreator = new Resource(CREATOR);
+		$surveyCreator = new Literal($rToolObject->creator->uid);
+		$this->model->add(new Statement($resourceSurvey, $predicateCreator, $surveyCreator));
+
+        if(isset($rToolObject->questions))
+        {
+            foreach($rToolObject->questions as $question)
+            {
+                $questionUid = new Literal($question->uid);
+                $predicateQuid = new Resource(HAS_QUESTION);
+                $this->model->add(new Statement($resourceSurvey,$predicateQuid,$questionUid));
+            }
+		}
+		$this->save();
+		return true;
+    }
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/SurveyEditorWidget.php
===================================================================
--- Dev/branches/jos-branch/classes_old/SurveyEditorWidget.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/SurveyEditorWidget.php	(revision 210)
@@ -0,0 +1,107 @@
+<?php
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * The PHP class that implements the survey editor interface
+ *
+ * @author Thijs Schipper
+ */
+class SurveyEditorWidget {
+
+    private $loadedSurvey;
+    private $dbi;
+
+    public function __construct() {
+        // Set basic variables
+        // Should probably include a default empty survey for the sake of safety
+        $dbi = new DatabaseInterface();
+    }
+
+    public function handlePost() {
+        // Get POSTed data and store variables to class instance properties
+        $dbi = new DatabaseInterface();
+        if (isset($_POST['objectUid']) && !empty($_POST['objectUid'])) {
+            $surveyResults = $dbi->get("Survey", array("uid" => $_POST['objectUid']));
+            if (!empty($surveyResults)) {
+                $this->loadedSurvey = $surveyResults[0];
+            } else {
+                die("No surveys found!");
+            }
+        } else {
+            die("Incorrect or null uid passed!");
+        }
+    }
+
+    public function init() {
+        $questionString = "";
+        foreach ($this->loadedSurvey->questions as $question) {
+            $questionString .= $question->code . ",";
+        }
+        // echo the HTML markup to display the editor on the screen
+        ?>
+
+        <div id="surveyEditor" class="largeFrame">
+            <div class="largeTitle" id="surveyTitle">
+                <?php echo $this->loadedSurvey->title; ?>
+            </div>
+            <div id="seqContent" class="innerLargeFrame">
+                <div id="seqContentWrapper">
+
+                </div>
+            </div>
+            <div id="surveyEditorVertControls" class="vertControls">
+                <div class="segment">
+                    <label>Move</label>
+                    <input type="button" id="vertControls_MoveUp" class="bigButton vertical" value="Ë" />
+                    <input type="button" id="vertControls_MoveDown" class="bigButton vertical" value="Ë
+" />
+                </div>
+                <input type="button" id="vertControls_Add" class="bigButton vertical" value="+" onClick="addQuestion_Click();" />
+            </div>
+            <div id="surveyEditorControls" class="controls">
+                <div id="pageControls">
+                    <input type="button" value="<<" id="pageControls_first" onClick="" />
+                    <input type="button" value="<" id="pageControls_previous" onClick="" />
+                    Page <input type="text" value="1" id="pageControls_current" onChange="" class="smallTextField" /> of 5
+                    <input type="button" value=">" id="pageControls_next" onClick="" />
+                    <input type="button" value=">>" id="pageControls_last" onClick="" />
+                </div>
+
+                <input type="button" value="Discard survey" onClick="javascript:alert('discard not yet supported');" class="smallButton" />
+                <input type="button" value="Save survey" onClick="saveSurvey(true);" class="smallButton" />
+            </div>
+
+        </div>
+
+
+        <form id="hiddenInputs">
+            <input type="hidden" id="surveyUidField" value="<?php echo $this->loadedSurvey->uid; ?>" />
+            <input type="hidden" id="questionUidsField" value="<?php echo $questionString ?>" />
+            <input type="hidden" id="surveyTitleField" value="<?php echo $this->loadedSurvey->title; ?>" />
+            <input type="hidden" id="numQuestionsField" value="<?php echo count($this->loadedSurvey->questions); ?>" />
+            <input type="hidden" id="surveyDescriptionField" value="<?php echo $this->loadedSurvey->description; ?>" />
+        </form>
+
+
+        <?php
+    }
+
+    public function javascript() {
+        // output the javascript tags and needed functions in the head of the page
+        ?>
+        <script type="text/javascript" src="js/sequencerScripts.js"></script>
+        <script type="text/javascript" src="js/generalscripts.js"></script>
+        <script type="text/javascript" src="js/jquery.js"></script>
+        <script type="text/javascript">
+            $(document).ready(function() {
+                loadSequencer();
+            });
+        </script>
+        <?php
+    }
+
+}
+?>
Index: Dev/branches/jos-branch/classes_old/Toolbox.php
===================================================================
--- Dev/branches/jos-branch/classes_old/Toolbox.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/Toolbox.php	(revision 210)
@@ -0,0 +1,32 @@
+<?php
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ * Description of ToolBox
+ *
+ * @author HP
+ */
+class Toolbox {
+
+    public function __construct() {
+        ?>
+
+        <br />
+
+        <div id="toolbox" class="largeFrame">
+            <div class="largeTitle">Toolbox</div>
+            <div class="content">
+                <p style="float: left; clear:both; margin-bottom: 1em;">Add new:</p>
+                <div class="bigButton toolbox" onClick="submitToolbox('Survey');"><img src="images/icons/survey.png" class="buttonIcon" /><p>Survey</p></div>
+                <div class="bigButton toolbox" onClick="submitToolbox('Application');"><img src="images/icons/application.png" class="buttonIcon" /><p>Application</p></div>
+                <div class="bigButton toolbox" onClick="submitToolbox('Dashboard');"><img src="images/icons/dashboard.png" class="buttonIcon" /><p>Dashboard</p></div>
+            </div>
+        </div>
+        <?php
+    }
+
+}
+?>
Index: Dev/branches/jos-branch/classes_old/User.php
===================================================================
--- Dev/branches/jos-branch/classes_old/User.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/User.php	(revision 210)
@@ -0,0 +1,29 @@
+<?php
+
+/**
+ * Description of User
+ *
+ * @author jkraaijeveld
+ */
+
+class User extends ResearchToolObject {
+    
+    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;
+	}
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/UserConnector.php
===================================================================
--- Dev/branches/jos-branch/classes_old/UserConnector.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/UserConnector.php	(revision 210)
@@ -0,0 +1,90 @@
+<?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 UserConnector
+ *
+ * @author jkraaijeveld
+ */
+class UserConnector extends Connector{
+    
+    /**
+     * Constructor for UserConnector.
+     */
+    public function __construct()
+    {
+		$this->fileName = 'data/users/users.rdf';
+        //Ensure the required folder for this connector exists
+        if (!is_dir('data/users/'))
+            mkdir('data/users/');	
+    }
+    
+    /**
+     * 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 function get($arguments) {
+        $this->load();
+        //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 ;
+					' . $this->createArguments($arguments) . '
+            }';
+        //Query the model
+		$results = $this->model->sparqlQuery($querystring);
+        $users = array();
+        if(!empty($results))
+        {
+            //Run over all results and create appropriate Application objets
+            foreach($results as $result)
+            { 
+                    $users[] = new User($result['?uid']->label, $result['?name']->label, $result['?password']->label);
+            }
+        }
+        return $users;
+    }
+    
+    /**
+     * Save the given User object in the file.
+     * @param type $rToolObject 
+     */
+    public function set($rToolObject)
+    {
+        $this->load();
+        $resourceUser = new Resource(USER . '/' . $rToolObject->uid);
+        //Remove the old value stored with the given id
+        $this->model->subtract($this->model->find($resourceUser, null, null));
+
+        $resourceUserType = new Resource(USER);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceUser,$predicateRType,$resourceUserType));
+
+        $literalUserID = new Literal($rToolObject->uid);
+        $predicateUniqueID = new Resource(UID);
+        $this->model->add(new Statement($resourceUser,$predicateUniqueID,$literalUserID));
+        
+        $literalUserName = new Literal($rToolObject->name);
+        $predicateName = new Resource(NAME);
+        $this->model->add(new Statement($resourceUser,$predicateName,$literalUserName));			
+
+        $literalPassword = new Literal($rToolObject->password);
+        $predicatePassword = new Resource(PASSWORD);
+        $this->model->add(new Statement($resourceUser,$predicatePassword,$literalPassword));
+        $this->save();
+    }
+}
+
+?>
Index: Dev/branches/jos-branch/classes_old/master.php
===================================================================
--- Dev/branches/jos-branch/classes_old/master.php	(revision 210)
+++ Dev/branches/jos-branch/classes_old/master.php	(revision 210)
@@ -0,0 +1,33 @@
+<?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) {
+    require 'classes/' . $class_name . '.php';
+}
+
+
+// Redirects user to $url
+function redirect($url = null)
+{
+	if (is_null($url))
+		$url = $_SERVER['PHP_SELF'];
+
+	header("Location: $url");
+	exit();
+}
+
+
+?>
