Home » Modeling » OCL » Ecore2OCLinEcore
| |
Re: Ecore2OCLinEcore [message #727237 is a reply to message #727185] |
Tue, 20 September 2011 16:53 |
ModelGeek Mising name Messages: 550 Registered: June 2011 |
Senior Member |
|
|
Hi,
Actually Ecore2OCLinEcore is available in org.eclipse.ocl.examples.xtext.oclinecore.resource.Ecore2OCLinEcore for Helios, but in Indigo this class is deleted.
I have tried to understand RoundTripTest Code which is given below:
public void doRoundTripFromOclInEcore(String stem) throws IOException, InterruptedException {
String inputName = stem + ".oclinecore";
String middleName = stem + ".converted.ecore";
String outputName = stem + ".regenerated.oclinecore";
String output2Name = stem + ".reconverted.ecore";
URI inputURI = getProjectFileURI(inputName);
URI middleURI = getProjectFileURI(middleName);
URI outputURI = getProjectFileURI(outputName);
URI output2URI = getProjectFileURI(output2Name);
Resource leftResource = resourceSet.getResource(inputURI, true);
assertNoResourceErrors("Load failed", leftResource);
// OCLinEcore2Ecore cs2e = new OCLinEcore2Ecore(resourceSet, leftResource, middleURI);
// Resource middleResource = cs2e.exportToEcore();
// assertEquals("To Ecore errors", 0, middleResource.getErrors().size());
// middleResource.save(null);
// resourceSet.getResources().add(middleResource);
RootPackageCS csDocument = null; // FIXME Ecore2OCLinEcore.importFromEcore(resourceSet, null, middleResource);
assertNoResourceErrors("From Ecore errors", csDocument.eResource());
Resource rightResource = resourceSet.createResource(outputURI);
// middleResource.getContents().addAll(csObjects);
rightResource.getContents().add(csDocument);
rightResource.save(null);
// OCLinEcore2Ecore cs2e2 = new OCLinEcore2Ecore(resourceSet, rightResource, output2URI);
// Resource right2Resource = cs2e2.exportToEcore();
assertNoResourceErrors("To Ecore errors", rightResource);
// right2Resource.save(null);
// resourceSet.getResources().add(right2Resource);
// assertSameModel(middleResource, right2Resource);
}
In the code, you have FIXME Ecore2OCLinEcore which is not part of Indigo. And here also XtextResource is not intialized/saved ? it conatins normal resource object. I am a bit confused. Sorry for being very demanding...
In my application i have object of EPackge which contains number of EClass, I am saving that ecore resource and i want to generate human friendly text. Can you please help me and guide me how to do that...
i really appreciate your help!
Regards
[Updated on: Tue, 20 September 2011 16:56] Report message to a moderator
|
|
|
Re: Ecore2OCLinEcore [message #727253 is a reply to message #727237] |
Tue, 20 September 2011 17:40 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
Ah Helios; that was look time ago....
The Helios release has no pivot so indeed there is direct
Ecore2OCLinEcore, but none of the good things that come from the pivot.
The RoundTripTests suggestion is therefore a red herring.
However the problem is probably still that the serialized resource is
not an XtextResource since you presumably have not called
OCLinEcoreStandaloneSetup.doSetup().
Use the debugger to show the class and class hierarchy of the resource
and make sure you use *.oclinecore as the extension.
In Indigo, an EMF limitation was fixed, so you should just be able to
load a resource as Ecore then Save As *.oclinecore.
Regards
Ed Willink
On 20/09/2011 17:53, ModelGeek wrote:
> Hi,
>
> Actually Ecore2OCLinEcore is available in
> org.eclipse.ocl.examples.xtext.oclinecore.resource.Ecore2OCLinEcore
> for Helios.
>
> But in Indigo this class is deleted.
>
> I have tried to understand RoundTripTest Code which is given below:
> public void doRoundTripFromOclInEcore(String stem) throws
> IOException, InterruptedException {
> String inputName = stem + ".oclinecore";
> String middleName = stem + ".converted.ecore";
> String outputName = stem + ".regenerated.oclinecore";
> String output2Name = stem + ".reconverted.ecore";
> URI inputURI = getProjectFileURI(inputName);
> URI middleURI = getProjectFileURI(middleName);
> URI outputURI = getProjectFileURI(outputName);
> URI output2URI = getProjectFileURI(output2Name);
> Resource leftResource = resourceSet.getResource(inputURI, true);
> assertNoResourceErrors("Load failed", leftResource);
> // OCLinEcore2Ecore cs2e = new OCLinEcore2Ecore(resourceSet,
> leftResource, middleURI);
> // Resource middleResource = cs2e.exportToEcore();
> // assertEquals("To Ecore errors", 0,
> middleResource.getErrors().size());
> // middleResource.save(null);
> // resourceSet.getResources().add(middleResource);
> RootPackageCS csDocument = null; // FIXME
> Ecore2OCLinEcore.importFromEcore(resourceSet, null, middleResource);
> assertNoResourceErrors("From Ecore errors",
> csDocument.eResource());
> Resource rightResource = resourceSet.createResource(outputURI);
> // middleResource.getContents().addAll(csObjects);
> rightResource.getContents().add(csDocument);
> rightResource.save(null);
> // OCLinEcore2Ecore cs2e2 = new OCLinEcore2Ecore(resourceSet,
> rightResource, output2URI);
> // Resource right2Resource = cs2e2.exportToEcore();
> assertNoResourceErrors("To Ecore errors", rightResource);
> // right2Resource.save(null);
> // resourceSet.getResources().add(right2Resource);
> // assertSameModel(middleResource, right2Resource);
> }
>
> here you have FIXME Ecore2OCLinEcore which is not part of Indigo. And
> here also XtextResource is not intialized/saved ? it conatins normal
> resource object. I am a bit confused. Sorry for being very demanding...
>
> In my application i have object of EPackge which contains number of
> EClass, I am saving that ecore resource and i want to generate human
> friendly text. Can you please help me and guide me how to do that
|
|
|
Goto Forum:
Current Time: Thu Mar 28 22:34:06 GMT 2024
Powered by FUDForum. Page generated in 0.02815 seconds
|