Changeset 128
- Timestamp:
- 10/17/11 17:21:45 (14 years ago)
- Location:
- Dev/branches/jos-branch
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/jos-branch/classes/Application.php
r122 r128 12 12 public $style; 13 13 14 public function __construct($ id = null, $title = null, $description = null, $style = null)14 public function __construct($uid = null, $title = null, $description = null, $style = null) 15 15 { 16 $this-> id = $id;16 $this->uid = $uid; 17 17 $this->title = $title; 18 18 $this->description = $description; -
Dev/branches/jos-branch/classes/ApplicationConnector.php
r123 r128 51 51 * Gets the array of Application objects belonging to arguments supplied. 52 52 * @param type $arguments : An array containing zero or more of the following keys: 53 * ' id', 'title', 'description', 'style'53 * 'uid', 'title', 'description', 'style' 54 54 */ 55 55 public function get($arguments) { … … 58 58 $keys = array_keys($arguments); 59 59 //Set default values for arguments 60 $ id = "?uid"; $title = "?title"; $description = "?description"; $style = "?style";60 $uid = "?uid"; $title = "?title"; $description = "?description"; $style = "?style"; 61 61 //Set the arguments if they are supplied 62 if(in_array(" id", $keys))63 $ id = "\"".$arguments["id"]."\"";62 if(in_array("uid", $keys)) 63 $uid = "\"".$arguments["id"]."\""; 64 64 if(in_array("title", $keys)) 65 65 $title = '\''.$arguments["title"].'\''; … … 77 77 { 78 78 _application predicates:resource_type resources:application ; 79 predicates:uid '. $id . '; 80 predicates:title '. $title . '; 81 predicates:description '. $description . '; 82 predicates:style '. $style .' 79 predicates:uid ?uid ; 80 predicates:title ?title ; 81 predicates:description ?description ; 82 predicates:style ?style ; 83 predicates:uid ' . $uid . ' 84 predicates:title ' . $title . ' 85 predicates:description ' . $description . ' 86 predicates:style ' . $style . ' 83 87 }'; 88 84 89 //Query the model 85 echo $querystring;86 90 $results = $this->model->sparqlQuery($querystring); 87 $applications = array(); 88 echo count($results); 89 //Run over all results and create appropriate Application objets 90 foreach($results as $result) 91 { 92 93 $applications[] = new Application($result['?uid']->label, $result['?title']->label, $result['?description']->label, $result['?style']->label); 94 } 95 //Return the list of application objects 96 return $applications; 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 } 97 106 } 98 107 99 108 /** 100 109 * function set() 101 * Finds the required databaseentry matching the given object sand removes102 * it from the rdf file. 103 * @param type $rToolObject 110 * Finds the required databaseentry matching the given object and removes 111 * it from the rdf file. Then adds the new RDF entry matching the object. 112 * @param type $rToolObject: The ResearchToolObject to be saved. 104 113 */ 105 114 public function set($rToolObject) 106 115 { 107 //TODO 116 $resourceApplication = new Resource(APPLICATION.'/'.$rToolObject->uid); 117 //Remove the old value stored with the given id 118 $this->model->subtract($this->model->find($resourceApplication, null, null)); 119 120 //Add the new statements to the model 121 $resourceApplicationType = new Resource(APPLICATION); 122 $predicateRType = new Resource(RTYPE); 123 $this->model->add(new Statement($resourceApplication,$predicateRType,$resourceApplicationType)); 124 125 $literalApplicationID = new Literal($rToolObject->uid); 126 $predicateUniqueID = new Resource(UID); 127 $this->model->add(new Statement($resourceApplication,$predicateUniqueID,$literalApplicationID)); 128 129 $applicationTitle = new Literal($rToolObject->title); 130 $predicateTitle = new Resource(TITLE); 131 $this->model->add(new Statement($resourceApplication,$predicateTitle,$applicationTitle)); 132 133 $applicationDescription = new Literal($rToolObject->description); 134 $predicateDescription = new Resource(DESCRIPTION); 135 $this->model->add(new Statement($resourceApplication,$predicateDescription,$applicationDescription)); 136 137 $applicationStyle = new Literal($rToolObject->style); 138 $predicateStyle = new Resource(STYLE); 139 $this->model->add(new Statement($resourceApplication,$predicateStyle,$applicationStyle)); 140 141 $this->save(); 108 142 } 109 143 } -
Dev/branches/jos-branch/classes/DatabaseInterface.php
r123 r128 32 32 } 33 33 } 34 35 public function set($rToolObject) 36 { 37 switch(get_class($rToolObject)) 38 { 39 case "Application": 40 $this->applicationConnector->set($rToolObject); 41 } 42 } 43 44 34 45 } 35 46 -
Dev/branches/jos-branch/classes/ResearchToolObject.php
r123 r128 6 6 */ 7 7 class ResearchToolObject { 8 p ublic $id;8 private $uid; 9 9 } 10 10
Note: See TracChangeset
for help on using the changeset viewer.