new CompositeEntityCollection(collections, owner)
Non destructively combine multiple instances of an Entity Collection into one collection. If an entity with the same ID exists in multiple sets, it will be non destructively merged into a new entity instance. If an entity has the same attribute in multiple sets, its attribute in the last set of its belonging list will be used. Composite Entity Collection can be used almost anywhere that requires the use of entity collections.
| Name | Type | Description |
|---|---|---|
collections |
Array.<EntityCollection> |
optional
The initial list of entity collection instances to be merged. |
owner |
DataSource | CompositeEntityCollection |
optional
Create a data source (or composite entity collection) for this collection. |
Members
-
readonly collectionChangedEvent
-
Get the event triggered when adding or removing entities from the collection. The generated event is an Entity Collection. collectionChangedEvent callback.
-
readonly idString
-
Get the globally unique identifier of the collection.
-
readonly ownerDataSource CompositeEntityCollection
-
Obtain the owner of this composite entity collection, i.e. the data source or composite entity collection that created it.
-
readonly valuesArray.<Entity>
-
Get an array of entity instances in the collection. This array cannot be directly modified.
Methods
-
addCollection(collection, index)
-
Add the collection to the composite file.
Name Type Description collectionEntityCollection The collection to be added.
indexNumber optional To add an index to the collection. If omitted, the set will be added at the top of all existing sets.
Throws:
-
The index (if provided) must be greater than or equal to zero and less than or equal to the number of collections.
- Type
- DeveloperError
-
-
computeAvailability(){TimeInterval}
-
Calculate the maximum availability of entities in the set. If the collection contains infinite available data and non infinite data, only the time interval related to the non infinite data is returned. If all data is infinite, then an infinite interval will be returned.
Returns:
Type Description TimeInterval The availability of entities in the collection. -
contains(entity){Boolean}
-
If the provided entity is in this collection, return true; otherwise, return false.
Name Type Description entityEntity Entity.
Returns:
Type Description Boolean If the provided entity is in this collection, it is true; otherwise, it is false. -
containsCollection(collection){Boolean}
-
Check if the composite content contains the given set.
Name Type Description collectionEntityCollection The collection to be checked.
Returns:
Type Description Boolean If the combination contains the set, it is true; otherwise, it is false. -
getById(id){Entity}
-
Retrieve an entity with the specified ID.
Name Type Description idObject The ID of the entity to be retrieved.
Returns:
Type Description Entity Entity with the provided ID; If there is no id in the collection, it is undefined. -
getCollection(index)
-
Retrieve a collection from composite data by index.
Name Type Description indexNumber The index to be retrieved.
-
getCollectionsLength()
-
Get the number of sets in this synthesis.
-
indexOfCollection(collection){Number}
-
Determine the index of the given set in the combination.
Name Type Description collectionEntityCollection To search for a collection of indexes.
Returns:
Type Description Number The index of the collection in the composite file; If the collection does not exist in the composite file, the index is -1. -
lowerCollection(collection)
-
Lower the position of the set in the synthesis by one.
Name Type Description collectionEntityCollection A mobile collection.
Throws:
-
This series is not included in this comprehensive sample.
- Type
- DeveloperError
-
-
lowerCollectionToBottom(collection)
-
Place the collection at the bottom of the composite.
Name Type Description collectionEntityCollection A mobile collection.
Throws:
-
This series is not included in this comprehensive sample.
- Type
- DeveloperError
-
-
raiseCollection(collection)
-
Raise the position of the set in the synthesis by one.
Name Type Description collectionEntityCollection A mobile collection.
Throws:
-
This series is not included in this comprehensive sample.
- Type
- DeveloperError
-
-
raiseCollectionToTop(collection)
-
Raise a collection to the top of the synthesis.
Name Type Description collectionEntityCollection A mobile collection.
Throws:
-
This series is not included in this comprehensive sample.
- Type
- DeveloperError
-
-
removeAllCollections()
-
Remove all sets from the composition.
-
removeCollection(collection){Boolean}
-
If present, remove a set from the composite element.
Name Type Description collectionEntityCollection The collection to be removed.
Returns:
Type Description Boolean If the set is in synthesis and has been removed, it is true; If the set is not in the synthesis, it is false. -
resumeEvents()
-
When adding or deleting an item, immediately restore and trigger the ElementCollection # collectiveChanged event. Any modifications made during the event pause will be triggered as a single event when this function is called. If the event is also recovered, this function can also ensure that the set is recombined. This function is a reference counting function, which can be safely called multiple times as long as there is a corresponding call to ElementCollection # resumeEvents.
Throws:
-
resumeEvents can not be called before suspendEvents.
- Type
- DeveloperError
-
-
suspendEvents()
-
Prevent the ElementCollection # collectible Changed event from being triggered until the corresponding call is made to ElementCollection # resumeEvents. This can effectively add and remove many items. When the event pauses, the reassembly of the collection will also pause, as this may be a costly operation. As long as there is a corresponding ElementCollection # resumeEvents call, the function can be safely called multiple times.