Changeset 287 for Dev/branches/jos-branch
- Timestamp:
- 02/24/12 15:54:20 (13 years ago)
- Location:
- Dev/branches/jos-branch/server/classes/models
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/jos-branch/server/classes/models/ApplicationInstance.php
r285 r287 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/jos-branch/server/classes/models/ResearchToolObject.php
r285 r287 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 }
Note: See TracChangeset
for help on using the changeset viewer.