I am attempting to serialize a ChangeDescription along with the model it
is performing a "change recording" on. The resulting XML contains the
description of the model but lacks the ChangeDescription. Can anyone
provide example code of a successful ChangeDescription serialization or
review the below code and tell me where I'm erring?
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "*",
new XMLResourceFactoryImpl());
Resource resource =
resourceSet.createResource(URI.createURI("/Users/markgunnels/temp/cd5.xml "));
resource.getContents().add(sr);
ChangeRecorder cr = new ChangeRecorder(resourceSet);
It's best to ask EMF questions in the EMF newsgroup, which I've added to
the "to" list of the reply.
Mark Gunnels wrote:
> I am attempting to serialize a ChangeDescription along with the model
> it is performing a "change recording" on. The resulting XML contains
> the description of the model but lacks the ChangeDescription. Can
> anyone provide example code of a successful ChangeDescription
> serialization or review the below code and tell me where I'm erring?
>
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "*",
> new XMLResourceFactoryImpl());
> Resource resource =
> resourceSet.createResource(URI.createURI("/Users/markgunnels/temp/cd5.xml "));
>
> resource.getContents().add(sr);
>
> ChangeRecorder cr = new ChangeRecorder(resourceSet);
>
> sr.setAction("GET");
> sr.setChangeReason("MA");
>
> ChangeDescription cd = cr.endRecording();
> resource.getContents().add(cd);
An XMLResource will only serialize a single root object. Use
XMIResourceFactoryImpl if you intend to use multiple root objects.
> try
> {
> resource.save(null);
> }
> catch (IOException e)
> {
> e.printStackTrace();
> }
>
> I am using org.eclipse.emf.ecore.change_2.4.0.v200808251517.jar.
>
> Thanks very much for any assistance.
>
It's best to ask EMF questions in the EMF newsgroup, which I've added to
the "to" list of the reply.
Mark Gunnels wrote:
> I am attempting to serialize a ChangeDescription along with the model
> it is performing a "change recording" on. The resulting XML contains
> the description of the model but lacks the ChangeDescription. Can
> anyone provide example code of a successful ChangeDescription
> serialization or review the below code and tell me where I'm erring?
>
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "*",
> new XMLResourceFactoryImpl());
> Resource resource =
> resourceSet.createResource(URI.createURI("/Users/markgunnels/temp/cd5.xml "));
>
> resource.getContents().add(sr);
>
> ChangeRecorder cr = new ChangeRecorder(resourceSet);
>
> sr.setAction("GET");
> sr.setChangeReason("MA");
>
> ChangeDescription cd = cr.endRecording();
> resource.getContents().add(cd);
An XMLResource will only serialize a single root object. Use
XMIResourceFactoryImpl if you intend to use multiple root objects.
> try
> {
> resource.save(null);
> }
> catch (IOException e)
> {
> e.printStackTrace();
> }
>
> I am using org.eclipse.emf.ecore.change_2.4.0.v200808251517.jar.
>
> Thanks very much for any assistance.
>