| OCL constraint problems with data types [message #414686] |
Fri, 16 November 2007 07:49  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #414696 is a reply to message #414695] |
Fri, 16 November 2007 10:38   |
Eclipse User |
|
|
|
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
|
|
|
|
|
Powered by
FUDForum. Page generated in 1.06841 seconds