Changeset 130 for Dev/branches
- Timestamp:
- 10/24/11 13:47:23 (14 years ago)
- Location:
- Dev/branches/jos-branch
- Files:
-
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/jos-branch/classes/Application.php
r128 r130 14 14 public function __construct($uid = null, $title = null, $description = null, $style = null) 15 15 { 16 if(!isset ($uid)) 17 { 18 $uid = md5(uniqid(rand(), true)); 19 } 16 20 $this->uid = $uid; 17 21 $this->title = $title; … … 19 23 $this->style = $style; 20 24 } 21 22 public static function getApplication($info)23 {24 return new Application(25 $info['applicationID'],26 $info['applicationTitle'],27 $info['applicationDescription'],28 $info['applicationStyle']);29 }30 25 31 26 } -
Dev/branches/jos-branch/classes/ApplicationConnector.php
r128 r130 61 61 //Set the arguments if they are supplied 62 62 if(in_array("uid", $keys)) 63 $uid = "\"".$arguments[" id"]."\"";63 $uid = "\"".$arguments["uid"]."\""; 64 64 if(in_array("title", $keys)) 65 65 $title = '\''.$arguments["title"].'\''; … … 81 81 predicates:description ?description ; 82 82 predicates:style ?style ; 83 83 predicates:uid ' . $uid . ' 84 84 predicates:title ' . $title . ' 85 85 predicates:description ' . $description . ' 86 predicates:style ' . $style . ' 86 predicates:style ' . $style . ' 87 87 }'; 88 88 89 89 //Query the model 90 90 $results = $this->model->sparqlQuery($querystring); 91 if(!empty($results)) 92 { 93 $applications = array(); 94 //Run over all results and create appropriate Application objets 95 foreach($results as $result) 96 { 97 $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label); 98 } 99 //Return the list of application objects 100 return $applications; 101 } 102 else 103 { 104 return array(); 105 } 91 $applications = array(); 92 if(!empty($results)) 93 { 94 //Run over all results and create appropriate Application objets 95 foreach($results as $result) 96 { 97 $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label); 98 } 99 } 100 return $applications; 106 101 } 107 102 … … 114 109 public function set($rToolObject) 115 110 { 111 $this->load(); 116 112 $resourceApplication = new Resource(APPLICATION.'/'.$rToolObject->uid); 117 118 119 120 113 //Remove the old value stored with the given id 114 $this->model->subtract($this->model->find($resourceApplication, null, null)); 115 116 //Add the new statements to the model 121 117 $resourceApplicationType = new Resource(APPLICATION); 122 118 $predicateRType = new Resource(RTYPE); … … 139 135 $this->model->add(new Statement($resourceApplication,$predicateStyle,$applicationStyle)); 140 136 141 137 $this->save(); 142 138 } 143 139 } -
Dev/branches/jos-branch/classes/DatabaseInterface.php
r128 r130 17 17 * Constructor for the DatabaseInterface class 18 18 */ 19 protected $applicationConnector; 19 private $applicationConnector; 20 private $questionConnector; 21 private $userConnector; 20 22 23 /** 24 * Constructor for DatabaseInterface. 25 * Initializes all the connectors. 26 */ 21 27 public function __construct() { 22 28 $this->applicationConnector = new ApplicationConnector(); 29 $this->questionConnector = new QuestionConnector(); 30 $this->userConnector = new UserConnector(); 23 31 } 24 32 33 /** 34 * Get the data corresponding to the given type and arguments 35 * @param type $type 36 * @param type $arguments 37 * @return type 38 */ 25 39 public function get($type, $arguments) 26 40 { 27 switch( $type)41 switch(strtolower($type)) 28 42 { 29 43 case "application": 30 44 return $this->applicationConnector->get($arguments); 31 45 break; 46 case "question": 47 return $this->questionConnector->get($arguments); 48 break; 49 case "user": 50 return $this->userConnector->get($arguments); 51 break; 32 52 } 33 53 } 34 54 35 public function set($rToolObject) 36 { 37 switch(get_class($rToolObject)) 38 { 39 case "Application": 40 $this->applicationConnector->set($rToolObject); 41 } 42 } 43 55 /** 56 * Saves the given object based on its class. 57 * @param type $rToolObject 58 */ 59 public function set($rToolObject) 60 { 61 switch(get_class($rToolObject)) 62 { 63 case "Application": 64 $this->applicationConnector->set($rToolObject); 65 break; 66 case "Question": 67 $this->questionConnector->set($rToolObject); 68 break; 69 case "User": 70 $this->userConnector->set($rToolObject); 71 break; 72 } 73 } 74 75 /** 76 * Saves all the objects in the given array, assuming they are 77 * valid ResearchToolObjects. 78 * @param type $rToolObjects 79 */ 80 public function batchSet($rToolObjects) 81 { 82 foreach ($rToolObjects as $rToolObject) 83 { 84 $this->set($rToolObject); 85 } 86 } 87 44 88 45 89 } -
Dev/branches/jos-branch/classes/Question.php
r114 r130 11 11 * @author fpvanagthoven 12 12 */ 13 class Question { 14 public $code; 13 class Question extends ResearchToolObject{ 15 14 public $title; 16 15 public $type; 17 16 public $description; 17 public $category; 18 18 public $answers; // format answers['#'] 19 public $category;20 19 21 public function __construct($code, $title = null, $type = null, $description = null) 20 /** 21 * Constructor for a Question. $uid equals the corresponding code. 22 * @param type $uid 23 * @param type $title 24 * @param type $type 25 * @param type $description 26 * @param type $category 27 * @param type $answers 28 */ 29 public function __construct($uid, $title = null, $type = null, $description = null, $category = null, $answers = null) 22 30 { 23 $this-> code = $code;31 $this->uid = $uid; 24 32 $this->title = $title; 25 33 $this->type = $type; 26 34 $this->description = $description; 27 $this->answers = array(); 35 $this->category = $category; 36 $this->answers = $answers; 28 37 } 29 30 /* reminder that constructor doesn't contain category haha */31 public function setCategory($category)32 {33 $this->category = $category;34 }35 36 public static function getQuestion($code, $info)37 {38 $question = new Question($code);39 $question->title = $info['questionTitle'];40 $question->type = $info['questionType'];41 if(isset($info['questionDescription']))42 $question->description = $info['questionDescription'];43 $question->category = $info['questionCategory'];44 45 $i = 1;46 while (isset($info['ans' . $i]))47 {48 array_push($question->answers, $info['ans' . $i]);49 $i++;50 }51 52 return $question;53 }54 55 38 } 56 39 -
Dev/branches/jos-branch/classes/ResearchToolObject.php
r128 r130 6 6 */ 7 7 class ResearchToolObject { 8 p rivate$uid;8 public $uid; 9 9 } 10 10 -
Dev/branches/jos-branch/data/applications/applications.rdf
r129 r130 8 8 xmlns:ns1="http://tbm.tudelft.nl/researchtool/predicates/"> 9 9 10 <rdf:Description rdf:about="http://tbm.tudelft.nl/researchtool/resources/application/ 364790b25634bf9b45fa16248a764eff">10 <rdf:Description rdf:about="http://tbm.tudelft.nl/researchtool/resources/application/c571ae05fa6e69ad63a8793f1484206e"> 11 11 <ns1:resource_type rdf:resource="http://tbm.tudelft.nl/researchtool/resources/application"/> 12 <ns1:uid> 364790b25634bf9b45fa16248a764eff</ns1:uid>13 <ns1:title> app2</ns1:title>14 <ns1:description> craft</ns1:description>15 <ns1:style> <![CDATA[]]></ns1:style>12 <ns1:uid>c571ae05fa6e69ad63a8793f1484206f</ns1:uid> 13 <ns1:title>Sup</ns1:title> 14 <ns1:description>herpderp</ns1:description> 15 <ns1:style>derpStyle</ns1:style> 16 16 </rdf:Description> 17 17 18 <rdf:Description rdf:about="http://tbm.tudelft.nl/researchtool/resources/application/ 29561e34ea30746a46f3027972a5d5f9">18 <rdf:Description rdf:about="http://tbm.tudelft.nl/researchtool/resources/application/19770b885bb13f2c5a1e3fd03bf77179"> 19 19 <ns1:resource_type rdf:resource="http://tbm.tudelft.nl/researchtool/resources/application"/> 20 <ns1:uid>29561e34ea30746a46f3027972a5d5f9</ns1:uid> 21 <ns1:title>Sup, testing if the title changes properly.</ns1:title> 22 <ns1:description>test</ns1:description> 23 <ns1:style><![CDATA[]]></ns1:style> 20 <ns1:uid>19770b885bb13f2c5a1e3fd03bf77179</ns1:uid> 21 <ns1:title>NewTestTitle</ns1:title> 22 <ns1:description>NewTestDescription</ns1:description> 23 <ns1:style>NewStylo</ns1:style> 24 </rdf:Description> 25 26 <rdf:Description rdf:about="http://tbm.tudelft.nl/researchtool/resources/application/cc91fba98ce357d9eb6709407d8cd4a4"> 27 <ns1:resource_type rdf:resource="http://tbm.tudelft.nl/researchtool/resources/application"/> 28 <ns1:uid>cc91fba98ce357d9eb6709407d8cd4a4</ns1:uid> 29 <ns1:title>NewTestTitle</ns1:title> 30 <ns1:description>NewTestDescription</ns1:description> 31 <ns1:style>NewStylo</ns1:style> 24 32 </rdf:Description> 25 33 -
Dev/branches/jos-branch/data/users/users.rdf
r129 r130 4 4 5 5 <rdf:RDF 6 xml:base="data/users/users.rdf#" 6 7 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 7 8 xmlns:ns1="http://tbm.tudelft.nl/researchtool/predicates/"> 8 9 9 <rdf:Description rdf:about="http://tbm.tudelft.nl/researchtool/resources/user/e978ee6bdc7af674060f558ce7ac1127"> 10 <rdf:Description rdf:about="http://tbm.tudelft.nl/researchtool/resources/user/b76cbf38cac7a3f048ca0d64a6c3ef58"> 11 <ns1:resource_type rdf:resource="http://tbm.tudelft.nl/researchtool/resources/user"/> 12 <ns1:name>iets</ns1:name> 13 <ns1:uid>b76cbf38cac7a3f048ca0d64a6c3ef58</ns1:uid> 14 <ns1:password>Vo87e37xIpm4uP4AfyHR9aSERlYpcgwE93Bc+rf2fD0=</ns1:password> 15 </rdf:Description> 16 17 <rdf:Description rdf:about="http://tbm.tudelft.nl/researchtool/resources/user/efa84d358d1bbd732c4075a1b3832dc7"> 18 <ns1:resource_type rdf:resource="http://tbm.tudelft.nl/researchtool/resources/user"/> 19 <ns1:name>booya</ns1:name> 20 <ns1:uid>efa84d358d1bbd732c4075a1b3832dc7</ns1:uid> 21 <ns1:password>Zk3CKJGWXcEvljUUmyAU5aLwTuwsMwdZZcDCzAH9Xrk=</ns1:password> 22 </rdf:Description> 23 24 <rdf:Description rdf:about="http://tbm.tudelft.nl/researchtool/resources/user/caa33a16c3b30cdcb7a5f0434c23e210"> 25 <ns1:resource_type rdf:resource="http://tbm.tudelft.nl/researchtool/resources/user"/> 26 <ns1:name>frans</ns1:name> 27 <ns1:uid>caa33a16c3b30cdcb7a5f0434c23e210</ns1:uid> 28 <ns1:password>YrNByNHxZwPoreIjW3lpAgeMg+J6kYBdl53uBCsHRKo=</ns1:password> 29 </rdf:Description> 30 31 <rdf:Description rdf:about="http://tbm.tudelft.nl/researchtool/resources/user/9043f64705e67ceb8f28242207b83adf"> 10 32 <ns1:resource_type rdf:resource="http://tbm.tudelft.nl/researchtool/resources/user"/> 11 33 <ns1:name>jkraaijeveld</ns1:name> 12 <ns1:uid> e978ee6bdc7af674060f558ce7ac1127</ns1:uid>34 <ns1:uid>9043f64705e67ceb8f28242207b83adf</ns1:uid> 13 35 <ns1:password>NWCbqdOCRGewETOoMI1YepJsoGQMjKozC5XOjtM5Mm8=</ns1:password> 14 36 </rdf:Description> -
Dev/branches/jos-branch/testpage.php
r128 r130 1 <?php 2 require 'classes/master.php'; 3 require 'rdfConstants.php'; 1 <?php 2 require 'classes/master.php'; 4 3 4 $db = new DatabaseInterface(); 5 // $arguments = array("id" => "c571ae05fa6e69ad63a8793f1484206e"); 5 6 6 7 $di = new DatabaseInterface(); 8 9 10 $args = array("description" => "test"); 11 $apps = $di->get("application", $args); 12 $app = $apps[0]; 13 $app->title = "Sup, testing if the title changes properly."; 14 $di->set($app); 15 7 8 9 $result = $db->get("user", array("name" => "jkraaijeveld")); 10 print_r($result); 16 11 ?>
Note: See TracChangeset
for help on using the changeset viewer.