%iKnow.Queries.MetadataI
Class %iKnow.Queries.MetadataI Extends %RegisteredObject [ Abstract, Deprecated, System = 4 ]
This is the interface to interact with metadata as expected by other parts of the iKnow libraries. A simple but flexible implementation is provided through %iKnow.Queries.MetadataAPI, but customers can choose to develop their own or wire to an existing metadata infrastructure by implementing the interface specified in this class.
Parameters
GetFieldsRT
Parameter GetFieldsRT = "mdFieldId:%String,fieldName:%String,supportedOperators:%List,dataType:%String,storage:%Integer,caseSensitive:%Boolean,lovId:%Integer,validateLov:%Boolean,hidden:%Boolean";
Methods
GetFieldId
ClassMethod GetFieldId(domainId As %Integer, fieldName As %String) As %Integer
Returns the metadata field ID corresponding to the supplied name, or "" if none exists in this domain.
AddField
ClassMethod AddField(domainId As %Integer, fieldName As %String, supportedOperators As %List, dataType As %String = {$$$MDDTSTRING}, storage As %Integer = {$$$MDSTNORMAL}, caseSensitive As %Boolean = 0, lovId As %Integer = -1, validateLov As %Boolean = 1, hidden As %Boolean = 0) As %Integer
Adds a field definition with the given name and properties.
- The supportedOperators parameter specifies which operations (such as $$$MDOPEQUAL) will be available for filtering criteria
- For dataType, choose either $$$MDDTSTRING, $$$MDDTNUMBER or $$$MDDTDATE ($horolog format)
- Use storage to control the way how values are stored: $$$MDSTNORMAL for cases where you would use a normal index, $$$MDSTBITMAP where you would use a bitmap index (few different metadata values compared to total # of records)
- If dataType is $$$MDDTSTRING, caseSensitive controls whether or not string values should be treated as case-sensitive.
- The lovId and validateLov parameters define wheter a List Of Values is available for this metadata field and whether input values should be verified against this list. See also AddListOfValues.
- If hidden is set to true, the field will by default not appear in metadata field and value lists.
SetValue
ClassMethod SetValue(domainId As %Integer, fieldName As %String, externalId As %String, value As %String) As %Status
Sets (or replaces if it exists) the value for a given metadata field (by name) for a given source (by External ID).
Values for fields of type $$$MDDTSTRING are normalized and stripped of whitespace and control characters at the beginning and end of the string.
SetValueById
ClassMethod SetValueById(domainId As %Integer, fieldId As %Integer, srcId As %Integer, value As %String) As %Status
Sets (or replaces if it exists) the value for a given metadata field (by ID) for a given source (by Source ID).
Values for fields of type $$$MDDTSTRING are normalized and stripped of whitespace and control characters at the beginning and end of the string.
StartBatch
ClassMethod StartBatch(domainId As %Integer) As %Status
Starts a 'batch' during which metadata values can be set. Some setting operations and index recalculations are optimized for batch processing.
NOTE: It is currently up to the user to make sure no metadata values are read during the batch and no values exist already (as replacing a value involves reading it). Reading metadata field values during a batch is not guaranteed to return correct results.
EndBatch
ClassMethod EndBatch(domainId As %Integer) As %Status
Ends a metadata batch. See StartBatch for more details.
SetValueByIdInternal
ClassMethod SetValueByIdInternal(domainId As %Integer, fieldId As %Integer, srcId As %Integer, value As %String, skipExistingValueCheck As %Boolean = 0) As %Status [ Internal ]
Internal method to set a metadata value directly, without performing any existence checks. If not implemented, defaults to SetValueById, ignoring skipExistingValueCheck
GetValue
ClassMethod GetValue(domainId As %Integer, fieldName As %String, externalId As %String, Output sc As %Status) As %String
Returns the actual value for a given metadata field (by name) and source (by External ID).
GetValueById
ClassMethod GetValueById(domainId As %Integer, fieldId As %Integer, srcId As %Integer, Output sc As %Status) As %String
Returns the actual value for a given metadata field (by ID) and source (by Source ID).
SortByField
ClassMethod SortByField(ByRef pResult, pDomainId As %Integer, ByRef pSources, pSort As %String, pPage As %Integer = 1, pPageSize As %Integer = 10) As %Status [ Internal ]
Allows the results of %iKnow.Queries.SourceAPI queries to be re-sorted along a particular metadata field. pSort is expected to contain the name of the metadata field to sort by, optionally followed by a space and "ASC" (default) or "DESC". The string "ExternalId" is also accepted as a valid sort field and should be resolved through the GetExternalId method in %iKnow.Queries.SourceAPI, unless there is a metadata field carrying the same name.
pSources is expected to be an array containing all (unsorted) query results with the source ID as the first row element, while pResult will be populated with the sorted results like a usual iKnow API query.
pSort can optionally be suffixed with a space and the string "ADDCOL", in which case, a column containing the actual metadata value is appended to the results. Use this feature with caution as it might impact SQL/WS clients, because the extra column is not declared in the original query specs.
Note: sources for which the requested metadata field is not populated or where its value is longer than $$$IKHASHSIZE (150 characters) will be left out of the results.
Note: This is a default implementation using other %iKnow.Queries.MetadataI methods. Subclasses may override this method using dedicated methods for improved performance
CreateFilter
ClassMethod CreateFilter(pDomainId As %Integer, pFieldName As %String, pOperator As %String, pValue As %String, Output pSC As %Status = {$$$OK}) As %iKnow.Filters.Filter [ Abstract ]
Create a %iKnow.Filters.Filter instance that filters sources according to the given criteria, using the filter class compatible with this %iKnow.Queries.MetadataI implementation.
GetFields
ClassMethod GetFields(ByRef result As %Integer, domainId As %Integer, includeHidden As %Boolean = 0) As %Status [ Abstract ]
Returns all field definitions (including their properties) for the given domain.
GetFieldInfo
ClassMethod GetFieldInfo(pDomainId As %Integer, pFieldName As %String, Output pInfo) As %Status [ Abstract ]
GetFieldInfoById
ClassMethod GetFieldInfoById(pDomainId As %Integer, pFieldId As %String, Output pInfo) As %Status [ Abstract ]