How to rename a class in your model – using the model debugger
No edit summary
No edit summary
Line 1: Line 1:
For background, see [[Using the model debugger to change the model itself]]
For background, see [[Using the model debugger to change the model itself]]


Use EAL to do search and replace in your model.
Use EAL to do a 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.
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!
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.
Then, run the OCL / EAL statements below, replacing the example names with the ones you’re working on. You can run them all at once, and 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, which 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!
After each EAL, 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'''
'''Links'''
Line 15: Line 15:
<code>AssociationEnd.allInstances->select(a|a.Name.Contains(‘CalendarView’))->collect(a|a.Name := a.Name.Replace(‘CalendarView’, ‘ViewSetting’))</code>
<code>AssociationEnd.allInstances->select(a|a.Name.Contains(‘CalendarView’))->collect(a|a.Name := a.Name.Replace(‘CalendarView’, ‘ViewSetting’))</code>


'''Class attributes'''
'''Class Attributes'''


<code>Attribute.allInstances->select(a|a.Name.Contains(‘CalendarView’))->collect(a|a.Name := c.Name.Replace(‘CalendarView’, ‘ViewSetting’))</code>
<code>Attribute.allInstances->select(a|a.Name.Contains(‘CalendarView’))->collect(a|a.Name := c.Name.Replace(‘CalendarView’, ‘ViewSetting’))</code>
Line 25: Line 25:
<code>AbstractAction.allInstances->select(aa|aa.ViewModelRootObjectExpression.Contains(‘CalendarView’))->collect(aa|aa.ViewModelRootObjectExpression := aa.ViewModelRootObjectExpression.Replace(‘CalendarView’, ‘ViewSetting’))</code>
<code>AbstractAction.allInstances->select(aa|aa.ViewModelRootObjectExpression.Contains(‘CalendarView’))->collect(aa|aa.ViewModelRootObjectExpression := aa.ViewModelRootObjectExpression.Replace(‘CalendarView’, ‘ViewSetting’))</code>


'''Viewmodels'''
'''ViewModels'''


<code>Span.allInstances->select(s|s.Name.Contains(‘CalendarView’))->collect(s|s.Name := s.Name.Replace(‘CalendarView’, ‘ViewSetting’))</code>
<code>Span.allInstances->select(s|s.Name.Contains(‘CalendarView’))->collect(s|s.Name := s.Name.Replace(‘CalendarView’, ‘ViewSetting’))</code>

Revision as of 07:10, 7 March 2023

For background, see Using the model debugger to change the model itself

Use EAL to do a 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. You can run them all at once, and 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, which makes me feel safer.

After each EAL, 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’))

This page was edited 145 days ago on 12/20/2023. What links here