Class: ReadOnlyRootCollectionSync

ReadOnlyRootCollectionSync

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

new ReadOnlyRootCollectionSync(eventHandlers)

Creates a new synchronous read-only root collection instance.

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

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.

Type:
  • string

<readonly> count :number

The count of the child objects in the collection.

Type:
  • number

<readonly> totalItems :number

The count of all available items if provided by the data access object.

Type:
  • number

Methods

<static> fetch(filter, method, eventHandlers) → {ReadOnlyRootCollectionSync}

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

Type
ReadOnlyRootCollectionSync

at(index) → {ReadOnlyChildModelSync}

Gets a collection item at a specific position.

Parameters:
Name Type Description
index number

The index of the required item in the collection.

Returns:

The required collection item.

Type
ReadOnlyChildModelSync

checkRules()

Executes all the validation rules of all business objects in the collection, including the ones of their child objects.

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

every(callback) → {boolean}

Tests whether all items in the collection pass the test implemented by the provided function.

Parameters:
Name Type Description
callback external.cbCollectionItem

Function to test for each collection item.

Returns:

True when callback returns truthy value for each item, otherwise false.

Type
boolean

<protected> fetch(filter, method)

Initializes a business object collection 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:

filter(callback) → {Array.<ReadOnlyChildModelSync>}

Creates a new array with all collection items that pass the test implemented by the provided function.

Parameters:
Name Type Description
callback external.cbCollectionItem

Function to test for each collection item.

Returns:

The new array of collection items.

Type
Array.<ReadOnlyChildModelSync>

forEach(callback)

Executes a provided function once per collection item.

Parameters:
Name Type Description
callback external.cbCollectionItem

Function that produces an item of the new collection.

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

Gets the broken rules of the business object collection.

By default read-only business object collections 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 collection.

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 object collections 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 objects in the collection, including the ones of their child objects, succeeds. A valid collection may have broken rules with severity of success, information and warning.

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

Returns:

True when the business object is valid, otherwise false.

Type
boolean

map(callback) → {Array.<*>}

Creates a new array with the results of calling a provided function on every item in this collection.

Parameters:
Name Type Description
callback external.cbCollectionItem

Function to test for each collection item.

Returns:

The new array of callback results.

Type
Array.<*>

some(callback) → {boolean}

Tests whether some item in the collection pass the test implemented by the provided function.

Parameters:
Name Type Description
callback external.cbCollectionItem

Function to test for each collection item.

Returns:

True when callback returns truthy value for some item, otherwise false.

Type
boolean

sort(fnCompare) → {Array.<ReadOnlyChildModelSync>}

Sorts the items of the collection in place and returns the collection.

Parameters:
Name Type Argument Description
fnCompare external.cbCompare <optional>

Function that defines the sort order. If omitted, the collection is sorted according to each character's Unicode code point value, according to the string conversion of each item.

Returns:

The sorted collection.

Type
Array.<ReadOnlyChildModelSync>

toCto() → {Array.<object>}

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

Returns:

The client transfer object.

Type
Array.<object>

Events

postFetch

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

Parameters:
Name Type Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

newObject ReadOnlyRootCollectionSync

The collection instance after the data portal action.

preFetch

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

Parameters:
Name Type Description
eventArgs bo.shared.DataPortalEventArgs

Data portal event arguments.

oldObject ReadOnlyRootCollectionSync

The collection instance 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.