RdfClass.php
Go to the documentation of this file.00001 <?php
00002 include_once("Namespaces.php");
00003
00006
00026 class RdfClass
00027 {
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00044 public $triples = array();
00045
00047 private $uri = "";
00048
00050 private $ontologiesGraph = "";
00051
00065 function __construct($classURI, $ontologiesGraph, $inferredOntologiesGraph, &$db)
00066 {
00067 $this->uri = $classURI;
00068 $this->ontologiesGraph = $ontologiesGraph;
00069
00070 $query =
00071 $db->build_sparql_query(
00072 "select ?g ?p ?o from named <$this->ontologiesGraph> from named <$inferredOntologiesGraph> where {graph ?g{<$classURI> ?p ?o.}}",
00073 array ('g', 'p', 'o'), FALSE);
00074
00075 $resultset = $db->query($query);
00076
00077 while(odbc_fetch_row($resultset))
00078 {
00079 $g = odbc_result($resultset, 1);
00080 $p = odbc_result($resultset, 2);
00081 $o = odbc_result($resultset, 3);
00082
00083 if(!isset($this->triples[$g]))
00084 {
00085 $this->triples[$g] = array();
00086 }
00087
00088 if(!isset($this->triples[$g][$p]))
00089 {
00090 $this->triples[$g][$p] = array();
00091 }
00092
00093 array_push($this->triples[$g][$p], $o);
00094 }
00095 }
00096
00097 function __destruct() { }
00098
00109 public function getLabel()
00110 {
00111 if(isset($this->triples[$this->ontologiesGraph][Namespaces::$iron . "prefLabel"]))
00112 {
00113 return $this->triples[$this->ontologiesGraph][Namespaces::$iron . "prefLabel"][0];
00114 }
00115
00116 if(isset($this->triples[$this->ontologiesGraph][Namespaces::$skos_2008 . "prefLabel"]))
00117 {
00118 return $this->triples[$this->ontologiesGraph][Namespaces::$skos_2008 . "prefLabel"][0];
00119 }
00120
00121 if(isset($this->triples[$this->ontologiesGraph][Namespaces::$skos_2004 . "prefLabel"]))
00122 {
00123 return $this->triples[$this->ontologiesGraph][Namespaces::$skos_2004 . "prefLabel"][0];
00124 }
00125
00126 if(isset($this->triples[$this->ontologiesGraph][Namespaces::$rdfs . "label"]))
00127 {
00128 return $this->triples[$this->ontologiesGraph][Namespaces::$rdfs . "label"][0];
00129 }
00130
00131
00132 $pos = strripos($this->uri, "#");
00133
00134 if($pos === FALSE)
00135 {
00136 $pos = strripos($this->uri, "/");
00137 }
00138
00139 if($pos !== FALSE)
00140 {
00141 $pos++;
00142 }
00143
00144 $resource = substr($this->uri, $pos, strlen($this->uri) - $pos);
00145
00146 return $resource;
00147 }
00148
00159 public function getDescription()
00160 {
00161 if(isset($this->triples[$this->ontologiesGraph][Namespaces::$iron . "description"]))
00162 {
00163 return $this->triples[$this->ontologiesGraph][Namespaces::$iron . "description"][0];
00164 }
00165
00166 if(isset($this->triples[$this->ontologiesGraph][Namespaces::$skos_2008 . "definition"]))
00167 {
00168 return $this->triples[$this->ontologiesGraph][Namespaces::$skos_2008 . "definition"][0];
00169 }
00170
00171 if(isset($this->triples[$this->ontologiesGraph][Namespaces::$skos_2004 . "definition"]))
00172 {
00173 return $this->triples[$this->ontologiesGraph][Namespaces::$skos_2004 . "definition"][0];
00174 }
00175
00176 if(isset($this->triples[$this->ontologiesGraph][Namespaces::$rdfs . "comment"]))
00177 {
00178 return $this->triples[$this->ontologiesGraph][Namespaces::$rdfs . "comment"][0];
00179 }
00180
00181 if(isset($this->triples[$this->ontologiesGraph][Namespaces::$dcterms . "description"]))
00182 {
00183 return $this->triples[$this->ontologiesGraph][Namespaces::$dcterms . "description"][0];
00184 }
00185
00186 if(isset($this->triples[$this->ontologiesGraph][Namespaces::$dc . "description"]))
00187 {
00188 return $this->triples[$this->ontologiesGraph][Namespaces::$dc . "description"][0];
00189 }
00190
00191 return "No description available";
00192 }
00193 }
00194
00196
00197 ?>
Copyright © 2009.
Structured Dynamics LLC. All rights reserved.