(Created page with "For background, see Using the model debugger to change the model itself Use EAL to do search and replace in your model. For example, I want to swap ‘CalendarView’ to...") |
No edit summary |
||
Line 34: | Line 34: | ||
<code>Column.allInstances->select(c|c.Name.Contains(‘CalendarView’))->collect(c|c.Name := c.Name.Replace(‘CalendarView’, ‘ViewSetting’))</code> | <code>Column.allInstances->select(c|c.Name.Contains(‘CalendarView’))->collect(c|c.Name := c.Name.Replace(‘CalendarView’, ‘ViewSetting’))</code> | ||
[[Category:Intermediate]] |
Revision as of 07:30, 6 September 2017
For background, see Using the model debugger to change the model itself
Use EAL to do search and replace in your model.
For example, I want to swap ‘CalendarView’ to ‘ViewSetting’, everywhere. The Class, Viewmodels, Derived attributes, Link names, Variables etc.
Start by manually changing the name of your class. Run the model validation (the green check-mark at the top of the model design window). You’ll get a lot of errors I guess!
Then, run the OCL / EAL statements below replacing the example names with the ones you’re working on. Of course you can run them all at once, and you could put them all in one EAL with variables for what to replace, but this is a start, and I usually want to take my replacing in steps anyway, makes me feel safer.
After each EAL you check to see if your model validates, if not, see what’s wrong and pick the next snippet to run below. The snippets below don’t cover every aspect in a model, but most and I’m sure you can amend this list on your own!
Links
AssociationEnd.allInstances->select(a|a.Name.Contains(‘CalendarView’))->collect(a|a.Name := a.Name.Replace(‘CalendarView’, ‘ViewSetting’))
Class attributes
Attribute.allInstances->select(a|a.Name.Contains(‘CalendarView’))->collect(a|a.Name := c.Name.Replace(‘CalendarView’, ‘ViewSetting’))
Actions
AbstractAction.allInstances->select(aa|aa.ExecuteExpression.Contains(‘CalendarView’))->collect(aa|aa.ExecuteExpression := aa.ExecuteExpression.Replace(‘CalendarView’, ‘ViewSetting’))
AbstractAction.allInstances->select(aa|aa.ViewModelRootObjectExpression.Contains(‘CalendarView’))->collect(aa|aa.ViewModelRootObjectExpression := aa.ViewModelRootObjectExpression.Replace(‘CalendarView’, ‘ViewSetting’))
Viewmodels
Span.allInstances->select(s|s.Name.Contains(‘CalendarView’))->collect(s|s.Name := s.Name.Replace(‘CalendarView’, ‘ViewSetting’))
SpanVariable.allInstances->select(sv|sv.Name.Contains(‘CalendarView’))->collect(sv|sv.Name := sv.Name.Replace(‘CalendarView’, ‘ViewSetting’))
Column.allInstances->select(c|c.Expression.Contains(‘CalendarView’))->collect(c|c.Expression := c.Expression.Replace(‘CalendarView’, ‘ViewSetting’))
Column.allInstances->select(c|c.Name.Contains(‘CalendarView’))->collect(c|c.Name := c.Name.Replace(‘CalendarView’, ‘ViewSetting’))