new PropertyManager(name, property)
Creates a new property manager object.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
name |
string | The name of the business object model. |
|
property |
bo.shared.PropertyInfo |
<optional> <repeatable> |
Description of a model property. |
Throws:
-
Argument error: The name must be a non-empty string.
-
Argument error: The property must be PropertyInfo object.
Members
-
<readonly> name :string
-
The name of the business object model.
Type:
- string
Methods
-
add(property)
-
Adds a new property to the business object model.
Parameters:
Name Type Description property
bo.shared.PropertyInfo Description of the model property to add.
Throws:
-
Argument error: The property must be PropertyInfo object.
-
Model error: Cannot change the definition after creation.
-
-
childCount() → {Number}
-
Gets the count of the child models and collections of the current model.
Returns:
The count of the child properties.
- Type
- Number
-
children() → {Array.<bo.shared.PropertyInfo>}
-
Gets the child models and collections of the current model.
Returns:
- The array of the child properties.
- Type
- Array.<bo.shared.PropertyInfo>
-
contains(property) → {boolean}
-
Determines whether a property belongs to the business object model.
Parameters:
Name Type Description property
bo.shared.PropertyInfo Property definition to be checked.
Throws:
Argument error: The property must be PropertyInfo object.Returns:
True if the model contains the property, otherwise false.
- Type
- boolean
-
create(name, type, flags) → {bo.shared.PropertyInfo}
-
Creates a new property for the business object model. The data type can be any one from the bo.dataTypes namespace or a custom data type based on DataType object, or can be any business object model or collection defined by the model types available in the bo namespace (i.e. models based on ModelBase or {@link bo.CollectionBase CollectionBase} objects). The flags parameter is ignored when data type is a model or collection.
Parameters:
Name Type Argument Description name
string The name of the property.
type
* The data type of the property.
flags
bo.shared.PropertyFlag <optional>
Other attributes of the property.
Throws:
-
Argument error: The name must be a non-empty string.
-
Argument error: The type must be a data type, a model or a collection.
-
Argument error: The flags must be PropertyFlag items.
-
Model error: Cannot change the definition after creation.
Returns:
The definition of the property.
-
-
filter(callback) → {Array.<bo.shared.PropertyInfo>}
-
Creates a new array with all properties that pass the test implemented by the provided function.
Parameters:
Name Type Description callback
external.cbCollectionItem Function to test each element of the properties, taking three arguments: property, index, array. Return true to keep the property definition, false otherwise.
Returns:
A new array with all properties that passed the test.
- Type
- Array.<bo.shared.PropertyInfo>
-
forEach(callback)
-
Executes the provided function once per property definition.
Parameters:
Name Type Description callback
external.cbCollectionItem Function that produces an element of the model properties, taking three arguments: property, index, array.
-
getByName(name, message, messageParams) → {bo.shared.PropertyInfo}
-
Gets the property with the given name.
Parameters:
Name Type Argument Description name
string The name of the property.
message
string <optional>
The error message in case of not finding the property.
messageParams
* <optional>
<repeatable>
Optional interpolation parameters of the message.
Throws:
-
Argument error: The name must be a non-empty string.
-
Argument error: The business object has no property with the given name.
Returns:
The requested property definition.
-
-
<protected> getKey(getPropertyValue) → {*}
-
Gets the key of the current model. If the model has no key properties, the method returns the data transfer object, If the model has one key property, then it returns the current value of the that property. If the model has more key properties, an object will be returned whose properties will hold the current values of the key properties.
Parameters:
Name Type Description getPropertyValue
internal~getValue A function that returns the current value of the given property.
Throws:
Argument error: The getPropertyValue argument must be a function.Returns:
The key value of the model.
- Type
- *
-
<protected> keyEquals(data, getPropertyValue) → {boolean}
-
Determines that the passed data contains current values of the model key.
Parameters:
Name Type Description data
object Data object whose properties can contain the values of the model key.
getPropertyValue
internal~getValue A function that returns the current value of the given property.
Throws:
-
Argument error: The data argument must be an object.
-
Argument error: The getPropertyValue argument must be a function.
Returns:
True when the values are equal, false otherwise.
- Type
- boolean
-
-
map(callback) → {Array}
-
Creates a new array with the results of calling a provided function on every element of the model properties.
Parameters:
Name Type Description callback
external.cbCollectionItem Function that produces an element of the new array, taking three arguments: property, index, array.
Returns:
A new array with items produced by the function.
- Type
- Array
-
toArray() → {Array.<bo.shared.PropertyInfo>}
-
Gets the property definitions of the business object model as an array.
Returns:
The array of model properties.
- Type
- Array.<bo.shared.PropertyInfo>
-
verifyChildTypes(allowedTypes)
-
Verifies the model types of child models and freezes properties of the model.
Parameters:
Name Type Description allowedTypes
Array.<string> The names of the model types of the allowed child models.
Throws:
-
Argument error: The allowed types must be an array of string values or a single string value.
-
Model error: The type of a model property should be an allowed type.
-