\OntologyWrapperNode

Node object

A node is a vertex in a graph structure, nodes reference {@link Term} and {@link Tag} instances, when referencing a term, nodes are used to build ontologies, type definitions and controlled vocabularies; when referencing tags they are used to build data structures, input and output templates and search forms.

Node objects, along with edge objects, represent the presentation layer of the ontology, users compose and consult network structures through these objects.

The class features the following default offsets:

  • {@link kTAG_NID}: Native identifier. This required attribute holds an integer serial number, nodes do not have a unique persistent identifier, since they act as references and because you may have more than one node referencing the same term or property. The native identifier is assigned automatically.
  • {@link kTAG_ID_PERSISTENT}: Persistent identifier. This optional attribute holds a string which represents a unique persitent identifier, this value must be unique among all nodes and is optional. The main duty of this attribute is to disambiguate nodes pointing to the same term or tag.
  • {@link kTAG_ID_GRAPH}: Graph node reference. If the wrapper uses a graph database, this property will be used to reference the graph node which represents the current node; it is an integer value which is automatically managed.
  • {@link kTAG_TERM}: Term. This attribute is a string that holds a reference to the term object that the current node represents in a graph structure. If this offset is set, the {@link kTAG_TAG} offset must be omitted. This attribute must be managed with its offset.
  • {@link kTAG_TAG}: Tag. This attribute is a string that holds a reference to the tag object that the current node represents in a graph structure. If this offset is set, the {@link kTAG_TERM} offset must be omitted. This attribute must be managed with its offset.
  • {@link kTAG_NODE_TYPE}: Type. This attribute is an enumerated set which qualifies and sets a context for the current node. The individual elements can be managed with the {@link NodeType()} method.
  • {@link kTAG_MASTER}: Master node. This property is featured by alias nodes, it references the master node. This property is handled automatically by the object.

The {@link __toString()} method will return the value stored in the {@link kTAG_TERM} or the {@link kTAG_TAG} offset, this value is not used as an identifier.

Node persistent identifiers are automatically assigned sequence numbers, this is because you may have more than one node pointing to the same term or tag. The object features a persistent unique identifier, {@link kTAG_ID_PERSISTENT}, which can be used to match a specific node, this attribute is optional and it is used to discriminate between master and alias nodes.

There are two main types of nodes: master and alias. A master node is considered the main referer of the featured term or tag, there can be only one master node which points to a specific term or tag. An alias node is, as the word says, an alias of the term or tag it points to. A node is an alias if it has the {@link kTAG_MASTER} property, there can be any number of alias nodes pointing to the same term or tag.

In general, master nodes are used to build the main ontology where all the functional relationships are described. Alias nodes are used to create views over the master nodes ontology, these are used to provide templates, forms and output views.

Objects of this class can hold any additional attribute that is considered necessary or useful to define and share the current node. In this class we define only those attributes that constitute the core functionality of the object, derived classes will add attributes specific to the domain in which the object will operate.

The object is considered initialised, {@link isInited()}, if it has at least the term reference, {@link kTAG_TERM}, or the tag reference, {@link kTAG_TAG}.

Summary

Methods
Properties
Constants
__construct()
__toString()
getName()
getReferenced()
ResolveDatabase()
CreateIndexes()
GetTagMaster()
GetTermMaster()
GetPidNode()
DefaultOffsets()
XMLRootElement()
insert()
commit()
export()
getMaster()
setAlias()
validate()
Delete()
Import()
ImportXML()
CreateIndex()
DeleteFieldsSelection()
ResolveCollection()
ResolveCollectionByName()
ResolveRefCountTag()
ResolveOffsetsTag()
ExternalOffsets()
DynamicOffsets()
OffsetTypes()
GetReferenceKey()
GetReferenceTypes()
GetReferenceCounts()
loadTagInformation()
loadReferenceInformation()
getReferenceTypeClass()
getReferenceTypeCollection()
getFullTextReference()
dictionary()
reference()
resolveOffset()
offsetExists()
offsetGet()
offsetSet()
offsetUnset()
InternalOffsets()
UnmanagedOffsets()
SelectLanguageString()
CastScalar()
CastShapeGeometry()
nestedOffsetGet()
nestedOffsetSet()
nestedOffsetUnset()
arrayKeys()
arrayValues()
Object2Array()
$sDefaultTags
kSEQ_NAME
preOffsetSet()
postOffsetSet()
postOffsetUnset()
preCommitPrepare()
preCommitObjectIdentifiers()
isReady()
lockedOffsets()
exportXMLObject()
loadXML()
xmlUnitElement()
matchGraphNode()
setGraphProperties()
getNodeDomain()
ClusterObjectOffsets()
preOffsetUnset()
insertObject()
commitObject()
updateObject()
deleteObject()
preCommit()
preCommitTraverse()
preCommitFinalise()
preCommitObjectTags()
preCommitObjectReferences()
preCommitGraphReferences()
postInsert()
postUpdate()
preDelete()
preDeletePrepare()
preDeleteTraverse()
preDeleteFinalise()
postDelete()
updateManyToOne()
updateOneToMany()
attributesList()
parseObject()
parseStructure()
parseProperty()
parseReference()
validateProperty()
validateReference()
castProperty()
filterExistingOffsets()
updateObjectReferenceCount()
updateTagRanges()
createGraphNode()
createRelatedGraphNodes()
exportXMLStructure()
exportXMLProperty()
exportXMLArray()
parseXMLElement()
parseXMLElementOffset()
setObjectShapes()
setObjectActualShape()
setObjectDisplayShape()
resetObjectShapes()
resolveWrapper()
compareObjectOffsets()
compareObjectReferences()
addToFullText()
preOffsetExists()
preOffsetGet()
nestedOffsetExists()
isOffsetListType()
$mDictionary
N/A
No private methods found
No private properties found
N/A

Constants

kSEQ_NAME

kSEQ_NAME

Default collection name.

This constant provides the default collection name in which objects of this class are stored.

Properties

$sDefaultTags

$sDefaultTags

Default tags table.

This static member holds the type and kind information regarding all default tags.

$mDictionary

$mDictionary : \OntologyWrapper\Dictionary

Dictionary.

This protected data member holds the data dictionary reference.

Type

\OntologyWrapper\Dictionary

Methods

__construct()

__construct(mixed $theContainer, mixed $theIdentifier, boolean $doAssert)

Instantiate class.

Objects derived from this class share the same constructor prototype and should not overload this method.

The method accepts three parameters:

  • $theContainer: This may either be an array containing the object's persistent attributes, or a reference to a {@link Wrapper} object. If this parameter is NULL, the next parameter will be ignored.
  • $theIdentifier: This parameter represents the object identifier or the object persistent attributes: in the first case it will used to select the object from the wrapper provided in the previous parameter, in the second case, it is assumed that the provided array holds the persistent attributes of an object committed in the provided container.
  • $doAssert: This boolean parameter is relevant only if the first parameter is a wrapper and the second is an identifier: if TRUE, the method will raise an exception if the object was not found.

The workflow is as follows:

  • Empty object: Both parameters are omitted.
  • Empty object with wrapper: The first parameter is a {@link Wrapper} object and the second parameter is omitted. In this case an empty object is instantiated, the committed status will not be set.
  • Filled non committed object: The first parameter is an array. In this case the committed status is not set, but the object will have content.
  • Filled committed object: The first parameter is {@link Wrapper} object and the second parameter is an array holding the object's persistent data. This combination can be used when you want to load a persistent object with its contents, in this case the object will be set committed.
  • Load object from container: The first parameter is a {@link Wrapper} object and the second parameter is a scalar identifier. Use this combination to load an object from the database, to check whether the object was loaded you must call the {@link committed()} method or provide TRUE in the third parameter to raise an exception if the object was not resolved; defaults to TRUE.

Any other combination will raise an exception.

This constructor sets the {@link isCommitted()} flag, derived classes should first call the parent constructor, then they should set the {@link isInited()} flag.

Parameters

mixed $theContainer

Data wrapper or properties.

mixed $theIdentifier

Object identifier or properties.

boolean $doAssert

Raise exception if not resolved.

Throws

\OntologyWrapper\Exception

__toString()

__toString() : string

<h4>Return global identifier</h4>

This method should return the current object's global identifier.

All derived concrete classes must implement this method.

Returns

string —

The global identifier.

getName()

getName(string $theLanguage) : string

Get object name

This method should return the object name, this value represents a name or label that characterises the current object.

Derived classes must overload this method.

Parameters

string $theLanguage

Name language.

Returns

string —

Object name.

getReferenced()

getReferenced(\OntologyWrapper\Wrapper $theWrapper, boolean $doAssert) : \OntologyWrapper\PersistentObject

Get referenced object

This method will return either the term or tag object if any is set; if none are set, the method will return NULL, or raise an exception if the second parameter is TRUE.

The first parameter is the wrapper in which the current object is, or will be, stored: if the current object has the {@link dictionary()}, this parameter may be omitted; if the wrapper cannot be resolved, the method will raise an exception.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Wrapper.

boolean $doAssert

Raise exception if not matched.

Throws

\OntologyWrapper\Exception

Returns

\OntologyWrapper\PersistentObject

Referenced tag or term or NULL.

ResolveDatabase()

ResolveDatabase(\OntologyWrapper\Wrapper $theWrapper, boolean $doAssert, boolean $doOpen) : \OntologyWrapper\DatabaseObject

Resolve the database

This method should return a {@link DatabaseObject} instance corresponding to the default database of the current class extracted from the provided {@link Wrapper} instance.

Since we cannot declare this method abstract, we raise an exception.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Wrapper.

boolean $doAssert

Raise exception if unable.

boolean $doOpen

TRUE open connection.

Throws

\OntologyWrapper\Exception

Returns

\OntologyWrapper\DatabaseObject

Database or NULL.

CreateIndexes()

CreateIndexes(\OntologyWrapper\DatabaseObject $theDatabase) : \OntologyWrapper\CollectionObject

Create indexes

This method will create the default indexes for the current class.

In this class we index the following offsets:

  • {@link kTAG_MASTER}: This will speed the search for the master object.
  • {@link kTAG_OBJECT_TAGS}: This will help the selection of objects based on the searched offsets.
  • {@link kTAG_OBJECT_OFFSETS}: This is necessary to speed referencial integrity.

Parameters

\OntologyWrapper\DatabaseObject $theDatabase

Database reference.

Returns

\OntologyWrapper\CollectionObject

The collection.

GetTagMaster()

GetTagMaster(\OntologyWrapper\Wrapper $theWrapper, mixed $theIdentifier, \OntologyWrapper\bitfield $theResult) : \OntologyWrapper\Node

Get tag node master

