Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » enriching code with ocl
enriching code with ocl [message #975206] Wed, 07 November 2012 17:44 Go to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 42
Registered: November 2012
Member
hi,

I want to enrich my code with ocl in EMF, juno. so, I wrote the OCLs in ecore file and generated the code after that. but no where in the methods of class,my conditions are considered.for example I wrote:

operation deleteFolder(fPath : String[?] { ordered })
{
precondition C3: self.folders.subfolders->size() + self.folders.tasks->size() = 0;
}

would you please help me?
Re: enriching code with ocl [message #975382 is a reply to message #975206] Wed, 07 November 2012 20:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

preconditions and postconditions are currently parsed but ignored; this
is common practice in OCL tooling.

Only bodies and initial/derived conditions are code generated or
interpreted.

Adding support for pre/postconditions is on the todo list for an
enhanced user interface to control execution/debugging.

Regards

Ed Willink



On 07/11/2012 17:55, Jeni Martin wrote:
> hi,
>
> I want to enrich my code with ocl in EMF, juno. so, I wrote the OCLs
> in ecore file and generated the code after that. but no where in the
> methods of class,my conditions are considered.for example I wrote:
>
> operation deleteFolder(fPath : String[?] { ordered })
> {
> precondition C3: self.folders.subfolders->size() +
> self.folders.tasks->size() = 0;
> }
>
> would you please help me?
>
Re: enriching code with ocl [message #975660 is a reply to message #975382] Thu, 08 November 2012 02:08 Go to previous messageGo to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 42
Registered: November 2012
Member
Thank you so much for your reply. I have noticed that only the codes for invariants are created and no where in the generated code it has been used. So, I think I need to call the validate function manually myself. I have no clue what should I pass for the parameter, any helps? here the piece of code for the constraints:


public boolean validateTask_C2(Task task, DiagnosticChain diagnostics, Map<Object, Object> context) {
return
validate
(TmsPackage.Literals.TASK,
task,
diagnostics,
context,
"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
"C2",
TASK__C2__EEXPRESSION,
Diagnostic.ERROR,
DIAGNOSTIC_SOURCE,
0);
}
Best
Re: enriching code with ocl [message #975865 is a reply to message #975660] Thu, 08 November 2012 06:03 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

The validation code is invoked by the standard EMF validation framework,
so the call-path is obscured by the EValidator regustration.

You have probably neglected to register the validation delegates as
described in the standalone setup documentation, but since you provide
no details I can only guess.

Regards

Ed Willink


On 08/11/2012 02:08, Jeni Martin wrote:
> Thank you so much for your reply. I have noticed that only the codes
> for invariants are created and no where in the generated code it has
> been used. So, I think I need to call the validate function manually
> myself. I have no clue what should I pass for the parameter, any
> helps? here the piece of code for the constraints:
>
>
> public boolean validateTask_C2(Task task, DiagnosticChain diagnostics,
> Map<Object, Object> context) {
> return
> validate
> (TmsPackage.Literals.TASK,
> task,
> diagnostics,
> context,
> "http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot",
> "C2",
> TASK__C2__EEXPRESSION,
> Diagnostic.ERROR,
> DIAGNOSTIC_SOURCE,
> 0);
> }
> Best
Re: enriching code with ocl [message #976534 is a reply to message #975865] Thu, 08 November 2012 16:55 Go to previous messageGo to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 42
Registered: November 2012
Member
Hi Ed,

thank you so much for your reply. I don't know how to register the validation delegates you mentioned. can you explain more please?

once again, thank you.
Re: enriching code with ocl [message #976720 is a reply to message #975865] Thu, 08 November 2012 20:04 Go to previous messageGo to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 42
Registered: November 2012
Member
hi Ed,

By the way, Where can I find that documentation? I didn't register as I didn't know what should I do with this generated code.

Re: enriching code with ocl [message #977293 is a reply to message #976534] Fri, 09 November 2012 06:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Look at the Standalone Configuration in the OCL Documentation.

Regards

Ed Willink


On 08/11/2012 16:55, Jeni Martin wrote:
> Hi Ed,
>
> thank you so much for your reply. I don't know how to register the
> validation delegates you mentioned. can you explain more please?
>
> once again, thank you.
Re: enriching code with ocl [message #977306 is a reply to message #976720] Fri, 09 November 2012 07:06 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Help->Help Contents->OCL Documention.

or just Google: Eclipse OCL Validate Delegate

Regards

Ed Willink

On 08/11/2012 20:04, Jeni Martin wrote:
> hi Ed,
>
> By the way, Where can I find that documentation? I didn't register as
> I didn't know what should I do with this generated code.
>
>
Previous Topic:How to get the whole set of containers
Next Topic:how to call OCL constraints( generated java source code of model ) from the main code of java
Goto Forum:
  


Current Time: Tue Apr 23 17:03:10 GMT 2024

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

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

Back to the top