Index: Dev/trunk/classes/SurveyConnector.php
===================================================================
--- Dev/trunk/classes/SurveyConnector.php	(revision 158)
+++ 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;
     }
     
