(no subject) [message #687004] |
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 #687006 is a reply to message #687004] |
Fri, 20 May 2011 15:48 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.02482 seconds