Index: Dev/trunk/classes/Application.php
===================================================================
--- Dev/trunk/classes/Application.php	(revision 75)
+++ Dev/trunk/classes/Application.php	(revision 78)
@@ -7,12 +7,16 @@
  */
 class Application {
+    
+    public $id;
     public $title;
     public $description;
     public $style;
 
-    public function __construct($title = null, $description = null, $style = null) {
+    public function __construct($id = null, $title = null, $description = null, $style = null) 
+    {
+        $this->id = $id;
         $this->title = $title;
-		$this->description = $description;
-		$this->style = $style;
+        $this->description = $description;
+	$this->style = $style;
     }
 
Index: Dev/trunk/classes/ApplicationDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/ApplicationDatabaseInterface.php	(revision 75)
+++ Dev/trunk/classes/ApplicationDatabaseInterface.php	(revision 78)
@@ -15,7 +15,12 @@
 
 
-    public function __construct()
-    {					
-        $this->applicationRDFWriter = new ApplicationRDFWriter();
+    public function __construct($applicationID)
+    {		
+        if($applicationID == null)
+            $applicationUID = md5( uniqid(rand(), true) );
+        else
+            $applicationUID = $applicationID;
+			
+        $this->applicationRDFWriter = new ApplicationRDFWriter($applicationUID);
         $this->applicationRDFReader = new ApplicationRDFReader();
     }
@@ -25,5 +30,5 @@
         $appTitle = $application['applicationTitle'];
         $appDescription = $application['applicationDescription'];
-        $appStyle	= $application['applicationStyle'];
+        $appStyle = $application['applicationStyle'];
 
         $this->applicationRDFWriter->setApplicationInfo($appTitle, $appDescription, $appStyle);
@@ -54,6 +59,6 @@
         for($aNumber = 0;$aNumber<=sizeof($resultApplication[0]);$aNumber++)
         {
-            $aID = substr($resultSurvey[0][$aNumber]['?uid'],9,strlen($resultSurvey[0][$aNumber]['?uid'])-11);
-            $aTitle = substr($resultSurvey[1][$aNumber]['?title'],9,strlen($resultSurvey[0][$aNumber]['?title'])-11);
+            $aID = substr($resultApplication[0][$aNumber]['?uid'],9,strlen($resultApplication[0][$aNumber]['?uid'])-11);
+            $aTitle = substr($resultApplication[1][$aNumber]['?title'],9,strlen($resultApplication[0][$aNumber]['?title'])-11);
             $applicationInfo[$aID] = $aTitle;
         }		
Index: Dev/trunk/classes/ApplicationMenu.php
===================================================================
--- Dev/trunk/classes/ApplicationMenu.php	(revision 75)
+++ Dev/trunk/classes/ApplicationMenu.php	(revision 78)
@@ -8,5 +8,5 @@
 class ApplicationMenu extends Menu {
 
-    public function __construct() {
+    public function __construct($applications) {
         ?><fieldset class="menu"><?php
         parent::__construct('Application');
@@ -15,5 +15,5 @@
         ApplicationMenu::loadApplicationButton();
         ?> </div> <?php
-        ApplicationMenu::loadApplicationList(null);
+        ApplicationMenu::loadApplicationList($applications);
         ?></fieldset><?php
     }
@@ -51,5 +51,5 @@
             if (!empty($applications)) {
                 foreach ($applications as $application) {
-                    ?><option value='<?php echo $application->id; ?>'><?php echo $application->name; ?></option><?php
+                    ?><option value='<?php echo $application->id; ?>'><?php echo $application->title; ?></option><?php
             }
         }
Index: Dev/trunk/classes/ApplicationRDFReader.php
===================================================================
--- Dev/trunk/classes/ApplicationRDFReader.php	(revision 75)
+++ Dev/trunk/classes/ApplicationRDFReader.php	(revision 78)
@@ -28,5 +28,5 @@
                                         predicates:uid			"' . $applicationID . '"	;
                                         predicates:title 		?title 	;
-                                        prdeicates:description		?description	;
+                                        predicates:description		?description	;
                                         predicates:style		?style
             }';
@@ -45,5 +45,5 @@
         $result[] = $this->readApplicationStyles();
 
-        return $restult;
+        return $result;
     }
 
@@ -91,5 +91,5 @@
             {
                     _application	predicates:resource_type	resources:application ;
-                                        prdeicates:description		?description	
+                                        predicates:description		?description	
             }';
 
Index: Dev/trunk/classes/Loader.php
===================================================================
--- Dev/trunk/classes/Loader.php	(revision 75)
+++ Dev/trunk/classes/Loader.php	(revision 78)
@@ -25,4 +25,34 @@
         return $surveys;
     }
+    
+    public static function loadApplications()
+    {
+        $applications = array();
+        
+        $applicationDBI = new ApplicationDatabaseInterface(null);
+        $applicationTitles = $applicationDBI->getExistingApplications();
+        
+        foreach ($applicationTitles as $id => $title) {
+            $application = new Application($id, $title);
+            array_push($applications, $application);
+        }
+        
+        return $applications;
+    }
+    
+    public static function loadSessions()
+    {
+        $sessions = array();
+        
+        $sessionDBI = new SessionDatabaseInterface(null);
+        $sessionTitles = $sessionDBI->getExistingSessions();
+        
+        foreach ($sessionIDTitles as $id => $title) {
+            $session = new Application($id, $title);
+            array_push($sessions, $session);
+        }
+        
+        return $sessions;
+    }
 
 }
Index: Dev/trunk/classes/SessionDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/SessionDatabaseInterface.php	(revision 78)
+++ Dev/trunk/classes/SessionDatabaseInterface.php	(revision 78)
@@ -0,0 +1,74 @@
+<?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");
+
+
+
+class SessionDatabaseInterface
+{		
+    protected $sessionRDFWriter;
+    protected $sessionRDFReader;
+
+
+    public function __construct($sessionID)
+    {
+        if($sessionID == null)
+            $sessionUID = md5( uniqid(rand(), true) );
+        else
+            $sessionUID = $sessionID;
+
+        $this->sessionRDFWriter = new SessionRDFWriter($surveyUID);
+        $this->sessionRDFReader = new SessionRDFReader($surveyUID);
+    }
+    
+    public function setSessionInfo($session)
+    {
+        $sTitle = $session['sessionTitle'];
+        $sDescription = $session['sessionDescription'];
+
+        $this->sessionRDFWriter->createSession($sTitle,$sDescription);
+        
+        $pipelineCount = $session['pipelineCount'];
+        
+        for($i = 1; $i <= $pipelineCount; $i++)
+        {
+            if(isset($session[$i.'s']))
+            {
+                $this->sessionRDFWriter->addSurveyToPipeline($session[$i.'s'], $i);
+            }
+            else if(isset($session[$i.'a']))
+            {
+                $this->sessionRDFWriter->addApplicationToPipeline($session[$i.'a'], $i);
+            }
+            else if(isset($session[$i.'d'])) 
+            {
+                $this->sessionRDFWriter->addDashboardToPipeline($session[$i.'d'], $i);
+            }
+        }
+    }
+    
+    public function getSessionInfo()
+    {
+        $sessionInfo = array();
+
+        $resultSession = $this->sessionRDFReader->getSurveyInfo();
+        
+        $sessionInfo['sessionTitle'] = substr($resultSession[0][0]['?title'],9,strlen($resultSession[0][0]['?title'])-11);
+        $sessionInfo['sessionDescription'] = substr($resultSession[0][0]['?description'],9,strlen($resultSession[0][0]['?description'])-11);
+        
+        foreach ($resultSession[1][1] as $surveyInfo) 
+         {
+            
+        }
+    }
+    
+    public function getExistingSessions()
+    {
+        
+    }
+}
+?>
Index: Dev/trunk/classes/SessionRDFReader.php
===================================================================
--- Dev/trunk/classes/SessionRDFReader.php	(revision 78)
+++ Dev/trunk/classes/SessionRDFReader.php	(revision 78)
@@ -0,0 +1,116 @@
+<?php
+
+class SessionRDFReader
+{
+    protected $model;
+
+    protected $sessionUID;
+    protected $filePath;
+
+    public function __construct($sessionUID)
+    {
+        // Create empty MemModel
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+
+        $this->sessionUID = $sessionUID;
+        $this->filePath = 'data/sessions/session_'.$this->surveyUID.'.rdf';
+    }
+
+    public function loadSurvey()
+    {
+        $this->model->load($this->filePath);
+    }
+    
+    public function getSessionInfo()
+    {        
+        $results[] = $this->readSessionInfo();
+        $results[] = $this->getPipeline();
+        
+        return $results;
+    }
+    
+    public function readSessionInfo()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?uid ?title ?description ?creator
+            WHERE 	
+            {
+                    _session	predicates:resource_type	resources:session ;
+                                predicates:uid			?uid	;
+                                predicates:title 		?title 	;
+                                predicates:description		?description 
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+    
+    public function getPipeline()
+    {
+        $results[] = $this->readSurveys();
+        $results[] = $this->readApplications();
+        $results[] = $this->readDashboards();
+        
+        return $results;
+    }
+    
+    public function readSurveys()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT DISTINCT ?uid ?index
+            WHERE 	
+            {
+                    _survey	predicates:resource_type	resources:survey ;
+                                predicates:uid			?uid	;
+                                predicates:index		?index 
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+    
+    public function readApplications()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT DISTINCT ?uid ?index
+            WHERE 	
+            {
+                    _application	predicates:resource_type	resources:application ;
+                                predicates:uid			?uid	;
+                                predicates:index		?index 
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+    
+    public function readDashboards()
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT DISTINCT ?uid ?index
+            WHERE 	
+            {
+                    _dashboard	predicates:resource_type	resources:dashboard ;
+                                predicates:uid			?uid	;
+                                predicates:index		?index 
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+}
+
+?>
Index: Dev/trunk/classes/SessionRDFWriter.php
===================================================================
--- Dev/trunk/classes/SessionRDFWriter.php	(revision 78)
+++ Dev/trunk/classes/SessionRDFWriter.php	(revision 78)
@@ -0,0 +1,98 @@
+<?php
+
+class SessionRDFWriter 
+{
+    protected $model;
+
+    protected $sessionUID;
+    protected $resourceSession;
+            
+    protected $filePath;
+
+    public function __construct($sessionUID)
+    {
+        // Create empty MemModel
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+
+        $this->sessionUID = $sessionUID;	
+        $this->filePath = 'data/sessions/';
+        if (!is_dir($this->filePath))
+            mkdir($this->filePath);	
+    }
+    
+    public function saveAs()
+    {
+        $this->model->saveAs($this->filePath.
+                'session_' . $this->surveyUID . '/.' . 
+                $this->surveyUID  .'.rdf',
+                'rdf');
+    }
+    
+    public function createSession($sTitle,$sDescription)
+    {
+        $this->resourceSession = new Resource(SESSION.'/'.$this->sessionUID);
+
+        $resourceSessionType = new Resource(SESSION);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($this->resourceSession,$predicateRType,$resourceSessionType));
+
+        $literalSessionID = new Literal($this->sessionUID);
+        $predicateUniqueID = new Resource(UID);
+        $this->model->add(new Statement($this->resourceSession,$predicateUniqueID,$literalSessionID));
+
+        $predicateTitle = new Resource(TITLE);		
+        $sessionTitle = new Literal($sTitle);
+        $this->model->add(new Statement($this->resourceSession,$predicateTitle,$sessionTitle));		
+
+        $predicateDescription = new Resource(DESCRIPTION);
+        $sessionDescription = new Literal($sDescription);
+        $this->model->add(new Statement($this->resourceSession,$predicateDescription,$sessionDescription));
+    }
+    
+    public function addSurveyToPipeline($uid,$index)
+    {
+        $resourceSurvey = new Resource(SURVEY);
+        $predicateHasProcess = new Resource(HAS_PROCESS);
+        $this->model->add(new Statement($this->resourceSession,$predicateHasProcess,$resourceSurvey));
+        
+        $literalSurveyID = new Literal($uid);
+        $predicateUID = new Resource(UID);
+        $this->model->add(new Statement($$resourceSurvey,$predicateUID,$literalSurveyID));        
+        
+        $literalIndex = new Literal($index);
+        $predicateIndex = new Resource(INDEX);        
+        $this->model->add(new Statement($resourceSurvey,$predicateIndex,$literalIndex));
+    }
+    
+    public function addApplicationToPipeline($uid,$index)
+    {
+        $resourceApplication = new Resource(APPLICATION);
+        $predicateHasProcess = new Resource(HAS_PROCESS);
+        $this->model->add(new Statement($this->resourceSession,$predicateHasProcess,$resourceApplication));
+        
+        $literalApplicationID = new Literal($uid,$index);
+        $predicateUID = new Resource(UID);
+        $this->model->add(new Statement($resourceApplication,$predicateUID,$literalApplicationID));        
+        
+        $literalIndex = new Literal($index);
+        $predicateIndex = new Resource(INDEX);        
+        $this->model->add(new Statement($resourceApplication,$predicateIndex,$literalIndex));
+    }
+    
+    public function addDashboardToPipeline($uid,$index)
+    {
+        $resourceDashboard = new Resource(DASHBOARD);
+        $predicateHasProcess = new Resource(HAS_PROCESS);
+        $this->model->add(new Statement($this->resourceSession,$predicateHasProcess,$resourceDashboard));
+        
+        $literalDashboardID = new Literal($uid);
+        $predicateUID = new Resource(UID);
+        $this->model->add(new Statement($resourceDashboard,$predicateUID,$literalDashboardID));        
+        
+        $literalIndex = new Literal($index);
+        $predicateIndex = new Resource(INDEX);        
+        $this->model->add(new Statement($resourceDashboard,$predicateIndex,$literalIndex));
+    }
+}
+?>
Index: Dev/trunk/classes/SurveyRDFReader.php
===================================================================
--- Dev/trunk/classes/SurveyRDFReader.php	(revision 75)
+++ Dev/trunk/classes/SurveyRDFReader.php	(revision 78)
@@ -20,5 +20,5 @@
     public function loadSurvey()
     {
-     $this->model->load($this->filePath);
+        $this->model->load($this->filePath);
     }
 
