Index: /Dev/trunk/classes/AnswerConnector.php
===================================================================
--- /Dev/trunk/classes/AnswerConnector.php	(revision 170)
+++ /Dev/trunk/classes/AnswerConnector.php	(revision 171)
@@ -10,7 +10,5 @@
  * @author jkraaijeveld
  */
-class AnswerConnector implements IConnector{
-    protected $model;
-	protected $fileName = 'data/answers/answers.rdf';
+class AnswerConnector extends Connector{
 	protected $db;
     
@@ -21,26 +19,6 @@
         //Ensure the required folder for this connector exists
         if (!is_dir('data/answers/'))
-            mkdir('data/answers/');
-    }
-    
-    /**
-     * function load()
-     * Loads the file into the standard MemModel.
-     */
-    public function load() {
-        //Get the Memory Model from the ModelFactory
-        $this->model = ModelFactory::getDefaultModel();
-        
-        //Ensure the required file exists before loading
-        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'); 
+			mkdir('data/answers/');
+		$this->fileName = 'data/answers/answers.rdf';
     }
     
@@ -53,17 +31,4 @@
 	{
 		$this->load();
-		$keys = array_keys($arguments);
-		$uid = ""; $question = ""; $value = ""; 
-		if(in_array("uid", $keys))
-			$uid = 'predicates:uid \''.$arguments["uid"].'\'';
-		if(in_array("question", $keys))
-			$question = 'predicates:question_code \''.$arguments["question"].'\'';
-		if(in_array("values", $keys))
-		{
-			foreach ($arguments["values"] as $val)
-			{
-				$value = $value . 'predicates:answered \'' . $val . '\' ';
-			}
-		}
 		//Create the querystring
 		$querystring = '
@@ -77,5 +42,5 @@
 				predicates:uid ?uid ;
 				predicates:question_code ?question_code ;
-				' . $uid . $question . $value . '
+				' . $this->createArguments($arguments) . '
 			}';
 
@@ -89,12 +54,11 @@
 			foreach($results as $result)
 			{
-				$values = $this->getValues($result['?uid']->label);
-				$questionResult = $this->db->get("question", array("uid" => $result['?question_code']->label));
-				$answers[] = new Answer($result['?uid']->label, $questionResult[0], $values);
+				$questionResult = $this->db->get("question", array("code" => $result['?question_code']->label));
+				$answers[] = new Answer($result['?uid']->label, $questionResult[0], $this->getValues($result['?uid']->label));
 			}
 		}
 		return $answers;
+	}
 
-	}
 	/**
 	 * function getValues()
@@ -103,24 +67,13 @@
 	private function getValues($uid)
 	{
-		$querystring = '
-			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-			SELECT DISTINCT ?answered
-			WHERE 
-			{
-				_answer predicates:resource_type resources:answer ;
-				predicates:answered ?answered ;
-				predicates:uid \''. $uid . '\'
-		}';
-		$values = $this->model->sparqlQuery($querystring);
-		$returnArray = array();
-		if(!empty($values))
+		$result = $this->model->findRegex("[(".$uid.")]", "[(answered)]", null);
+		$iterator = $result->getStatementIterator();
+		$values = array();
+		while($iterator->hasNext())
 		{
-			foreach($values as $value)
-			{
-				$returnArray[] = $value['?answered']->label;
-			}
+			$element = $iterator->next();
+			$values[] = $element->getLabelObject();
 		}
-		return $returnArray;
+		return $values;
 	} 
 
Index: /Dev/trunk/classes/AnswerSetConnector.php
===================================================================
--- /Dev/trunk/classes/AnswerSetConnector.php	(revision 170)
+++ /Dev/trunk/classes/AnswerSetConnector.php	(revision 171)
@@ -6,7 +6,5 @@
  * @author jkraaijeveld
  */
