Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL expr as an initializer
OCL expr as an initializer [message #42068] Wed, 31 October 2007 08:20 Go to next message
Eclipse UserFriend
Originally posted by: krzysztof_kaczmarski.o2.pl

Hi All,

in the OCL standard description there is an information that OCL
expression may be used as an initialization expression for UML class
attributes. I suppose that in such case Property's defaultValue is set
to ExpressionInOCL object.
My question is how are the types and values mapped between OCL and
UML. If we have a Property that is a collection ( dogs:Dog[0..*] ) are
the values from a resulting OCL matched automatically?

This question has a little deeper meaning for me. If we use
ExpressionInOCL as a ValueSpecification in a UML Action (for example
ValueSpecificationAction) and we need to use OutputPin and ObjectFlow
to actually consume resulting values. How is the OCL collection
interpreted then?

Thanks in advance,
Krzysztof
Re: OCL expr as an initializer [message #42162 is a reply to message #42068] Wed, 31 October 2007 12:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Krzysztof,

The default value could be an ExpressionInOcl, or it could simply be an
OpaqueExpression having "OCL" in its language.

I'm not sure what you mean by matching. The OCL parser will interpret the
types of MultiplicityElements in your model as having the appropriate OCL
collection type.

ExpressionInOcl is not a MultiplicityElement, so it cannot implicitly
declare its type as a collection type in the usual UML way. Pins are
MultiplicityElements, so I suppose that inputs to them should conform to
their implied collection types.

Some Actions have the ability to index collections, so these should work
with Sequences and OrderedSets. I'm not sure that there is much cohesion
between the specifications in this area, though. For example, the
AddStructuralFeatureValueAction has an "inserAt" InputPin that accepts the
collection index. However, UML requires this to be an UnlimitedNatural
(why? * would never be valid), but indexing in OCL is by Integer.
Moreover, the WriteStructuralFeatureAction abstract metaclass requires that
the type of the "value" InputPin be the same as the structural feature's
type, but doesn't account for multiplicities of either the structural
feature or the value specified by the pin (either by an ObjectFlow or by
using a ValuePin). On that subject, the only constraint on ValuePin is
that its value specification must have a type "compatible with" the pin's
type. That's pretty vague.

All of this is to say, that I'm not sure that you can actually satisfy the
type conformance constraints using ValueSpecifications of any kind in
Actions because ValueSpecifications are not MultiplicityElements, so you
cannot express collection types in the way that Pins require.

HTH,

Christian

Krzysztof Kaczmarski wrote:

> Hi All,
>
> in the OCL standard description there is an information that OCL
> expression may be used as an initialization expression for UML class
> attributes. I suppose that in such case Property's defaultValue is set
> to ExpressionInOCL object.
> My question is how are the types and values mapped between OCL and
> UML. If we have a Property that is a collection ( dogs:Dog[0..*] ) are
> the values from a resulting OCL matched automatically?
>
> This question has a little deeper meaning for me. If we use
> ExpressionInOCL as a ValueSpecification in a UML Action (for example
> ValueSpecificationAction) and we need to use OutputPin and ObjectFlow
> to actually consume resulting values. How is the OCL collection
> interpreted then?
>
> Thanks in advance,
> Krzysztof
Re: OCL expr as an initializer [message #42369 is a reply to message #42162] Wed, 31 October 2007 22:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: krzysztof_kaczmarski.o2.pl

Christian,
two more questions.

Although ExpressionInOCL is not a MultiplicityElement it can be used
to specify initialization of an object property.
Are you saying that it cannot be used in ValuePin as value in
AddStructuralFeatureValueAction ? I understand that the type will be
different (in EIOCL we get for example Bag(Integer) while the pin
requires Integer[0..*]) but couldn't it be somehow translated as it is
done the other way around when we access UML attributes in OCL queries?

I noticed that ExpressionInOCL result is of type
org.eclipse.ocl.expressions.Variable... couldn't it be
org.eclipse.uml2.uml.Variable ? This would give required multiplicity
and possibility of proper type conversion.

Thanks for help,
Krzysztof

Christian W. Damus wrote:
> Hi, Krzysztof,
>
> The default value could be an ExpressionInOcl, or it could simply be an
> OpaqueExpression having "OCL" in its language.
>
> I'm not sure what you mean by matching. The OCL parser will interpret the
> types of MultiplicityElements in your model as having the appropriate OCL
> collection type.
>
> ExpressionInOcl is not a MultiplicityElement, so it cannot implicitly
> declare its type as a collection type in the usual UML way. Pins are
> MultiplicityElements, so I suppose that inputs to them should conform to
> their implied collection types.
>
> Some Actions have the ability to index collections, so these should work
> with Sequences and OrderedSets. I'm not sure that there is much cohesion
> between the specifications in this area, though. For example, the
> AddStructuralFeatureValueAction has an "inserAt" InputPin that accepts the
> collection index. However, UML requires this to be an UnlimitedNatural
> (why? * would never be valid), but indexing in OCL is by Integer.
> Moreover, the WriteStructuralFeatureAction abstract metaclass requires that
> the type of the "value" InputPin be the same as the structural feature's
> type, but doesn't account for multiplicities of either the structural
> feature or the value specified by the pin (either by an ObjectFlow or by
> using a ValuePin). On that subject, the only constraint on ValuePin is
> that its value specification must have a type "compatible with" the pin's
> type. That's pretty vague.
>
> All of this is to say, that I'm not sure that you can actually satisfy the
> type conformance constraints using ValueSpecifications of any kind in
> Actions because ValueSpecifications are not MultiplicityElements, so you
> cannot express collection types in the way that Pins require.
>
> HTH,
>
> Christian
>
> Krzysztof Kaczmarski wrote:
>
>> Hi All,
>>
>> in the OCL standard description there is an information that OCL
>> expression may be used as an initialization expression for UML class
>> attributes. I suppose that in such case Property's defaultValue is set
>> to ExpressionInOCL object.
>> My question is how are the types and values mapped between OCL and
>> UML. If we have a Property that is a collection ( dogs:Dog[0..*] ) are
>> the values from a resulting OCL matched automatically?
>>
>> This question has a little deeper meaning for me. If we use
>> ExpressionInOCL as a ValueSpecification in a UML Action (for example
>> ValueSpecificationAction) and we need to use OutputPin and ObjectFlow
>> to actually consume resulting values. How is the OCL collection
>> interpreted then?
>>
>> Thanks in advance,
>> Krzysztof
>
Re: OCL expr as an initializer [message #42572 is a reply to message #42369] Thu, 01 November 2007 14:34 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Krzysztof,

Yes, your UML application can do this translation, but it wouldn't be
following the UML Specification to the letter because this would appear to
be a violation of the constraints that it defines for model validity. That
is always your choice :-).

The result cannot be an org.eclipse.uml2.uml.Variable because the OCL
specification defines its own Variable metaclass. It does not import it
from UML as is the case with Classifier, TypedElement, Operation, etc.

Cheers,

Christian


Krzysztof Kaczmarski wrote:

> Christian,
> two more questions.
>
> Although ExpressionInOCL is not a MultiplicityElement it can be used
> to specify initialization of an object property.
> Are you saying that it cannot be used in ValuePin as value in
> AddStructuralFeatureValueAction ? I understand that the type will be
> different (in EIOCL we get for example Bag(Integer) while the pin
> requires Integer[0..*]) but couldn't it be somehow translated as it is
> done the other way around when we access UML attributes in OCL queries?
>
> I noticed that ExpressionInOCL result is of type
> org.eclipse.ocl.expressions.Variable... couldn't it be
> org.eclipse.uml2.uml.Variable ? This would give required multiplicity
> and possibility of proper type conversion.
>
> Thanks for help,
> Krzysztof

-----8<-----
Previous Topic:Checking whether "self" is a reference of it's "container"
Next Topic:accessing uml attributes from queries
Goto Forum:
  


Current Time: Fri Apr 19 23:07:04 GMT 2024

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

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

Back to the top