Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » problem in evaluating the UML model with OCL API
problem in evaluating the UML model with OCL API [message #1512096] Mon, 15 December 2014 12:54 Go to next message
Jane Rokh is currently offline Jane RokhFriend
Messages: 3
Registered: December 2014
Junior Member
Hi everyone,

I want to use OCL APIs in a standalone java application to validate a UML model. I created a UML profile and defined the OCL constraints in the profile. then applied the profile on a UML model. when I run my application, it can evaluate the OCL constraints that are defined over a single stereotype correctly. But when I have a constraint which has navigation from a stereotype to the second one, I get the following error.
when I debug the code I can see that the context and the query that I am creating and sending to ocl.evaluate is correct but it throws the error.

I should also say that I can validate the model by right click-> OCL->validate , and it return the validation result correctly (successful or error depending on model values) for both single element constraint and the constraint with navigation. So the constraints are fine and the problem is in my code.

Sorry if it is elementary. I am new to OCL programming.


Exception in thread main"org.eclipse.ocl.examples.domain.values.impl.InvalidValueException: Failed to evaluate PR2::Stereotype1::stereotype2
at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.evaluatePropertyCallExp(EvaluationVisitorImpl.java:176)
at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitPropertyCallExp(EvaluationVisitorImpl.java:752)
at org.eclipse.ocl.examples.pivot.internal.impl.PropertyCallExpImpl.accept(PropertyCallExpImpl.java:381)
at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.evaluate(EvaluationVisitorImpl.java:149)
at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.evaluatePropertyCallExp(EvaluationVisitorImpl.java:165)
at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitPropertyCallExp(EvaluationVisitorImpl.java:752)
at org.eclipse.ocl.examples.pivot.internal.impl.PropertyCallExpImpl.accept(PropertyCallExpImpl.java:381)
at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:684)
at org.eclipse.ocl.examples.pivot.internal.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:426)
at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.safeVisit(EvaluationVisitorImpl.java:195)
at org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitExpressionInOCL(EvaluationVisitorImpl.java:419)
at org.eclipse.ocl.examples.pivot.internal.impl.ExpressionInOCLImpl.accept(ExpressionInOCLImpl.java:523)
at org.eclipse.ocl.examples.pivot.OCL.evaluate(OCL.java:422)


