- Timestamp:
- 11/07/11 16:54:41 (13 years ago)
- Location:
- Dev/branches/jos-branch
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/jos-branch/classes/DatabaseInterface.php
r143 r148 47 47 * @return type 48 48 */ 49 public function get($type, $arguments )49 public function get($type, $arguments = array()) 50 50 { 51 51 switch(strtolower($type)) … … 71 71 case "answerset": 72 72 return $this->answerSetConnector->get($arguments); 73 break; 73 74 case "session": 74 75 return $this->sessionConnector->get($arguments); 75 76 break; 76 77 } 77 78 } … … 109 110 $this->sessionConnector->set($rToolObject); 110 111 break; 111 112 112 } 113 113 } -
Dev/branches/jos-branch/classes/SessionConnector.php
r143 r148 1 1 <?php 2 // Survey database interface class as intermediate for storing data from the site to the RDF database 3 require_once 'rdfConstants.php'; 4 // Include RAP Library to write RDF files 5 include(RDFAPI_INCLUDE_DIR . "RDFAPI.php"); 6 2 7 /** 3 8 * Description of SessionConnector … … 103 108 foreach($results as $result) 104 109 { 110 //Create a session object out of every result, get all required fields as well. 105 111 $pipeline = $this->getPipeline($result['?uid']->label); 106 112 $answersets = $this->getAnswerSets($result['?uid']->label); … … 118 124 private function getPipeline($uid) 119 125 { 120 $querystring = ' 121 PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE .'> 122 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE .'> 123 SELECT DISTINCT ?object 124 WHERE 125 { 126 _session predicates:resource_type resources:session . 127 ?x predicates:uid \'' . $uid . '\' . 128 { ?x predicates:has_application ?object .} 129 UNION 130 { ?x predicates:has_survey ?object .} 131 132 133 }'; 134 $result = $this->model->sparqlQuery($querystring); 135 print_r($result); 126 $result = $this->model->findRegex("[(".$uid.")]", "[(has_application)|(has_survey)]" ,null); 127 $iterator = $result->getStatementIterator(); 128 $pipeline = array(); 129 while($iterator->hasNext()) 130 { 131 $element = $iterator->next(); 132 if(strpos($element->getLabelPredicate(), "has_application") != false) 133 { 134 $applications = $this->db->get("application", array("uid" => $element->getLabelObject())); 135 $pipeline[] = $applications[0]; 136 } 137 else 138 { 139 $surveys = $this->db->get("survey", array("uid" => $element->getLabelObject())); 140 $pipeline[] = $surveys[0]; 141 } 142 } 143 return $pipeline; 136 144 } 137 145 … … 142 150 private function getAnswerSets($uid) 143 151 { 152 $result = $this->model->findRegex("[(".$uid.")]", "[(has_answerset)]" ,null); 153 $iterator = $result->getStatementIterator(); 154 $answersets = array(); 155 while($iterator->hasNext()) 156 { 157 $element = $iterator->next(); 158 $resultsets = $this->db->get("answerset", array("uid" => $element->getLabelObject())); 159 $answersets[] = $resultsets[0]; 160 } 161 return $answersets; 144 162 } 145 163 … … 172 190 $this->model->add(new Statement($resourceSession, $predicateTimestamp, $sessionTimestamp)); 173 191 192 //Create a sequence to store the different applications and surveys. 174 193 if(isset($rToolObject->pipeline)) 175 194 { … … 187 206 } 188 207 189 if(isset($rToolObject s->answerSets))208 if(isset($rToolObject->answersets)) 190 209 { 191 210 foreach($rToolObject->answersets as $answerset) … … 199 218 $this->save(); 200 219 } 201 202 203 204 220 } 205 221 ?> -
Dev/branches/jos-branch/classes/Survey.php
r138 r148 12 12 public $questions; 13 13 14 public function __construct($uid = null, $title = null, $description = null, $ questions = null) {14 public function __construct($uid = null, $title = null, $description = null, $creator = null, $questions = null) { 15 15 if(!isset($uid)) 16 16 { … … 19 19 $this->uid = $uid; 20 20 $this->title = $title; 21 $this->description = $description; 21 $this->description = $description; 22 $this->creator = $creator; 22 23 $this->questions = $questions; 23 24 } -
Dev/branches/jos-branch/classes/SurveyConnector.php
r143 r148 55 55 $keys = array_keys($arguments); 56 56 //Set default values for arguments 57 $uid = "?uid"; $title = "?title"; $description = "?description"; $ questions = "";57 $uid = "?uid"; $title = "?title"; $description = "?description"; $creator = "?creator"; $questions = ""; 58 58 if(in_array("uid", $keys)) 59 59 $uid = '\''.$arguments["uid"].'\''; … … 61 61 $title = '\''.$arguments["title"].'\''; 62 62 if(in_array("description", $keys)) 63 $description = "\"".$arguments["description"]."\""; 63 $description = "\"".$arguments["description"]."\""; 64 if(in_array("creator", $keys)) 65 $creator = "\"".$arguments["creator"]."\""; 64 66 if(in_array("questions", $keys)) 65 67 { … … 75 77 PREFIX predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '> 76 78 PREFIX resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '> 77 SELECT DISTINCT ?uid, ?title, ?description 79 SELECT DISTINCT ?uid, ?title, ?description, ?creator 78 80 WHERE 79 81 { … … 84 86 predicates:uid ' . $uid . ' 85 87 predicates:title ' . $title . ' 86 predicates:description ' . $description . ' 88 predicates:description ' . $description . ' 89 predicates:creator ' . $creator . ' 87 90 ' . $questions . ' 88 91 }'; … … 95 98 if(!empty($results)) 96 99 { 100 $this->db = new DatabaseInterface(); 97 101 foreach($results as $result) 98 102 { 99 $questions = $this->getQuestions($result['?uid']->label); 100 $surveys[] = new Survey($result['?uid']->label, $result['?title']->label, $result['?description']->label, $questions); 103 $questions = $this->getQuestions($result['?uid']->label); 104 $creator = $this->db->get("user", array("uid" => $result['?creator']->label)); 105 $surveys[] = new Survey($result['?uid']->label, $result['?title']->label, $result['?description']->label, $creator[0], $questions); 101 106 } 102 107 } … … 127 132 if(!empty($results)) 128 133 { 129 $this->db = new DatabaseInterface();130 134 foreach($results as $questionId) 131 135 { … … 165 169 $this->model->add(new Statement($resourceSurvey,$predicateDescription,$surveyDescription)); 166 170 171 $predicateCreator = new Resource(CREATOR); 172 $surveyCreator = new Literal($rToolObject->creator->uid); 173 $this->model->add(new Statement($resourceSurvey, $predicateCreator, $surveyCreator)); 174 167 175 if(isset($rToolObject->questions)) 168 176 { -
Dev/branches/jos-branch/classes/UserConnector.php
r140 r148 81 81 predicates:password ' . $password . ' 82 82 }'; 83 echo $querystring;84 83 //Query the model 85 84 $results = $this->model->sparqlQuery($querystring); -
Dev/branches/jos-branch/data/sessions/sessions.rdf
r143 r148 7 7 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 8 8 xmlns:ns1="http://tbm.tudelft.nl/researchtool/predicates/"> 9 9 10 10 <rdf:Description rdf:about="http://tbm.tudelft.nl/researchtool/resources/session/f2989fac2de2ac27f78162b637ae84b5"> 11 11 <ns1:resource_type rdf:resource="http://tbm.tudelft.nl/researchtool/resources/session"/> … … 20 20 <ns1:uid>6cf683023d644b1794cd8c410134ca91</ns1:uid> 21 21 <ns1:title>Supervet, deze sessie</ns1:title> 22 <ns1:datetime> 1320072148</ns1:datetime>22 <ns1:datetime>0</ns1:datetime> 23 23 <ns1:has_survey>b91d39e8667372e220bb861b3f94b5bd</ns1:has_survey> 24 24 <ns1:has_application>c571ae05fa6e69ad63a8793f1484206f</ns1:has_application> 25 25 <ns1:has_application>c9390a27f525d84c1795bcb5c6caf33f</ns1:has_application> 26 26 <ns1:has_survey>bab0492e295700ed0324f724b9c8a815</ns1:has_survey> 27 <ns1:has_answerset>52fe4a3e1f42f0f646226e184852dd00</ns1:has_answerset> 27 28 </rdf:Description> 28 29 -
Dev/branches/jos-branch/data/surveys/surveys.rdf
r143 r148 13 13 <ns1:title>SuperSurvey</ns1:title> 14 14 <ns1:description>Dit is een surveybeschrijving</ns1:description> 15 <ns1:creator>b76cbf38cac7a3f048ca0d64a6c3ef58</ns1:creator> 15 16 <ns1:has_question>q1</ns1:has_question> 16 <ns1:has_question>q2</ns1:has_question>17 17 <ns1:has_question>q3</ns1:has_question> 18 <ns1:has_question>2807fdaf2fe624323d24a5d85599eb83</ns1:has_question> 18 19 </rdf:Description> 19 20 … … 23 24 <ns1:title>TestSurveyDeluxe</ns1:title> 24 25 <ns1:description>Zomaar, jeweetwel</ns1:description> 26 <ns1:creator>b76cbf38cac7a3f048ca0d64a6c3ef58</ns1:creator> 25 27 <ns1:has_question>q2</ns1:has_question> 26 28 <ns1:has_question>2807fdaf2fe624323d24a5d85599eb83</ns1:has_question> 27 29 </rdf:Description> 28 30 29 30 31 </rdf:RDF> -
Dev/branches/jos-branch/testpage.php
r143 r148 3 3 4 4 $db = new DatabaseInterface(); 5 $results = $db->get("session", array()); 5 $user = $db->get("user", array("name" => "jkraaijeveld")); 6 print_r($user[0]); 6 7 7 8 ?>
Note: See TracChangeset
for help on using the changeset viewer.