This article was moved to MDriven Wiki – How to rename a class in your model – using the model debugger
It’s important to keep your model in sync with the reality it reflects! But in a large model, some things might be a lot of work to change. Then you’ll have a degrading model – not good!
You might not know, but the model in MDriven is itself a MDriven model.
In most places, in the designer, you can right-click and select Extras and then “Show autoform…” or “Open Model Debugger…”
You will get exactly the same dialog as you would in your own model, but with the model’s terms.
So, in the Model Debugger, you can run any OCL against your model to find what you’re looking for, and then manually alter any and everything.
Better still, you can 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’))