OCLOperators PSEval
No edit summary
No edit summary
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<message>Write the content here to display this box</message>
The OCLOperator PSEval makes it possible to use oclPS in any OCL expression. Using this, you can "reach into" the database from OCL and action-language (EAL).
The OCLOperator PSEval makes it possible to use oclPS in any OCL expression. Using this, you can "reach into" the database from OCL and action-language (EAL).


Expression template:
===== Expression template: =====
  SomeClass.PSEval(<ps-expression>,maxfetch,offset,<dependon>)
  SomeClass.PSEval(<ps-expression>,maxfetch,offset,<dependon>)
'''Note!''' PSEval doesn't subscribe to sets from 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.
'''Note!''' PSEval doesn't subscribe to sets from 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.
Line 9: Line 10:
'''Note!''' Offset is 0-based.
'''Note!''' Offset is 0-based.


Example:
'''Note!''' PSEval can't load subclasses of child-mapped class. To load subclasses of a superclass, you need to have several PSEval expressions and use [[Documentation:OCLOperators union|union]] to add them to a complete set.
 
==== Example: ====
  Uppdrag.PSEval(self.Uppdrag->select(u|u.Aktivt)->orderDescending(u|u.Startdatum),  1000, 0, self.Uppdrag)
  Uppdrag.PSEval(self.Uppdrag->select(u|u.Aktivt)->orderDescending(u|u.Startdatum),  1000, 0, self.Uppdrag)
For example, this expression from a method has "userName" as a parameter:
For example, this expression from a method has "userName" as a parameter:
Line 17: Line 20:
'''Note!''' The offset parameter should almost always be 0, if not used to show a seconds page in a pagination or similar.
'''Note!''' The offset parameter should almost always be 0, if not used to show a seconds page in a pagination or similar.


See also: [[OCLOperators Sqlpassthrough|Sqlpassthrough]], [[OCLOperators PSEvalValue|PSEvalValue]], [[OCLOperators PSEvalTuples|PSEvalTuples]]
'''See also:''' [[Documentation:OCLOperators sqlpassthrough|Sqlpassthrough]], [[Documentation:OCLOperators PSEvalValue|PSEvalValue]], [[Documentation:OCLOperators PSEvalTuples|PSEvalTuples]]
[[Category:OCLOperators]]
[[Category:OCLOperators]]
{{Edited|July|12|2024}}
{{Edited|July|12|2025}}

Latest revision as of 05:28, 6 February 2025

This page was created by Hans.karlsen@mdriven.net on 2022-01-11. Last edited by Stephanie@mdriven.net on 2025-02-06.

The OCLOperator PSEval makes it possible to use oclPS in any OCL expression. Using this, you can "reach into" the database from OCL and action-language (EAL).

Expression template:
SomeClass.PSEval(<ps-expression>,maxfetch,offset,<dependon>)

Note! PSEval doesn't subscribe to sets from 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.

Note! Offset is 0-based.

Note! PSEval can't load subclasses of child-mapped class. To load subclasses of a superclass, you need to have several PSEval expressions and use union to add them to a complete set.

Example:

Uppdrag.PSEval(self.Uppdrag->select(u|u.Aktivt)->orderDescending(u|u.Startdatum),  1000, 0, self.Uppdrag)

For example, this expression from a method has "userName" as a parameter:

SysUser.PSEval(SysUser.allinstances->select(su|su.Username=userName),2,0,'')

Always remember that your SQL-server might also need indexes and other performance settings to execute your expression efficiently.

Note! The offset parameter should almost always be 0, if not used to show a seconds page in a pagination or similar.

See also: Sqlpassthrough, PSEvalValue, PSEvalTuples