Objects (package)
The package contains objects representing syntactical blocks of a TM1 rule. All contained classes are derived from a common ancestor TM1RuleToken
. The root class contains essential method convert
providing the splicing conversion. Derived classes redefine this method to achieve desired splicing conversion. Contained objects are described in following paragraphs.
TM1RuleToken
(class in TM1RuleToken.py
)
The class represents any string (token) contained within the associated rule with starting and ending position enumerated as number of characters from the rule beginning. This reflects notation in which parser enumerates parsed tokens when calling custom actions in Parser/TM1RuleParser
.
The class defines convert method that is by default returning original text as returned from Parser/TM1RuleParser
during the rule parsing (token passthrough). However this method is overloaded in classes descending from this base class to achieve correct splicing.
The class defines following attributes:
Attribute | Type | Usage |
---|---|---|
|
| Text as parsed by Parser/TM1RuleParser when calling custom actions that cover all cases except for TM1 calculation rule and feeder commands. |
|
| Global position of the |
|
| Global position of the |
The class exposes following methods:
Method | Usage |
---|---|
| Method updates intrinsic attributes of the object by |
| Method returns length of |
| Method returns original value of |
| Method returns original value of |
TM1CalcRule
(class in TM1CalcRule.py
, derived from TM1RuleToken
)
This class represents entire TM1 calculation rule or a feeder command. It breaks down the calculation rule or a feeder into two essential parts - area statement (part before equal sign) and statement (part following equal sign, sign inclusive).
The class redefines convert
method by returning string obtained by concatenating result of convert
method of associated area statement and statement. Each object of this class is aware of which regions the associated rule is encapsulated in and it has link to a directive resolver used to return all directives applying to the associated rule. This is essential information to be able to properly splice the associated rule by applying conversion based on region membership and associated directives.
The class defines following attributes:
Attribute | Type | Usage |
---|---|---|
|
| Link to associated area statement of the TM1 rule or the feeder statement. |
|
| Link to token following the area statement including equal sign. |
|
| Link to directive resolver to identify all splicing directives that apply to the TM1 rule. |
|
| List of region names in which the TM1 rule or feeder statement is encapsulated. |
The class exposes following methods:
Method | Usage |
---|---|
| Method returns concatenated string composed from result of |
TM1RuleAreaStatement
(class in TM1RuleAreaStatement.py
, derived from TM1RuleToken
)
The class represents area statement of TM1 calculation rule or a feeder command. The area statement is decomposed to dimensions and hierarchy:element pairs belonging to each of the dimensions. This implies that the rule has to contain full specification of each element in the area statement. Not following this pattern in TM1 development will result in an error during splicing of the rule.
The convert
method implements splicing of dimensional elements based on directives that apply to the associated TM1CalcRule
. Once the directives are applied, the convert method will return modified area statement based on apply
method output.
The class defines following attributes:
Attribute | Type | Usage |
---|---|---|
|
| Whitespaces between |
|
| Whitespaces between dimension/hierarchy/element indices and |
|
| Link to directive resolver to identify all splicing directives that apply to the area statement of the TM1 rule. |
|
| Dictionary containing list of hierarchy/element pairs indexed by dimension, relating to dimension/hierarchy/elements as defined in the rule statement. |
|
| Dictionary containing list of hierarchy/element pairs indexed by dimension, relating to dimension/hierarchy/elements after splicing. |
|
| Flag indicating whether the splicing directives have been applied. |
|
| Link to |
The class exposes following methods:
Method | Usage |
---|---|
| Setter for |
| Returns list of keys from |
| Returns list of hierarchy/elements pairs from |
| Constructs converted_dim_elem_dict by either adding or merging new elements into the dictionary. The method is called from |
| The method will call |
| This method constructs and returns entire area statement after the directives have been applied by using |