Assign actions a menu group based on class
(Created page with "The scenario is that many classes based on a superclass has Class actions that all should have the same Menu Group. This OCL will list all classes with a named superclass and list the class actions and their Menu Group Class.allInstances->select(c|c.AllSuperClassesAndSelf->includes(Class.allInstances->select(c|c.Name='PeWork')->first)).ClassActions->collect(ca|ca.Name, ca.MenuGroup.Name) Replace 'PeWork' in the example above to the class or superclass you want to find...")
 
(Added Edited template with July 12, 2025.)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The scenario is that many classes based on a superclass has Class actions that all should have the same Menu Group.
{{Edited|July|12|2025}}
<message>Write the content here to display this box</message>
The scenario is that many classes based on a superclass have Class actions that should all have the same Menu Group.


This OCL will list all classes with a named superclass and list the class actions and their Menu Group
This OCL will list all classes with a named superclass and list the class actions and their Menu Group:
  Class.allInstances->select(c|c.AllSuperClassesAndSelf->includes(Class.allInstances->select(c|c.Name='PeWork')->first)).ClassActions->collect(ca|ca.Name, ca.MenuGroup.Name)
  Class.allInstances->select(c|c.AllSuperClassesAndSelf->includes(Class.allInstances->select(c|c.Name='PeWork')->first)).ClassActions->collect(ca|ca.Name, ca.MenuGroup.Name)
Replace 'PeWork' in the example above to the class or superclass you want to find
Replace 'PeWork' in the example above to the class or superclass you want to find.


The EAL code will update the Menu Group to a named one.
The EAL code will update the Menu Group to a named one.
  Class.allInstances->select(c|c.AllSuperClassesAndSelf->includes(Class.allInstances->select(c|c.Name='PeWork')->first)).ClassActions->forEach(ca|ca.MenuGroup := MenuGroup.allInstances->select(mg|mg.Name='PE')->first)
  Class.allInstances->select(c|c.AllSuperClassesAndSelf->includes(Class.allInstances->select(c|c.Name='PeWork')->first)).ClassActions->forEach(ca|ca.MenuGroup := MenuGroup.allInstances->select(mg|mg.Name='PE')->first)
Replace 'PeWork' in the example above to the class or superclass you want to find and 'PE' to the existing Menu group you want to set.
Replace 'PeWork' in the example above to the class or superclass you want to find and change 'PE' to the existing Menu Group you want to set.
[[Category:Actions]]
[[Category:OCL]]
[[Category:EAL]]

Latest revision as of 06:27, 20 January 2025

This page was created by Lars.olofsson@mdriven.net on 2024-05-01. Last edited by Edgar on 2025-01-20.


The scenario is that many classes based on a superclass have Class actions that should all have the same Menu Group.

This OCL will list all classes with a named superclass and list the class actions and their Menu Group:

Class.allInstances->select(c|c.AllSuperClassesAndSelf->includes(Class.allInstances->select(c|c.Name='PeWork')->first)).ClassActions->collect(ca|ca.Name, ca.MenuGroup.Name)

Replace 'PeWork' in the example above to the class or superclass you want to find.

The EAL code will update the Menu Group to a named one.

Class.allInstances->select(c|c.AllSuperClassesAndSelf->includes(Class.allInstances->select(c|c.Name='PeWork')->first)).ClassActions->forEach(ca|ca.MenuGroup := MenuGroup.allInstances->select(mg|mg.Name='PE')->first)

Replace 'PeWork' in the example above to the class or superclass you want to find and change 'PE' to the existing Menu Group you want to set.