Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » using OCL from java
using OCL from java [message #692754] Tue, 05 July 2011 07:21 Go to next message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
hello

i'm new with OCL in eclipse, so that coul be a noob question:

i tried to validate an uml model at runtime with java
i read the OCL Interpreter Tutorial and tried to use this for my aim

but i could not run the example, because i got a compile error in this line

OCL<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, Constraint, EClass, EObject> ocl;

"the type OCL is not generic"

if i had understand the tutorial, i have to adapt the following line

ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);

into something like this:
ocl = OCL.newInstance(UMLEnvironment.);
but there is no choice of INSTANCE like above

ever help is welcome

regards
stoehm
Re: using OCL from java [message #692771 is a reply to message #692754] Tue, 05 July 2011 07:54 Go to previous messageGo to next message
Axel Uhl is currently offline Axel UhlFriend
Messages: 41
Registered: July 2009
Member
Stoehm,

are you sure you imported OCL from the correct package? Please note that there is more than one class named "OCL," each in a different package.

Best,
-- Axel
Re: using OCL from java [message #692795 is a reply to message #692771] Tue, 05 July 2011 08:57 Go to previous messageGo to next message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
hi alex
thanks for your reply
thats it, i just took the false imports Embarrassed
but for me its still a problem, what is the analog call to
ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
i want to have an UMLEnvironment but UMLEnvironmentFactory has no static fiel INSTANCE, i tried to call this:
ocl = OCL.newInstance(new UMLEnvironmentFactory().createEnvironment());
which causes again an compileerror
so maybe you can tell me the rigth call

best regards
stoehm
Re: using OCL from java [message #692820 is a reply to message #692795] Tue, 05 July 2011 09:56 Go to previous messageGo to next message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
hi
ok i checked out the other problem with the resource, but for me there is still the problem, that i don't know what is the right call in case of UML since

ocl = OCL.newInstance(new UMLEnvironmentFactory().createEnvironment());

is not working

any hint is welcome

best regards

[Updated on: Tue, 05 July 2011 12:45]

Report message to a moderator

Re: using OCL from java [message #693014 is a reply to message #692795] Tue, 05 July 2011 16:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
HI

If you use F4, Open Type hierrachy you will discover four UML variants
of OCL.newInstance. The closest has a UMLEnvironmentFactory argument so
you could do OCL.newInstance(new UMLEnvironmentFactory()).

I'm afraid the UML documentation is thin.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=351214 raised.

We are not entirely clear whether the asymmetry between the UML and
Ecore binding is really necessary. It's a pain for us too.

Regards

Ed Willink


On 05/07/2011 09:57, stoehm wrote:
> hi alex
> thanks for your reply
> thats it, i just took the false imports :blush: but for me its still
> a problem, what is the analog call to
> ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
> i want to have an UMLEnvironment but UMLEnvironmentFactory has no
> static fiel INSTANCE, i tried to call this:
> ocl = OCL.newInstance(new
> UMLEnvironmentFactory().createEnvironment());
> which causes again an compileerror
> so maybe you can tell me the rigth call
>
> best regards
> stoehm
>
Re: using OCL from java [message #693015 is a reply to message #692820] Tue, 05 July 2011 16:09 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The helper requires a Class argument, which you may obtain by naigating
your UML meta-model using UML's helper operations such as getOwnedType(c1);

Regards

Ed Willink


On 05/07/2011 10:56, stoehm wrote:
> hi
> trying to run the example, i have another question now
> is there an easy way to set the context of an OCLHelper object
> for example i have an example.uml which is located in any location,
> and this example.uml contains a package p1, with a class c1, now i
> want to set the context of an OCLHelper something like this
> helper.setContext(pathOfTheExampleUML.p1.c1)
>
> best regards
Re: using OCL from java [message #693352 is a reply to message #693015] Wed, 06 July 2011 09:53 Go to previous message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
hello ed
thanks for your reply it helped me a lot
for now i have to read the APIs, i hope i get well along with it

best regards
stoehm
Previous Topic:Creating concrete model using threading
Next Topic:can ocl validate runtimeobjects against their classes
Goto Forum:
  


Current Time: Thu Apr 25 09:40:19 GMT 2024

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

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

Back to the top