$mMetadata
$mMetadata : \OntologyWrapper\DatabaseObject
Metadata.
This data member holds the metadata {@link DatabaseObject} derived instance.
Wrapper
This class extends its ancestor to wrap an interface around the various components of the system; the metadata, entities and the units.
The object is considered {@link isInited()} when the metadata, entities and units databases are set.
$mMetadata : \OntologyWrapper\DatabaseObject
Metadata.
This data member holds the metadata {@link DatabaseObject} derived instance.
$mEntities : \OntologyWrapper\DatabaseObject
Entities.
This data member holds the entities {@link DatabaseObject} derived instance.
$mUnits : \OntologyWrapper\DatabaseObject
Units.
This data member holds the units {@link DatabaseObject} derived instance.
$mGraph : \OntologyWrapper\DatabaseGraph
Graph.
This data member holds the graph {@link DatabaseGraph} derived instance.
Metadata(mixed $theValue, boolean $getOld, boolean $doOpen) : mixed
Manage metadata database
This method can be used to manage the metadata database, it accepts a parameter which represents either the metadata database instance or the requested operation, depending on its value:
The second parameter is a boolean which if TRUE will return the old value when replacing or resetting; if FALSE, it will return the current value.
mixed | $theValue | Metadata database or operation. |
boolean | $getOld | TRUE get old value. |
boolean | $doOpen | TRUE open connection. |
New or old metadata database.
Entities(mixed $theValue, boolean $getOld, boolean $doOpen) : mixed
Manage entities database
This method can be used to manage the entities database, it accepts a parameter which represents either the entities database instance or the requested operation, depending on its value:
The second parameter is a boolean which if TRUE will return the old value when replacing or resetting; if FALSE, it will return the current value.
mixed | $theValue | Entities database or operation. |
boolean | $getOld | TRUE get old value. |
boolean | $doOpen | TRUE open connection. |
New or old entities database.
Units(mixed $theValue, boolean $getOld, boolean $doOpen) : mixed
Manage units database
This method can be used to manage the units database, it accepts a parameter which represents either the units database instance or the requested operation, depending on its value:
The second parameter is a boolean which if TRUE will return the old value when replacing or resetting; if FALSE, it will return the current value.
mixed | $theValue | Units database or operation. |
boolean | $getOld | TRUE get old value. |
boolean | $doOpen | TRUE open connection. |
New or old units database.
Graph(mixed $theValue, boolean $getOld, boolean $doOpen) : mixed
Manage graph database
This method can be used to manage the graph database, it accepts a parameter which represents either the graph database instance or the requested operation, depending on its value:
The second parameter is a boolean which if TRUE will return the old value when replacing or resetting; if FALSE, it will return the current value.
mixed | $theValue | Hraph database or operation. |
boolean | $getOld | TRUE get old value. |
boolean | $doOpen | TRUE open connection. |
New or old graph database.
resetOntology(boolean $doLog, boolean $doDrop)
Reset databases
This method can be used to reset the ontology, it will erase the current ontology, and re-load it from the files in the standards directory.
When you erase the ontology, you might lose tags and terms which are necessary for the entities and the data databases: be aware that by doing so you might render these databases useless.
boolean | $doLog | Log operations. |
boolean | $doDrop | Drop collections. |
resetUnits(boolean $doLog, boolean $doDrop) : array
Reset units
This method can be used to reset the units database, it will erase the current units collection and load the FAO insatitutes.
The method will take care of setting the necessary indexes.
boolean | $doLog | Log operations. |
boolean | $doDrop | Drop collections. |
Statistics.
resetEntities(boolean $doLog, boolean $doDrop) : array
Reset entities
This method can be used to reset the entities database, it will erase the current entities collection and load the FAO insatitutes.
The method will take care of setting the necessary indexes.
boolean | $doLog | Log operations. |
boolean | $doDrop | Drop collections. |
Statistics.
loadTagCache()
Reload tag cache
This method can be used to reset the tag cache.
The method will return TRUE if the object is connected and the operation was executed and FALSE if the object is not connected, or if the metadata is missing.
Note that although the operation might have been executed, this doesn't mean that the dictionary was loaded: this depends on the contents of the metadata database.
copyRelationships(mixed $theSrcNode, mixed $theSrcPredicate, string $theSrcDirection, int $theDstNode, string $theDstPredicate, string $theDstDirection)
<h4>Copy relationships from one node to another</h4>
This method can be used to copy all the relationships of a given predicate affecting one node to another node. The method will select the source node relationships of the provided predicate and direction, it will duplicate these relationships, it will substitute the source node with the destination node and replace the source predicate with the destination predicate.
The method expects these parameters:
mixed | $theSrcNode | Source relationship vertex(s). |
mixed | $theSrcPredicate | Source predicate(s). |
string | $theSrcDirection | Source relationship direction. |
int | $theDstNode | Destination relationship vertex. |
string | $theDstPredicate | Destination predicate. |
string | $theDstDirection | Destination relationship direction. |
loadIUCNStandards(boolean $doLog) : array
Load IUCN standards
This method can be used to load the IUCN standards in the metadata database, it will load the standards XML files.
Note that this method expects other standards to have been loaded.
boolean | $doLog | Log operations. |
Statistics.
loadNatServeStandards(boolean $doLog) : array
Load NatureServe standards
This method can be used to load the NatureServe standards in the metadata database, it will load the standards XML files.
Note that this method expects other standards to have been loaded.
boolean | $doLog | Log operations. |
Statistics.
loadFAOStandards(boolean $doLog) : array
Load FAO standards
This method can be used to load the FAO standards in the metadata database, it will load the standards XML files.
Note that this method expects other standards to have been loaded.
boolean | $doLog | Log operations. |
Statistics.
loadEECStandards(boolean $doLog) : array
Load EEC standards
This method can be used to load the EEC standards in the metadata database, it will load the standards XML files.
Note that this method expects other standards to have been loaded.
boolean | $doLog | Log operations. |
Statistics.
loadGENSStandards(boolean $doLog) : array
Load GENS standards
This method can be used to load the GENS standards in the metadata database, it will load the standards XML files.
Note that this method expects other standards to have been loaded.
boolean | $doLog | Log operations. |
Statistics.
loadGLOBCOVStandards(boolean $doLog) : array
Load GLOBCOV standards
This method can be used to load the GLOBCOV standards in the metadata database, it will load the standards XML files.
Note that this method expects other standards to have been loaded.
boolean | $doLog | Log operations. |
Statistics.
loadHWSDStandards(boolean $doLog) : array
Load HWSD standards
This method can be used to load the HWSD standards in the metadata database, it will load the standards XML files.
Note that this method expects other standards to have been loaded.
boolean | $doLog | Log operations. |
Statistics.
loadStandards(boolean $doLog) : array
Load standards
This method can be used to load the standards in the metadata database, it will load the standards XML files.
Note that this method expects other standards to have been loaded.
boolean | $doLog | Log operations. |
Statistics.
loadCollections(boolean $doLog) : array
Load collections
This method can be used to load the standards collection elements in the metadata database, it will load the collection XML files.
Note that this method expects other standards to have been loaded, so it must be called as the last element.
boolean | $doLog | Log operations. |
Statistics.
loadXMLFile(string $theFile)
Load an XML file
This method can be used to load an XML file containing metadata, entities or units. The method expects an XML file as the paraneter, any error during the load process will raise an exception.
string | $theFile | XML file path. |
collectStructureOffsets(mixed $theNode, int $theType) : array
Get structure offsets.
This method will return the list of offsets belonging to the provided structure or schema node.
The method expects the following parameters:
If the node cannot be resolved, the method will raise an exception.
All schema and structure elements present as sub-elements will be resolved.
mixed | $theNode | Node reference. |
int | $theType | Result type. |
List of offsets belonging to the structure.
resolveCollection(string $theCollection) : \OntologyWrapper\CollectionObject
Resolve collection
Given a collection name, this method will return a collection reference.
string | $theCollection | Collection name. |
The collection reference.
__construct(mixed $theIdentifier, array $theServers)
Instantiate class.
The constructor accepts two parameters:
The constructor will first instantiate the {@link Memcached} object, then it will check if the connection resource has already a list of servers associated, if that is the case we assume the cache is already initialised; if that is not the case, we will add the servers provided in the second parameter.
mixed | $theIdentifier | Persistent identifier. |
array | $theServers | List of servers. |
setTag(mixed $theTag, integer $theLife)
Set tag
This method should commit the provided tag, both as an identifier and as an object.
The method expects the following parameters:
mixed | $theTag | Tag object. |
integer | $theLife | Element lifetime. |
setTagsByIterator(\OntologyWrapper\ObjectIterator $theTags, integer $theLife)
Set tags by iterator
This method should commit the provided tags, both as identifiers and as an objects.
The method expects the following parameters:
\OntologyWrapper\ObjectIterator | $theTags | Tag iterator. |
integer | $theLife | Elements lifetime. |
getSerial(string $theIdentifier, boolean $doAssert) : integer
Get serial number
This method should return the serial identifier corresponding to the provided persistent identifier.
The second parameter represents a boolean flag: if TRUE and the provided identifier is not matched, the method will raise an exception; if FALSE, the method will return NULL on a mismatch. By default this option is TRUE.
string | $theIdentifier | Persistent identifier. |
boolean | $doAssert | If TRUE assert match. |
Sequence number or NULL. +
getObject(string $theIdentifier, boolean $doAssert) : mixed
Get object
This method should return the tag object corresponding to the provided serial identifier.
The second parameter represents a boolean flag: if TRUE and the provided identifier is not matched, the method will raise an exception; if FALSE, the method will return NULL on a mismatch. By default this option is TRUE.
string | $theIdentifier | Serial identifier. |
boolean | $doAssert | If TRUE assert match. |
Tag object array or NULL.
getTypes(string $theIdentifier, string $theType, array $theKind, mixed $theMin, mixed $theMax, string $thePattern, boolean $doAssert) : boolean
Get tag types
This method should return the tag data type, kind, range and pattern in the provided reference parameters, the method expects the identifier to be a tag sequence number, it will be cast to an integer.
The last parameter represents a boolean flag: if TRUE and the provided identifier is not matched, the method will raise an exception; if FALSE, the method will set the data type to NULL, the data kind to an empty array, the range to an empty array and the pattern to NULL.
string | $theIdentifier | Serial identifier. |
string | $theType | Receives data type. |
array | $theKind | Receives data kind. |
mixed | $theMin | Receives minimum data range. |
mixed | $theMax | Receives maximum data range. |
string | $thePattern | Receives data pattern. |
boolean | $doAssert | If TRUE assert match. |
TRUE means the tag was found.
getTagOffsets() : array
Get dictionary tag offsets
This method should return the list of tag sequence numbers corresponding to the tag properties that will be stored in the dictionary.
By default we store:
Other properties are either not needed for this purpose, or they are modified frequently, making reading from the database slower, but safer.
The method will return an array suited to be used for querying with a field selection, the tag offsets are the key and a boolean is the value.
List of tag offsets.
delTag(mixed $theIdentifier, boolean $doAssert) : boolean
Delete tag
This method should delete a tag entry corresponding to the provided persistent or serial identifier. This means that the method will delete both the identifier and the object entries.
Note that an integer identifier is assumed to be the serial identifier and anything else will be cast to string and assumed to be the persistent identifier.
The second parameter rperesents a boolean flag: if TRUE and the provided identifier is not matched, the method will raise an exception. By default this option is FALSE.
mixed | $theIdentifier | Persistent or serial identifier. |
boolean | $doAssert | If TRUE assert match. |
TRUE deleted, FALSE not found.
dictionaryFilled() : boolean
Check if dictionary is filled
This method will return TRUE if the current dictionary can resolve the kTAG_ROLES identifier.
We assume that if the dictionary can resolve this identifier, it means it must be filled.
We check whether the {@link kTAG_ROLES} serial resolved to the correct tag object.
TRUE means filled.
dictionaryFlush(integer $theDelay)
Flush dictionary elements
This method should invalidate all the elements of the dictionary.
The method expects one parameter that corresponds to the delay in seconds before the elements will be invalidated.
integer | $theDelay | Delay before flush. |
offsetGet(mixed $theOffset) : mixed
Return a value at a given offset
We overload this method to call the preflight method: if it returns NULL we call the parent method; if not, we return the received value.
We also overload this method to handle unmatched offsets: we prevent warnings from being issued and return NULL.
mixed | $theOffset | Offset. |
Offset value or NULL.
offsetSet(string $theOffset, mixed $theValue)
Set a value at a given offset
We overload this method to call the preflight and postflight methods: if the preflight method returns NULL we call the parent method; if not, we stop.
We also overload this method to handle NULL values: in that case we delete the offset.
string | $theOffset | Offset. |
mixed | $theValue | Value to set at offset. |
offsetUnset(string $theOffset)
Reset a value at a given offset
We overload this method to call the preflight and postflight methods: if the preflight method returns NULL we call the parent method; if not, we stop.
We also overload this method to prevent warnings on unmatched offsets.
string | $theOffset | Offset. |
Object2Array(\OntologyWrapper\reference $theSource, \OntologyWrapper\reference $theDestination)
<h4>Convert object to array</h4>
This method can be used to obtain an array of arrays from a nested structure.
The method expects as the first parameter a reference to an {@link ArrayObject} or to an array, it will convert the provided parameter to an array and traverse it, converting recursively any {@link ArrayObject} instance into an array.
The method accepts the following parameters:
\OntologyWrapper\reference | $theSource | Reference to the source structure. |
\OntologyWrapper\reference | $theDestination | Reference to the destination array. |
loadXMLMetadata(\OntologyWrapper\SimpleXMLElement $theXML)
Parse and load metadata
This method will parse and load the provided metadata XML structure.
It is assumed that the object has its comnnections open and that the provided XML structure has the correct root element.
\OntologyWrapper\SimpleXMLElement | $theXML | Metadata XML. |
loadXMLUsers(\OntologyWrapper\SimpleXMLElement $theXML)
Parse and load entities
This method will parse and load the provided entities XML structure.
It is assumed that the object has its comnnections open and that the provided XML structure has the correct root element.
\OntologyWrapper\SimpleXMLElement | $theXML | Entities XML. |
loadXMLUnits(\OntologyWrapper\SimpleXMLElement $theXML)
Parse and load entities
This method will parse and load the provided units XML structure.
It is assumed that the object has its comnnections open and that the provided XML structure has the correct root element.
\OntologyWrapper\SimpleXMLElement | $theXML | Units XML. |
loadXMLTag(\OntologyWrapper\SimpleXMLElement $theXML, \OntologyWrapper\reference $theCache)
Parse and load XML tag
This method will parse and load the provided tag XML structure.
\OntologyWrapper\SimpleXMLElement | $theXML | Tag XML structure. |
\OntologyWrapper\reference | $theCache | Objects cache. |
loadXMLTerm(\OntologyWrapper\SimpleXMLElement $theXML, \OntologyWrapper\reference $theCache)
Parse and load XML term
This method will parse and load the provided term XML structure.
\OntologyWrapper\SimpleXMLElement | $theXML | Term XML structure. |
\OntologyWrapper\reference | $theCache | Objects cache. |
loadXMLNode(\OntologyWrapper\SimpleXMLElement $theXML, \OntologyWrapper\reference $theCache)
Parse and load XML node
This method will parse and load the provided node XML structure.
\OntologyWrapper\SimpleXMLElement | $theXML | Node XML structure. |
\OntologyWrapper\reference | $theCache | Objects cache. |
loadXMLEdge(\OntologyWrapper\SimpleXMLElement $theXML, \OntologyWrapper\reference $theCache)
Parse and load XML edge
This method will parse and load the provided edge XML structure.
\OntologyWrapper\SimpleXMLElement | $theXML | Edge XML structure. |
\OntologyWrapper\reference | $theCache | Objects cache. |
parseXMLElement(\OntologyWrapper\SimpleXMLElement $theElement, \OntologyWrapper\PersistentObject $theObject)
Parse and load XML element
This method will parse and load the provided XML element, the provided element is supposed to be a root level offset of the object.
The method expects two parameters:
\OntologyWrapper\SimpleXMLElement | $theElement | XML element. |
\OntologyWrapper\PersistentObject | $theObject | The object to load. |
parseXMLItem(\OntologyWrapper\reference $theValue, \OntologyWrapper\SimpleXMLElement $theElement, \OntologyWrapper\PersistentObject $theObject, string $theNode)
Parse and load XML element
This method will parse and load the provided XML element and return the tag, the eventual array element key and the value in the provided references.
This method is called recursively, it will first parse the attributes of the element determining the current tag, then it will traverse eventual embedded structures until a scalar value is found which will be fed to the {@link castXMLScalarValue()} method that will cast the value according to the most recent tag's data type.
\OntologyWrapper\reference | $theValue | Receives value. |
\OntologyWrapper\SimpleXMLElement | $theElement | XML element. |
\OntologyWrapper\PersistentObject | $theObject | The object to load. |
string | $theNode | Node reference type. |
traverseStructureOffsets(array $theOffsets, int $theNode, int $theType, $theLevel)
Traverse structure offsets.
This method will traverse the relationships of the provided node, filling the provided array container with the list of matched offsets.
The main duty of this method is to iterate all nodes pointing to the provided node via the {@link kPREDICATE_PROPERTY_OF} or {@link kPREDICATE_SUBCLASS_OF} predicates, loading the provided array container with the encountered tag offsets according to the provided type parameter, eventually recursing nested structures and schemas.
The method expects the following parameters:
If the node cannot be resolved, the method will raise an exception.
All schema and structure elements present as sub-elements will be resolved.
array | $theOffsets | Receives offsets. |
int | $theNode | Node native identifier. |
int | $theType | Result type. |
$theLevel |
setEntry(mixed $theKey, mixed $theValue, integer $theLife)
Set a dictionary entry
This method should commit a new entry in the dictionary, if it doesn't exist yet, or replace the matching entry if it already exists.
The method expects the following parameters:
If the operation fails the method should raise an exception.
mixed | $theKey | Entry key. |
mixed | $theValue | Entry value. |
integer | $theLife | Entry lifetime. |
getEntry(mixed $theKey) : mixed
Get a dictionary entry
This method should return the dictionary entry corresponding to the provided key; if the entry is not matched, the method should return NULL.
If the operation fails the method should raise an exception.
mixed | $theKey | Entry key. |
Entry value or NULL.
delEntry(mixed $theKey) : boolean
Get a dictionary entry
This method should delete the dictionary entry corresponding to the provided key; if the entry was deleted, the method should return TRUE, if the entry was not found, the method should return FALSE.
If the operation fails the method should raise an exception.
mixed | $theKey | Entry key. |
TRUE deleted, FALSE not matched.
preOffsetExists(\OntologyWrapper\reference $theOffset) : mixed
Handle offset before checking it
This method can be used to manage the offset before passing it to the inherited {@link ArrayObject::OffsetExists()} method.
The method provides the offset as a reference, if the method returns NULL it means that the offset must be passed to the inherited {@link ArrayObject::OffsetExists()}; if the method returns any other value, this will be returned and the inherited {@link ArrayObject::OffsetExists()} will be skipped.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |
NULL check offset, other, return.
preOffsetGet(\OntologyWrapper\reference $theOffset) : mixed
Handle offset before getting it
This method can be used to manage the offset before passing it to the inherited {@link ArrayObject::OffsetGet()} method.
The method provides the offset as a reference, if the method returns NULL it means that the offset must be passed to the inherited {@link ArrayObject::OffsetGet()}; if the method returns any other value, this must be returned and the inherited {@link ArrayObject::OffsetGet()} skipped.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |
NULL get offset value, other, return.
preOffsetSet(\OntologyWrapper\reference $theOffset, \OntologyWrapper\reference $theValue) : mixed
Handle offset and value before setting it
This method can be used to manage the offset before passing it to the inherited {@link ArrayObject::OffsetSet()} method.
The method provides the offset and value as references, if the method returns NULL it means that the offset and value must be passed to the inherited {@link ArrayObject::OffsetSet()}; if the method returns any other value, this means that the inherited {@link ArrayObject::OffsetSet()} should be skipped.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |
\OntologyWrapper\reference | $theValue | Offset value reference. |
NULL set offset value, other, return.
postOffsetSet(\OntologyWrapper\reference $theOffset, \OntologyWrapper\reference $theValue)
Handle offset and value after setting it
This method can be used to manage the object after calling the {@link ArrayObject::OffsetSet()} method.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |
\OntologyWrapper\reference | $theValue | Offset value reference. |
preOffsetUnset(\OntologyWrapper\reference $theOffset) : mixed
Handle offset and value before deleting it
This method can be used to manage the offset before passing it to the inherited {@link ArrayObject::OffsetUnset()} method.
The method provides the offset as reference, if the method returns NULL it means that the offset and value must be passed to the inherited {@link ArrayObject::OffsetUnset()}; if the method returns any other value, this means that the inherited {@link ArrayObject::OffsetUnset()} should be skipped.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |
NULL delete offset value, other, return.
postOffsetUnset(\OntologyWrapper\reference $theOffset)
Handle offset after deleting it
This method can be used to manage the object after calling the {@link ArrayObject::OffsetUnset()} method.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |