Data Model > Extending the UNICOM Intelligence Data Model > Creating a CDSC > How should a CDSC return categorical data?
 
How should a CDSC return categorical data?
The Metadata Model assigns each category full name a value that is unique within the Document. These values are called the MDM mapped category values (sometimes shortened to mapped values) and are stored in the ElementInstance object's Value property.
The MDSC can also store a value called the native value that can be used to identify the raw value used for the category in the particular data source. This value is stored in the IElementInstance.NativeValue property. If the actual raw values stored for the categories in the case data are always integers, the native value property can be used to store the raw values. If the raw values are not always integers, an integer identifier can be stored instead. For example, stores an index in the range of 1 to the number of categories in the variable.
Both the Visual Basic and the Visual C++ XML CDSCs expect the MDM mapped values to be stored in the XML case data. This means that the raw values and the MDM mapped values are the same. Therefore the source code does not make it clear which values a CDSC should return when the native and mapped values differ.
The Case Data Model has two connection properties that determine how and in what format it returns categorical data. These connection properties are:
MR Init Category Values
0 indicates that the CDSC should return the MDM mapped values.
1 indicates that the CDSC should return the CDSC's native values.
If an MDM document is not available, this setting has no effect and the CDSC should always return the native values.
MR Init Category Names
0 indicates that the Provider should return the category values (either native values or MDM mapped values).
If the MDM mapped values are being used, a value of 1 indicates that the Provider should return the category names instead of the category values.
If native values are being used, this setting has no effect and the category values are always returned. However, this connection property should not affect how the CDSC returns the data, because the Provider handles the conversions.
When the native values are returned and the native values are not the actual raw values stored in the case data (for example, because the raw values are not always integers), the CDSC and the MDSC should use the same algorithm to define the native values.
If the MDM mapped values are to be returned and an MDM document is available, provided that the IElementInstance.NativeValue property is set up for every category, the CDSC could use code similar to the following to convert from the native value to the MDM mapped value:
Dim NativeValue As Long
Dim MDMValue As Long
Dim MDMVariable As MDM.VariableInstance
' ...
' Read NativeValue from the raw data
' ...
MDMValue = MDMVariable.ElementInstances.NativeValueToValue(NativeValue)
The CDSC can return the categorical data as a string in the form "{1,2,3,5}", where 1, 2, 3, 5 are either the MDM mapped values or the native values. Alternatively, the CDSC can return the categorical data as an array of integers.
See also
Connection properties
Structure of the CDSC interface
CDSCs and variables
Custom connection properties
Testing your CDSC
Creating a CDSC