Changeset 289 for Dev/branches/rest-dojo-ui/server/classes
- Timestamp:
- 02/24/12 16:17:56 (13 years ago)
- Location:
- Dev/branches/rest-dojo-ui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui
- Property svn:mergeinfo changed
/Dev/branches/jos-branch merged: 285-287
- Property svn:mergeinfo changed
-
Dev/branches/rest-dojo-ui/server/classes/models/ApplicationInstance.php
r274 r289 32 32 * @param type $periodicresults: Periodical results from playing. 33 33 */ 34 public function __construct($uid = null, $application = null, $starttime = null, $endtime = null, $open = false, $playerresults = null, $groupresults = null, $periodicresults = null)34 public function __construct($uid = null, $application = null, $starttime = null, $endtime = null, $open = 0, $playerresults = null, $groupresults = null, $periodicresults = null) 35 35 { 36 36 if(!isset($uid)) … … 56 56 if(is_string($this->application)) 57 57 { 58 $result = Application::get(array("uid" => $this->application)); 58 $app = ResearchToolObject::stripUri($this->application); 59 $result = Application::get(array("uid" => $app["uid"])); 59 60 if(!isset($result[0])) 60 61 return false; … … 96 97 $model->add(new Statement($resourceAI, $predicateUid, $AIUid)); 97 98 98 $AIApplication = new Literal($this->application->uid);99 $AIApplication = new Resource(APPLICATION . '/' . $this->application->uid); 99 100 $predicateApplication = new Resource(OF_APPLICATION); 100 101 $model->add(new Statement($resourceAI, $predicateApplication, $AIApplication)); … … 108 109 $model->add(new Statement($resourceAI, $predicateEndTime, $AIEndTime)); 109 110 110 $AIOpen = new Literal( $this->open);111 $AIOpen = new Literal((bool)$this->open); 111 112 $predicateOpen = new Resource(OPEN); 112 113 $model->add(new Statement($resourceAI, $predicateOpen, $AIOpen)); … … 127 128 { 128 129 $model = ResearchToolObject::load(ApplicationInstance::$filename); 130 $model->writeAsHTMLTable(); 129 131 130 132 //Build the query string … … 135 137 WHERE 136 138 { 137 _applicationinstance predicates:resource_type resources:applicationinstance ;139 ?applicationinstance predicates:resource_type resources:applicationinstance ; 138 140 predicates:uid ?uid ; 139 141 predicates:of_application ?of_application ; … … 141 143 predicates:endtime ?endtime ; 142 144 predicates:open ?open ; 143 144 145 ' . ResearchToolObject::createArguments($arguments) . ' 146 }'; 145 147 //Query the model 146 148 $results = $model->sparqlQuery($querystring); 147 148 149 //Create the corresponding ApplicationInstance objects 149 150 $aInstances = array(); … … 156 157 $endTime = new DateTime(); 157 158 $endTime->setTimestamp(intval($result['?endtime']->label)); 158 $open = false; 159 if ($result['?open'] == 'true') 160 $open = true; 161 162 $aInstances[] = new ApplicationInstance($result['?uid']->label, $result['?of_application']->label, $startTime, $endTime, $open, null, null, null); 159 $open = (bool) $result['?open']; 160 $aInstances[] = new ApplicationInstance($result['?uid']->label, $result['?of_application']->uri, $startTime, $endTime, $open, null, null, null); 163 161 } 164 162 } -
Dev/branches/rest-dojo-ui/server/classes/models/ResearchToolObject.php
r274 r289 30 30 $model->load($filename); 31 31 return $model; 32 } 33 34 /** 35 * function stripUri($inString) 36 * @param type $inString 37 * Takes a URI and creates a new array which contains the type and the uid of the object 38 */ 39 public static function stripUri($inString) 40 { 41 $exp = explode('/', $inString); 42 if(sizeof($exp) < 7) 43 return null; 44 else 45 return array("type" => $exp[5], "uid" => $exp[6]); 32 46 } 33 47 … … 67 81 case "answersets" : foreach($arguments[$key] as $answerset) { $addition = $addition . "predicates:has_answerset '" . $answerset . "'\n"; } break; 68 82 case "questions" : foreach($arguments[$key] as $question) { $addition = $addition . "predicates:has_question '" . $question . "'\n"; } break; 69 case "location" : $addition = "predicates:location '" . $arguments[$key] . " \n"; break;70 case "facilitator" : $addition = "predicates:facilitator '" . $arguments[$key] . " \n"; break;71 case "starttime" : $addition = "predicates:starttime '" . $arguments[$key] . " \n"; break;72 case "endtime" : $addition = "predicates:endtime '" . $arguments[$key] . " \n"; break;73 case "session" : $addition = "predicates:of_session '" . $arguments[$key] . " \n"; break;74 case "resultset" : $addition = "predicates:has_resultset '" . $arguments[$key] . " \n"; break;75 case "of_application" : $addition = "predicates:of_application '" . $arguments[$key] . "\n"; break;83 case "location" : $addition = "predicates:location '" . $arguments[$key] . "'\n"; break; 84 case "facilitator" : $addition = "predicates:facilitator '" . $arguments[$key] . "'\n"; break; 85 case "starttime" : $addition = "predicates:starttime '" . $arguments[$key] . "'\n"; break; 86 case "endtime" : $addition = "predicates:endtime '" . $arguments[$key] . "'\n"; break; 87 case "session" : $addition = "predicates:of_session '" . $arguments[$key] . "'\n"; break; 88 case "resultset" : $addition = "predicates:has_resultset '" . $arguments[$key] . "'\n"; break; 89 case "of_application" : $addition = "predicates:of_application <" . APPLICATION . '/' . $arguments[$key] . ">\n"; break; 76 90 case "open" : $addition = "predicates:open '" . $arguments[$key] . "\n"; break; 77 91 } -
Dev/branches/rest-dojo-ui/server/classes/models/SurveyInstance.php
r274 r289 26 26 * @param type $answersets: A list of answersets. 27 27 */ 28 public function __construct($uid, $survey, $starttime, $endtime, $open, $presetanswers, $answersets)28 public function __construct($uid = null, $survey = null, $starttime = null, $endtime = null, $open = null, $presetanswers = null, $answersets = null) 29 29 { 30 30 if(!isset($uid)) … … 242 242 } 243 243 244 public static function create($obj) { 245 return new SurveyInstance($obj->uid, $obj->survey, $obj->starttime, 246 $obj->endtime, $obj->open, $obj->presetanswers, 247 $obj->answersets); 248 } 244 /** 245 * Creates a new SurveyInstance object out of the given object. 246 */ 247 public static function create($obj) 248 { 249 return new Survey($obj->uid, $obj->survey, $obj->starttime, $obj->endtime, $obj->open, $obj->presetanswers, $obj->answersets); 250 } 249 251 250 252 }
Note: See TracChangeset
for help on using the changeset viewer.