%pkg.isc.rest.model.dbMappedResource
abstract class %pkg.isc.rest.model.dbMappedResource extends %pkg.isc.rest.model.resource, %pkg.isc.json.adaptor
Base class for all models that directly correspond to data from the database (e.g., %pkg.isc.rest.model.proxy and %pkg.isc.rest.model.adaptor)Method Inventory
- DeleteModelInstance()
- GetCollection()
- GetModelFromObject()
- GetModelFromResultRow()
- GetModelInstance()
- JSONExport()
- JSONExportToStream()
- JSONExportToString()
- JSONImport()
- OnAfterSaveModel()
- OnBeforeSaveModel()
- OnGetProxyColumnList()
- SaveModelInstance()
Parameters
parameter ConstructFromResultRow = 0;
If true, the whole SQL result row is passed to GetModelInstance rather than just the ID.
If true, GetModelFromResultRow() must be overridden and implemented.
parameter IndexToUse = ID;
Override to use an alternative unique index name
parameter JSONGENERATOR = %pkg.isc.json.generator;
Override to use an alternative JSON generator
parameter JSONMAPPING;
The JSON mapping of the related JSON-enabled class to use.
Defaults to empty (the default mapping for the associated class).
parameter SOURCECLASS;
The class to which this class provides REST access. It must extend %Persistent and have its %JSONENABLED class parameter set to 1 (e.g., by extending %JSON.Adaptor).
Subclasses must override this parameter.
Methods
Deletes an instance of this model, based on the identifier pID
classmethod GetCollection(ByRef URLParams, selectMode As %Integer = 0)
Since a proxy connects directly to a %persistent class, getting a collection constitutes
building and running a query, and then printing out the result set in a json format.
abstract classmethod GetModelFromObject(object As %Persistent) as %pkg.isc.rest.model.dbMappedResource
Uses the data from a persistent object to populate the properties of this model.
The object argument is a %Persistent object of whatever class is specified by SOURCECLASS. It was either opened with %OpenId, opened with an IndexOpen method, or created with %New().
This method should instantiate an instance of this model with ..%New(), populate its properties using object, and then return the model. For example, a subclass implementation might look something like:
The object argument is a %Persistent object of whatever class is specified by SOURCECLASS. It was either opened with %OpenId, opened with an IndexOpen method, or created with %New().
This method should instantiate an instance of this model with ..%New(), populate its properties using object, and then return the model. For example, a subclass implementation might look something like:
set myModel = ..%New() set myModel.name = object.DisplayName set myModel.alive = 'object.isDead() set myModel.age = object.age return myModelThis method must be overwritten by subclasses.
classmethod GetModelFromResultRow(pResultRow As %Library.IResultSet) as %pkg.isc.rest.model.dbMappedResource
May be overridden to get an instance of this class from a result set row instead of an object.
This is particularly useful for loading data from a linked table, where individual reads are expensive.
final classmethod GetModelInstance(index As %String) as %pkg.isc.rest.model.dbMappedResource
Returns an existing instance of this model, based on the identifier index, or a new instance if index is not supplied.
method JSONExport() as %Status
Serialize a JSON enabled class as a JSON document and write it to the current device.
method JSONExportToStream(ByRef export As %Stream.Object) as %Status
Serialize a JSON enabled class as a JSON document and write it to a stream.
Serialize a JSON enabled class as a JSON document and return it as a string.
method JSONImport(input) as %Status
JSONImport imports JSON or dynamic object input into this object.
The input argument is either JSON as a string or stream, or a subclass of %DynamicAbstractObject.
The input argument is either JSON as a string or stream, or a subclass of %DynamicAbstractObject.
method OnAfterSaveModel(pUserContext As %RegisteredObject)
Subclasses may override this method to do additional security checks or otherwise make changes to the model before it is saved.
Only relevant for subclasses of %pkg.isc.rest.model.proxy and %pkg.isc.rest.model.adaptor.
Should throw an exception if an error occurs - e.g., $$$ThrowStatus($$$ERROR($$$AccessDenied))
method OnBeforeSaveModel(pUserContext As %RegisteredObject)
Subclasses may override this method to do additional security checks or otherwise make changes to the model before it is saved.
Only relevant for subclasses of %pkg.isc.rest.model.proxy and %pkg.isc.rest.model.adaptor.
Should throw an exception if an error occurs - e.g., $$$ThrowStatus($$$ERROR($$$AccessDenied))
classmethod OnGetProxyColumnList(pColumnList As %DynamicObject)
Subclasses may override this method to modify the permitted set of columns/aliases for use in queries
(by default, this is the full set of exposed properties in the model with their JSON aliases)
abstract method SaveModelInstance(pUserContext As %RegisteredObject)
Saves the model instance
Inherited Members
Inherited Methods
- %AddToSaveSet()
- %ClassIsLatestVersion()
- %ClassName()
- %ConstructClone()
- %DispatchClassMethod()
- %DispatchGetModified()
- %DispatchGetProperty()
- %DispatchMethod()
- %DispatchSetModified()
- %DispatchSetMultidimProperty()
- %DispatchSetProperty()
- %Extends()
- %GetParameter()
- %IsA()
- %IsModified()
- %JSONExport()
- %JSONExportToStream()
- %JSONExportToString()
- %JSONImport()
- %JSONMappingInfo()
- %JSONNew()
- %New()
- %NormalizeObject()
- %ObjectModified()
- %OriginalNamespace()
- %PackageName()
- %RemoveFromSaveSet()
- %SerializeObject()
- %SetModified()
- %ValidateObject()
- CheckPermission()
- ModifyOpenAPIInfo()
- Supports()
- SupportsDefault()