The method expects the following parameters:

  • $theWrapper: This parameter represents the wrapper containing both the nodes and the tags.
  • $theIdentifier: This parameter represents the tag identifier:
    • integer: If the value is an integer, the method will match the identifier with the {@link kTAG_ID_HASH} offset of the tag;
    • string: Any other type will be cast to a string, the method will match the identifier with the {@link kTAG_NID} offset of the tag.
  • $theResult: This parameter determines what the method should return, it is a bitfield which accepts two sets of values:
    • {@link kQUERY_ASSERT}: If this flag is set and the criteria doesn't match any record, the method will raise an exception.
    • Result type: This set of values can be added to the previous flag, only one of these should be provided:
      • {@link kQUERY_OBJECT}: Return the matched object.
      • {@link kQUERY_ARRAY}: Return the matched object array value.
      • {@link kQUERY_NID}: Return the matched object native identifier.
      • {@link kQUERY_COUNT}: Return the number of matched objects.

By default the result is set to return the native identifier.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Wrapper.

mixed $theIdentifier

Tag native identifier or sequence.

\OntologyWrapper\bitfield $theResult

Result type.

Returns

\OntologyWrapper\Node

Master node or NULL

GetTermMaster()

GetTermMaster(\OntologyWrapper\Wrapper $theWrapper, mixed $theIdentifier, \OntologyWrapper\bitfield $theResult) : \OntologyWrapper\Node

Get term node master

The method expects the following parameters:

  • $theWrapper: This parameter represents the wrapper containing both the nodes and the tags.
  • $theIdentifier: This parameter represents the term native identifier.
  • $theResult: This parameter determines what the method should return, it is a bitfield which accepts two sets of values:
    • {@link kQUERY_ASSERT}: If this flag is set and the criteria doesn't match any record, the method will raise an exception.
    • Result type: This set of values can be added to the previous flag, only one of these should be provided:
      • {@link kQUERY_OBJECT}: Return the matched object.
      • {@link kQUERY_ARRAY}: Return the matched object array value.
      • {@link kQUERY_NID}: Return the matched object native identifier.
      • {@link kQUERY_COUNT}: Return the number of matched objects.

By default the result is set to return the native identifier.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Wrapper.

mixed $theIdentifier

Term native identifier.

\OntologyWrapper\bitfield $theResult

Result type.

Returns

\OntologyWrapper\Node

Master node or NULL

GetPidNode()

GetPidNode(\OntologyWrapper\Wrapper $theWrapper, string $theIdentifier, \OntologyWrapper\bitfield $theResult) : \OntologyWrapper\Node

Get node by PID

The method expects the following parameters:

  • $theWrapper: This parameter represents the wrapper containing both the nodes and the tags.
  • $theIdentifier: This parameter represents the node persistent identifier.
  • $theResult: This parameter determines what the method should return, it is a bitfield which accepts two sets of values:
    • {@link kQUERY_ASSERT}: If this flag is set and the criteria doesn't match any record, the method will raise an exception.
    • Result type: This set of values can be added to the previous flag, only one of these should be provided:
      • {@link kQUERY_OBJECT}: Return the matched object.
      • {@link kQUERY_ARRAY}: Return the matched object array value.
      • {@link kQUERY_NID}: Return the matched object native identifier.
      • {@link kQUERY_COUNT}: Return the number of matched objects.

By default the result is set to return the native identifier.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Wrapper.

string $theIdentifier

Node persistent identifier.

\OntologyWrapper\bitfield $theResult

Result type.

Returns

\OntologyWrapper\Node

Node or NULL

DefaultOffsets()

DefaultOffsets() : array

Return default offsets

This method will return the list of default offsets for the current class, these are the properties known to be part of the current class: since objects may feature any defined tag, this selection provides an indication of which properties one could expect.

This selection can also be used as the minimum set of properties which an object may feature.

In this class we return an empty array.

Returns

array —

List of default offsets.

XMLRootElement()

XMLRootElement() : \OntologyWrapper\SimpleXMLElement

Return XML root element

In this class we return the METADATA root element.

Returns

\OntologyWrapper\SimpleXMLElement —

XML export root element.

insert()

insert(\OntologyWrapper\Wrapper $theWrapper, \OntologyWrapper\bitfield $theOptions) : mixed

Insert the object

This method will insert the current object into the provided persistent store only if it doesn't exist already:

  • The object is not committed:
    • The object already exists in the store: the method will do nothing.
    • The object does not exist in the store: the object will be inserted.
  • The object is committed: the method will do nothing.

The $theOptions field can be used to enable or disable related objects updates.

The method will return the inserted object native identifier or NULL if the the object was not inserted.

Do not overload this method, you should overload the methods called in this method.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Data wrapper.

\OntologyWrapper\bitfield $theOptions

Operation options.

Returns

mixed —

The object's native identifier or NULL.

commit()

commit(\OntologyWrapper\Wrapper $theWrapper, \OntologyWrapper\bitfield $theOptions) : mixed

Commit the object

This method will insert or update the current object into the provided persistent store, the method expects a single parameter representing the wrapper, this can be omitted if the object was instantiated with a wrapper.

The method will call the {@link commitObject()} method if the object was not committed and the {@link updateObject()} method if it was.

The $doRelated parameter can be used to prevent the object from updating related objects. This can be useful when adding objects as batches: in that case it may be much faster to first add the objects and then at a later stage update them.

Do not overload this method, you should overload the methods called in this method.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Data wrapper.

\OntologyWrapper\bitfield $theOptions

Operation options.

Returns

mixed —

The object's native identifier.

export()

export(string $theFormat, mixed $theContainer, \OntologyWrapper\Wrapper $theWrapper) : mixed

Export the object

This method will export the object in the provided format using the provided options.

The method expects the following parameters:

  • $theFormat: The format in which the object should be exported:
    • xml: XML, the result of the method will be a SimpleXMLElement object.
  • $theContainer: The container in which the object is to be exported; the type of this value depends on the format:
    • xml: A SimpleXMLElement object.
    Or NULL to have the method create it.
  • $theWrapper: The data wrapper related to the object, this parameter may be omitted if the object was instantiated with a wrapper.

The exported object is to be assumed a new object, this means that you should only use this method if the exported objects are to be inserted.

Parameters

string $theFormat

Dump format.

mixed $theContainer

Dump container.

\OntologyWrapper\Wrapper $theWrapper

Data wrapper.

Throws

\OntologyWrapper\Exception

Returns

mixed —

The exported object.

getMaster()

getMaster(\OntologyWrapper\Wrapper $theWrapper) : \OntologyWrapper\PersistentObject

Get master object

This method will return the master object, if the current object is already a master, the method will return it; if the master cannot be located, the method will raise an exception.

The first parameter is the wrapper in which the current object is, or will be, stored: if the current object has the {@link dictionary()}, this parameter may be omitted; if the wrapper cannot be resolved, the method will raise an exception.

This method assumes that the {@link kTAG_MASTER} property is correctly set, if that is not the case, the method will return the current object, which may not be what you want.

Note that this method should only be called on objects that are {@link isCommitted()}, if that is not the case, the method will raise an exception.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Wrapper.

Throws

\OntologyWrapper\Exception

Returns

\OntologyWrapper\PersistentObject

Master node.

setAlias()

setAlias(boolean $doSet)

Signal object as alias

This method can be used to set or reset the object {@link isAlias()} flag, this signals that the current object is an alias of the object referenced by the {@link kTAG_MASTER} offset value: to set the status pass TRUE in the parameter and FALSE to reset it.

This method should only be called on non committed objects, once set, this status is immutable, so in that case the method will raise an exception.

When resetting the status, the method will also remove the eventual {@link kTAG_MASTER} attribute.

Note that not any object can be set as alias: objects that can take this state must feature a method that selects their master object, so you should shadow this method in derived classes that do not implement the concept of master and alias.

Parameters

boolean $doSet

TRUE to set.

Throws

\OntologyWrapper\Exception

validate()

validate(boolean $doText)

Validate object

This method will validate the object by:

  • validating properties data structures,
  • casting all properties to their tag related data type,
  • validating all references.

The object is expected to have its dictionary set.

If any error occurs, the method will raise an exception.

Parameters

boolean $doText

TRUE load full text tags.

Delete()

Delete(\OntologyWrapper\Wrapper $theWrapper, mixed $theIdentifier) : mixed

Delete an object

This method will delete the object corresponding to the provided native identifier.

Deleting objects is a static matter, since, in order to ensure referential integrity, it is necessary to traverse an object which is a mirror of the persistent image. The methods which actually delete the object are declared protected, so that it should not be easy to delete an incomplete object.

This method should be called using the base class of the object one wants to delete, this means that either you know the class, or you may call this method from the object that you want to delete.

The method expects the following parameters:

  • $theWrapper: The data wrapper.
  • $theIdentifier: The object native identifier.

The method will first load the object from the persistent store and then it will call its protected {@link deleteObject()} method, returning:

  • Native identifier: If the object was deleted, the method will return the deleted object's native identifier.
  • NULL: This value will be returned if the method was unable to locate the object.
  • FALSE: This value will be returned if the object features reference counts, this means that other objects reference it and for that reason it cannot be deleted.

When loading the object only the {@link kTAG_NID}, {@link kTAG_OBJECT_OFFSETS} and {@link kTAG_OBJECT_REFERENCES} will be loaded, since these are the offsets that contain the necessary information for maintaining referential integrity, if you need to handle other object offsets, you should overload the static {@link DeleteFieldsSelection()} method.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Data wrapper.

mixed $theIdentifier

Object native identifier.

Throws

\OntologyWrapper\Exception

Returns

mixed —

Identifier, NULL or FALSE.

Import()

Import(\OntologyWrapper\Wrapper $theWrapper, mixed $theContainer) : \OntologyWrapper\PersistentObject

Import

This method can be used to instantiate an object from an export container, the method expects the data wrapper and the export container.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Data wrapper.

mixed $theContainer

Export container.

Throws

\OntologyWrapper\Exception

Returns

\OntologyWrapper\PersistentObject

The imported object.

ImportXML()

ImportXML(\OntologyWrapper\Wrapper $theWrapper, \OntologyWrapper\SimpleXMLElement $theContainer) : array

Import

This method will instantiate an object from the provided XML container.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Data wrapper.

\OntologyWrapper\SimpleXMLElement $theContainer

Export container.

Throws

\OntologyWrapper\Exception

Returns

array —

List of imported objects.

CreateIndex()

CreateIndex(\OntologyWrapper\Wrapper $theWrapper, string $theOffset, boolean $doBackground) : array

Create index

This method will create an index, for the provided tag, on all used offsets in the current object's collection.

This method should be used when a tag is to be indexed in a collection: call this static method using the desired class.

The method expects as paraneters the database and the tag's sequence number or native identifier.

If the method is unable to resolve the provided tag, it will raise an exception.

