Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » CompleteOCL to XMI
CompleteOCL to XMI [message #792741] Tue, 07 February 2012 10:58 Go to next message
D O is currently offline D OFriend
Messages: 13
Registered: November 2011
Junior Member
Hi,

I added a command to "CompleteOCL Editor" to save a fragment in XMI (see the file as an attachment).

This file represents the OCL expression (validate in CompleteOCL Editor) below:

def: getCountECT01(dateStart: ISODatatypes::TS, dateEnd: ISODatatypes::TS, dateLimit: ISODatatypes::TS): Integer =
Subject.allInstances()->select(sbj: Subject |
sbj.entityClassCode.code = 'PAT'
and sbj.determinerCode.code = 'INSTANCE'
and sbj.birthTime.greaterOrEqual(dateStart).value
and sbj.birthTime.lessOrEqual(dateEnd).value
and sbj.clinicalStatements->exists(cs: ClinicalStatement |
cs.classCode.code = 'OBS'
and cs.code.code = 'idiopathic Parkinson"s Disease'
and cs.effectiveTime.terms->exists(ts | ts.oclAsType(ISODatatypes::TS).greaterOrEqual(dateLimit).value)
)
and sbj.clinicalStatements->exists(cs: ClinicalStatement |
cs.code.code = 'Hoehn and Yahr stage'
and cs.value.oclAsType(ISODatatypes::INT).value >= 1
and cs.value.oclAsType(ISODatatypes::INT).value <= 4
)
)->size()


But the file is not valid, I conclude that my approach is not good. What approach would you recommend to do that?

The ultimate goal is to use this file with Acceleo.

For information, I use OCL Tools 4.0.0M5.

Best regard.

DO
  • Attachment: test.xmi
    (Size: 28.30KB, Downloaded 92 times)
Re: CompleteOCL to XMI [message #793176 is a reply to message #792741] Tue, 07 February 2012 21:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi

You have saved the CST corresponding to the Xtext model to an XMI file;
it should be valid; just not what you expected.

You need to save the AST.

Generally a CS2Pivot is used to convert CS to Pivot AST and the
resulting resources are managed in the MetaModelManger.pivotResourceSet.

Look at existing usage of PivotSaver to make sure that orphan
synthesized types are copied to your resource before saving.

[I have a nagging doubt that there may be a bug in the declaration of
xsi:schemaLocation, so you may have to add it by hand. Let me know if
it's a problem.]

Regards

Ed Willink


On 07/02/2012 10:58, D O wrote:
> Hi,
>
> I added a command to "CompleteOCL Editor" to save a fragment in XMI (see the file as an attachment).
>
> This file represents the OCL expression (validate in CompleteOCL Editor) below:
>
> def: getCountECT01(dateStart: ISODatatypes::TS, dateEnd: ISODatatypes::TS, dateLimit: ISODatatypes::TS): Integer =
> Subject.allInstances()->select(sbj: Subject |
> sbj.entityClassCode.code = 'PAT'
> and sbj.determinerCode.code = 'INSTANCE'
> and sbj.birthTime.greaterOrEqual(dateStart).value
> and sbj.birthTime.lessOrEqual(dateEnd).value
> and sbj.clinicalStatements->exists(cs: ClinicalStatement |
> cs.classCode.code = 'OBS'
> and cs.code.code = 'idiopathic Parkinson"s Disease'
> and cs.effectiveTime.terms->exists(ts | ts.oclAsType(ISODatatypes::TS).greaterOrEqual(dateLimit).value)
> )
> and sbj.clinicalStatements->exists(cs: ClinicalStatement |
> cs.code.code = 'Hoehn and Yahr stage'
> and cs.value.oclAsType(ISODatatypes::INT).value>= 1
> and cs.value.oclAsType(ISODatatypes::INT).value<= 4
> )
> )->size()
>
>
> But the file is not valid, I conclude that my approach is not good. What approach would you recommend to do that?
>
> The ultimate goal is to use this file with Acceleo.
>
> For information, I use OCL Tools 4.0.0M5.
>
> Best regard.
>
> DO
Re: CompleteOCL to XMI [message #793220 is a reply to message #793176] Tue, 07 February 2012 22:28 Go to previous messageGo to next message
D O is currently offline D OFriend
Messages: 13
Registered: November 2011
Junior Member
Hi,

You understood my problem. But I do not see how to use CS2Pivot. Below is the piece of code that is a problem. How CS2Pivot intervene in this code?

final EObjectNode eObjectNode = (EObjectNode) sel;
IXtextDocument documentProvider = ((XtextEditor)editor).getDocument();
documentProvider.readOnly(new IUnitOfWork<Object, XtextResource>() {
	public Object exec(XtextResource resource) throws Exception {
		String fragment = eObjectNode.getEObjectURI().fragment();
		EObject object = resource.getEObject(fragment);
								
		ResourceSet resourceSet = object.eResource().getResourceSet();
		Resource xmiResource = resourceSet.createResource(URI.createFileURI(file));
		xmiResource.getContents().add(object);
								
		xmiResource.save(saveOptions);
								
		return null;
	}
});


Thanks.

DO
Re: CompleteOCL to XMI [message #793582 is a reply to message #793220] Wed, 08 February 2012 10:07 Go to previous messageGo to next message
D O is currently offline D OFriend
Messages: 13
Registered: November 2011
Junior Member
Hi,

To solve my problem, I looked at the class "SaveExpressionAction" which proposes a solution approaching my goal. In the current release OCL Tools, the XMI file is almost empty! (see attached file)

And in version 4.0.0M5, there is an exception! (org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The object 'dateStart : EHR4CR_IM.uml::ISODIS21090::ISODatatypes::TS' is not contained in a resource.)

Below is the code used:

documentProvider.readOnly(new IUnitOfWork<Object, XtextResource>() {
	public Object exec(XtextResource resource) throws Exception {
		CS2PivotResourceAdapter csAdapter = CS2PivotResourceAdapter.findAdapter((BaseCSResource)resource);
		csAdapter.refreshPivotMappings(null);
		Resource pivotResource = csAdapter.getPivotResource(resource);
		pivotResource.setURI(URI.createFileURI(file));
		pivotResource.save(saveOptions);
		return null;
	}
});


I wonder if it's not a bug.

DO
Re: CompleteOCL to XMI [message #794048 is a reply to message #793582] Wed, 08 February 2012 21:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi

Well done you've found a good bit of example code. But ....

The code saves an expression plausibly because it is self-contained.

A Complete OCL document complements an existing model, so when you save
the Complete OCL XMI in isolation there are a lot of dangling
references. This functionality is totally undefined in the OCL
specification and I've clearly not thought it through properly yet for
Eclipse OCL.

Perhaps it is illegal to save partial Pivot ResourceSets and that the
XMI must comprise the complete ResourceSet. Perhaps each resource should
be saved to a file of a designated folder. Perhaps ...

What problem are you trying to solve (not what solution are you
pursuing)? Maybe if I understand your use case I can be more inspired
about how Complete OCL XMI might be meaningful.

Regards

Ed Willink


On 08/02/2012 10:07, D O wrote:
> Hi,
>
> To solve my problem, I looked at the class "SaveExpressionAction" which proposes a solution approaching my goal. In the current release OCL Tools, the XMI file is almost empty! (see attached file)
>
> And in version 4.0.0M5, there is an exception! (org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The object 'dateStart : EHR4CR_IM.uml::ISODIS21090::ISODatatypes::TS' is not contained in a resource.)
>
> Below is the code used:
>
>
> documentProvider.readOnly(new IUnitOfWork<Object, XtextResource>() {
> public Object exec(XtextResource resource) throws Exception {
> CS2PivotResourceAdapter csAdapter = CS2PivotResourceAdapter.findAdapter((BaseCSResource)resource);
> csAdapter.refreshPivotMappings(null);
> Resource pivotResource = csAdapter.getPivotResource(resource);
> pivotResource.setURI(URI.createFileURI(file));
> pivotResource.save(saveOptions);
> return null;
> }
> });
>
>
> I wonder if it's not a bug.
>
> DO
>
Re: CompleteOCL to XMI [message #794096 is a reply to message #794048] Wed, 08 February 2012 22:57 Go to previous messageGo to next message
D O is currently offline D OFriend
Messages: 13
Registered: November 2011
Junior Member
Hi,

I want to use Acceleo. OCL is defined by a metamodel, it is usually possible to use tools such Acceleo, does not it?

DO
Re: CompleteOCL to XMI [message #794388 is a reply to message #794096] Thu, 09 February 2012 08:19 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi

OK. That makes sense. You definitely want the full model, not just the
Complete OCL contribution.

The MetaModelManager.pivotResourceSet has one Resource for each
contribution, typically
- primary meta-model
- Complete OCL contributions
- orphanage of synthesized types
packages and types appearing in multiple contributions have additional
server/client relationships so that using reflection you can access a
composite or partitioned view.

See my 'design' discussion with myself on
https://bugs.eclipse.org/bugs/show_bug.cgi?id=371018.

Regards

Ed Willink

On 08/02/2012 22:57, D O wrote:
> Hi,
>
> I want to use Acceleo. OCL is defined by a metamodel, it is usually
> possible to use tools such Acceleo, does not it?
>
> DO
Re: CompleteOCL to XMI [message #990005 is a reply to message #794388] Mon, 10 December 2012 12:44 Go to previous messageGo to next message
Fi Fi is currently offline Fi FiFriend
Messages: 133
Registered: March 2010
Senior Member
Hi D O,
I have the same problem like you in order to get the XMI file
from the CompleteOCL.

Can you please explain for me how to generate the XMI file please?

Best regards,

Fy Za
Re: CompleteOCL to XMI [message #1017172 is a reply to message #794388] Sun, 10 March 2013 13:19 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi

After revisiting this thread, I suspect there is a misunderstanding.

There are two possible use cases.

A) Exploit Complete OCL definitions to provide additional facilities to
be used by the Acceleo transformation engine.

B) Use a Complete OCL model as one of the source models to be transformed.

My responses have been in regard to the loadable validity of a Complete
OCL document from its XMI serialization for B). It presents many
challenges some of which are outlined in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=371018 and others in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=402780.

I think the actual problem is A). This too presents problems addressed
in https://bugs.eclipse.org/bugs/show_bug.cgi?id=402830. These are
variously language and tooling issues. There is no language
specification indicating how a Complete OCL document might be loadable.
Consequently Acceleo provides no syntax to support such loading and
Eclipse OCL provides limited facilities that might assist Acceleo in
doing so.

For Acceleo there are two problems. Firstly loading the Complete OCL
document so that the editor/builder exploits it. Then loading so that
the run-time uses it. For the latter there is a semi-programmatic
workaround; user code may be added to the auto-generated Java main
program to load the Complete OCL document using the Ecore-based OCL API.
I can see no workaround for the former;
https://bugs.eclipse.org/bugs/show_bug.cgi?id=402836 raised.

Regards

Ed Willink






On 09/02/2012 08:19, Ed Willink wrote:
> Hi
>
> OK. That makes sense. You definitely want the full model, not just the
> Complete OCL contribution.
>
> The MetaModelManager.pivotResourceSet has one Resource for each
> contribution, typically
> - primary meta-model
> - Complete OCL contributions
> - orphanage of synthesized types
> packages and types appearing in multiple contributions have additional
> server/client relationships so that using reflection you can access a
> composite or partitioned view.
>
> See my 'design' discussion with myself on
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=371018.
>
> Regards
>
> Ed Willink
>
> On 08/02/2012 22:57, D O wrote:
>> Hi,
>>
>> I want to use Acceleo. OCL is defined by a metamodel, it is usually
>> possible to use tools such Acceleo, does not it?
>>
>> DO
>
Previous Topic:transform completeocl resource
Next Topic:import platform-resource to completeoclfile
Goto Forum:
  


Current Time: Thu Nov 27 17:22:51 GMT 2014

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

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