classCommandObjectSync
Source: command-object-sync.
Represents the definition of a synchronous command object model.
Property
Methods
Events
new CommandObjectSync([eventHandlers])
Creates a new synchronous command object model instance.
The name of the model type available as: <instance>.constructor.modelType, returns 'CommandObjectSync'.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
eventHandlers |
Yes |
The event handlers of the instance. |
- Extends
- ModelBase
- Fires
- CommandObjectSync#event:preExecute
- CommandObjectSync#event:postExecute
- Throws
-
Argument error: The event handlers must be an EventHandlerList object or null.
Property
read-only$modelName
string
The name of the model. However, it can be hidden by a model property with the same name.
Methods
staticcreate([eventHandlers]) → CommandObjectSync
Creates a new command object instance.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
eventHandlers |
Yes |
The event handlers of the instance. |
- Throws
-
Argument error: The event handlers must be an EventHandlerList object or null.
- Returns
-
CommandObjectSync
A new command object.
checkRules()
Executes all the validation rules of the command object, including the ones of its child objects.
execute([method][, isTransaction])
Executes the business object's statements in the repository.
If method is not an empty string, <instance>.execute(method)
can be called as <instance>.method() as well.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
method |
string |
Yes |
An alternative execute method of the data access object. |
isTransaction |
boolean |
Yes |
Indicates whether transaction is required. |
- Throws
-
Argument error: The method must be a string or null.
-
Argument error: The transaction indicator must be a Boolean value or null.
-
Authorization error: The user has no permission to execute the action.
-
Data portal error: Executing the command object has failed.
getBrokenRules([namespace]) → bo.rules.BrokenRulesOutput
Gets the broken rules of the command object.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
namespace |
string |
Yes |
The namespace of the message keys when messages are localizable. |
- Returns
-
bo.rules.BrokenRulesOutput
The broken rules of the business object.
getResponse([message][, namespace]) → bo.rules.BrokenRulesResponse
Gets the response to send to the client in case of broken rules.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
message |
string |
Yes |
Human-readable description of the reason of the failure. |
namespace |
string |
Yes |
The namespace of the message keys when messages are localizable. |
- Returns
-
bo.rules.BrokenRulesResponse
The broken rules response to send to the client.
isValid() → boolean
Indicates whether all the validation rules of the command object, including the ones of its child objects, succeeds. A valid command object may have broken rules with severity of success, information and warning.
- Returns
-
boolean
True when the command object is valid, otherwise false.
Events
postExecute
The event arises after the command object has been executed in the repository.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
eventArgs |
|
Data portal event arguments. |
|
newObject |
|
The instance of the model after the data portal action. |
preExecute
The event arises before the command object will be executed in the repository.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
eventArgs |
|
Data portal event arguments. |
|
oldObject |
|
The instance of the model before the data portal action. |