The method will return the list of indexed offsets.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Wrapper.

string $theOffset

Tag offset.

boolean $doBackground

Background creation.

Returns

array —

List of indexed offsets.

DeleteFieldsSelection()

DeleteFieldsSelection() : array

Return delete fields selection

This method should return the fields selection used to load the object to be deleted. By default we load the {@link kTAG_NID}, {@link kTAG_OBJECT_OFFSETS} and {@link kTAG_OBJECT_REFERENCES} properties, derived classes may overload this method to add other offsets.

Throws

\OntologyWrapper\Exception

Returns

array —

Delete object fields selection.

ResolveCollection()

ResolveCollection(\OntologyWrapper\DatabaseObject $theDatabase, boolean $doOpen) : \OntologyWrapper\CollectionObject

Resolve the collection

This method should return a {@link CollectionObject} instance corresponding to the persistent store in which the current object was either read or will be inserted.

The method expects the object to feature a constant, {@link kSEQ_NAME}, which serves the double purpose of providing the default collection name and the eventual sequence number index: the method will use this constant and the provided database reference to return the default {@link CollectionObject} instance.

Parameters

\OntologyWrapper\DatabaseObject $theDatabase

Database reference.

boolean $doOpen

TRUE open connection.

Returns

\OntologyWrapper\CollectionObject

Collection or NULL.

ResolveCollectionByName()

ResolveCollectionByName(\OntologyWrapper\Wrapper $theWrapper, string $theCollection) : \OntologyWrapper\CollectionObject

Resolve collection by name

Given a wrapper and a collection name, this method will return a collection reference.

If the wrapper is not connected, or if the collection could not be resolved, the method will raise an exception.

Parameters

\OntologyWrapper\Wrapper $theWrapper

Data wrapper.

string $theCollection

Collection name.

Throws

\OntologyWrapper\Exception

Returns

\OntologyWrapper\CollectionObject

The collection reference.

ResolveRefCountTag()

ResolveRefCountTag(string $theCollection) : integer

Resolve reference count tag

Given a collection name, this method will return the tag sequence number corresponding to the offset holding the number of objects, stored in the provided collection reference, that reference the current object.

If the tag could not be resolved, the method will raise an exception.

Parameters

string $theCollection

Collection name.

Throws

\OntologyWrapper\Exception

Returns

integer —

Tag sequence number.

ResolveOffsetsTag()

ResolveOffsetsTag(string $theCollection) : integer

Resolve offsets tag

Given a collection name, this method will return the tag sequence number corresponding to the tag object offset holding the set of offsets in which the tag was used by objects stored in the provided collection.

If the tag could not be resolved, the method will raise an exception.

Parameters

string $theCollection

Collection name.

Throws

\OntologyWrapper\Exception

Returns

integer —

Tag sequence number.

ExternalOffsets()

ExternalOffsets() : array

Return external offsets

This method will return the list of external offsets for the current class. These are offsets which are managed neither by clients nor by the object itself, these will generally be managed by events triggered by other objects.

These offsets:

  • Will not be part of the offset management framework.

In this class we return an empty array.

Returns

array —

List of external offsets.

DynamicOffsets()

DynamicOffsets() : array

Return dynamic offsets

This method will return the list of dynamic offsets for the current class. These are offsets which are managed by the object itself, and should not be modified by clients.

These offsets:

  • Will not be part of the offset management framework.
  • Will be reset each time the object is committed.

In this class we return an empty array.

Returns

array —

List of dynamic offsets.

OffsetTypes()

OffsetTypes(\OntologyWrapper\DictionaryObject $theDictionary, mixed $theOffset, string $theType, array $theKind, mixed $theMin, mixed $theMax, string $thePattern, boolean $doAssert) : mixed

Resolve offset types

This method will resolve the provided offset into a {@link Tag} object and return in the provided reference parameters the data type, kind, range and pattern; this is done by using the provided {@link Dictionary} object.

The method expects the following parameters:

  • $theDictionary: This parameter represents the data dictionary.
  • $theOffset: This parameter represents the offset.
  • $theType: This parameter will receive the data type of the referenced tag, if the tag could not be resolved, the value will be NULL.
  • $theKind: This parameter will receive the data kind of the referenced tag, if the tag could not be resolved, the value will be an empty array; if the tag has no data kind, the parameter will hold an empty array.
  • $theMin: This parameter will receive the data minimum range of the referenced tag, if the tag could not be resolved, the value will be NULL; if the tag has no minimum data range, the parameter will hold NULL.
  • $theMax: This parameter will receive the data maximum range of the referenced tag, if the tag could not be resolved, the value will be NULL; if the tag has no maximum data range, the parameter will hold NULL.
  • $thePattern: This parameter will receive the data pattern of the referenced tag, if the tag could not be resolved, or if the pattern is not set, the value will be NULL.
  • $doAssert: If TRUE and either the offset or the tag could not be resolved, the method will raise an exception; the default is TRUE.

If the provided offset is numeric, the method will assume it is a tag sequence number, if not, the method will resolve it into a tag sequence number; if this fails and the last paraneter is TRUE, the method will raise an exception.

The method will return TRUE if the types were resolved and NULL if not.

Parameters

\OntologyWrapper\DictionaryObject $theDictionary

Data dictionary.

mixed $theOffset

Offset.

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 offset.

Returns

mixed —

TRUE if the tag was resolved, or NULL.

GetReferenceKey()

GetReferenceKey() : string

Return reference key

The reference key is the offset that will be used when storing a set of objects into a multi class matrix. By default we use the native identifier, but in some cases other required and unique identifiers may be used for this purpose.

In this class we use {@link kTAG_NID}.

Returns

string —

Key offset.

GetReferenceTypes()

GetReferenceTypes() : array

Get reference types

This method will return the list of types that represent an object reference.

Returns

array —

List of reference types.

GetReferenceCounts()

GetReferenceCounts() : array

Get reference counts

This method will return the list of tags that represent an object reference counts.

Returns

array —

List of reference counts.

loadTagInformation()

loadTagInformation(array $theTags, array $theKind, string $theType, mixed $theMin, mixed $theMax, string $thePattern, string $thePath, string $theTag)

Load tag information

The duty of this method is to load the provided tag information into the provided array reference, the method expects the following parameters:

  • $theTags: This parameter will receive the the tag information, it is a reference to an array structured as follows:
    • key: The element key represents the tag sequence number, the value is an array structured as follows:
      • {@link kTAG_DATA_TYPE}: The item holding this key will contain the tag data type.
      • {@link kTAG_DATA_KIND}: The item holding this key will contain the tag data kind; if the tag has no data kind, this item will be an empty array.
      • {@link kTAG_MIN_RANGE}: The item holding this key will contain the tag minimum range value.
      • {@link kTAG_MAX_RANGE}: The item holding this key will contain the tag maximum range value.
      • {@link kTAG_PATTERN}: The item holding this key will contain the tag data pattern.
      • {@link kTAG_OBJECT_OFFSETS}: The item holding this key will contain the list of offset paths in which the current tag is referenced as a leaf offset (an offset holding a value, not a structure).
  • $theKind: This parameter holds the tag data kind, if missing, it will be an empty array.
  • $theType: This parameter holds the tag data type, if missing, it will be NULL.
  • $thePath: This parameter holds the offset path.
  • $theTag: This parameter holds the tag sequence number.

Parameters

array $theTags

Receives tag information.

array $theKind

Data kind.

string $theType

Data type.

mixed $theMin

Receives minimum data range.

mixed $theMax

Receives maximum data range.

string $thePattern

Receives data pattern.

string $thePath

Offset path.

string $theTag

Tag sequence number.

loadReferenceInformation()

loadReferenceInformation(mixed $theProperty, array $theRefs, string $theType, string $thePath)

Load reference information

The duty of this method is to load the provided array reference with the eventual object references, the method expects the following parameters:

  • $theProperty: This parameter represents the current property.
  • $theRefs: This parameter is a reference to an array which will receive the list of object references held by the structure, the array is structured as follows:
  • $theType: This parameter holds the tag data type.
  • $thePath: This parameter holds the offset path.

Parameters

mixed $theProperty

Property.

array $theRefs

Receives object references.

string $theType

Data type.

string $thePath

Offset path.

getReferenceTypeClass()

getReferenceTypeClass(string $theType) : string

Resolve object reference data type class

Given a data type, this method will return the base class name corresponding to the referenced object, or NULL if the data type is not an object reference.

If provided the {@link kTYPE_REF_SELF} data type, the method will return the base class name of the current object.

Parameters

string $theType

Data type.

Returns

string —

Base class name.

getReferenceTypeCollection()

getReferenceTypeCollection(string $theType) : string

Retun the collection name for a reference data type

Given a data type, this method will return the collection name corresponding to the referenced object, or NULL if the data type is not an object reference.

If provided the {@link kTYPE_REF_SELF} data type, the method will return the current object's collection name.

Parameters

string $theType

Data type.

Returns

string —

Base class name.

getFullTextReference()

getFullTextReference() : string

Retun the object full text reference

In order to generate a static URL which points to a selection it is necessary to have a value which can be selected via a full-text search: this method should return this value, which should be set just befor the object is committed.

In this class we do not use this feature, so the method will return NULL.

Returns

string —

Full text search reference.

dictionary()

dictionary(mixed $theDictionary, boolean $getOld) : \OntologyWrapper\Dictionary

Set or return data dictionary

This method can be used to set or retrieve the object's data dictionary, which is required by all derived objects to resolve offsets.

You should set this data member as soon as the object has been instantiated, before adding offsets to it.

The method expects the following parameters:

  • $theDictionary: Data dictionary or operation:
    • NULL: Return current dictionary.
    • {@link Dictionary}: Set dictionary with provided value.
  • $getOld: This parameter is a boolean which if TRUE will return the old dictionary when replacing, if FALSE, it will return the current value.

The method will raise an exception if the dictionary holds any other type except the above.

Parameters

mixed $theDictionary

New dictionary or NULL.

boolean $getOld

TRUE get old value.

Throws

\OntologyWrapper\Exception

Returns

\OntologyWrapper\Dictionary

Object data dictionary.

reference()

reference() : mixed

Return object reference

This method will return the current object's reference. This value should uniquely identify the referenced object, making it easy to retrieve the object given this reference.

In this class, and generally in all classes, the reference of an object is its native identifier, {@link kTAG_NID}.

The method must raise an exception if the reference cannot be provided.

Throws

\OntologyWrapper\Exception

Returns

mixed —

Object reference.

resolveOffset()

resolveOffset(string $theOffset, boolean $doAssert) : string

Resolve offset

This method will resolve the provided offset into a {@link Tag} serial number, this is done by using a {@link Dictionary} object stored in the current object's {@link $mDictionary} data member.

