Property

new EditableRootModelSync([eventHandlers])

Creates a new synchronous editable root model instance.

The name of the model type available as: <instance>.constructor.modelType, returns 'EditableRootModelSync'.

Parameter

Name Type Optional Description

eventHandlers

bo.shared.EventHandlerList

Yes

The event handlers of the instance.

Extends
ModelBase
Fires
EditableRootModelSync#event:preCreate
EditableRootModelSync#event:postCreate
EditableRootModelSync#event:preFetch
EditableRootModelSync#event:postFetch
EditableRootModelSync#event:preInsert
EditableRootModelSync#event:postInsert
EditableRootModelSync#event:preUpdate
EditableRootModelSync#event:postUpdate
EditableRootModelSync#event:preRemove
EditableRootModelSync#event:postRemove
EditableRootModelSync#event:preSave
EditableRootModelSync#event:postSave
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

static
create([eventHandlers]) → EditableRootModelSync

Creates a new editable business object instance.

Parameter

Name Type Optional Description

eventHandlers

bo.shared.EventHandlerList

Yes

The event handlers of the instance.

Throws

Argument error: The event handlers must be an EventHandlerList object or null.

Authorization error: The user has no permission to execute the action.

Data portal error: Creating the business object has failed.

Returns

EditableRootModelSync A new editable business object.

static
fetch([filter][, method][, eventHandlers]) → EditableRootModelSync

Retrieves an editable business object from the repository.

Parameters

Name Type Optional Description

filter

any type

Yes

The filter criteria.

method

string

Yes

An alternative fetch method of the data access object.

eventHandlers

bo.shared.EventHandlerList

Yes

The event handlers of the instance.

Throws

Argument error: The method must be a string or null.

Argument error: The event handlers must be an EventHandlerList object or null.

Authorization error: The user has no permission to execute the action.

Data portal error: Fetching the business object has failed.

Returns

EditableRootModelSync The required editable business object.

checkRules()

Executes all the validation rules of the business object, including the ones of its child objects.

protected
childHasChanged()

Notes that a child object has changed.
This method is called by child objects.

protected
create()

Initializes a newly created business object.
This method is called by a factory method with the same name.

Throws

Authorization error: The user has no permission to execute the action.

Data portal error: Creating the business object has failed.

protected
fetch([filter][, method])

Initializes a business object to be retrieved from the repository.
This method is called by a factory method with the same name.

Parameters

Name Type Optional Description

filter

any type

Yes

The filter criteria.

method

string

Yes

An alternative fetch method of the data access object.

Throws

Argument error: The method must be a string or null.

Authorization error: The user has no permission to execute the action.

Data portal error: Fetching the business object has failed.

fromCto(cto)

Rebuilds the business object from a plain object sent by the client.

Parameter

Name Type Optional Description

cto

object

 

The client transfer object.

getBrokenRules([namespace]) → bo.rules.BrokenRulesOutput

Gets the broken rules of the business 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.

getModelState() → string

Gets the state of the model. Valid states are: pristine, created, changed, markedForRemoval and removed.

Returns

string The state of the model.

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.

isDeleted() → boolean

Indicates whether the business object will be deleted from the repository, i.e. its state is markedForRemoval.

Returns

boolean True when the business object will be deleted, otherwise false.

isDirty() → boolean

Indicates whether the business object itself or any of its child objects differs the one that is stored in the repository, i.e. its state is created, changed or markedForRemoval.

Returns

boolean True when the business object has been changed, otherwise false.

isNew() → boolean

Indicates whether the business object has been created newly and not has been yet saved, i.e. its state is created.

Returns

boolean True when the business object is new, otherwise false.

isSavable() → boolean

Indicates whether the business object can be saved to the repository, i.e. it has ben changed and is valid, and the user has permission to save it.

Returns

boolean True when the user can save the business object, otherwise false.

isSelfDirty() → boolean

Indicates whether the business object itself, ignoring its child objects, differs the one that is stored in the repository.

Returns

boolean True when the business object itself has been changed, otherwise false.

isValid() → boolean

Indicates whether all the validation rules of the business object, including the ones of its child objects, succeeds. A valid business object may have broken rules with severity of success, information and warning.

Returns

boolean True when the business object is valid, otherwise false.

remove()

Marks the business object to be deleted from the repository on next save.

save() → EditableRootModelSync

Saves the changes of the business object to the repository.

Throws

Authorization error: The user has no permission to execute the action.

Data portal error: Inserting the business object has failed.

Data portal error: Updating the business object has failed.

Data portal error: Deleting the business object has failed.

Returns

EditableRootModelSync The business object with the new state after the save.

toCto() → object

Transforms the business object to a plain object to send to the client.

Returns

object The client transfer object.

Events

postCreate

The event arises after the business object instance has been initialized in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

newObject

EditableRootModelSync

 

The instance of the model after the data portal action.

postFetch

The event arises after the business object instance has been retrieved from the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

newObject

EditableRootModelSync

 

The instance of the model after the data portal action.

postInsert

The event arises after the business object instance has been created in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

newObject

EditableRootModelSync

 

The instance of the model after the data portal action.

postRemove

The event arises after the business object instance has been removed from the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

newObject

EditableRootModelSync

 

The instance of the model after the data portal action.

postSave

The event arises after the business object instance has been saved in the repository. The event is preceded by a postInsert, postUpdate or postRemove event depending on the state of the business object instance.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

newObject

EditableRootModelSync

 

The instance of the model after the data portal action.

postUpdate

The event arises after the business object instance has been updated in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

newObject

EditableRootModelSync

 

The instance of the model after the data portal action.

preCreate

The event arises before the business object instance will be initialized in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

oldObject

EditableRootModelSync

 

The instance of the model before the data portal action.

preFetch

The event arises before the business object instance will be retrieved from the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

oldObject

EditableRootModelSync

 

The instance of the model before the data portal action.

preInsert

The event arises before the business object instance will be created in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

oldObject

EditableRootModelSync

 

The instance of the model before the data portal action.

preRemove

The event arises before the business object instance will be removed from the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

oldObject

EditableRootModelSync

 

The instance of the model before the data portal action.

preSave

The event arises before the business object instance will be saved in the repository. The event is followed by a preInsert, preUpdate or preRemove event depending on the state of the business object instance.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

oldObject

EditableRootModelSync

 

The instance of the model before the data portal action.

preUpdate

The event arises before the business object instance will be updated in the repository.

Parameters

Name Type Optional Description

eventArgs

bo.shared.DataPortalEventArgs

 

Data portal event arguments.

oldObject

EditableRootModelSync

 

The instance of the model before the data portal action.