class staticbo.shared. PropertyManager
Source: shared/
Provides methods to manage the properties of a business object model.
Property
new PropertyManager(name[, ...property])
Creates a new property manager object.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
name |
string |
|
The name of the business object model. |
property |
Yes |
Description of a model property. Value can be repeated. |
- Throws
-
Argument error: The name must be a non-empty string.
-
Argument error: The property must be PropertyInfo object.
Property
read-onlyname
string
The name of the business object model.
Methods
add(property)
Adds a new property to the business object model.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
property |
|
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
-
Number
The count of the child properties.
children() → Array of bo.shared.PropertyInfo
Gets the child models and collections of the current model.
- Returns
-
Array of bo.shared.PropertyInfo
- The array of the child properties.
contains(property) → boolean
Determines whether a property belongs to the business object model.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
property |
|
Property definition to be checked. |
- Throws
-
Argument error: The property must be PropertyInfo object.
- Returns
-
boolean
True if the model contains the property, otherwise false.
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 | Optional | Description |
---|---|---|---|
name |
string |
|
The name of the property. |
type |
any type |
|
The data type of the property. |
flags |
Yes |
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
-
bo.shared.PropertyInfo
The definition of the property.
filter(callback) → Array of bo.shared.PropertyInfo
Creates a new array with all properties that pass the test implemented by the provided function.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
callback |
|
Function to test each element of the properties, taking three arguments: property, index, array. Return true to keep the property definition, false otherwise. |
- Returns
-
Array of bo.shared.PropertyInfo
A new array with all properties that passed the test.
forEach(callback)
Executes the provided function once per property definition.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
callback |
|
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 | Optional | Description |
---|---|---|---|
name |
string |
|
The name of the property. |
message |
string |
Yes |
The error message in case of not finding the property. |
messageParams |
any type |
Yes |
Optional interpolation parameters of the message. Value can be repeated. |
- Throws
-
Argument error: The name must be a non-empty string.
-
Argument error: The business object has no property with the given name.
- Returns
-
bo.shared.PropertyInfo
The requested property definition.
protectedgetKey(getPropertyValue) → any type
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.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
getPropertyValue |
|
A function that returns the current value of the given property. |
- Throws
-
Argument error: The getPropertyValue argument must be a function.
- Returns
-
any type
The key value of the model.
protectedkeyEquals(data, getPropertyValue) → boolean
Determines that the passed data contains current values of the model key.
Parameters
Name | Type | Optional | Description |
---|---|---|---|
data |
object |
|
Data object whose properties can contain the values of the model key. |
getPropertyValue |
|
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
-
boolean
True when the values are equal, false otherwise.
map(callback) → Array
Creates a new array with the results of calling a provided function on every element of the model properties.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
callback |
|
Function that produces an element of the new array, taking three arguments: property, index, array. |
- Returns
-
Array
A new array with items produced by the function.
toArray() → Array of bo.shared.PropertyInfo
Gets the property definitions of the business object model as an array.
- Returns
-
Array of bo.shared.PropertyInfo
The array of model properties.
verifyChildTypes(allowedTypes)
Verifies the model types of child models and freezes properties of the model.
Parameter
Name | Type | Optional | Description |
---|---|---|---|
allowedTypes |
Array of 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.