Index: Dev/branches/jos-branch/classes/DatabaseInterface.php
===================================================================
--- Dev/branches/jos-branch/classes/DatabaseInterface.php	(revision 143)
+++ Dev/branches/jos-branch/classes/DatabaseInterface.php	(revision 148)
@@ -47,5 +47,5 @@
      * @return type 
      */
-    public function get($type, $arguments)
+    public function get($type, $arguments = array())
     {
         switch(strtolower($type))
@@ -71,7 +71,8 @@
 			case "answerset":
 				return $this->answerSetConnector->get($arguments);
+				break;
 			case "session":
 				return $this->sessionConnector->get($arguments);
-
+				break;
         }
     }
@@ -109,5 +110,4 @@
 				$this->sessionConnector->set($rToolObject);
 				break;
-
         }
     }
Index: Dev/branches/jos-branch/classes/SessionConnector.php
===================================================================
--- Dev/branches/jos-branch/classes/SessionConnector.php	(revision 143)
+++ Dev/branches/jos-branch/classes/SessionConnector.php	(revision 148)
@@ -1,3 +1,8 @@
 <?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
@@ -103,4 +108,5 @@
 			foreach($results as $result)
 			{
+				//Create a session object out of every result, get all required fields as well.
 				$pipeline = $this->getPipeline($result['?uid']->label);
 				$answersets = $this->getAnswerSets($result['?uid']->label);
@@ -118,20 +124,22 @@
 	private function getPipeline($uid)
 	{
-		$querystring = '
-			PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE .'>
-			PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE .'>
-			SELECT DISTINCT ?object 
-			WHERE
-			{
-				_session predicates:resource_type resources:session .
-				?x predicates:uid \'' . $uid . '\' .
-				{ ?x predicates:has_application ?object .}
-				UNION
-				{ ?x predicates:has_survey ?object .}
-
-			
-		}';	
-		$result = $this->model->sparqlQuery($querystring);
-		print_r($result);
+		$result = $this->model->findRegex("[(".$uid.")]", "[(has_application)|(has_survey)]" ,null);
+		$iterator = $result->getStatementIterator();
+		$pipeline = array();
+		while($iterator->hasNext())
+		{
+			$element = $iterator->next();
+			if(strpos($element->getLabelPredicate(), "has_application") != false)
+			{
+				$applications = $this->db->get("application", array("uid" => $element->getLabelObject()));
+				$pipeline[] = $applications[0];
+			}
+			else
+			{
+				$surveys = $this->db->get("survey", array("uid" => $element->getLabelObject()));
+				$pipeline[] = $surveys[0];
+			}
+		}
+		return $pipeline;
 	}
 
@@ -142,4 +150,14 @@
 	private function getAnswerSets($uid)
 	{
+		$result = $this->model->findRegex("[(".$uid.")]", "[(has_answerset)]" ,null);
+		$iterator = $result->getStatementIterator();
+		$answersets = array();
+		while($iterator->hasNext())
+		{
+			$element = $iterator->next();
+			$resultsets = $this->db->get("answerset", array("uid" => $element->getLabelObject()));
+			$answersets[] = $resultsets[0];
+		}
+		return $answersets;
 	}
 
@@ -172,4 +190,5 @@
 		$this->model->add(new Statement($resourceSession, $predicateTimestamp, $sessionTimestamp));
 
+		//Create a sequence to store the different applications and surveys.
 		if(isset($rToolObject->pipeline))
 		{
@@ -187,5 +206,5 @@
 		}
 
-		if(isset($rToolObjects->answerSets))
+		if(isset($rToolObject->answersets))
 		{
 			foreach($rToolObject->answersets as $answerset)
@@ -199,7 +218,4 @@
 		$this->save();
 	}
-
-
-
 }
 ?>
Index: Dev/branches/jos-branch/classes/Survey.php
===================================================================
--- Dev/branches/jos-branch/classes/Survey.php	(revision 143)
+++ Dev/branches/jos-branch/classes/Survey.php	(revision 148)
@@ -12,5 +12,5 @@
     public $questions;
     
-    public function __construct($uid = null, $title = null, $description = null, $questions = null) {
+    public function __construct($uid = null, $title = null, $description = null, $creator = null, $questions = null) {
         if(!isset($uid))
         {
@@ -19,5 +19,6 @@
         $this->uid = $uid;
         $this->title = $title;
-        $this->description = $description;
+		$this->description = $description;
+		$this->creator = $creator;
         $this->questions = $questions;
     }
Index: Dev/branches/jos-branch/classes/SurveyConnector.php
===================================================================
--- Dev/branches/jos-branch/classes/SurveyConnector.php	(revision 143)
+++ Dev/branches/jos-branch/classes/SurveyConnector.php	(revision 148)
@@ -55,5 +55,5 @@
         $keys = array_keys($arguments);
         //Set default values for arguments
-        $uid = "?uid"; $title = "?title"; $description = "?description"; $questions = "";
+        $uid = "?uid"; $title = "?title"; $description = "?description"; $creator = "?creator"; $questions = "";
         if(in_array("uid", $keys))
             $uid = '\''.$arguments["uid"].'\'';
@@ -61,5 +61,7 @@
             $title = '\''.$arguments["title"].'\'';
         if(in_array("description", $keys))
-            $description = "\"".$arguments["description"]."\"";
+			$description = "\"".$arguments["description"]."\"";
+		if(in_array("creator", $keys))
+			$creator = "\"".$arguments["creator"]."\"";
         if(in_array("questions", $keys))
         {
@@ -75,5 +77,5 @@
             PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
             PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT DISTINCT ?uid, ?title, ?description
+            SELECT DISTINCT ?uid, ?title, ?description, ?creator
             WHERE
             {
@@ -84,5 +86,6 @@
                 predicates:uid ' . $uid . ' 
                 predicates:title ' . $title . '
-                predicates:description ' . $description . '
+				predicates:description ' . $description . '
+				predicates:creator ' . $creator . '
                 ' . $questions . '
             }';
@@ -95,8 +98,10 @@
         if(!empty($results))
         {
+            $this->db = new DatabaseInterface();
             foreach($results as $result)
             {
-                $questions = $this->getQuestions($result['?uid']->label);
-                $surveys[] = new Survey($result['?uid']->label, $result['?title']->label, $result['?description']->label, $questions);
+				$questions = $this->getQuestions($result['?uid']->label);
+				$creator = $this->db->get("user", array("uid" => $result['?creator']->label));
+                $surveys[] = new Survey($result['?uid']->label, $result['?title']->label, $result['?description']->label, $creator[0], $questions);
             }
         }
@@ -127,5 +132,4 @@
         if(!empty($results))
         {
-            $this->db = new DatabaseInterface();
             foreach($results as $questionId)
             {
@@ -165,4 +169,8 @@
         $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))
         {
Index: Dev/branches/jos-branch/classes/UserConnector.php
===================================================================
--- Dev/branches/jos-branch/classes/UserConnector.php	(revision 143)
+++ Dev/branches/jos-branch/classes/UserConnector.php	(revision 148)
@@ -81,5 +81,4 @@
 					predicates:password ' . $password . ' 
             }';
-        echo $querystring;
         //Query the model
         $results = $this->model->sparqlQuery($querystring);
