IMCExpression is the beauty of IMCScript which can help user to traverse across the schematic information in the graph. That means, the syntax and suggestions are automatically generated based on the schema objects (i.e. SalesItem) and attributes (i.e. includesConfigItem) being used.
Before proceeding further, reader should refer below terms, which are usually interchanged based on the domains it is referred from. To keep it simple, we will try to follow our own notations which is same way followed in most of IT companies.
|Programming world||Ontology world||InMindCloud/IT domain||Example|
IMCExpression is usually a single line of expression, which helps script to read/write the data based on defined schema, hence it is expected from developer/modeler to understand the schematic relation before using it. Below is a partial relation graph, generated from IMC’s standard schema file.
IMCScript is composed of 3 main parts:
This gives starting point to IMCExpression to begin traversal inside context. Ideally user can start with any BusinessObject (BO) / BusinessType (BT) (Although there are certain cases where user can use even BusinessAttribute, however we do not want to discuss about that for now).
As shown above, user can determine to start with BT or BO. To see how that matters to outcome, we will soon discuss Parallel Universe.
The outcome of Starting Object is always ExpressionBean, which is needed to continue further traversal based on Schema.
This is the most significant part of IMCExpression which helps user to traverse as per schema definition. These intermediate steps can be either BusinessAttributes (includesConfigItem, includesSalesItem, …) or ExpressionBean functions.
Below example will help user reach SalesItem BO from QuoteBO.
By default, intermediate steps return collection of elements, hence you can see  at the end of above IMCExpression, which helps to fetch first objectName in our case.
Please refer below graphs to see how each fragment of IMCExpression helps user to traverse in schema.
IMCExpression: Quote ().includesSalesItem
IMCExpression: Quote ().includesSalesItem.objectName
Throughout the traversal of IMCExpression, the outcome is always ExpressionBean, which helps user to traverse further using schema syntax or use methods applicable on ExpressionBean. In case user wants to terminate this traversal and fetch literal value wrapped inside, he can call one of the terminal steps.
Method value() provides appropriate literal value wrapped inside ExpressionBean, which is nothing but an outcome IMCExpression so far. In case of non-literal objects such as BO/BT, it provides URI of it.
This operation is just for the understanding to technical users, but it’s not advisable to use this without the need, because IMCScript evaluator is smart enough to perform this operation internally whenever appropriate situations occur.
Method toString() provides appropriate string value of literal or URI of non-literal objects such as BO/BT wrapped inside ExpressionBean.
The outcome of above operation is generic in the sense that it will always provide String type outcome regardless to various kinds of IMCExpressions which may return Literal/BO/BT of single or multiple values.
Outcome of IMCExpression can really differ when Starting Object of the expression is changed.
i.e. Outcome of Quote.includesSalesItem.objectName will be different from Quote().includesSalesItem.objectName.
As you can see here that earlier IMCExpression starts with BusinessType (BT) whereas the later one starts with BusinessObject (BO), that means, the first one will traverse on Schema layer, whereas second one will traverse on Data layer (which is still following syntax of Schema).
This phenomenon where even though the syntax of IMCExpressions is similar (because of IMCExpression’s dependency on Schema), but traversing surface and outcome completely differs based on Starting Object is BT or BO, can be described as Parallel Universe.
Below is an example of such different outcomes, when user determines to start with BT or BO, and continue with Intermediate Steps.
Note: Most of the time user will find a need to have BO as a Starting Object, however second approach is provided to give completeness to language as well as to provide certain validation checks on backend side by replacing starting BO with BT.
Schema update is very easier to understand once you know how to write IMCExpression for reading schema. Simply usage of equals operator (=) can help to assign values from right hand side to left hand side. Below is the format of assignment expression.
Below is an example for assigning/clean objectName to active SalesItem object.
Thing to note over here is that Left-hand side of update expression must be collection, whereas right hand side can be collection or single object. See below.
Note: User can only update BDA (Business Dynamic Attribute), updating BRA (Business Relational Attribute) is restricted by the system.
There are several reserved keywords inclusive of but not limited to all Starting Objects of IMCExpression, Inbuilt Global variables (i.e. Math, String, Double etc), syntax of conditional statements (if, else, while, for, break, continue) as well as : var, eq, ne, le, ge.