Skip to main content



      Home
Home » Modeling » EMF » OCL constraint problems with data types
OCL constraint problems with data types [message #414686] Fri, 16 November 2007 07:49 Go to next message
Eclipse UserFriend
Hi!

We're using EMF Validation Framework to write OCL constraints for our EMF
models through the "org.eclipse.emf.validation.constraintProviders"
extension point.
However, we have problems with this when using different data types.
If we have an attribute "vNVSHUNT" of type 'int' or 'EInt' an OCL
constraint defined in plugin.xml as below works fine:

<constraint
lang="OCL"
severity="ERROR"
mode="Batch"
name="Valid value range for vNVSHUNT"
id="vNVSHUNT.validValue"
statusCode="1">
<description>vNVSHUNT set to value >= 5.</description>
<message>"{0}". Invalid value.</message>
<target class="Pct3Def"/>
<![CDATA[
self.vNVSHUNT >= 5
]]>
</constraint>

BUT, for other types such as 'short', 'float', 'EShort' etc there's
problem.
No matter what the value of vNVSHUNT is set to, the constraint always
evaluates that the value is not valid!

Any idea what the problem could be?
Is it only possible to have these OCL constraints for a certain range of
data types (e.g. int, string)?
Are there any drawbacks of not using only the 'EXxxx' data types? I.e.
what's the functional difference of using e.g. 'EInt' vs. 'int'?


Really appreciate a quick answer on above issues.

Regards,
Joachim
Re: OCL constraint problems with data types [message #414690 is a reply to message #414686] Fri, 16 November 2007 08:58 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Joachim,

Which versions of EMF Validation and MDT OCL are you using?

The OCL parser's Ecore metamodel binding should be mapping data types to OCL
types as follows:

- EInt, EIntegerObject ==> Integer
- EShort, EShortObject ==> Integer
- ELong, ELongObject ==> Integer
- EFloat, EFloatObject ==> Real
- EDouble, EDoubleObject ==> Real

Moreover, any EDataType whose instance-class is a Java numeric type should
have an appropriate mapping. If this isn't the case, then you likely have
a bug for the MDT OCL component.

Cheers,

Christian


Joachim Rietz wrote:

> Hi!
>
> We're using EMF Validation Framework to write OCL constraints for our EMF
> models through the "org.eclipse.emf.validation.constraintProviders"
> extension point.
> However, we have problems with this when using different data types.
> If we have an attribute "vNVSHUNT" of type 'int' or 'EInt' an OCL
> constraint defined in plugin.xml as below works fine:
>
> <constraint
> lang="OCL"
> severity="ERROR"
> mode="Batch"
> name="Valid value range for vNVSHUNT"
> id="vNVSHUNT.validValue"
> statusCode="1">
> <description>vNVSHUNT set to value >= 5.</description>
> <message>"{0}". Invalid value.</message>
> <target class="Pct3Def"/>
> <![CDATA[
> self.vNVSHUNT >= 5
> ]]>
> </constraint>
>
> BUT, for other types such as 'short', 'float', 'EShort' etc there's
> problem.
> No matter what the value of vNVSHUNT is set to, the constraint always
> evaluates that the value is not valid!
>
> Any idea what the problem could be?
> Is it only possible to have these OCL constraints for a certain range of
> data types (e.g. int, string)?
> Are there any drawbacks of not using only the 'EXxxx' data types? I.e.
> what's the functional difference of using e.g. 'EInt' vs. 'int'?
>
>
> Really appreciate a quick answer on above issues.
>
> Regards,
> Joachim
Re: OCL constraint problems with data types [message #414695 is a reply to message #414690] Fri, 16 November 2007 10:17 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

Thanks for your quick answer.

We have the following plugin versions:
org.eclipse.ocl_1.1.0.v200706201508.jar
org.eclipse.ocl.ecore_1.1.0.v200706071450.jar
org.eclipse.emf.ocl_1.1.0.v200706201508.jar

I guess, hope, these are the required MDT OCL plugins?

However, just can't get it working...
Am I missing some further dependency?

/Joachim
Re: OCL constraint problems with data types [message #414696 is a reply to message #414695] Fri, 16 November 2007 10:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Joachim,

These are of the the plug-ins that would be required for your application.

However, you might just try this with the M3 milestone of OCL 1.2. We made
some improvements in the handling of numeric values. Since your problem
isn't in the parsing but in the evaluation, I think the cause is simply
that the interpreter is getting run-time values that are Shorts and trying
to cast them to Integer. It doesn't do that any more in the 1.2 release.

HTH,

Christian


Joachim Rietz wrote:

> Hi,
>
> Thanks for your quick answer.
>
> We have the following plugin versions:
> org.eclipse.ocl_1.1.0.v200706201508.jar
> org.eclipse.ocl.ecore_1.1.0.v200706071450.jar
> org.eclipse.emf.ocl_1.1.0.v200706201508.jar
>
> I guess, hope, these are the required MDT OCL plugins?
>
> However, just can't get it working...
> Am I missing some further dependency?
>
> /Joachim
Re: OCL constraint problems with data types [message #414770 is a reply to message #414686] Wed, 21 November 2007 02:45 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

I have the same problem. Does anyone know anything about this?

Regards

Henrik


Joachim Rietz wrote:

> Hi!

> We're using EMF Validation Framework to write OCL constraints for our EMF
> models through the "org.eclipse.emf.validation.constraintProviders"
> extension point.
> However, we have problems with this when using different data types.
> If we have an attribute "vNVSHUNT" of type 'int' or 'EInt' an OCL
> constraint defined in plugin.xml as below works fine:

> <constraint
> lang="OCL"
> severity="ERROR"
> mode="Batch"
> name="Valid value range for vNVSHUNT"
> id="vNVSHUNT.validValue"
> statusCode="1">
> <description>vNVSHUNT set to value >= 5.</description>
> <message>"{0}". Invalid value.</message>
> <target class="Pct3Def"/>
> <![CDATA[
> self.vNVSHUNT >= 5
> ]]>
> </constraint>

> BUT, for other types such as 'short', 'float', 'EShort' etc there's
> problem.
> No matter what the value of vNVSHUNT is set to, the constraint always
> evaluates that the value is not valid!

> Any idea what the problem could be?
> Is it only possible to have these OCL constraints for a certain range of
> data types (e.g. int, string)?
> Are there any drawbacks of not using only the 'EXxxx' data types? I.e.
> what's the functional difference of using e.g. 'EInt' vs. 'int'?


> Really appreciate a quick answer on above issues.

> Regards,
> Joachim
Re: OCL constraint problems with data types [message #414771 is a reply to message #414770] Wed, 21 November 2007 02:48 Go to previous message
Eclipse UserFriend
Hmm, you should ignore my last message. I didn't notice that there already
was an answer on the topic...

/Henrik
Previous Topic:Restrict visibility in editors
Next Topic:XMLCalender:: NoClassDefFoundError
Goto Forum:
  


Current Time: Tue Oct 28 11:42:00 EDT 2025

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

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

Back to the top