If you provide a string prefixed by the {@link kTOKEN_TAG_PREFIX} token, the method will simply return it.

All other types of offsets, except those returned by the {@link InternalOffsets()} method, will be used to locate the tag native identifier using a {@link Dictionary} object stored in the current object's {@link $mDictionary} data member; if the provided offset cannot be resolved, the method will raise an exception if the second parameter is TRUE, or NULL if the second parameter is FALSE.

The method will raise an exception if the tag cache is not set.

Parameters

string $theOffset

Data offset.

boolean $doAssert

Assert offset tag reference.

Throws

\OntologyWrapper\Exception

Returns

string —

Resolved offset.

offsetExists()

offsetExists(mixed $theOffset) : boolean

Check if an offset exists

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.

Parameters

mixed $theOffset

Offset.

Returns

boolean —

TRUE the offset exists.

offsetGet()

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.

Parameters

mixed $theOffset

Offset.

Returns

mixed —

Offset value or NULL.

offsetSet()

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.

Parameters

string $theOffset

Offset.

mixed $theValue

Value to set at offset.

offsetUnset()

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.

Parameters

string $theOffset

Offset.

InternalOffsets()

InternalOffsets() : array

Return internal offsets

This method will return the list of internal offsets for the current class, these offsets are not defined in the data dictionary and are private to the object. This method is used to exclude these offsets from the default offset resolution workflow.

These offsets:

  • Will not be part of the offset management framework.

In this class we return:

  • {@link kTAG_NID}: Native identifier.
  • {@link kTAG_CLASS}: Object class name.
  • {@link kTAG_TYPE}: Property type.
  • {@link kTAG_LANGUAGE}: Property language.
  • {@link kTAG_TEXT}: Property text.
  • {@link kTAG_URL}: Property URL.
  • {@link kTAG_GEOMETRY}: Shape property geometry.
  • {@link kTAG_RADIUS}: Shape property radius.
  • {@link kTAG_FULL_TEXT_10}: Full-text values, weight 10.
  • {@link kTAG_FULL_TEXT_06}: Full-text values, weight 6.
  • {@link kTAG_FULL_TEXT_03}: Full-text values, weight 3.

Returns

array —

List of internal offsets.

UnmanagedOffsets()

UnmanagedOffsets() : array

Return unmanaged offsets

This method will return the list of offsets which should be excluded from the offset management framework.

By default we include offsets returned by:

  • {@link ExternalOffsets()}: External offsets.
  • {@link DynamicOffsets()}: Synamic offsets.

Note that internal offsets, {@link InternalOffsets()}, are also not managed, but since those offsets do not have a sequence number, we need to treat them separately.

Derived classes may overload this method to add custom offsets.

Returns

array —

List of unmanaged offsets.

SelectLanguageString()

SelectLanguageString(array $theStrings, string $theLanguage) : string

Return language string

This method expects the value from a property of type {@link kTYPE_LANGUAGE_STRING} or {@link kTYPE_LANGUAGE_STRINGS} and a language code, its duty is to return the string matching the language code, or the default string.

The method will perform the following steps:

  • If the string matching the code is there, use it.
  • If a code 0 is there, use it.
  • Use the first string.

Parameters

array $theStrings

Language strings property.

string $theLanguage

Selected language code.

Returns

string —

The string in the provided language.

CastScalar()

CastScalar(mixed $theProperty, string $theType)

Cast scalar

The duty of this method is to cast the provided scalar property to the provided data type.

Parameters

mixed $theProperty

Property.

string $theType

Data type.

CastShapeGeometry()

CastShapeGeometry(\OntologyWrapper\reference $theShape)

Cast shape geometry

The duty of this method is to verify and cast the geometry of the provided shape. The method expects the shape to have a correct root structure, that is, it must have the shape type and geometry array, this method will traverse the geometry and its structure.

Parameters

\OntologyWrapper\reference $theShape

Shape.

nestedOffsetGet()

nestedOffsetGet(mixed $theOffset, array $theValue, mixed $theFound) : mixed

Return a value at a given nested offset

This method is the equivalent of {@link offsetGet()} for nested offsets, the method will traverse the current value until it finds the offset, if at any level an offset is not resolved, the method will return NULL.

It is assumed that all offsets except the last one must be arrays, if that is not the case, the method will return NULL.

The provided offset must be a valid nested offset, which is a sequence of numerics separated by a period; this check must have been performed by the caller.

If at any stage of the path there is a list of structures, the result will be an array of all found values.

Note that this method will only be called if the offset exists, so it must find it.

Parameters

mixed $theOffset

Offset.

array $theValue

Current value.

mixed $theFound

Found value.

Returns

mixed —

Offset value or NULL.

nestedOffsetSet()

nestedOffsetSet(string $theOffset, mixed $theValue, string $theRootOffset, array $theRootValue, string $theCurrentOffset, array $theCurrentValue) : array

Set a value at a given offset

This method is the equivalent of {@link offsetSet()} for nested offsets, the method will traverse the current value setting eventual missing intermediate offsets as arrays; note that if the method finds another kind of value, it will overwrite it with an empty array: it is assumed that setting an offset replaces the previous contents.

The method expects the following parameters:

  • $theOffset: This parameter expects the nested offset string, when recursing, it will be passed the nested offset path array.
  • $theValue: This parameter expects the value to be set at the leaf offset.
  • $theRootOffset: This parameter is only used during recursion.
  • $theRootValue: This parameter is only used during recursion.
  • $theCurrentValue: This parameter is only used during recursion.

The method will take care of setting the the object's offset.

It is assumed that all offsets except the last one must be arrays, if that is not the case, the method will return NULL.

The provided offset must be a valid nested offset, which is a sequence of numerics separated by a period; this check must have been performed by the caller.

Parameters

string $theOffset

Offset.

mixed $theValue

Value to set at offset.

string $theRootOffset

Receives root offset.

array $theRootValue

Receives root value.

string $theCurrentOffset

Receives current offset.

array $theCurrentValue

Current level value.

Throws

\OntologyWrapper\Exception

Returns

array —

The updated nested structure.

nestedOffsetUnset()

nestedOffsetUnset(string $theOffset, string $theRootOffset, array $theCurrentValue)

Reset a value at a given offset

This method is the equivalent of {@link offsetUnset()} for nested offsets, the method will traverse the current value until it reaches the requested offset and it will delete it, if any offset is not matched, or if any intermediate offset is not an array, the method will do nothing.

The method expects the following parameters:

  • $theOffset: This parameter expects the nested offset string, when recursing, it will be passed the nested offset path array.
  • $theRootOffset: This parameter is only used during recursion.
  • $theCurrentValue: This parameter is only used during recursion.

The method will take care of deleting the the object's offset. If any intermediate offset holds an empry array, the method will delete it.

It is assumed that all offsets except the last one must be arrays, if that is not the case, the method will return NULL.

The provided offset must be a valid nested offset, which is a sequence of numerics separated by a period; this check must have been performed by the caller.

Parameters

string $theOffset

Offset.

string $theRootOffset

Receives root offset.

array $theCurrentValue

Current level value.

arrayKeys()

arrayKeys() : array

Return object's offsets

This method has the same function as the PHP function {@link array_keys()}, it will return all the object's offset keys as an array.

Returns

array —

List of object offsets.

arrayValues()

arrayValues() : array

Return object's offset values

This method has the same function as the PHP function {@link array_values()}, it will return all the object's offset values as an array.

Returns

array —

List of object offset values.

Object2Array()

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:

  • $theSource: Source structure reference (read-only).
  • $theDestination: Destination array reference.

Parameters

\OntologyWrapper\reference $theSource

Reference to the source structure.

\OntologyWrapper\reference $theDestination

Reference to the destination array.

Throws

\OntologyWrapper\Exception

preOffsetSet()

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.

Parameters

\OntologyWrapper\reference $theOffset

Offset reference.

\OntologyWrapper\reference $theValue

Offset value reference.

Returns

mixed —

NULL set offset value, other, return.

postOffsetSet()

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.

Parameters

\OntologyWrapper\reference $theOffset

Offset reference.

\OntologyWrapper\reference $theValue

Offset value reference.

postOffsetUnset()

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.

Parameters

\OntologyWrapper\reference $theOffset

Offset reference.

preCommitPrepare()

preCommitPrepare(\OntologyWrapper\reference $theTags, \OntologyWrapper\reference $theRefs)

Prepare object before commit

This method is called by the {@link preCommit()} method, it should perform preliminary checks to ensure that the object is fit to be committed.

In this class we check if the object is {@link isInited()}, in derived classes you can overload this method to perform custom checks.

The method features the caller parameters, see the {@link preCommit()} method for a description of those parameters.

Parameters

\OntologyWrapper\reference $theTags

Object tags.

\OntologyWrapper\reference $theRefs

Object references.

Throws

\OntologyWrapper\Exception

preCommitObjectIdentifiers()

preCommitObjectIdentifiers()

Load object identifiers

This method is called by the {@link preCommitFinalise()} method, its duty is to compute eventual object identifiers.

In this class we do not handle identifiers, derived classes should overload this method if they need to compute identifiers.

This method should only be called if the object is not committed, since it is here that all immutable identifiers are set: in derived classes be sure to make this check.

isReady()

isReady() : boolean

Check if object is ready

This method should return TRUE if the object is ready to be committed.

In this class we ensure the object is initialised and that it holds the dictionary.

Returns

boolean —

TRUE means ready.

lockedOffsets()

lockedOffsets() : array

Return list of locked offsets

This method should return the list of locked offsets, that is, the offsets which cannot be modified once the object has been committed.

In this class we return the list of internal tags plus the {@link kTAG_MASTER}.

Returns

array —

List of locked offsets.

exportXMLObject()

exportXMLObject(\OntologyWrapper\SimpleXMLElement $theContainer, \OntologyWrapper\Wrapper $theWrapper, array $theUntracked)

Export the current object in XML format

The method will return the XML representation of the object as a SimpleXMLElement object.

The method expects the following parameters:

  • $theContainer: The root XML node element.
  • $theWrapper: The data wrapper related to the object.
  • $theUntracked: The list of offsets to be excluded.

The provided parameter represents dynamic and run-time offsets that are managed by the object's persistent framework.

The method will generate a single XML element containing the object.

Parameters

\OntologyWrapper\SimpleXMLElement $theContainer

Dump container.

\OntologyWrapper\Wrapper $theWrapper

Data wrapper.

array $theUntracked

List of untracked offsets.

loadXML()

loadXML(\OntologyWrapper\SimpleXMLElement $theElement)

Load from XML

This method will load the object with the data contained in the provided XML container, the container must be pointing to the unit node.

In this class the method will process all the {@link kIO_XML_DATA} element of the root node, derived classes should overload this method to handle root level attributes.

The object is expected to have its wrapper set.

