$mWrapper
$mWrapper : \OntologyWrapper\Wrapper
Wrapper.
This data member holds the data wrapper.
Service object
A service is an object that can be used to implement a set of web services, the current class implements the base functionality, concrete derived classes will extend this class to implement specific behaviours.
$mWrapper : \OntologyWrapper\Wrapper
Wrapper.
This data member holds the data wrapper.
__construct(\OntologyWrapper\Wrapper $theWrapper)
Instantiate class.
The constructor accepts a single parameter which is a {@link Wrapper} instance.
The method will perform the following steps:
\OntologyWrapper\Wrapper | $theWrapper | Data wrapper. |
handleRequest()
Handle request.
This method will handle the request and return the result.
The method will call the protected {@link executeRequest()} method which should perform what the current service was requested to do, it will then send a header signalling JSON content and send the json-encoded result.
Note that this method will exit the script, which means that you cannot do anything after this method; this also means that the caller does not need to set an {@link exit()} command.
The method will initialise the
GetStatisticsList(string $theDomain) : array
Get statistics
This method will return the statistics list related to the provided domain, the result is an array whose elements are structured as follows:
If the domain has no associated statistics, the method will return an empty array.
string | $theDomain | Statistics domain. |
List of statistics.
offsetGet(mixed $theOffset) : mixed
Return a value at a given offset
We overload this method to call the preflight method: if it returns NULL we call the parent method; if not, we return the received value.
We also overload this method to handle unmatched offsets: we prevent warnings from being issued and return NULL.
mixed | $theOffset | Offset. |
Offset value or NULL.
offsetSet(string $theOffset, mixed $theValue)
Set a value at a given offset
We overload this method to call the preflight and postflight methods: if the preflight method returns NULL we call the parent method; if not, we stop.
We also overload this method to handle NULL values: in that case we delete the offset.
string | $theOffset | Offset. |
mixed | $theValue | Value to set at offset. |
offsetUnset(string $theOffset)
Reset a value at a given offset
We overload this method to call the preflight and postflight methods: if the preflight method returns NULL we call the parent method; if not, we stop.
We also overload this method to prevent warnings on unmatched offsets.
string | $theOffset | Offset. |
Object2Array(\OntologyWrapper\reference $theSource, \OntologyWrapper\reference $theDestination)
<h4>Convert object to array</h4>
This method can be used to obtain an array of arrays from a nested structure.
The method expects as the first parameter a reference to an {@link ArrayObject} or to an array, it will convert the provided parameter to an array and traverse it, converting recursively any {@link ArrayObject} instance into an array.
The method accepts the following parameters:
\OntologyWrapper\reference | $theSource | Reference to the source structure. |
\OntologyWrapper\reference | $theDestination | Reference to the destination array. |
parseRequest()
Parse request.
This method will parse the request provided in the $_REQUEST global parameter, it will place all recognised parameters in the object's array, ignoring any unknown option.
The method takes advantage of the following protected methods:
The method will raise an exception if the operation is missing.
parseOperation()
Parse operation.
The duty of this method is to parse the provided operation and set it into the current object.
In derived classes you should parse your custom operations or call the parent method, in this class we only parse the following operations:
If the operation is not recognised, the method will raise an exception.
parseParameters()
Parse parameters.
The duty of this method is to parse the additional parameters provided in the {@link kAPI_REQUEST_PARAMETERS} argument of the service.
Each parameter will be fed to the protected {@link parseParameter()} method which derived classes can overload to handle custom values.
parseParameter(string $theKey, mixed $theValue)
Parse parameter.
The duty of this method is to parse the provided single parameter, the method expects the parameter key and value.
Both the key and the value are provided as references, this may allow derived classes to transform parameters.
Derived classes should handle their custom parameters or call the parent method, any parameter which is not handled will be ignored.
string | $theKey | Parameter key. |
mixed | $theValue | Parameter value. |
parseStringMatchOperator(mixed $theValue)
Parse string match operator.
This method will parse the provided string match operator converting the provided value to an array using the comma as a separator.
If the resiulting array is empty, the method will set by default the operator to "contains case and accent insensitive".
mixed | $theValue | Parameter value. |
validateRequest()
Validate request.
This method will be called once all parameters have been parsed and set in the object, its duty is to validate the request; this activity involves ensuring all required parameters are there and perform eventual other modifications.
In this class we check the following operations:
Any unrecognised operation will raise an exception.
Derived classes should match custom operations or call the parent method.
validateListStats()
Validate match label strings services.
This method will validate all service operations which match label strings, the method will perform the following actions:
validateMatchLabelStrings()
Validate match label strings services.
This method will validate all service operations which match label strings, the method will perform the following actions:
validateGetTagEnumerations()
Validate get tag enumerations service.
This method will validate all service operations which return tag enumerated sets, the method will perform the following actions:
validateGetNodeEnumerations()
Validate get node enumerations service.
This method will validate all service operations which return node enumerated sets, the method will perform the following actions:
validateGetNodeStruct()
Validate get node form service.
This method will validate all service operations which return node form structures, the method will perform the following actions:
validateMatchUnits()
Validate match units service.
This method will validate all service operations which match units using a list of criteria, the method will perform the following actions:
validateGetUnit()
Validate get unit service.
This method will validate all service operations which match a single unit using an identifier, the method will perform the following actions:
validateStringMatchOperator(string $theValue)
Validate string match operator.
This method will validate the operator parameter passed to all service operations which match strings, the method will perform the following operations:
If the operator is missing we will assume by default contains case and accent insensitive.
Any error will raise an exception.
string | $theValue | Operator value. |
validateRangeMatchOperator(string $theValue)
Validate range match operator.
This method will validate the operator parameter passed to all service operations which match ranges, the method will perform the following operations:
Any error will raise an exception.
string | $theValue | Operator value. |
validateCollection(array $theValue)
Validate collection reference.
This method will validate the collection parameter.
Any error will raise an exception.
This method expects the collection parameter to be an array if provided.
array | $theValue | Collection. |
validateRecurseFlag(int $theLimit)
Validate recurse flag.
This method will validate the recurse flag parameter passed to all service operations which may recursively traverse structures.
The method will remove paging if the {@link kAPI_PARAM_RECURSE} flag was provided; if the flag was not provided, the method will set the default limits to the provided maximum value, or raise an exception if both the flag and limits are missing.
Any error will raise an exception.
int | $theLimit | Default limits. |
validateGroup() : array
Validate group offset
This method will validate the provided group offset and raise an exception if the related tag does not have the {@link kTYPE_SUMMARY} kind.
The method will set the normalised list of group leaf tag sequence numbers in the {@link kAPI_PARAM_GROUP} parameter and collect all group element information in the internal {@link kAPI_PARAM_GROUP_DATA} parameter.
Group elements can be provided as tag native identifiers or offsets.
Normalised group list.
validateShape(array $theValue)
Validate shape
This method will validate the shape parameter passed to all service operations which should select objects based on geographic queries.
Any error will raise an exception.
array | $theValue | Shape value. |
executeRequest()
Execute request.
This method will parse the request operation and execute the appropriate action.
In this class we execute the following operations:
Derived classes can parse their custom operations or call the parent method.
executeMatchLabelStrings(\OntologyWrapper\CollectionObject $theCollection)
Match label strings.
This method will match all label strings from objects stored in the provided collection.
The method uses the {@link executeMatchLabelStringsQuery()} method to produce the query cursor and the {@link executeMatchLabelStringsResults()} method to compile the results.
\OntologyWrapper\CollectionObject | $theCollection | Data collection. |
executeMatchLabelObjects(\OntologyWrapper\CollectionObject $theCollection)
Match label objects.
This method will match all objects in the provided collection matching labels.
The method uses the {@link executeMatchLabelStringsQuery()} method to produce the query cursor and the {@link executeMatchLabelObjectsResults()} method to compile the results.
\OntologyWrapper\CollectionObject | $theCollection | Data collection. |
executeMatchLabelStringsQuery(\OntologyWrapper\CollectionObject $theCollection, array $theFields) : \OntologyWrapper\ObjectIterator
Query label strings.
This method will match all label strings from objects stored in the provided collection and return a recordset.
The method expects the following parameters to have been set:
The last parameter represents the fields selection.
The method will set the affected count and will skip eventual records, other cursor operations will have to be performed by the caller.
\OntologyWrapper\CollectionObject | $theCollection | Data collection. |
array | $theFields | Fields selection. |
Matched data or NULL.
executeMatchLabelStringsResults(\OntologyWrapper\ObjectIterator $theIterator)
Build label strings results.
This method will use the provided cursor to fill the service results with the requested label strings.
\OntologyWrapper\ObjectIterator | $theIterator | Iterator object. |
executeMatchLabelObjectsResults(\OntologyWrapper\ObjectIterator $theIterator)
Build label objects results.
This method will use the provided cursor to fill the service results with the requested label objects.
\OntologyWrapper\ObjectIterator | $theIterator | Iterator object. |
executeLoadEnumerations(\OntologyWrapper\ObjectIterator $theIterator, array $theContainer)
Load enumerations.
This method expects an iterator containing a list of enumerations and a reference to the results element that will receive the results.
\OntologyWrapper\ObjectIterator | $theIterator | Iterator object. |
array | $theContainer | Reference to the results container. |
executeLoadEnumeration(array $theEdge, array $theContainer)
Load single enumeration.
This method expects an iterator containing a list of enumerations and a reference to the results element that will receive the results.
array | $theEdge | Edge object. |
array | $theContainer | Reference to the results container. |
executeGroupUnits(array $theGroup, array $theContainer, string $theCollection)
Group units.
This method expects the filter data member set with the requested query.
array | $theGroup | Groupings list. |
array | $theContainer | Reference to the results container. |
string | $theCollection | collection name. |
executeUnitStat1(array $theContainer, \OntologyWrapper\ObjectIterator $theIterator)
Perform statistic 1.
This method will perform the statistics according to the data provided in the iterator parameter.
array | $theContainer | Reference to the results container. |
\OntologyWrapper\ObjectIterator | $theIterator | Iterator. |
executeUnitStat2(array $theContainer, \OntologyWrapper\ObjectIterator $theIterator)
Perform statistic 2.
This method will perform the statistics according to the data provided in the iterator parameter.
array | $theContainer | Reference to the results container. |
\OntologyWrapper\ObjectIterator | $theIterator | Iterator. |
executeUnitStat3(array $theContainer, \OntologyWrapper\ObjectIterator $theIterator)
Perform statistic 3.
This method will perform the statistics according to the data provided in the iterator parameter.
array | $theContainer | Reference to the results container. |
\OntologyWrapper\ObjectIterator | $theIterator | Iterator. |
executeUnitStat4(array $theContainer, \OntologyWrapper\ObjectIterator $theIterator)
Perform statistic 4.
This method will perform the statistics according to the data provided in the iterator parameter.
array | $theContainer | Reference to the results container. |
\OntologyWrapper\ObjectIterator | $theIterator | Iterator. |
executeUnitStat5(array $theContainer, \OntologyWrapper\ObjectIterator $theIterator)
Perform statistic 5.
This method will perform the statistics according to the data provided in the iterator parameter.
array | $theContainer | Reference to the results container. |
\OntologyWrapper\ObjectIterator | $theIterator | Iterator. |
executeUnitStat6(array $theContainer, \OntologyWrapper\ObjectIterator $theIterator)
Perform statistic 5.
This method will perform the statistics according to the data provided in the iterator parameter.
array | $theContainer | Reference to the results container. |
\OntologyWrapper\ObjectIterator | $theIterator | Iterator. |
executeUnitStat7(array $theContainer, \OntologyWrapper\ObjectIterator $theIterator)
Perform statistic 7.
This method will perform the statistics according to the data provided in the iterator parameter.
array | $theContainer | Reference to the results container. |
\OntologyWrapper\ObjectIterator | $theIterator | Iterator. |
executeSerialiseResults(\OntologyWrapper\ObjectIterator $theIterator)
Serialise results.
This method will userialise the data from the provided iterator.
\OntologyWrapper\ObjectIterator | $theIterator | Iterator object. |
executeSerialiseSummaryTags(\OntologyWrapper\ObjectIterator $theIterator)
Serialise summary tags.
This method will serialise the data from the provided iterator which is expected to hold a list of summary tag objects.
\OntologyWrapper\ObjectIterator | $theIterator | Iterator object. |
handleException(\OntologyWrapper\Exception $theException)
Handle exception.
This method should be called whenever an exception is catched, it will load the exception arguments in the {@link kAPI_RESPONSE_STATUS} block, delete all other blocks and return the JSON encoded result.
Note that the script will exit in this method.
\OntologyWrapper\Exception | $theException | Exception. |
stringMatchPattern(string $thePattern, array $theOperator) : array
Return string match criteria pattern.
This method will return the pattern corresponding to the provided operator that should be used to match a string.
The methoid will only consider the following main operators:
If none of the above are present in the operator, the method will raise an exception.
The method will only return the match value to be used in the filter criteria, it is up to the caller to add the property reference.
string | $thePattern | Match pattern. |
array | $theOperator | Match operator. |
Search criteria.
rangeMatchPattern(mixed $theMin, mixed $theMax, array $theOperator) : array
Return range match criteria pattern.
This method will return the query corresponding to the provided range input type.
Depending on the clause operator:
If none of the above are present in the operator, the method will assume range inclusive.
The method will only return the match value to be used in the filter criteria, it is up to the caller to add the property reference.
mixed | $theMin | Minimum bound. |
mixed | $theMax | Maximum bound. |
array | $theOperator | Match operator. |
Search criteria.
getRefCountTag(array $theCollection) : mixed
Get reference count tag.
This method will return the reference count tags related to the provided} value, which should be the {@link kAPI_PARAM_REF_COUNT} service parameter.
If the value is an array, the method will return an array indexed by the element with as value the reference count tag; if the value has one element, the method will return the reference count tag; if the value is missing, the method will return NULL.
array | $theCollection | Collection name. |
Reference count tags.
buildCriteria(string $theOffset, mixed $theValue, array $theOffsets) : array
Build criteria entry.
This method will return a criteria entry according to the provided parameters; it is the responsibility of the caller to manage the criteria element key.
The match is assumed an exact match.
string | $theOffset | Offset. |
mixed | $theValue | Value. |
array | $theOffsets | Offsets list. |
Criteria record.
traverseStructure(array $theContainer, int $theNode, string $theLanguage, int $theParent, string $theRefCount) : array
Traverse structure.
This method will traverse the structure of the provided form node, loading the information in the provided container.
The information is loaded as follows:
If any element cannot be resolved, the method will raise an exception.
array | $theContainer | Receives information. |
int | $theNode | Node native identifier. |
string | $theLanguage | Default language. |
int | $theParent | Parent node native identifier. |
string | $theRefCount | Reference count tag. |
Criteria record.
traverseEdges(array $theContainer, int $theNode, string $theLanguage, int $theParent, string $theRefCount) : array
Traverse edges.
This method will scan the edges that point to the provided node, recursing subclass predicates.
If any element cannot be resolved, the method will raise an exception.
array | $theContainer | Receives information. |
int | $theNode | Node native identifier. |
string | $theLanguage | Default language. |
int | $theParent | Parent node native identifier. |
string | $theRefCount | Reference count tag. |
Criteria record.
loadNodeElementInfo(array $theContainer, mixed $theNode, string $theLanguage, int $theParent, string $theRefCount) : \OntologyWrapper\Node
Load node element information.
This method will load the provided container with the information pertaining to the provided node, the information will be set as follows:
If the node cannot be resolved, the method will raise an exception.
array | $theContainer | Receives information. |
mixed | $theNode | Node native identifier. |
string | $theLanguage | Default language. |
int | $theParent | Parent node native identifier. |
string | $theRefCount | Reference count tag. |
Node object.
getStatistics(array $theContainer, string $theLanguage, string $theDomain, string $theStatistics)
Load statistics information information.
This method will load the provided container with the information pertaining to the statistics related to the provided domain in the provided language.
The container is expected to point to an array.
array | $theContainer | Results container. |
string | $theLanguage | Default language. |
string | $theDomain | Statistics domain. |
string | $theStatistics | Optional statistics code. |
setStatisticsCriteria(array $theContainer, string $theStatistics, string $theDomain)
Set statistics criteria.
This method will update the criteria according to the requested statistics.
The container is expected to hold the current criteria.
array | $theContainer | Current criteria. |
string | $theStatistics | Statistics code. |
string | $theDomain | Statistics domain. |
preOffsetExists(\OntologyWrapper\reference $theOffset) : mixed
Handle offset before checking it
This method can be used to manage the offset before passing it to the inherited {@link ArrayObject::OffsetExists()} method.
The method provides the offset as a reference, if the method returns NULL it means that the offset must be passed to the inherited {@link ArrayObject::OffsetExists()}; if the method returns any other value, this will be returned and the inherited {@link ArrayObject::OffsetExists()} will be skipped.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |
NULL check offset, other, return.
preOffsetGet(\OntologyWrapper\reference $theOffset) : mixed
Handle offset before getting it
This method can be used to manage the offset before passing it to the inherited {@link ArrayObject::OffsetGet()} method.
The method provides the offset as a reference, if the method returns NULL it means that the offset must be passed to the inherited {@link ArrayObject::OffsetGet()}; if the method returns any other value, this must be returned and the inherited {@link ArrayObject::OffsetGet()} skipped.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |
NULL get offset value, other, return.
preOffsetSet(\OntologyWrapper\reference $theOffset, \OntologyWrapper\reference $theValue) : mixed
Handle offset and value before setting it
This method can be used to manage the offset before passing it to the inherited {@link ArrayObject::OffsetSet()} method.
The method provides the offset and value as references, if the method returns NULL it means that the offset and value must be passed to the inherited {@link ArrayObject::OffsetSet()}; if the method returns any other value, this means that the inherited {@link ArrayObject::OffsetSet()} should be skipped.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |
\OntologyWrapper\reference | $theValue | Offset value reference. |
NULL set offset value, other, return.
postOffsetSet(\OntologyWrapper\reference $theOffset, \OntologyWrapper\reference $theValue)
Handle offset and value after setting it
This method can be used to manage the object after calling the {@link ArrayObject::OffsetSet()} method.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |
\OntologyWrapper\reference | $theValue | Offset value reference. |
preOffsetUnset(\OntologyWrapper\reference $theOffset) : mixed
Handle offset and value before deleting it
This method can be used to manage the offset before passing it to the inherited {@link ArrayObject::OffsetUnset()} method.
The method provides the offset as reference, if the method returns NULL it means that the offset and value must be passed to the inherited {@link ArrayObject::OffsetUnset()}; if the method returns any other value, this means that the inherited {@link ArrayObject::OffsetUnset()} should be skipped.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |
NULL delete offset value, other, return.
postOffsetUnset(\OntologyWrapper\reference $theOffset)
Handle offset after deleting it
This method can be used to manage the object after calling the {@link ArrayObject::OffsetUnset()} method.
In this class we do nothing.
\OntologyWrapper\reference | $theOffset | Offset reference. |