Change Object Level in Inheritance

3
I would like to change the 'level' of an object in an inheritance domain model. For instance, lets say I have two entities: Book and Novel. Novel has Book as a generalization. Now suppose I have an instance of Book that I realize should really be a Novel. Is there a straightforward way to do this in Mendix? Has anyone had experience doing this? Any pitfalls and pointers appreciated.
asked
3 answers
1

I think the simplest solution would be to create a new Novel, clone its properties and references from the Book, and then destroy the book. This (I think) should be fairly easy to set up if you use the CommunityCommons.Clone action. So, something like:

Create -> Clone -> Commit -> Delete

You'd definitely want to verify via the debugger that all associations are set correctly. I believe the Questionnaire module on the app store does something similar when creating new "Elements" before setting their specialized type.

answered
0

I think you can just take the object as a parameter in a Microflow, and cast it as the new Type and commit.

answered
0

Having to do this would should trigger a re-evaluation of your domain model. Are you truly using inheritance to leverage the parent object and its properties. If its not too late, have you considered... Just keeping one entity and creating a flag or enumeration for the book level. Or creating a second entity "Level" and associating each book that the level or category. This approach will give you added flexibility when you have a new "Type" of book.

answered