-class AnswerSetConnector implements IConnector{
-    protected $model;
-    protected $fileName = 'data/answers/answersets.rdf';
+class AnswerSetConnector extends Connector{
     protected $db;
 
@@ -16,29 +14,8 @@
 	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 load()
-	 * Loads the file into the standard MemModel
-	 */
-	public function load()
-	{
-	    //Get the Memory Model from the ModelFactory
-        $this->model = ModelFactory::getDefaultModel();
-        
-        //Ensure the required file exists before loading
-        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'); 
 	}
 
@@ -51,20 +28,4 @@
 	{
 		$this->load();
-		
-		$keys = array_keys($arguments);
-		$uid = ""; $survey = ""; $respondent = ""; $answers = "";
-		if(in_array("uid", $keys))
-			$uid = 'predicates:uid \''.$arguments["uid"].'\' ';
-		if(in_array("survey", $keys))
-			$survey = 'predicates:for_survey \''.$arguments["survey"].'\' ';
-		if(in_array("respondent", $keys))
-			$respondent = 'predicates:by_respondent \''.$arguments["respondent"].'\' ';
-		if(in_array("answers", $keys))
-		{
-			foreach ($arguments["answers"] as $answer)
-			{
-				$answers = $answers . 'predicates:given_answer \'' . $answer . '\' ';
-			}
-		}
 
 		//Build the query string
@@ -79,7 +40,6 @@
 				predicates:for_survey ?for_survey ;
 				predicates:by_respondent ?by_respondent ;
-				' . $uid . $survey . $respondent . $answers . '
+				' . $this->createArguments($arguments) . '
 			}';
-
 		//Query the model
 		$results = $this->model->sparqlQuery($querystring);
@@ -105,25 +65,14 @@
 	private function getAnswers($uid)
 	{
-		$querystring = '
-			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE .'>
-			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE .'>
-			SELECT DISTINCT ?given_answer
-			WHERE
-			{
-				_answerset predicates:resource_type resources:answerset ;
-				predicates:given_answer ?given_answer ;
-				predicates:uid \'' . $uid . '\'
-			}';
-		$answers = $this->model->sparqlQuery($querystring);
-		$returnArray = array();
-		if(!empty($answers))
+		$result = $this->model->findRegex("[(".$uid.")]", "[(given_answer)]", null);
+		$iterator = $result->getStatementIterator();
+		$answers = array();
+		while($iterator->hasNext())
 		{
-			foreach($answers as $answer)
-			{
-				$answerR = $this->db->get("answer", array("uid" => $answer["?given_answer"]->label));
-				$returnArray[] = $answerR[0];
-			}
+			$element = $iterator->next();
+			$answersR = $this->db->get("answer", array("uid" => $element->getLabelObject()));
+			$answers[] = $answersR[0];
 		}
-		return $returnArray;
+		return $answers;
 	}
 
Index: /Dev/trunk/classes/ApplicationConnector.php
===================================================================
--- /Dev/trunk/classes/ApplicationConnector.php	(revision 170)
+++ /Dev/trunk/classes/ApplicationConnector.php	(revision 171)
@@ -11,9 +11,6 @@
  * @author jkraaijeveld
  */
-class ApplicationConnector implements IConnector{
+class ApplicationConnector extends Connector{
     
-    protected $model;
-    protected $fileName = 'data/applications/applications.rdf';
-
     /**
      * Constructor for ApplicationConnector.
@@ -21,28 +18,8 @@
     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 load()
-     * Loads the file into the standard MemModel.
-     */
-    public function load() {
-        //Get the Memory Model from the ModelFactory
-        $this->model = ModelFactory::getDefaultModel();
-        
-        //Ensure the required file exists before loading
-        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'); 
     }
     
@@ -54,17 +31,4 @@
     public function get($arguments) {
         $this->load();
-        //Determine which arguments are supplied
-        $keys = array_keys($arguments);
-        //Set default values for arguments
-        $uid = ""; $title = ""; $description = ""; $style = "";
-        //Set the arguments if they are supplied
-        if(in_array("uid", $keys))
-            $uid = "predicates:uid \"".$arguments["uid"]."\"";
-        if(in_array("title", $keys))
-            $title = 'predicates:title \''.$arguments["title"].'\'';
-        if(in_array("description", $keys))
-            $description = "predicates:description \"".$arguments["description"]."\"";
-        if(in_array("style", $keys))
-            $style = "predicates:style \"".$arguments["style"]."\"";    
 
         //Create the querystring 
@@ -80,5 +44,5 @@
 					predicates:description ?description ;
 					predicates:style ?style ; '
-                    . $uid . $title . $description . $style . ' 
+                    . $this->createArguments($arguments) . ' 
             }';
 
Index: /Dev/trunk/classes/Connector.php
===================================================================
--- /Dev/trunk/classes/Connector.php	(revision 171)
+++ /Dev/trunk/classes/Connector.php	(revision 171)
@@ -0,0 +1,85 @@
+<?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 "datetime" : $addition = "predicates:datetime '" . $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;
+
+			}
+			$argumentString = $argumentString . $addition;
+		}
+		return $argumentString;
+	}
+}
+
+
+
+?>
+
Index: /Dev/trunk/classes/QuestionConnector.php
===================================================================
--- /Dev/trunk/classes/QuestionConnector.php	(revision 170)
+++ /Dev/trunk/classes/QuestionConnector.php	(revision 171)
@@ -12,8 +12,6 @@
  * @author jkraaijeveld
  */