Thanks,
Jane
Re: problem in evaluating the UML model with OCL API [message #1512214 is a reply to message #1512096] Mon, 15 December 2014 15:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5429
Registered: July 2009
Senior Member
HI

https://wiki.eclipse.org/OCL/ForumNetiquette

Regards

Ed Willink


On 15/12/2014 14:43, Jane Rokh wrote:
> Hi everyone,
>
> I want to use OCL APIs in a standalone java application to validate a
> UML model. I created a UML profile and defined the OCL constraints in
> the profile. then applied the profile on a UML model. when I run my
> application, it can evaluate the OCL constraints that are defined over a
> single stereotype correctly. But when I have a constraint which has
> navigation from a stereotype to the second one, I get the following error.
> when I debug the code I can see that the context and the query that I am
> creating and sending to ocl.evaluate is correct but it throws the error.
>
> I should also say that I can validate the model by right click->
> OCL->validate , and it return the validation result correctly
> (successful or error depending on model values) for both single element
> constraint and the constraint with navigation. So the constraints are
> fine and the problem is in my code.
> Sorry if it is elementary. I am new to OCL programming.
>
>
> Exception in thread
> main"org.eclipse.ocl.examples.domain.values.impl.InvalidValueException:
> Failed to evaluate PR2::Stereotype1::stereotype2
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.evaluatePropertyCallExp(EvaluationVisitorImpl.java:176)
>
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitPropertyCallExp(EvaluationVisitorImpl.java:752)
>
> at
> org.eclipse.ocl.examples.pivot.internal.impl.PropertyCallExpImpl.accept(PropertyCallExpImpl.java:381)
>
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.evaluate(EvaluationVisitorImpl.java:149)
>
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.evaluatePropertyCallExp(EvaluationVisitorImpl.java:165)
>
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitPropertyCallExp(EvaluationVisitorImpl.java:752)
>
> at
> org.eclipse.ocl.examples.pivot.internal.impl.PropertyCallExpImpl.accept(PropertyCallExpImpl.java:381)
>
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitOperationCallExp(EvaluationVisitorImpl.java:684)
>
> at
> org.eclipse.ocl.examples.pivot.internal.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:426)
>
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.safeVisit(EvaluationVisitorImpl.java:195)
>
> at
> org.eclipse.ocl.examples.pivot.evaluation.EvaluationVisitorImpl.visitExpressionInOCL(EvaluationVisitorImpl.java:419)
>
> at
> org.eclipse.ocl.examples.pivot.internal.impl.ExpressionInOCLImpl.accept(ExpressionInOCLImpl.java:523)
>
> at org.eclipse.ocl.examples.pivot.OCL.evaluate(OCL.java:422)
>
>
> Thanks,
> Jane
>
Re: problem in evaluating the UML model with OCL API [message #1512358 is a reply to message #1512214] Mon, 15 December 2014 17:43 Go to previous messageGo to next message
Jane Rokh is currently offline Jane RokhFriend
Messages: 3
Registered: December 2014
Junior Member
Hi,

Sorry for incomplete information. I attached the small project. I basically used the code that one of the members previously posted in the forum. The project has two classes :First and Second in the src/package A.B/ .
The uml model and profile applied on that are saved in the "models" folder.
I run the application by right click on First class/ run as Java application

I am using Luna SR1 and I updated OCL to version 5.03

Thanks,
Jane
  • Attachment: testOCL.zip
    (Size: 18.20KB, Downloaded 101 times)
Re: problem in evaluating the UML model with OCL API [message #1516165 is a reply to message #1512358] Thu, 18 December 2014 17:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5429
Registered: July 2009
Senior Member
Hi

Thanks for the repro.

The problem is an assumption that the stereotype properties have a
sensible String representation, which objects don't.

No obvious workaround. You'll need the fix.

Regards

Ed Willink

On 15/12/2014 17:43, Jane Rokh wrote:
> Hi,
>
> Sorry for incomplete information. I attached the small project. I basically used the code that one of the members previously posted in the forum. The project has two classes :First and Second in the src/package A.B/ .
> The uml model and profile applied on that are saved in the "models" folder.
> I run the application by right click on First class/ run as Java application
>
> I am using Luna SR1 and I updated OCL to version 5.03
>
> Thanks,
> Jane
>
Re: problem in evaluating the UML model with OCL API [message #1517049 is a reply to message #1516165] Fri, 19 December 2014 08:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5429
Registered: July 2009
Senior Member
On 18/12/2014 17:59, Ed Willink wrote:
> No obvious workaround. You'll need the fix.

Please follow

https://bugs.eclipse.org/bugs/show_bug.cgi?id=455704

for further progress. The fix should be available in a couple of days
when org.eclipse.ocl.examples.pivot etc are promoted to
org.eclipse.ocl.pivot etc for M5.

Regards

Ed Willink
Re: problem in evaluating the UML model with OCL API [message #1517380 is a reply to message #1517049] Fri, 19 December 2014 13:09 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 295
Registered: March 2012
Senior Member
On 19/12/2014 09:08, Ed Willink wrote:
> when org.eclipse.ocl.examples.pivot etc are promoted to
> org.eclipse.ocl.pivot etc for M5.

Nice to see this happening!
Felix
Re: problem in evaluating the UML model with OCL API [message #1523320 is a reply to message #1517380] Mon, 22 December 2014 21:39 Go to previous message
Jane Rokh is currently offline Jane RokhFriend
Messages: 3
Registered: December 2014
Junior Member
Thanks very much Ed!
Previous Topic:Valuation of forAll in combination with @pre and check of vanished items
Next Topic:Unexpected conversion from Sequence to OrderedSet
Goto Forum:
  


Current Time: Thu Oct 19 14:38:33 GMT 2017

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

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