Models
Some adaptors connect to data stores that maintain their own metadata,
or schemas. These schemas may be harvested by the adaptor and presented
as a collection of Adaptive Object Types and Property Types, referred to
as Adaptive Schemas
. For instance, an SQL database
will contain tables that describe their table columns. A SQL adaptor may
translate those tables into Adaptive Schemas by converting them into the
appropriate Object Type definitions.
Adaptive Framework provides a special adaptor, known as the
Model Adaptor
, which takes as input an
Adaptive Model
, and uses it to transform the objects
provided by a separate adaptor, such as SQL. These transforms can by
simple, such as name mapping, or more complex, by completely
synthesizing new objects using Adaptive Scripts or Expressions.
An Adaptive Model is defined by an instance of the object type
_AdaptiveModel_
. An Adaptive Model can be stored
by any adaptor that supports the configuration parameter
isModelLocation=true
. The model is then
referenced by the Model Adaptor, using the
modelLocationAdaptorId
and
modelId
parameter combination.
Adaptive Model Example
{
"modelId": "mycorp",
"description": "Model for mycorp employees",
"objectTypes": {
"Employee": {
"mappedObjectType": "Person",
"propertyTypes": {
"employeeEmail": {
"mappedPropertyName": "fullName",
"onGetValue": "${current::mappedPropertyName}@mycorp.com"
}
}
}
}
}
Model Functions
In the previous example, you'll notice a special property called
onGetValue
. This is one of many on
functions that can be declared in an Adaptive Model to compute object
and property values on particular adaptor functions.
Here is a table of more of these functions:
Function | Description |
---|---|
onGetObject | Script to execute on get_object() |
onAddObject | Script to execute on add_object() |
onDeleteObject | Script to execute on delete_object() |
onModifyObject | Script to execute on modify_object() |
onReplaceObject | Script to execute on replace_object() |
onRetrieveObjects | Script to execute on retrieve_objects() |
onGetProperty | Evaluated when getting an object property |
onGetInitialObjectId | Optional hybrid value is evaluated to determine the objectId on add requests |
onGetInitialValue | Get initial value to for this property |
onSetProperty | Evaluated when setting an object property |
Qualified Variables
The following lists some qualified variables that can be used during model processing "on" functions. For a complete list of variables, refer to the Developer Guide on Adaptive Models.
Variable | Description |
---|---|
adaptorId | The adaptor id of the object being converted to mapped object. |
adaptorTypeSpecific | This is the adaptorTypeSpecific parameter value. |
mapBackObject | The function to map back an object. |
mappedAdaptorId | The adaptor id of the object being converted to object. |
mappedObjectType | The object type of the object being converted to object. |
objectId | This is objectId of the object to get. |
objectType | The object type of the object being converted to mapped object. |
useDefaultProcessing | Return this value to cause default processing to occur. |