Parameters

\OntologyWrapper\SimpleXMLElement $theElement

XML element.

xmlUnitElement()

xmlUnitElement(\OntologyWrapper\SimpleXMLElement $theRoot) : \OntologyWrapper\SimpleXMLElement

Return XML unit element

This method should return the default XML unit element as a SimpleXMLElement object.

The method expects the root element, it will add the unit element to it and return the newly created child element.

Derived concrete classes must implement this method.

Parameters

\OntologyWrapper\SimpleXMLElement $theRoot

Root container.

Returns

\OntologyWrapper\SimpleXMLElement —

XML export unit element.

matchGraphNode()

matchGraphNode(\OntologyWrapper\DatabaseGraph $theGraph) : integer

Match graph node

The responsibility of this method is to check whether a node already exists in the graph, in that case the method should return its identifier, if not, it should return FALSE.

The caller determines a match if the returned falue is an integer.

In this class we return FALSE by default.

Parameters

\OntologyWrapper\DatabaseGraph $theGraph

Graph connection.

Returns

integer —

Graph node identifier, or FALSE.

setGraphProperties()

setGraphProperties(array $theLabels, array $theProperties) : mixed

Compute graph labels and properties

This method should compute the current object's graph labels and properties, these should be set in the reference parameters.

The method returns the following values:

  • integer: An integer indicates that the object is already referenced in the graph.
  • TRUE: This value indicates that the properties have been set.
  • FALSE: This value indicates that the object should not be set in the graph.

In this class we reset the labels, the default properties are set as:

  • STORE: We set the current object's kSEQ_NAME constant.
  • CLASS: We set the current object's class name. (We cannot use the {@link kTAG_CLASS} offset, since it is set by the collection object when committing.)
  • {@link kTAG_NID}: We set the object's {@link kTAG_NID}.

Derived classes can call the parent method, then set the labels and eventual other properties.

Parameters

array $theLabels

Labels.

array $theProperties

Properties.

Returns

mixed —

Node identifier, TRUE or FALSE.

getNodeDomain()

getNodeDomain()

Get node domain

The node domain is the node type that characterises the current node, it is the element of the {@link kTAG_NODE_TYPE} enumerated set which is not among the {@link kTYPE_NODE_ROOT}, {@link kTYPE_NODE_PROPERTY} and the {@link kTYPE_NODE_ENUMERATED} node types.

The method will exclude the above values and return the first element left; if there are no elements left, it will return the {@link kTYPE_NODE_TERM}.

ClusterObjectOffsets()

ClusterObjectOffsets(array $theOffsets) : array

Cluster object offsets

This method expects a list of offsets and will return the list clustered by tag: the resulting array will be indexed by tag and the value will hold all offsets featuring that tag as the leaf node.

The method will raise an exception if iot founds a nested array.

Parameters

array $theOffsets

Offsets to normalise.

Returns

array —

Clustered offsets

preOffsetUnset()

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.

Parameters

\OntologyWrapper\reference $theOffset

Offset reference.

Returns

mixed —

NULL delete offset value, other, return.

insertObject()

insertObject(\OntologyWrapper\CollectionObject $theCollection, \OntologyWrapper\bitfield $theOptions) : mixed

Insert the object

This method will insert the current object into the provided persistent store only if not yet committed, the method will perform the following steps:

  • We call the {@link preCommit()} method that is responsible of:
    • {@link preCommitPrepare()}: Prepare the object before committing.
    • {@link preCommitTraverse()}: Traverse the object's properties validating formats and references.
    • {@link preCommitFinalise()}: Load the dynamic object properties and compute the eventual object identifiers.
  • We check whether the object already exists, if that is the case we exit.
  • We pass the current object to the collection's {@link CollectionObject::commit()} method and recuperate the identifier.
  • We call the {@link postInsert()} method that is responsible of:
    • {@link postCommitReferences()}: Update object references.
    • {@link postCommitTags()}: Update object tags.
  • We set the object {@link isCommitted()} and reset the {@link isDirty()} status.
  • We return the object's identifier.

If any of the above steps fail the method must raise an exception.

Note that this method can only be called with objects that do not have native identifiers assigned by the database, oin that case all objects will appear to be new and will be inserted.

The $doRelated parameter can be used to prevent the object from updating related objects. This can be useful when adding objects as batches: in that case it may be much faster to first add the objects and then at a later stage update them.

Do not overload this method, you should overload the methods called in this method.

Parameters

\OntologyWrapper\CollectionObject $theCollection

Data collection.

\OntologyWrapper\bitfield $theOptions

Operation options.

Returns

mixed —

The object's native identifie or NULL.

commitObject()

commitObject(\OntologyWrapper\CollectionObject $theCollection, \OntologyWrapper\bitfield $theOptions) : mixed

Commit the object

This method will insert the current object into the provided persistent store, the method will perform the following steps:

  • We call the {@link preCommit()} method that is responsible of:
    • {@link preCommitPrepare()}: Prepare the object before committing.
    • {@link preCommitTraverse()}: Traverse the object's properties validating formats and references.
    • {@link preCommitFinalise()}: Load the dynamic object properties and compute the eventual object identifiers.
  • We pass the current object to the collection's {@link CollectionObject::commit()} method and recuperate the identifier.
  • We call the {@link postInsert()} method that is responsible of:
    • {@link postCommitReferences()}: Update object references.
    • {@link postCommitTags()}: Update object tags.
  • We set the object {@link isCommitted()} and reset the {@link isDirty()} status.
  • We return the object's identifier.

If any of the above steps fail the method must raise an exception.

The $doRelated parameter can be used to prevent updating related objects.

Do not overload this method, you should overload the methods called in this method.

Parameters

\OntologyWrapper\CollectionObject $theCollection

Data collection.

\OntologyWrapper\bitfield $theOptions

Operation options.

Returns

mixed —

The object's native identifier.

updateObject()

updateObject(\OntologyWrapper\CollectionObject $theCollection, \OntologyWrapper\bitfield $theOptions) : mixed

Update the object

