Index: Dev/branches/jos-branch/server/classes/models/ApplicationInstance.php
===================================================================
--- Dev/branches/jos-branch/server/classes/models/ApplicationInstance.php	(revision 286)
+++ Dev/branches/jos-branch/server/classes/models/ApplicationInstance.php	(revision 287)
@@ -32,5 +32,5 @@
 	 * @param type $periodicresults: Periodical results from playing.
 	 */
-	public function __construct($uid = null, $application = null, $starttime = null, $endtime = null, $open = false, $playerresults = null, $groupresults = null, $periodicresults = null)
+	public function __construct($uid = null, $application = null, $starttime = null, $endtime = null, $open = 0, $playerresults = null, $groupresults = null, $periodicresults = null)
 	{
 		if(!isset($uid))
@@ -56,5 +56,6 @@
 		if(is_string($this->application))
 		{
-			$result = Application::get(array("uid" => $this->application));
+			$app = ResearchToolObject::stripUri($this->application);
+			$result = Application::get(array("uid" => $app["uid"]));
 			if(!isset($result[0]))
 				return false;
@@ -96,5 +97,5 @@
 		$model->add(new Statement($resourceAI, $predicateUid, $AIUid));
 
-		$AIApplication = new Literal($this->application->uid);
+		$AIApplication = new Resource(APPLICATION . '/' . $this->application->uid);
 		$predicateApplication = new Resource(OF_APPLICATION);
 		$model->add(new Statement($resourceAI, $predicateApplication, $AIApplication));
@@ -108,5 +109,5 @@
 		$model->add(new Statement($resourceAI, $predicateEndTime, $AIEndTime));
 
-		$AIOpen = new Literal($this->open);
+		$AIOpen = new Literal((bool)$this->open);
 		$predicateOpen = new Resource(OPEN);
 		$model->add(new Statement($resourceAI, $predicateOpen, $AIOpen));
@@ -127,4 +128,5 @@
 	{
 		$model = ResearchToolObject::load(ApplicationInstance::$filename);
+		$model->writeAsHTMLTable();
 
 		//Build the query string
@@ -135,5 +137,5 @@
 			WHERE
 			{
-				_applicationinstance	predicates:resource_type	resources:applicationinstance ;
+				?applicationinstance	predicates:resource_type	resources:applicationinstance ;
 				predicates:uid ?uid ;
 				predicates:of_application ?of_application ;
@@ -141,9 +143,8 @@
 				predicates:endtime ?endtime ;
 				predicates:open ?open ;
-				' . ResearchToolObject::createArguments($arguments) . '
-			}';
+			' . ResearchToolObject::createArguments($arguments) . '
+	}';
 		//Query the model
 		$results = $model->sparqlQuery($querystring);
-
 		//Create the corresponding ApplicationInstance objects
 		$aInstances = array();
@@ -156,9 +157,6 @@
 				$endTime = new DateTime();
 				$endTime->setTimestamp(intval($result['?endtime']->label));
-				$open = false;
-				if ($result['?open'] == 'true')
-					$open = true;
-
-				$aInstances[] = new ApplicationInstance($result['?uid']->label, $result['?of_application']->label, $startTime, $endTime, $open, null, null, null); 
+				$open = (bool) $result['?open'];
+				$aInstances[] = new ApplicationInstance($result['?uid']->label, $result['?of_application']->uri, $startTime, $endTime, $open, null, null, null); 
 			}
 		}
Index: Dev/branches/jos-branch/server/classes/models/ResearchToolObject.php
===================================================================
--- Dev/branches/jos-branch/server/classes/models/ResearchToolObject.php	(revision 286)
+++ Dev/branches/jos-branch/server/classes/models/ResearchToolObject.php	(revision 287)
@@ -30,4 +30,18 @@
 			$model->load($filename);
 		return $model;
+	}
+
+	/**
+	 * function stripUri($inString)
+	 * @param type $inString
+	 * Takes a URI and creates a new array which contains the type and the uid of the object
+	 */
+	public static function stripUri($inString)
+	{
+		$exp = explode('/', $inString);
+		if(sizeof($exp) < 7)
+			return null;
+		else
+			return array("type" => $exp[5], "uid" => $exp[6]);
 	}
 
@@ -67,11 +81,11 @@
 				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 = "predicates:has_resultset '" . $arguments[$key] . "\n"; break;
-				case "of_application" : $addition = "predicates:of_application '" . $arguments[$key] . "\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 = "predicates:has_resultset '" . $arguments[$key] . "'\n"; break;
+				case "of_application" : $addition = "predicates:of_application <" . APPLICATION . '/' .  $arguments[$key] . ">\n"; break;
 				case "open" : $addition = "predicates:open '" . $arguments[$key] . "\n"; break;
 			}
