Class: ReadOnlyRootModelSync

ReadOnlyRootModelSync

Represents the definition of a synchronous read-only root model.

new ReadOnlyRootModelSync(eventHandlers)

Creates a new synchronous read-only root model instance.

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

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> fetch(filter, method, eventHandlers) → {ReadOnlyRootModelSync}

Retrieves a read-only 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.

Throws:
Returns:

The required read-only business object.

Type
ReadOnlyRootModelSync

checkRules()

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

By default read-only business objects are supposed to be valid.

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

The filter criteria.

method string <optional>

An alternative fetch method of the data access object.

Throws:

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

Gets the broken rules of the business object.

By default read-only business objects are supposed to be valid.

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

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

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

By default read-only business objects are supposed to be valid.

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

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.

By default read-only business objects are supposed to be valid.

Returns:

True when the business object is valid, otherwise false.

Type
boolean

toCto() → {object}

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

Returns:

The client transfer object.

Type
object

Events

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 ReadOnlyRootModelSync

The instance of the model after 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 ReadOnlyRootModelSync

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.