Skip to main content



      Home
Home » Modeling » OCL » Extend OCL(to add new types (Date for instance))
Extend OCL [message #1719837] Tue, 12 January 2016 09:15 Go to next message
Eclipse UserFriend
Hi,

I am completely newbie in the OCL world.

I would like to extend the OCL standard library to add new types. As an example, it would be nice to add constraints on dates in my files (isBefore, isAfter). I made some researchs on the internet and I came with the idea that it is possible. I would use the java.util.Date class.

Does anyone know how to extend the OCL standard library / or know how to add new types (and particularly types based on Java classes ?).

Thanks a lot
Re: Extend OCL [message #1719873 is a reply to message #1719837] Tue, 12 January 2016 13:59 Go to previous messageGo to next message
Eclipse UserFriend
Hi

The new Pivot-based OCL has an extensible library model, so you can
extend it in similar fashion to its definition. Unfortunately I haven't
yet written a tutorial.

http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/plugins/org.eclipse.ocl.pivot/model/OCL-2.5.oclstdlib

(declarations referencing Java implementation classes.)

http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/examples/org.eclipse.ocl.examples.codegen/model/CGLibrary.oclstdlib

is an example extension.

If you just want to add constraints to Java classes you can define them
as EDataTypes. See EDate in Ecore.ecore.

Using OCLinEcore you can add internal constramts.

Using Complete OCL you can add external constraints.

If you're a newbie, I suggest using OCLinEcore since that gives you the
most integration. Follow the tutorials.

Regards

Ed Willink


On 12/01/2016 14:16, John Prestwick wrote:
> Hi,
>
> I am completely newbie in the OCL world.
>
> I would like to extend the OCL standard library to add new types. As
> an example, it would be nice to add constraints on dates in my files
> (isBefore, isAfter). I made some researchs on the internet and I came
> with the idea that it is possible. I would use the java.util.Date class.
>
> Does anyone know how to extend the OCL standard library / or know how
> to add new types (and particularly types based on Java classes ?).
>
> Thanks a lot
>
Re: Extend OCL [message #1721025 is a reply to message #1719873] Fri, 22 January 2016 11:35 Go to previous message
Eclipse UserFriend
Hi,

Thanks for your answer.

So, I defined my attributes as EDate.

I am able to use some operations (<, >) on Dates directly into my (Complete) OCL constraints. That is nice.

I want now to add new operations by using Java methods that I will create.

As you told me, I need to extend the OCL Standard Library.

The file that you gave me as an example is the following (I've deleted 2 operations) :

import 'http://www.eclipse.org/ocl/2015/Library';

library ocl : ocl = 'http://www.eclipse.org/ocl/2015/Library'
{
type String {
	operation getSeverity() : Integer[1] => 'org.eclipse.ocl.pivot.library.string.CGStringGetSeverityOperation';

}
}


When copying this file and opening, I have the following error :

index.php/fa/24724/0/

I have no idea how to link the oclstdlib file with the org.eclipse.ocl.pivot.library.string.CGStringGetSeverityOperation.java ?

And I am not able to find org.eclipse.ocl.pivot.library.string.CGStringGetSeverityOperation.getSeverity() to see how it is implemented.

Could you help me on this two points ? This might looks stupid but I am really a newbie.

Thanks a lot
Regards

[Updated on: Sun, 24 January 2016 13:25] by Moderator

Previous Topic:Unresolvable property on class with exactly one association
Next Topic:Customized Helper Methods in EmbeddedXtextEditor
Goto Forum:
  


Current Time: Wed Jul 23 15:17:58 EDT 2025

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

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

Back to the top