nx.data.CollectionRelation Class
Prepare a calculation provider for a map of collections.
Constructor
nx.data.CollectionRelation
-
map
Parameters:
-
map
Object/MapA map indicates names of the collection for calculation.
Item Index
Methods
- and static
- buildExpressionTree static
- calculate
- complement static
- cross static
- delta static
- getCollectionSyncMonitor
- or static
- union static
Methods
and
-
target
-
sources
Affect target to be the equivalent collection of the first empty collection or the last collection. Release object could stop the dependencies.
Parameters:
-
target
Collection -
sources
Array of Collection
Returns:
an object with release method
buildExpressionTree
-
tokens
Build a tree of expresson syntax with the expression tokens.
e.g. tokens ["A", "|", "B", "&", "(", "C", "&", "D", ")"], which was separated from expression "A | B & (C | D)",
will be separated into [|, A, [&, B, [|, C, D]]], because '&' has higher priority than '|',
and braced "C | D" has higher priority than &.
Similar to the priorities in JavaScript:
operator | functionality |
---|---|
() | braces |
- | complement |
& | cross |
^ | symmetric difference |
| | union |
&& | and (the first empty collection or the last collection) |
|| | or (the first non-empty collection) |
Parameters:
-
tokens
Array of token
Returns:
Parsed syntax tree of the expression tokens.
calculate
-
target
-
expression
Apply a inter-collection releation to a collection.
Supported operators:
Operator | Calculation | Method |
---|---|---|
& | Sets cross | cross |
| | Sets union | union |
^ | Sets symmetric difference | delta |
- | Sets complement | complement |
&& | Sets logical and | and |
|| | Sets logical or | or |
- Logical and means 'first empty collection or last collection'
- Logical or means 'first non-empty collection or last collection'
Parameters:
-
target
CollectionThe target collection.
-
expression
StringThe relation expression.
Returns:
An object with release method.
complement
-
target
-
sources
Affect target to be the complement collection of sources collections. Release object could stop the dependencies.
Parameters:
-
target
Collection -
sources
Array of Collection
Returns:
an object with release method
cross
-
target
-
sources
Affect target to be the cross collection of sources collections. Release object could stop the dependencies.
Parameters:
-
target
Collection -
sources
Array of Collection
Returns:
an object with release method
delta
-
target
-
sources
Affect target to be the symmetric difference collection of sources collections. Release object could stop the dependencies. The name 'delta' is the symbol of this calculation in mathematics.
Parameters:
-
target
Collection -
sources
Array of Collection
Returns:
an object with release method
getCollectionSyncMonitor
-
collection
-
sync
This util returns a monitor function of ObservableCollection, which is used to synchronize item existance between 2 collections.
Parameters:
Returns:
The monitor function.
or
-
target
-
sources
Affect target to be the equivalent collection of the first non-empty collection. Release object could stop the dependencies.
Parameters:
-
target
Collection -
sources
Array of Collection
Returns:
an object with release method
union
-
target
-
sources
Affect target to be the union collection of sources collections. Release object could stop the dependencies.
Parameters:
-
target
Collection -
sources
Array of Collection
Returns:
an object with release method