Source for file OntResource.php
Documentation is available at OntResource.php
// ----------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------
* Provides a common super-type for all of the abstractions in
* this ontology representation package.
* @version $Id: fsource_ontModel__ontModelOntResource.php.html 443 2007-06-01 16:25:38Z cax $
* @author Daniel Westphal <mail at d-westphal dot de>
* Holds a reference to the assoiated vocabulary
* Holds a resResource of the type, which is this ontResource of.
* If this value is set, the ontModel will add an additional
* statement about this resource and the fiven rdf:type
* Sets the reference to the assoiated vocabulary
* @param object OntVocabulary $vocabulary
$this->vocabulary =
& $vocabulary;
* Add the given comment to this resource.
* @param object ResLiteral $comment
return $this->addProperty($this->vocabulary->COMMENT(),$comment);
* Answer the comment string for this object. If there is more than one such resource, an arbitrary selection is made.
* @return object ResLiteral or NULL
* Add a resource that is declared to provide a definition of this resource.
* @param object ResResource $resResource
return $this->addProperty($this->vocabulary->IS_DEFINED_BY(),$resResource);
* Answer a resource that is declared to provide a definition of this resource.
* If there is more than one such resource, an arbitrary selection is made.
* @return object ResResource
* Add the given Label to this resource
* @param object ResLiteral $resLiteral
return $this->addProperty($this->vocabulary->LABEL(),$resLiteral);
* Answer the label ResLiteral for this object.
* If there is more than one such resource, an arbitrary selection is made.
* @return object ResResource
* Add the given class as one of the rdf:type's for this resource.
* @param object ResResource $resResource
return $this->addProperty($this->vocabulary->TYPE(),$resResource);
* Answer the rdf:type (ie the class) of this resource.
* If there is more than one type for this resource, the return value will
* be one of the values, but it is not specified which one
* (nor that it will consistently be the same one each time).
* @return object ResResource
* Add a resource that is declared to provided additional
* information about the definition of this resource.
* @param object ResResource $resResource
return $this->addProperty($this->vocabulary->SEE_ALSO(),$resResource);
* Answer a resource that provides additional information about this resource.
* If more than one such resource is defined, make an arbitrary choice.
* @return object ResResource
* Answer a view of this resource as a class
* @return object OntClass
return $this->model->createOntClass($this->uri);
* Answer a view of this resource as an Individual
* @return object Individual
return $this->model->createIndividual($this->uri);
* Answer a view of this resource as a property
* @return object OntProperty
return $this->model->createOntProperty($this->uri);
* Answer a reference to the ontology language profile that governs the
* ontology model to which this ontology resource is attached.
* @return object OntClass
return $this->vocabulary ;
* Answer the value of a given RDF property for this resource as $returnType, or null
* if it doesn't have one. If there is more than one RDF statement with
* the given property for the current value, it is not defined which of
* the values will be returned.
* The following return Types are supported: 'OntClass', 'OntProperty', 'Individual', and 'ResResource'
* Default is 'ResResource'
* @param object ResResource $property
* @param string $returnType
* @return object OntClass
return $this->model->createOntClass($statement->getLabelObject());
return $this->model->createOntProperty($statement->getLabelObject());
return $this->model->createIndividual($statement->getLabelObject());
return $statement->getObject();
* Answer true if this resource has the given comment.
* @param object ResLiteral $resLiteral
return $this->hasProperty($this->vocabulary->COMMENT(),$resLiteral);
* Answer true if this resource has the given label.
* @param object ResLiteral $resLiteral
return $this->hasProperty($this->vocabulary->LABEL(),$resLiteral);
* Answer true if this resource has the given rdf:type.
* @param object ResResource $ontClass
return $this->hasProperty($this->vocabulary->TYPE(),$ontClass);
* Answer true if this resource has the given resource as a source
* of additional information.
* @param object ResResource $resResource
return $this->hasProperty($this->vocabulary->SEE_ALSO(),$resResource);
* Answer true if this resource is defined by the given resource.
* @param object ResResource $resResource
return $this->hasProperty($this->vocabulary->IS_DEFINED_BY(),$resResource);
* Answer an array of all of the comment literals for this resource.
* @param string $language
foreach ($return as $key =>
$resLiteral)
if (!is_a($resLiteral,'ResLiteral') ||
$resLiteral->getLanguage() !=
$language)
* Answer an array of all of the resources that are declared to define this resource.
return $this->listProperty($this->vocabulary->IS_DEFINED_BY());
* Answer an array of all of the label literals for this resource, with the given
* language, if $language is set.
foreach ($return as $key =>
$resLiteral)
if (!is_a($resLiteral,'ResLiteral') ||
$resLiteral->getLanguage() !=
$language)
* Answer an array of the RDF classes to which this resource belongs.
* If $direct is true, only answer those resources that are direct types of
* this resource, not the super-classes of the class etc.
* @return array Array of ResResources
* Answer an array of all of the resources that are declared to
* provide addition information about this resource.
* @return array Array of ResResources
* Answer an array of values of a given RDF property for this resource as $returnType, or null
* if it doesn't have one.
* The following return Types are supported: 'OntClass', 'OntProperty', 'Individual', and 'ResResource'
* Default is 'ResResource'
* @param object ResResource $property
* @param string $returnType
* @return array of ResResources
function listProperty($property, $returnType =
'OntResource')
foreach ($resArray as $statement)
$return[]=
$this->model->createOntClass($statement->getLabelObject());
$return[]=
$this->model->createOntProperty($statement->getLabelObject());
$return[]=
$this->model->createIndividual($statement->getLabelObject());
$return[]=
$statement->getObject();
* Remove the statement that the given ResLiteral is a comment on this resource.
* Returns true, if a statement was removed
* @param object ResLiteral $resLiteral
return $this->removeProperty($this->vocabulary->COMMENT(),$resLiteral);
* Remove the statement that this resource is defined by the given resource.
* @param object ResResource $resResource
return $this->removeProperty($this->vocabulary->IS_DEFINED_BY(),$resResource);
* Remove the statement that the given ResLiteral is a label on this resource.
* Returns true, if a statement was removed
* @param object ResLiteral $resLiteral
* Remove the specific property-value pair from this resource.
* @param object ResResource $property
* @param object ResResource $value
return $this->model->remove(new Statement($this,$property,$value));
* Remove the statement that this resource is of the given RDF type.
* @param object ResResource $resResource
* Remove the statement indicating the given resource as a source of
* additional information about this resource.
* @param object ResResource $resResource
return $this->removeProperty($this->vocabulary->SEE_ALSO(),$resResource);
* Assert that the given string is the comment on this resource.
* Any existing statements for comment will be removed.
* @param object ResLiteral $resLiteral
* Assert that the given resource provides a source of definitions about this resource.
* Any existing statements for isDefinedBy will be removed.
* @param object ResResource $resResource
* Assert that the given string is the label on this resource.
* Any existing statements for comment will be removed.
* @param object ResLiteral $resLiteral
* Set the value of the given property of this ontology resource to the given value.
* Maintains the invariant that there is at most one value of the property for a
* given resource, so existing property values are first removed.
* To add multiple properties, use addProperty.
* @param object ResResource $property
* @param object ResResource $value
* Set the RDF type (ie the class) for this resource,
* replacing any existing rdf:type property. Any existing statements
* for the RDF type will first be removed.
* @param object ResResource $resResource
* Add a resource that is declared to provided additional information
* about the definition of this resource
* @param object ResResource $resResource
* Returns an array of ResResources that are recursively connected by $attribute
* in superProperty direction.
* If $onlyFindThisResResource is set to a ResResource, this function returns boolean
* if this distinct resource recursively is connected to the $startResource.
* @param object ResResource $startResource
* @param object ResResource $attribute
* @param array $attribute
* @param object ResResource $onlyFindThisResResource
* @return array OR boolean
function _getSuperAttributeStatementsRec(& $startResource,& $attribute,& $attributeIndex, $onlyFindThisResResource =
false)
$return =
$startResource->listProperties($attribute);
if ($onlyFindThisResResource)
foreach ($return as $statement)
if ($onlyFindThisResResource->equals($statement->getObject()))
foreach ($return as $statement)
$attributeLabel=
$statement->getLabelObject();
if (!in_array($attributeLabel,$attributeIndex))
$attributeIndex[]=
$attributeLabel;
$subReturn =
$this->_getSuperAttributeStatementsRec($statement->getObject(), $attribute, $attributeIndex, $onlyFindThisResResource);
* Returns an array of ResResources that are recursively connected by $attribute
* in subProperty direction.
* If $onlyFindThisResResource is set to a ResResource, this function returns boolean
* if this distinct resource recursively is connected to the $startResource.
* @param object ResResource $startResource
* @param object ResResource $attribute
* @param array $attribute
* @param object ResResource $onlyFindThisResResource
* @return array OR boolean
function _getSubAttributeStatementsRec(& $startResource,& $attribute,& $attributeIndex, $onlyFindThisResResource =
false)
$return =
$this->model->find(null,$attribute,$startResource);
if ($onlyFindThisResResource)
foreach ($return as $statement)
if ($onlyFindThisResResource->equals($statement->getSubject()))
foreach ($return as $statement)
$attributeLabel=
$statement->getLabelSubject();
if (!in_array($attributeLabel,$attributeIndex))
$attributeIndex[]=
$attributeLabel;
$subReturn =
$this->_getSubAttributeStatementsRec($statement->getSubject(), $attribute, $attributeIndex, $onlyFindThisResResource);
* Add a property to this resource.
* A statement with this resource as the subject, p as the predicate and o
* as the object is added to the model associated with this resource.
* If $this->rdfType is set, an additional statement about it's type
* @param ResResource $property
* @param ResResource/ResLiteral $object
* @return object ResResource
if ($this->rdfType !==
false)
$this->model->add(new Statement($this,$this->vocabulary->TYPE(),$this->rdfType));
* Sets the rdf:type, that this distinct resource is instance of.
* If this value is set, the ontModel will add an additional
* statement about this resource and the fiven rdf:type
* @param object ResResource $resResource
$this->rdfType =
$resResource;
* returns the rdf:type, that this distinct resource is instance of.
* @return object ResResource $resResource
Documentation generated on Fri, 1 Jun 2007 16:50:14 +0200 by phpDocumentor 1.3.2