This method will update the current object in the provided persistent store, the method will perform the following steps:

  • We call the {@link preCommit()} method that is responsible of:
    • {@link preCommitPrepare()}: Prepare the object before committing.
    • {@link preCommitTraverse()}: Traverse the object's properties validating formats and references.
    • {@link preCommitFinalise()}: Load the dynamic object properties and compute the eventual object identifiers.
  • We pass the current object to the collection's {@link CollectionObject::save()} method and recuperate the identifier.
  • We call the {@link postUpdate()} method that is responsible of updating object references and object tags.
  • We return the object's identifier. If any of the above steps fail the method must raise an exception. The $doRelated parameter can be used to prevent updating related objects. Do not overload this method, you should overload the methods called in this method.

    Parameters

    \OntologyWrapper\CollectionObject $theCollection

    Data collection.

    \OntologyWrapper\bitfield $theOptions

    Operation options.

    Returns

    mixed —

    The object's native identifier.

  • deleteObject()

    deleteObject() : mixed

    Delete the object

    This method will delete the current object from its persistent store, the method is declared protected, because it should not be called by clients: rather, the static {@link Delete()} method should be used for this purpose.

    Deleting an object involves much more than simply removing the object from its container: all reference counts and tag offsets must be updated to maintain referential integrity, for this reason, this method should be called by an object which is {@link isCommitted()} and not {@link isDirty()}; if that is not the case, an exception will be raised.

    The object only needs the {@link kTAG_NID}, {@link kTAG_OBJECT_OFFSETS} and {@link kTAG_OBJECT_REFERENCES} properties, these are the offsets loaded by the static {@link Delete()} method which calls this one; if derived classes need other properties, they should also modify the static {@link Delete()} method accordingly.

    This method follows a workflow similar to the {@link commit()} method:

    • We check whether the object is committed and not dirty.
    • We resolve the object's collection.
    • We call the {@link preDelete()} method which is responsible for:
      • checking whether the current object is referenced, in which case the method will return FALSE and not delete the object;
      • collecting data type and kind information related to the object's tags. This operation will use the current object's {@link kTAG_OBJECT_OFFSETS} and {@link kTAG_OBJECT_REFERENCES} properties of the current object to build the tag and reference parameters holding the same information as the parameters shared by the commit phase;
      • performing final operations before the object gets deleted.
    • We pass the current object to the collection's {@link CollectionObject::delete()} method which will delete it from the collection and recuperate the result which will be returned by this method.
    • We call the {@link postDelete()} method which is the counterpart of the {@link postInsert()} method, it will:
      • update tag reference count and offsets;
      • update referenced object's reference counts.
      This method will be called only if the collection delete method returns a non NULL result: in that case it means the object doesn't exist in the collection, thus referential integrity is not affected. This should only happen if the object has been deleted after it was loaded and before this method was called.
    • We reset both the object's {@link isCommitted()} and {@link isDirty()} status.
    • We return the result of the collection delete operation.

    The method will return the object's native identifier if it was deleted; if the object is referenced, the method will return FALSE; if the object was not found in the container, the method will return NULL.

    The $doRelated parameter can be used to prevent updating related objects.

    You should overload the methods called in this method, not this method.

    Throws

    \OntologyWrapper\Exception

    Returns

    mixed —

    Native identifier, NULL or FALSE.

    preCommit()

    preCommit(\OntologyWrapper\reference $theTags, \OntologyWrapper\reference $theRefs)

    Prepare object for commit

    This method should prepare the object for being committed, the method will perform the following steps:

    • {@link preCommitPrepare()}: This method will check if the object is initialised, derived classes may overload this method to perform custom actions.
    • {@link preCommitTraverse()}: This method will traverse the object's structure performing the following actions:
      • Collect information: The method will collect all referenced tags, all offset paths and all referenced objects: this information will be used in the post-commit phase to update reference counts and tag offset usage.
      • Validate properties: The method will validate the structure and values of the object's properties, if any invalid value is encountered, an exception will be raised.
      • Cast properties: The method will cast all property values to the relative tag's data type.
    • {@link preCommitFinalise()}: This method will load the object's {@link kTAG_OBJECT_TAGS}, {@link kTAG_OBJECT_OFFSETS} and {@link kTAG_OBJECT_REFERENCES} properties, it will then compute eventual object identifiers.
    • {@link isReady()}: The final step of the pre-commit phase is to test whether the object is ready to be committed, if that is not the case, the method will raise an exception.

    The method accepts two array reference parameters which will be initialised in this method, these will be filled by the {@link preCommitTraverse()} method and will be used to set the {@link kTAG_OBJECT_TAGS}, {@link kTAG_OBJECT_OFFSETS} and {@link kTAG_OBJECT_REFERENCES} properties. These arrays are structured as follows:

    • $theTags: This array collects the set of all tags referenced by the object's properties, except for the offsets corresponding to the {@link InternalOffsets()}, the array is structured as follows:
      • key: The tag sequence number.
      • value: An array collecting all the relevant information about that tag, each element of the array is structured as follows:
        • {@link kTAG_DATA_TYPE}: The item indexed by this key will contain the corresponding tag object offset.
        • {@link kTAG_DATA_KIND}: The item indexed by this key will contain the corresponding tag object offset.
        • {@link kTAG_OBJECT_OFFSETS}: The item indexed by this key will collect the list of all the offsets in which the current tag appears as a leaf offset. In practice, this element collects all the possible offsets at any depth level in which the current tag holds a value. This also means that it will only be filled if the current tag is not a structural element.
    • $theRefs: This parameter collects all the object references featured in the current object. It is an array of elements structured as follows:
      • key: The referenced object's collection name.
      • value: The set of all native identifiers representing the referenced objects.

    These parameter will be initialised in this method.

    Derived classes should overload the called methods rather than the current one.

    Parameters

    \OntologyWrapper\reference $theTags

    Object tags.

    \OntologyWrapper\reference $theRefs

    Object references.

    Throws

    \OntologyWrapper\Exception

    preCommitTraverse()

    preCommitTraverse(\OntologyWrapper\reference $theTags, \OntologyWrapper\reference $theRefs, boolean $doValidate)

    Traverse object before commit

    This method is called by the {@link preCommit()} method, it will traverse the current object, fill the provided parameters and validate property values. For a description of the parameters to this method, please consult the {@link preCommit()} method documentation.

    In this class we perform the following actions:

    • Clear local offsets: The method will delete all offsets returned by the {@link DynamicOffsets()} static method, this is to ensure these properties are filled with current data.
    • Parse object: The method will call the {@link parseObject()} method that will perform the following actions:
      • Collect information: The method will collect all referenced tags, all offset paths and all referenced objects: this information will be used in the post-commit phase to update reference counts and tag offset usage.
      • Validate properties: The method will validate the structure and values of the object's properties, if any invalid value is encountered, an exception will be raised.
      • Cast properties: The method will cast all property values to the relative tag's data type.

    The last parameter of this method is a flag which if set will activate the validation, reference check and casting of the offsets; if not set, the method will only collect tag and reference information.

    Parameters

    \OntologyWrapper\reference $theTags

    Object tags.

    \OntologyWrapper\reference $theRefs

    Object references.

    boolean $doValidate

    TRUE validate.

    preCommitFinalise()

    preCommitFinalise(\OntologyWrapper\reference $theTags, \OntologyWrapper\reference $theRefs)

    Finalise object before commit

    This method is called by the {@link preCommit()} method, it will be executed before checking if the object is ready, {@link isReady()}, its duty is to make the last preparations before the object is to be committed.

    The method calls three methods:

    • {@link preCommitObjectTags()}: This method is responsible for loading the {@link kTAG_OBJECT_TAGS} and {@link kTAG_OBJECT_OFFSETS} object properties.
    • {@link preCommitObjectReferences()}: This method is responsible for loading the {@link kTAG_OBJECT_REFERENCES} object property.
    • {@link preCommitObjectIdentifiers()}: This method is responsible of computing eventual object identifiers.

    For a description of the parameters to this method, please consult the {@link preCommit()} method documentation.

    Parameters

    \OntologyWrapper\reference $theTags

    Object tags.

    \OntologyWrapper\reference $theRefs

    Object references.

    preCommitObjectTags()

    preCommitObjectTags(array $theTags)

    Load object tags

    This method is called by the {@link preCommitFinalise()} method, it will collect the offset tags from the provided parameter and populate the {@link kTAG_OBJECT_TAGS} and {@link kTAG_OBJECT_OFFSETS} properties of the current object.

    Note that the provided list of tags should only include leaf offset references, in other words, only properties which are not of the {@link kTYPE_STRUCT} type.

    For a description of the parameters to this method, please consult the {@link preCommit()} method documentation.

    Parameters

    array $theTags

    Object tags.

    preCommitObjectReferences()

    preCommitObjectReferences(\OntologyWrapper\reference $theRefs)

    Load object references

    This method is called by the {@link preCommitFinalise()} method, it will collect the object references from the provided parameter and populate the {@link kTAG_OBJECT_REFERENCES} property of the current object.

    For a description of the parameters to this method, please consult the {@link preCommit()} method documentation.

    In this class we simply copy the parameter to the property, derived classes may overload this method to perform custom modifications and call the parent method that will set the property.

    Parameters

    \OntologyWrapper\reference $theRefs

    Object references.

    preCommitGraphReferences()

    preCommitGraphReferences(\OntologyWrapper\DatabaseGraph $theGraph) : mixed

    Load object in graph

    This method is called by the {@link preCommitFinalise()} method, its duty is to load the object into the eventual graph

    The method will be called only if the object is not committed and if the current object's wrapper features a graph.

    Derived classes should not overload this method, but rather the methods it calls; the only exception is if the object should not be stored in the graph: in that case overload the method to return FALSE.

    If the method returns an integer, it means that the value represents the graph node identifier; if the method returns FALSE, it means that there will be no graph node.

    Parameters

    \OntologyWrapper\DatabaseGraph $theGraph

    Graph connection.

    Returns

    mixed —

    The node identifier or FALSE.

    postInsert()

    postInsert(array $theOffsets, array $theReferences, \OntologyWrapper\bitfield $theOptions)

    Handle object after insert

    This method is called immediately after the object was inserted, its duty is to update object and tag reference counts and tag offset paths, the method will perform the following steps:

    • Update tag reference counts: All tags referenced by the object's leaf offsets will have their reference count property related to the current object's base class incremented.
    • Update tag offsets: The set of offset paths in which a specific tag was referenced as a leaf offset will be added to the tag's property related to the current object's base class.
    • Update object reference counts: All objects referenced by the current object will have their reference count property related to the current object's base class incremented.

    The method expects the following parameters:

    • $theOffsets: This array parameter must be structured as the {@link kTAG_OBJECT_OFFSETS} property, the provided offsets will be added to the relative tags property set.
    • $theReferences: This array parameter must be structured as the {@link kTAG_OBJECT_REFERENCES} property, the reference counts of the objects referenced by the identifiers provided in the parameter will be incremented.

    This method is identical to the {@link postDelete()} method, except that in this case offsets will be added and reference counts will be incremented.

    Parameters

    array $theOffsets

    Tag offsets to be added.

    array $theReferences

    Object references to be incremented.

    \OntologyWrapper\bitfield $theOptions

    Operation options.

    postUpdate()

    postUpdate(array $theOffsets, array $theReferences, \OntologyWrapper\bitfield $theOptions)

    Handle object after update

    This method is called immediately after the object was updated, its duty is to update object and tag reference counts and tag offset paths, the method will perform the following steps:

    • Update new tags reference counts: All new object tags will have their relative tag object reference count property related to the current object incremented.
    • Update new tag offsets: All new tag offsets will be added to the relative tag object property determined by the static {@link ResolveOffsetsTag()} method.
    • Update new object reference counts: All new objects referenced by the current object will have their reference count property related to the current object's base class incremented.
    • Select deleted offsets: All offsets no longer part of the current object will be selected.
    • Filter existing offsets: The deleted offsets selection will be rediuced by removing all offsets which currently exist in the collection.
    • Update deleted tag offsets: All deleted tag offsets will be removed from the relative tag object property determined by the static {@link ResolveOffsetsTag()} method.
    • Update deleted object reference counts: All deleted objects referenced by the current object will have their reference count property related to the current object's base class decremented.

    The method expects the following parameters:

    • $theOffsets: This array parameter is expected to be the {@link kTAG_OBJECT_OFFSETS} property of the persistent object before it was updated.
    • $theReferences: This array parameter is expected to be the {@link kTAG_OBJECT_REFERENCES} property of the persistent object before it was updated.

    The provided array references are read-only.

    Parameters

    array $theOffsets

    Original tag offsets.

    array $theReferences

    Original object references.

    \OntologyWrapper\bitfield $theOptions

    Operation options.

    preDelete()

    preDelete() : boolean

    Prepare object for delete

    This method should prepare the object for being deleted, it mirrors the counterpart {@link preCommit()} method, except that it is intended for deleting objects. The following steps will be performed:

    • {@link preDeletePrepare()}: This method should check whether the object can be deleted, in this class we verify that the object is not referenced.
    • {@link preDeleteTraverse()}: This method is the counterpart of the {@link precommitTraverse()} method, in this class it does nothing, derived classes may overload it to modify the reference properties of the current object.
    • {@link preDeleteFinalise()}: This method should finalise the pre-delete phase ensuring the object is ready to be deleted.

    Unlike the {@link preCommit()} method, this one doesn't need to compute tag and references information, since that information is already contained in the {@link kTAG_OBJECT_OFFSETS} and {@link kTAG_OBJECT_REFERENCES} properties of the current object.

    The method will return TRUE if the object can be deleted, if any of the called methods do not return TRUE, the operation will be aborted.

    Derived classes should overload the called methods rather than the current one.

    Returns

    boolean —

    TRUE the object can be deleted.

    preDeletePrepare()

    preDeletePrepare() : boolean

    Prepare object before delete

    This method should perform a preliminary check to ensure whether the object can be deleted, the method returns a boolean value which if TRUE it indicates that it is safe to delete the object.

    In this class we check whether the object is referenced, in that case the method will return FALSE.

    Returns

    boolean —

    TRUE the object can be deleted.

    preDeleteTraverse()

    preDeleteTraverse() : boolean

    Traverse object before delete

    This method is called by the {@link preDelete()} method, in this class it does nothing; derived classes may overload it to modify the {@link kTAG_OBJECT_OFFSETS} and {@link kTAG_OBJECT_REFERENCES} properties of the current object that will be used in the post-delete phase to update referential integrity.

    In this class we return by default TRUE.

    Returns

    boolean —

    TRUE the object can be deleted.

    preDeleteFinalise()

    preDeleteFinalise() : boolean

    Finalise object before delete

    This method will be called before the object will be deleted, it is the last chance to perform custom checks or modify the parameters passed to the post-delete phase.

    In this class we do nothing.

    Returns

    boolean —

    TRUE the object can be deleted.

    postDelete()

    postDelete(array $theOffsets, array $theReferences)

    Handle object after delete

    This method is called immediately after the object was deleted, its duty is to update object and tag reference counts and tag offset paths, the method will perform the following steps:

    • Update tag reference counts: All tags referenced by the object's leaf offsets will have their reference count property related to the current object's base class decremented.
    • Update tag offsets: The set of offset paths in which a specific tag was referenced as a leaf offset will be removed from the tag's property related to the current object's base class.
    • Update object reference counts: All objects referenced by the current object will have their reference count property related to the current object's base class decremented.

    The method expects the following parameters:

    • $theOffsets: This array parameter must be structured as the {@link kTAG_OBJECT_OFFSETS} property, the provided offsets will be removed from the relative tags property set.
    • $theReferences: This array parameter must be structured as the {@link kTAG_OBJECT_REFERENCES} property, the reference counts of the objects referenced by the identifiers provided in the parameter will be decremented.

    This method is identical to the {@link postInsert()} method, except that in this case offsets will be removed and reference counts will be decremented.

    In this method we call be default the {@link updateManyToOne() } method to ensure referential integrity.

    Parameters

    array $theOffsets

    Tag offsets to be removed.

    array $theReferences

    Object references to be decremented.

    updateManyToOne()

    updateManyToOne(\OntologyWrapper\bitfield $theOptions)

    Update many to one relationships

    The duty of this method is to load the current object reference in the object that keeps track of it, this is the counterpart of the {@link updateOneToMany()} method.

    This usually happens whan the related object holds the list of objects which point to it. This method should add or update the entry relating to the current object in the related object.

    The method wxpects the wrapper of the current object to be set and expects a single parameter which holds the commit or delete operation options: the method should be called only if the {@link kFLAG_OPT_REL_ONE} flag is set, will this method perform its duty.

    This method will be called after the object was committed.

    By default only this method is called, since it ensures referential integrity: the relations are recursed up to the root element.

    By default this method does nothing.

    Parameters

    \OntologyWrapper\bitfield $theOptions

    Operation options.

    updateOneToMany()

    updateOneToMany(\OntologyWrapper\bitfield $theOptions)

    Update one to many relationships

    The duty of this method is to load the references of objects pointing to the current object, this is the counterpart of the {@link updateOneToMany()} method.

    This usually happens whan the current object holds a list of objects, this method should select all the objects to which it points to and load them in the appropriate property.

    The method wxpects the wrapper of the current object to be set and expects a single parameter which holds the commit or delete operation options: the method should be called only if the {@link kFLAG_OPT_REL_MANY} flag is set, will this method perform its duty.

    This method will be called before the object's commit phase.

    By default this method does nothing.

    Parameters

    \OntologyWrapper\bitfield $theOptions

    Operation options.

    attributesList()

    attributesList() : array

    Return object list attributes

    This method should return an array with the significant attributes of the current object, this information will be used by other objects when referencing the current object.

    If the object wishes not to provide information, the method should return an empty array.

    In this class the method does nothing.

    Returns

    array —

    The list of properties.

    parseObject()

    parseObject(array $theTags, array $theRefs, boolean $doValidate, boolean $doText)

    Parse object

    The duty of this method is to traverse the current object structure, collect tag, offset and reference information and eventually validate the object properties.

    The method expects the following parameters:

    • $theTags: This parameter will receive the list of tags used in the current object, the parameter is a reference to an array indexed by tag sequence number holding the following elements:
      • {@link kTAG_DATA_TYPE}: The item indexed by this key will contain the tag data type.
      • {@link kTAG_DATA_KIND}: The item indexed by this key will contain the tag data kinds.
      • {@link kTAG_OBJECT_OFFSETS}: The item indexed by this key will collect all the possible offsets at any depth level in which the current tag holds a scalar value (not a structure).
    • $theRefs: This parameter will receive the list of all object references held by the object, the parameter is an array reference in which the key is the collection name and the value is a list of native identifiers of the referenced objects held by the collection.
    • $doValidate: If this parameter is TRUE, the object's properties will be validated and cast to their correct type.
    • $doText: If this parameter is TRUE, the object will be filled with the full-text properties, if FALSE, these properties will be left untouched.

    Parameters

    array $theTags

    Receives tag information.

    array $theRefs

    Receives references information.

    boolean $doValidate

    TRUE validate.

    boolean $doText

    TRUE load full text search.

    parseStructure()

    parseStructure(array $theStructure, array $thePath, array $theTags, array $theRefs, boolean $doValidate, boolean $doText)

    Parse structure

    This method will parse the provided structure collecting tag, offset and object reference information in the provided reference parameters, the method will perform the following actions:

    • Collect tag information: The method will collect all tags referenced by the leaf offsets of the provided structure and for each tag it will collect the data type, data kind and offset path.
    • Collect object references: The method will collect all object references contained in the provided structure, these references will be grouped by collection.
    • Validate properties: The method will validate all properties of the provided structure, if the last parameter is TRUE.
    • Cast properties: The method will cast all properties of the provided structure to the expected data type, if the last parameter is TRUE.

    The above actions will only be applied to offsets not belonging to the list of internal offsets, {@link InternalOffsets()}, and the method will recursively be applied to all nested structures.

    The method expects the following parameters:

    • $theStructure: This parameter is a reference to an array containing the structure.
    • $thePath: This parameter is a reference to an array representing the path of offsets pointing to the provided structure.
    • $theTags: This parameter is a reference to an array which will receive tag information related to the provided structure's offsets, the array is structured as follows:
      • key: The element key represents the tag sequence numbers referenced by the offset. Each element is an array structured as follows:
        • {@link kTAG_DATA_TYPE}: The item holding this key will contain the tag data type.
        • {@link kTAG_DATA_KIND}: The item holding this key will contain the tag data kind; if the tag has no data kind, this item will be an empty array.
        • {@link kTAG_OBJECT_OFFSETS}: The item holding this key will contain the list of offset paths in which the current tag is referenced as a leaf offset (an offset holding a value, not a structure).
    • $theRefs: This parameter is a reference to an array which will receive the list of object references held by the structure, the array is structured as follows:
      • key: The element key represents a collection name.
      • value: The element value is the list of references to objects belonging to the collection.
    • $doValidate: This boolean flag indicates whether the method should validate and cast the structure elements.
    • $doText: If this parameter is TRUE, the full-text search properties will be updated.

    Parameters

    array $theStructure

    Structure.

    array $thePath

    Receives the offset path.

    array $theTags

    Receives the tag information.

    array $theRefs

    Receives the object references.

    boolean $doValidate

    TRUE validate.

    boolean $doText

    TRUE load full text search.

    Throws

    \OntologyWrapper\Exception

    parseProperty()

    parseProperty(mixed $theProperty, string $theType, array $theKind, mixed $theMin, mixed $theMax, string $thePattern, string $thePath, boolean $doValidate, boolean $doText) : string

    Parse property

    The duty of this method is to parse the provided scalar property and perform the following actions:

    • Validate reference: If the provided property is an object reference, the method will commit it, if it is a non committed object and the .
    • Validate properties: The method will check if the provided list or structure is an array, or validate the provided property if it is a scalar.
    • Cast properties: The method will cast the property value if it is a scalar.

    The method expects the following parameters:

    • $theProperty: The property to parse, a scalar property is expected.
    • $theType: The property data type.
    • $thePath: The property offset path.
    • $doValidate: This boolean flag indicates whether the method should validate and cast the structure elements.
    • $doText: If this parameter is TRUE, the object will be filled with the full-text properties, if FALSE, these properties will be left untouched.

    Parameters

    mixed $theProperty

    Property.

    string $theType

    Data type.

    array $theKind

    Data kind.

    mixed $theMin

    Minimum data range.

    mixed $theMax

    Maximum data range.

    string $thePattern

    Data pattern.

    string $thePath

    Offset path.

    boolean $doValidate

    TRUE validate.

    boolean $doText

    TRUE load full text search.

    Returns

    string —

    Eventual property class name.

    parseReference()

    parseReference(mixed $theProperty, string $theClass, string $thePath)

    Parse reference

    The duty of this method is to parse the provided reference expressed as an object, the method will perform the following actions:

    • Check class: If the provided property is an object and is not an instance of the provided class, the method will raise an exception.
    • Commit object: If the provided property is an uncommitted object, the method will commit it.
    • Check object identifier: If the provided property is an object which lacks its native identifier, the method will raise an exception.
    • Use object native identifier: The method will replace the object with its native identifier.

    Parameters

    mixed $theProperty

    Property.

    string $theClass

    Object class name.

    string $thePath

    Offset path.

    Throws

    \OntologyWrapper\Exception

    validateProperty()

    validateProperty(mixed $theProperty, string $theType, array $theKind, mixed $theMin, mixed $theMax, string $thePattern, string $thePath)

    Validate property

    The duty of this method is to validate the provided scalar property. In this class we check whether the structure of the property is correct, we assert the following properties:

    • We check whether structured data types are arrays.
    • We check the contents of shapes.
    • We assert that all other data types are not arrays.

    Parameters

    mixed $theProperty

    Property.

    string $theType

    Data type.

    array $theKind

    Data kind.

    mixed $theMin

    Receives minimum data range.

    mixed $theMax

    Receives maximum data range.

    string $thePattern

    Receives data pattern.

    string $thePath

    Offset path.

    Throws

    \OntologyWrapper\Exception

    validateReference()

    validateReference(mixed $theProperty, string $theType, string $theClass, string $thePath)

    Validate reference

    The duty of this method is to validate the provided object reference, the method will perform the following actions:

    • Cast reference: The method will cast the object references.
    • Assert reference: The method will resolve the references.

    This method expects an object reference, not an object, the latter case must have been handled by the {@link parseReference()} method.

    Parameters

    mixed $theProperty

    Property.

    string $theType

    Data type.

    string $theClass

    Object class name.

    string $thePath

    Offset path.

    Throws

    \OntologyWrapper\Exception

    castProperty()

    castProperty(mixed $theProperty, string $theType, string $thePath, boolean $doValidate, boolean $doText)

    Cast scalar

    The duty of this method is to cast the provided scalar property to the provided data type.

    Parameters

    mixed $theProperty

    Property.

    string $theType

    Data type.

    string $thePath

    Offset path.

    boolean $doValidate

    TRUE validate.

    boolean $doText

    TRUE load full text search.

    Throws

    \OntologyWrapper\Exception

    filterExistingOffsets()

    filterExistingOffsets(\OntologyWrapper\CollectionObject $theCollection, array $theTags)

    Filter existing offsets

    The duty of this method is to remove from the provided offset paths list all those elements which exist in the provided collection. This method should be called after deleting or modifying an object, the processed list can then be used to update the tag offset paths.

    The provided offsets list should have the same structure as the {@link kTAG_OBJECT_OFFSETS} property.

    for each offset, the method will check whether it exists in the provided collection, if that is the case, the method will remove it from the array item, removing tag elements if there are no offsets left.

    The method expects the tags parameter to be an array.

    Parameters

    \OntologyWrapper\CollectionObject $theCollection

    Collection.

    array $theTags

    Object tags.

    updateObjectReferenceCount()

    updateObjectReferenceCount(string $theCollection, mixed $theIdent, string $theIdentOffset, integer $theCount)

    Update object reference count

    This method expects the collection, identifiers and identifier offsets of the objects in which the reference count property referred to this object will be updated by the count provided in the last parameter.

    The method accepts the following parameters:

    • $theCollection: The name of the collection containing the objects in which the reference count properties should be updated.
    • $theIdent: The object identifier or list of identifiers of the provided collection.
    • $theIdentOffset: The offset matching to the provided identifiers.
    • $theCount: The reference count by which to update.

    The method will first resolve the reference count property tag corresponding to the current object using the static {@link ResolveRefCountTag()} method; it will then select all objects in the provided collection whose provided identifier offset matches the provided identifiers list; it will then update the reference count property, resolved in the first step, of all the selected objects by the count provided in the last parameter.

    The method assumes the current object has its {@link dictionary()} set.

    Parameters

    string $theCollection

    Collection name.

    mixed $theIdent

    Object identifier or identifiers.

    string $theIdentOffset

    Identifier offset.

    integer $theCount

    Reference count.

    updateTagRanges()

    updateTagRanges()

    Update tag ranges

    This method will update all tag objects range values according to the current object tag values which are recorded in the {@link kTAG_OBJECT_OFFSETS} property.

    The method will cycle all object's tag offsets and with all those of kind continuous, {@link kTYPE_QUANTITATIVE}, it will collect the minimum and maximum values and update the related tag object's minimum, {@link kTAG_MIN_VAL},and maximum {@link kTAG_MAX_VAL}, properties.

    The method assumes the current object has its {@link dictionary()} set.

    createGraphNode()

    createGraphNode(\OntologyWrapper\DatabaseGraph $theGraph) : mixed

    Create graph node

    The responsibiliuty of this method is to create the current object's graph node and to return its identifier. If the object already has a related node, the method will only return its identifier.

    If the object should not be stored in the graph, the method should return FALSE.

    This method is called by the {@link preCommitGraphReferences()} method which will only call it if the current object is not committed and if the current object's wrapper features a graph connection.

    Parameters

    \OntologyWrapper\DatabaseGraph $theGraph

    Graph connection.

    Returns

    mixed —

    Node identifier, TRUE or FALSE.

    createRelatedGraphNodes()

    createRelatedGraphNodes(\OntologyWrapper\DatabaseGraph $theGraph)

    Create related graph nodes

    The responsibility of this method is to create eventual related graph nodes, the method expects the graph connection and the current object's graph node reference must have been set in the {@link kTAG_ID_GRAPH} property.

    If In thyis class we do nothing.

    Parameters

    \OntologyWrapper\DatabaseGraph $theGraph

    Graph connection.

    exportXMLStructure()

    exportXMLStructure(mixed $theStructure, \OntologyWrapper\SimpleXMLElement $theContainer, \OntologyWrapper\Wrapper $theWrapper, array $theUntracked)

    Export the provided structure to XML

    The method will load the provided structure into the provided XML container.

    Parameters

    mixed $theStructure

    Structure to export.

    \OntologyWrapper\SimpleXMLElement $theContainer

    XML container (parent).

    \OntologyWrapper\Wrapper $theWrapper

    Data wrapper.

    array $theUntracked

    List of untracked offsets.

    exportXMLProperty()

    exportXMLProperty(mixed $theProperty, \OntologyWrapper\SimpleXMLElement $theContainer, \OntologyWrapper\Wrapper $theWrapper, array $theUntracked, array $theTag)

    Export the provided property to XML

    The method will load the provided property into the provided XML container.

    Parameters

    mixed $theProperty

    Property to export.

    \OntologyWrapper\SimpleXMLElement $theContainer

    XML container (parent).

    \OntologyWrapper\Wrapper $theWrapper

    Data wrapper.

    array $theUntracked

    List of untracked offsets.

    array $theTag

    Property tag.

    exportXMLArray()

    exportXMLArray(mixed $theProperty, \OntologyWrapper\SimpleXMLElement $theContainer)

    Export the provided array to XML

    The method will load the provided array into the provided XML container, the method expects an array or a series of nested arrays.

    Parameters

    mixed $theProperty

    Property to export.

    \OntologyWrapper\SimpleXMLElement $theContainer

    XML container (parent).

    parseXMLElement()

    parseXMLElement(\OntologyWrapper\SimpleXMLElement $theElement, mixed $theValue) : string

    Parse XML element

    The duty of this method is to parse the provided XML element and return the element value in the provided container reference and the element offset as the result.

    Parameters

    \OntologyWrapper\SimpleXMLElement $theElement

    XML element.

    mixed $theValue

    Value container.

    Throws

    \OntologyWrapper\Exception

    Returns

    string —

    Offset.

    parseXMLElementOffset()

    parseXMLElementOffset(\OntologyWrapper\SimpleXMLElement $theElement) : mixed

    Parse XML element offset

    The duty of this method is to parse the provided XML element and return the element offset.

    The method will return:

    • integer: The element references a tag.
    • string: The element references an object key.
    • NULL: The element is an array element.

    Parameters

    \OntologyWrapper\SimpleXMLElement $theElement

    XML element.

    Throws

    \OntologyWrapper\Exception

    Returns

    mixed —

    Offset or NULL for array elements.

    setObjectShapes()

    setObjectShapes(boolean $doUpdate) : boolean

    Set object shapes

    This method can be used to set the object {@link kTAG_GEO_SHAPE} and {@link kTAG_GEO_SHAPE_DISP} properties, the method will first set the actual shape, if this was performed, it will set the display shape.

    The method will return TRUE if the shapes were set or found and FALSE if not.

    Parameters

    boolean $doUpdate

    TRUE means force update.

    Returns

    boolean —

    TRUE if the shapes were set or found.

    setObjectActualShape()

    setObjectActualShape() : boolean

    Set object actual shape

    This method can be used to the the object {@link kTAG_GEO_SHAPE} which represents the object's real shape.

    The method will return TRUE if the shape was set or found and FALSE if not.

    In this class we assume the object does not have a shape, in derived classes you should only need to overload this method if the object features a shape.

    Returns

    boolean —

    TRUE if the shape was set or found.

    setObjectDisplayShape()

    setObjectDisplayShape()

    Set object display shape

    This method can be used to the the object display shape, {@link kTAG_GEO_SHAPE_DISP}, it expects the {@link setObjectActualShape()} to have been called beforehand.

    resetObjectShapes()

    resetObjectShapes()

    Reset object shapes

    This method can be used to reset the object {@link kTAG_GEO_SHAPE} and {@link kTAG_GEO_SHAPE_DISP} properties, by default, the method will assume the shapes to be at the root level of the object, derived classes should overload the method to handle shapes embedded in sub-structures.

    resolveWrapper()

    resolveWrapper(\OntologyWrapper\reference $theWrapper)

    Resolve wrapper

    This method can be used to resolve the wrapper, it expects a reference to a wrapper which will either set the current object's {@link dictionary()}, or will be set by the current object's {@link dictionary()}.

    The method assumes that the wrapper must be resolved, if that is not the case, the method will raise an exception.

    Parameters

    \OntologyWrapper\reference $theWrapper

    Data wrapper.

    Throws

    \OntologyWrapper\Exception

    compareObjectOffsets()

    compareObjectOffsets(\OntologyWrapper\reference $theNew, \OntologyWrapper\reference $theOld, boolean $doDiff) : array

    Compare object offsets

    This method expects two parameters structured as the {@link kTAG_OBJECT_OFFSETS} property, it will return either the differences or the matches between the two parameters.

    The difference is computed by selecting all elements featured by the first parameter not existing in the second parameter; the similarity is computed by selecting only those elements belonging to both parameters.

    If the third parameter is TRUE, the method will compute the difference, if not, the similarity.

    The method will return the computed array, no elements will be empty.

    Parameters

    \OntologyWrapper\reference $theNew

    New parameter.

    \OntologyWrapper\reference $theOld

    Old parameter.

    boolean $doDiff

    TRUE compute difference.

    Returns

    array —

    The difference or intersection.

    compareObjectReferences()

    compareObjectReferences(\OntologyWrapper\reference $theNew, \OntologyWrapper\reference $theOld, boolean $doDiff) : array

    Compare object references

    This method expects two parameters structured as the {@link kTAG_OBJECT_REFERENCES} property, it will return either the differences or the matches between the two parameters.

    The difference is computed by selecting all elements featured by the first parameter not existing in the second parameter; the similarity is computed by selecting only those elements belonging to both parameters.

    If the third parameter is TRUE, the method will compute the difference, if not, the similarity.

    The method will return the computed array, no elements will be empty.

    Parameters

    \OntologyWrapper\reference $theNew

    New parameter.

    \OntologyWrapper\reference $theOld

    Old parameter.

    boolean $doDiff

    TRUE compute difference.

    Returns

    array —

    The difference or intersection.

    addToFullText()

    addToFullText(mixed $theValue, string $theLanguage, string $theType, array $theKind)

    Add value to full text

    This method will add the label of the provided term to the {@link kTAG_FULL_TEXT_10}, {@link kTAG_FULL_TEXT_06} and {@link kTAG_FULL_TEXT_03} of the current object.

    The method assumes the current object has its wrapper set and the default language definition is in the includes.

    If the term is not resolved, the method will do nothing.

    Parameters

    mixed $theValue

    Value to add.

    string $theLanguage

    Text language.

    string $theType

    Tag type.

    array $theKind

    Tag kind.

    preOffsetExists()

    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.

    Parameters

    \OntologyWrapper\reference $theOffset

    Offset reference.

    Returns

    mixed —

    NULL check offset, other, return.

    preOffsetGet()

    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.

    Parameters

    \OntologyWrapper\reference $theOffset

    Offset reference.

    Returns

    mixed —

    NULL get offset value, other, return.

    nestedOffsetExists()

    nestedOffsetExists(array $theOffset, mixed $theValue) : boolean

    Check if an offset exists

    This method is the equivalent of {@link offsetExists()} for nested offsets, the method will traverse the current value until it finds the offset, if at any level an offset is not resolved, the method will return FALSE.

    It is assumed that all offsets except the last one must be structures, if that is not the case, the method will return FALSE.

    The provided offset must be a valid nested offset, which is a sequence of numerics separated by a period; this check must have been performed by the caller.

    Parameters

    array $theOffset

    Offsets path.

    mixed $theValue

    Parent offset value.

    Returns

    boolean —

    TRUE the offset exists.

    isOffsetListType()

    isOffsetListType(mixed $theOffset) : boolean

    Check if offset is a list type

    This method will check whether the provided offset is a list type, that is, if it has the {@link kTYPE_LIST} in its data kind, or if the root element is an array.

    The method will return TRUE if the provided offset is an array.

    If the offset is not a tag, the method will raise an exception.

    Parameters

    mixed $theOffset

    Offset.

    Returns

    boolean —

    TRUE if the offset is an array.