Best practice for changing EClass to abstract [message #672299] |
Fri, 20 May 2011 15:43 |
h1055071 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 #686825 is a reply to message #672299] |
Fri, 20 May 2011 15:48 |
Ed Merks Messages: 33216 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/
|
|
|
Re: Best practice for changing EClass to abstract [message #686829 is a reply to message #672379] |
Fri, 20 May 2011 23:32 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Phillip,
That's why I suggested using what you have for loading (it maps the
"old" name to the new name) and given that it's created the
ArchimateDiagramModelImpl, when you serialize after that, with no
special options, it will use ArchimateDiagramModel. Right?
Phillip Beauvoir wrote:
> I suppose the short question is this:
>
> How do I get Ecore to load the class ArchimateDiagramModel instead of
> class DiagramModel when it de-serialises the xml element
> "DiagramModel", but write the xml element "ArchimateDiagramModel" when
> it serialises it?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Best practice for changing EClass to abstract [message #687012 is a reply to message #672379] |
Fri, 20 May 2011 23:32 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Phillip,
That's why I suggested using what you have for loading (it maps the
"old" name to the new name) and given that it's created the
ArchimateDiagramModelImpl, when you serialize after that, with no
special options, it will use ArchimateDiagramModel. Right?
Phillip Beauvoir wrote:
> I suppose the short question is this:
>
> How do I get Ecore to load the class ArchimateDiagramModel instead of
> class DiagramModel when it de-serialises the xml element
> "DiagramModel", but write the xml element "ArchimateDiagramModel" when
> it serialises it?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.05719 seconds