How to rename a class in your model – using the model debugger

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.

  1. 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!
  2. 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.
  3. 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 of a model, but you will see most of them, 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 37 days ago on 10/08/2024. What links here