-class QuestionConnector implements IConnector {
+class QuestionConnector extends Connector {
     
-    protected $model;
-    protected $fileName = 'data/questions/questions.rdf';
     
     /**
@@ -22,4 +20,5 @@
     public function __construct()
     {
+		$this->fileName = 'data/questions/questions.rdf';
         //Ensure the required folder for this connector exists
         if (!is_dir('data/questions/'))
@@ -28,54 +27,11 @@
     
     /**
-     * function load()
-     * Loads the file into the standard MemModel.
-     */
-    public function load() {
-        //Get the Memory Model from the ModelFactory
-        $this->model = ModelFactory::getDefaultModel();
-        
-        //Ensure the required file exists before loading
-        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'); 
-    }
-    
-    /**
      * Get the questions corresponding to the arguments.
 	 * @param type $arguments : An array having one ore more of the following elements:
-	 * 'uid', 'title', 'type', 'description', 'category', 'has_answer'.
+	 * 'code', 'title', 'type', 'description', 'category', 'definedanswers'.
      */
     public function get($arguments)
     {
         $this->load();
-        
-        $keys = array_keys($arguments);
-        //Set default values for arguments
-        $uid = ""; $title = ""; $type = ""; $description = ""; $category = ""; $has_answer = "";
-        //Set the arguments if they are supplied
-        if(in_array("uid", $keys))
-            $uid = 'predicates:question_code \''.$arguments["uid"].'\'';
-        if(in_array("title", $keys))
-            $title = 'predicates:title \''.$arguments["title"].'\'';
-        if(in_array("type", $keys))
-            $type = 'predicates:type \''.$arguments["type"].'\'';
-        if(in_array("description", $keys))
-            $description = "predicates:description \"".$arguments["description"]."\"";
-        if(in_array("category", $keys))
-			$style = "predicates:category \"".$arguments["category"]."\"";
-		if(in_array("answers", $keys))
-		{
-			foreach($arguments["answers"] as $answer)
-			{
-				$has_answer = $has_answer . 'predicates:has_answer \'' . $answer . '\' ';
-			}
-		}
            
         $querystring = '
@@ -91,6 +47,8 @@
                 predicates:description ?description ;
                 predicates:question_category ?category ;
-				'. $uid . $title . $type . $description . $category . $has_answer . '
-            }';
+				'. $this->createArguments($arguments) . '
+	}';
+
+		
         //Create the querystring 
         $results = $this->model->sparqlQuery($querystring);
@@ -115,27 +73,15 @@
     private function getAnswers($uid)
     {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT DISTINCT ?has_answer
-            WHERE
-            {
-                 _question	predicates:resource_type	resources:question ;
-                predicates:has_answer ?has_answer ; 
-                predicates:question_code \'' . $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;
 
-        $answers = $this->model->sparqlQuery($querystring);
-        $returnArray = array();
-        if(!empty($answers))
-        {
-            foreach($answers as $answer)
-            {
-                $returnArray[] = $answer['?has_answer']->label;
-            }
-        }
-        return $returnArray;
-    }
-
+	}
     
     /**
Index: /Dev/trunk/classes/RespondentConnector.php
===================================================================
--- /Dev/trunk/classes/RespondentConnector.php	(revision 170)
+++ /Dev/trunk/classes/RespondentConnector.php	(revision 171)
@@ -10,7 +10,5 @@
  * @author jkraaijeveld
  */
-class RespondentConnector implements IConnector{
-    
-    protected $fileName = 'data/users/respondents.rdf';
+class RespondentConnector extends Connector{
     
     /**
@@ -19,26 +17,7 @@
     public function __construct()
     {
+		$this->fileName = 'data/users/respondents.rdf';
         if (!is_dir('data/users/'))
             mkdir('data/users/');	
-    }
-    
-    /**
-     * function load()
-     * Loads the file into the standard MemModel.
-     */
-    public function load() {
-        //Get the Memory Model from the ModelFactory
-        $this->model = ModelFactory::getDefaultModel();
-        //Ensure the required file exists before loading
-        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'); 
     }
     
@@ -51,15 +30,4 @@
     public function get($arguments) {
         $this->load();
-        //Determine which arguments are supplied
-        $keys = array_keys($arguments);
-        //Set default values for arguments
-        $uid = ""; $name = ""; $password = "";
-        //Set the arguments if they are supplied
-        if(in_array("uid", $keys))
-            $uid = "predicates:uid \"".$arguments["uid"]."\"";
-        if(in_array("name", $keys))
-            $name = 'predicates:name \''.$arguments["name"].'\'';
-        if(in_array("password", $keys))
-            $password = "predicates:password \"".$arguments["password"]."\"";
        
         //Create the querystring 
@@ -74,5 +42,5 @@
 					predicates:name ?name ;
 					predicates:password ?password ;
-					' . $uid . $name . $password . '
+					' . $this->createArguments($arguments) .  '
             }';
         //Query the model
Index: /Dev/trunk/classes/Session.php
===================================================================
--- /Dev/trunk/classes/Session.php	(revision 170)
+++ /Dev/trunk/classes/Session.php	(revision 171)
@@ -48,4 +48,5 @@
 			mkdir($location);
 		}
+		//Create the filename, open the file at the given location
 		$fileName = $this->datetime->format("d-m-Y") . "_" . $this->title . ".txt";
 
Index: /Dev/trunk/classes/SessionConnector.php
===================================================================
--- /Dev/trunk/classes/SessionConnector.php	(revision 170)
+++ /Dev/trunk/classes/SessionConnector.php	(revision 171)
@@ -10,8 +10,6 @@
  * @author jkraaijeveld
  */
-class SessionConnector implements IConnector
+class SessionConnector extends Connector  
 {
-	protected $model;
-	protected $fileName = 'data/sessions/sessions.rdf';
 	protected $db;
 
@@ -21,27 +19,8 @@
 	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 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);
-	}
-
-	/**
-	 * fucntion save()
-	 * Saves the MemModel into the given file.
-	 */
-	public function save()
-	{
-		$this->model->saveAs($this->fileName,'rdf');
 	}
 
@@ -54,36 +33,4 @@
 	{
 		$this->load();
-
-		$keys = array_keys($arguments);
-		$uid = ""; $title = ""; $creator = ""; $datetime = ""; $applications = ""; $surveys = ""; $answersets = "";
-		if(in_array("uid", $keys))
-			$uid = 'predicates:uid \''.$arguments["uid"].'\' ';
-		if(in_array("title", $keys))
-			$title = 'predicates:title \''.$arguments["title"].'\' ';
-		if(in_array("creator", $keys))
-			$creator = 'predicates:creator \''.$arguments["creator"].'\' ';
-		if(in_array("datetime", $keys))
-			$datetime = 'predicates:datetime \''.$arguments["datetime"].'\' ';
-		if(in_array("applications", $keys))
-		{
-			foreach($arguments["applications"] as $application)
-			{
-				$applications = $applications . 'predicates:has_application \'' . $application . '\' ';
-			}
-		}
-		if(in_array("surveys", $keys))
-		{
-			foreach($arguments["surveys"] as $survey)
-			{
-				$surveys = $surveys . 'predicates:has_survey \'' . $survey . '\' ';
-			}
-		}
-		if(in_array("answersets", $keys))
-		{
-			foreach($arguments["answersets"] as $answerset)
-			{
-				$answersets = $answersets . 'predicates:has_answerset \'' . $answerset . '\' ';
-			}
-		}
 	
 		//Build the query string
@@ -99,6 +46,7 @@
 				predicates:creator ?creator ;
 				predicates:datetime ?datetime ;
-				' . $uid . $title . $creator . $datetime . $applications . $surveys . $answersets . '
+				' . $this->createArguments($arguments) . '
 			}';
+		echo $querystring;
 		//Query the model
 		$results = $this->model->sparqlQuery($querystring);
Index: /Dev/trunk/classes/SurveyConnector.php
===================================================================
--- /Dev/trunk/classes/SurveyConnector.php	(revision 170)
+++ /Dev/trunk/classes/SurveyConnector.php	(revision 171)
@@ -6,7 +6,5 @@
  * @author jkraaijeveld
  */
-class SurveyConnector implements IConnector{
-    protected $model;
-    protected $fileName = 'data/surveys/surveys.rdf';
+class SurveyConnector extends Connector{
     protected $db;
 
@@ -16,28 +14,8 @@
     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 load()
-     * Loads the file into the standard MemModel.
-     */
-    public function load() {
-        //Get the Memory Model from the ModelFactory
-        $this->model = ModelFactory::getDefaultModel();
-        
-        //Ensure the required file exists before loading
-        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'); 
     }
     
@@ -53,24 +31,4 @@
         $this->load();
         
-        $keys = array_keys($arguments);
-        //Set default values for arguments
-        $uid = ""; $title = ""; $description = ""; $creator = ""; $questions = "";
-        if(in_array("uid", $keys))
-            $uid = 'predicates:uid \''.$arguments["uid"].'\'';
-        if(in_array("title", $keys))
-            $title = 'predicates:title \''.$arguments["title"].'\'';
-        if(in_array("description", $keys))
-			$description = "predicates:description \"".$arguments["description"]."\"";
-		if(in_array("creator", $keys))
-			$creator = "predicates:creator \"".$arguments["creator"]."\"";
-        if(in_array("questions", $keys))
-        {
-            //Append the questions string to filter for questions properly
-            foreach ($arguments["questions"] as $questionUid)
-            {
-                $questions = $questions . 'predicates:has_question \'' . $questionUid . '\' ';
-            }
-        }
-        
         //Build the query string
         $querystring = '
@@ -85,5 +43,5 @@
 				predicates:description ?description ;
 				predicates:creator ?creator ;
-				' . $uid . $title . $description . $creator . $questions . '
+				' . $this->createArguments($arguments) . '
             }';
         
@@ -112,28 +70,14 @@
     private function getQuestions($uid)
     {
-        //Create the querystring. Note that the UID is the only argument in this case.
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT DISTINCT ?has_question
-            WHERE
-            {
-                 _survey	predicates:resource_type	resources:survey ;
-                predicates:has_question ?has_question ; 
-                predicates:uid \'' . $uid . '\'
-            }';
-
-        $results = $this->model->sparqlQuery($querystring);
-        $questions = array();
-        //For every question id, get the corresponding question
-        if(!empty($results))
-        {
-            foreach($results as $questionId)
-            {
-                $resultQ = $this->db->get("question", array("uid" => $questionId['?has_question']->label));
-                $questions[] = $resultQ[0];
-            }
-        }
-        return $questions;
+		$result = $this->model->findRegex("[(".$uid.")]", "[(has_question)]", null);
+		$iterator = $result->getStatementIterator();
+		$questions = array();
+		while($iterator->hasNext())
+		{
+			$element = $iterator->next();
+			$result = $this->db->get("question", array("code" => $element->getLabelObject()));
+			$questions[] = $result[0];
+		}
+		return $questions;
     }
     
Index: /Dev/trunk/classes/UserConnector.php
===================================================================
--- /Dev/trunk/classes/UserConnector.php	(revision 170)
+++ /Dev/trunk/classes/UserConnector.php	(revision 171)
@@ -10,37 +10,15 @@
  * @author jkraaijeveld
  */
-class UserConnector implements IConnector{
-    
-    protected $model;
-    protected $fileName = 'data/users/users.rdf';
+class UserConnector extends Connector{
     
     /**
-     * Constructor for RespondentConnector.
+     * 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 load()
-     * Loads the file into the standard MemModel.
-     */
-    public function load() {
-        //Get the Memory Model from the ModelFactory
-        $this->model = ModelFactory::getDefaultModel();
-        //Ensure the required file exists before loading
-        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'); 
     }
     
@@ -53,16 +31,4 @@
     public function get($arguments) {
         $this->load();
-        //Determine which arguments are supplied
-        $keys = array_keys($arguments);
-        //Set default values for arguments
-        $uid = ""; $name = ""; $password = "";
-        //Set the arguments if they are supplied
-        if(in_array("uid", $keys))
-            $uid = "predicates:uid \"".$arguments["uid"]."\"";
-        if(in_array("name", $keys))
-            $name = 'predicates:name \''.$arguments["name"].'\'';
-        if(in_array("password", $keys))
-            $password = "predicates:password \"".$arguments["password"]."\"";
-       
         //Create the querystring 
         $querystring = '
@@ -76,8 +42,8 @@
 					predicates:name ?name ;
 					predicates:password ?password ;
-					' . $uid . $name . $password . '
+					' . $this->createArguments($arguments) . '
             }';
         //Query the model
-        $results = $this->model->sparqlQuery($querystring);
+		$results = $this->model->sparqlQuery($querystring);
         $users = array();
         if(!empty($results))
