Hans Karlsen (talk | contribs) No edit summary |
No edit summary |
||
(8 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
OCLOperator PSEvalValue makes it possible to use oclPS in any OCL expression. | |||
SomeClass.PSEvalValue(SomeClass.allinstances->select(x|x.name=vWhatever)->size,dependon) | Expression template: | ||
SomeClass.PSEvalValue(SomeClass.allinstances->select(x|x.name=vWhatever)->size,dependon) | |||
Using this, you can "reach into" the database from OCL and action-language (EAL). | |||
'''Note!''' PSEval doesn't subscribe to the value from the DB. To make the operator auto-updating, provide an expression in "dependon" that, when changed, should also rerun the PSEval expression. This can, for example, be a timer. | |||
'''Warning!''' Remember that using PSEval means that no changes to the result set content will be fetched automatically. This breaks the very nice subscription feature built into the framework for that data. | |||
For example, this expression from a method has "userName" as a parameter: | |||
SysAsyncTicket.PSEvalValue(SysAsyncTicket.allInstances->select(at|at.Error.notNull)->size, Calendar.Now).asString | |||
The expression above will execute the '''select count(*)''' on the table SysAsyncTicket with a where statement filtering on '''Error IS NOT NULL''' and then getting the value (number of rows). In the [[BaseApp]] model, Calendar.Now updates every minute, which makes the count reevaluate as long as this value is used. | |||
Always remember that your SQL-server might also need indexes and other performance settings to execute your expression efficiently. | |||
See also: [[OCLOperators Sqlpassthrough|Sqlpassthrough]], [[OCLOperators PSEval|PSEval]], [[OCLOperators PSEvalTuples|PSEvalTuples]] | |||
[[Category:OCLOperators]] | |||
{{Edited|July|12|2024}} |
Latest revision as of 21:31, 3 May 2024
OCLOperator PSEvalValue makes it possible to use oclPS in any OCL expression.
Expression template:
SomeClass.PSEvalValue(SomeClass.allinstances->select(x|x.name=vWhatever)->size,dependon)
Using this, you can "reach into" the database from OCL and action-language (EAL).
Note! PSEval doesn't subscribe to the value from the DB. To make the operator auto-updating, provide an expression in "dependon" that, when changed, should also rerun the PSEval expression. This can, for example, be a timer.
Warning! Remember that using PSEval means that no changes to the result set content will be fetched automatically. This breaks the very nice subscription feature built into the framework for that data.
For example, this expression from a method has "userName" as a parameter:
SysAsyncTicket.PSEvalValue(SysAsyncTicket.allInstances->select(at|at.Error.notNull)->size, Calendar.Now).asString
The expression above will execute the select count(*) on the table SysAsyncTicket with a where statement filtering on Error IS NOT NULL and then getting the value (number of rows). In the BaseApp model, Calendar.Now updates every minute, which makes the count reevaluate as long as this value is used.
Always remember that your SQL-server might also need indexes and other performance settings to execute your expression efficiently.
See also: Sqlpassthrough, PSEval, PSEvalTuples