Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » (no subject)
(no subject) [message #687004] Fri, 20 May 2011 15:43 Go to next message
h1055071 is currently offline h1055071Friend
Messages: 335
Registered: July 2009
Senior Member
Hi,

My Ecore model has an EClass, DiagramModel. It's not abstract and is persisted to an XML file with the same name, "DiagramModel".

Now I want to make this class abstract and have a new class extending it called ArchimateDiagramModel. This new class replaces the functionality of the old DiagramModel class and I can extend DiagramModel with new classes.

But because I need to read the XML element "DiagramModel" from file and load in the new ArchimateDiagramModel class in place of the old one I have added to the ExtendedMetaData like this:

ExtendedMetaData ext = new BasicExtendedMetaData(........
ext.setName(IArchimatePackage.Literals.DIAGRAM_MODEL, "AbstractDiagramModel");
ext.setName(IArchimatePackage.Literals.ARCHIMATE_DIAGRAM_MODEL, "DiagramModel");

This means that the (now abstract) DiagramModel is given a new name and loading in an XML file loads the new ArchimateDiagramModel class whenever the element "DiagramModel" is encountered. Likewise when saving the model.

Ideally, though, I would like to save and load the ArchimateDiagramModel class with the tag "ArchimateDiagramModel" and only replace the "DiagramModel" with ArchimateDiagramModel class for backward compatibility. In other words:

1. ArchimateDiagramModel is persisted with "ArchimateDiagramModel" xml tag
2. If "DiagramModel" tag is encountered, load ArchimateDiagramModel class

Is this possible?

Many thanks,

Phil
Re: Best practice for changing EClass to abstract [message #687006 is a reply to message #687004] Fri, 20 May 2011 15:48 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Philip,

Comments below.

Phillip Beauvoir wrote:
> Hi,
>
> My Ecore model has an EClass, DiagramModel. It's not abstract and is
> persisted to an XML file with the same name, "DiagramModel".
>
> Now I want to make this class abstract and have a new class extending
> it called ArchimateDiagramModel. This new class replaces the
> functionality of the old DiagramModel class and I can extend
> DiagramModel with new classes.
>
> But because I need to read the XML element "DiagramModel" from file
> and load in the new ArchimateDiagramModel class in place of the old
> one I have added to the ExtendedMetaData like this:
>
> ExtendedMetaData ext = new BasicExtendedMetaData(........
> ext.setName(IArchimatePackage.Literals.DIAGRAM_MODEL,
> "AbstractDiagramModel");
> ext.setName(IArchimatePackage.Literals.ARCHIMATE_DIAGRAM_MODEL,
> "DiagramModel");
>
> This means that the (now abstract) DiagramModel is given a new name
> and loading in an XML file loads the new ArchimateDiagramModel class
> whenever the element "DiagramModel" is encountered. Likewise when
> saving the model.
>
> Ideally, though, I would like to save and load the
> ArchimateDiagramModel class with the tag "ArchimateDiagramModel" and
> only replace the "DiagramModel" with ArchimateDiagramModel class for
> backward compatibility. In other words:
>
> 1. ArchimateDiagramModel is persisted with "ArchimateDiagramModel" xml
> tag
> 2. If "DiagramModel" tag is encountered, load ArchimateDiagramModel class
>
> Is this possible?
You could use the extended meta data option only for loading...
>
> Many thanks,
>
> Phil
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:(no subject)
Next Topic:(no subject)
Goto Forum:
  


Current Time: Fri Apr 26 22:32:55 GMT 2024

Powered by FUDForum. Page generated in 0.02482 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top