Class: EditableRootModel

EditableRootModel

Represents the definition of an asynchronous editable root model.

new EditableRootModel(eventHandlers)

Creates a new asynchronous editable root model instance.

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

Parameters:
Name Type Argument Description
eventHandlers bo.shared.EventHandlerList <optional>

The event handlers of the instance.

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

Extends

Members

<readonly> $modelName :string

The name of the model. However, it can be hidden by a model property with the same name.

Type:
  • string

Methods

<static> create(eventHandlers, callback)

Creates a new editable business object instance.

Parameters:
Name Type Argument Description
eventHandlers bo.shared.EventHandlerList <optional>

The event handlers of the instance.

callback external.cbDataPortal

Returns a new editable business object.

Throws:

<static> fetch(filter, method, eventHandlers, callback)

Retrieves an editable business object from the repository.

Parameters:
Name Type Argument Description
filter * <optional>

The filter criteria.

method string <optional>

An alternative fetch method of the data access object.

eventHandlers bo.shared.EventHandlerList <optional>

The event handlers of the instance.

callback external.cbDataPortal

Returns the required editable business object.

Throws:

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(callback)

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

Parameters:
Name Type Description
callback external.cbDataPortal

Returns a new editable business object.

Throws:

<protected> fetch(filter, method, callback)

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 Argument Description
filter * <optional>

The filter criteria.

method string <optional>

An alternative fetch method of the data access object.

callback external.cbDataPortal

Returns the required editable business object.

Throws:

fromCto(cto, callback)

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

Parameters:
Name Type Description
cto object

The client transfer object.

callback external.cbFromCto

Returns the eventual error.

getBrokenRules(namespace) → {bo.rules.BrokenRulesOutput}

Gets the broken rules of the business object.

Parameters:
Name Type Argument Description
namespace string <optional>

The namespace of the message keys when messages are localizable.

Returns:

The broken rules of the business object.

Type
bo.rules.BrokenRulesOutput

getModelState() → {string}

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

Returns:

The state of the model.

Type
string

getResponse(message, namespace) → {bo.rules.BrokenRulesResponse}

Gets the response to send to the client in case of broken rules.

Parameters:
Name Type Argument Description
message string <optional>

Human-readable description of the reason of the failure.

namespace string <optional>

The namespace of the message keys when messages are localizable.

Returns:

The broken rules response to send to the client.

Type
bo.rules.BrokenRulesResponse

isDeleted() → {boolean}

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

Returns:

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

Type
boolean

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:

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

Type
boolean

isNew() → {boolean}

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

Returns:

True when the business object is new, otherwise false.

Type
boolean

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:

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

Type
boolean

isSelfDirty() → {boolean}

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

Returns:

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

Type
boolean

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:

True when the business object is valid, otherwise false.

Type
boolean

remove()

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

save(callback)

Saves the changes of the business object to the repository.

Parameters:
Name Type Description
callback external.cbDataPortal

Returns the business object with the new state after the save.

Throws:

toCto() → {object}

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

Returns:

The client transfer object.

Type
object

Events

postCreate

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

Parameters:
Name Type Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

newObject EditableRootModel

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 Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

newObject EditableRootModel

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 Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

newObject EditableRootModel

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 Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

newObject EditableRootModel

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 Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

newObject EditableRootModel

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 Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

newObject EditableRootModel

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 Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

oldObject EditableRootModel

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 Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

oldObject EditableRootModel

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 Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

oldObject EditableRootModel

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 Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

oldObject EditableRootModel

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 Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

oldObject EditableRootModel

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 Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

oldObject EditableRootModel

The instance of the model before the data portal action.

If you find bugs or have feature requests, please let us know.

JavaScript business objects ♦ Copyright © 2014-2016 Logikum, Ltd.
Documentation generated by JSDoc 3.2.2 on 2015. December 31. using the DocStrap template.