Accessing Owned Attributes

Other topics that do not fit in any of categories.

Moderator: Moderators

Accessing Owned Attributes

Postby nadka123 » Wed Apr 08, 2015 6:51 am

Hello,

I’m trying to put together an OCL where the initialValue of the EmployeeEnumeration needs to be the same as the name of at least one of its child Employee_Element. How do I access the contents of an owned attribute? My OCL doesn’t work. (see attachment)
You do not have the required permissions to view the files attached to this post.
nadka123
Forum Expert
Forum Expert
 
Posts: 143
Posts Rating:0
Joined: Sun Jan 26, 2014 10:56 am

Re: Accessing Owned Attributes

Postby rimvydas.vaidelis » Thu Apr 09, 2015 6:33 am

Hello,

The OCL expression:

Code: Select all
self.ownedAttribute -> exists(name = self.initialValue)


Best Regards,
Rimvydas Vaidelis
rimvydas.vaidelis
Customer Support
Customer Support
 
Posts: 259
Posts Rating:15
Joined: Fri May 28, 2010 4:45 am

Re: Accessing Owned Attributes

Postby nadka123 » Thu Apr 09, 2015 7:19 am

why can't I access the name of the ownedAttribute using the OCL expression:
Code: Select all
self.ownedAttribute.name


?
nadka123
Forum Expert
Forum Expert
 
Posts: 143
Posts Rating:0
Joined: Sun Jan 26, 2014 10:56 am

Re: Accessing Owned Attributes

Postby rimvydas.vaidelis » Thu Apr 09, 2015 7:55 am

If you are talking about the property access in general then the expression self.ownedAttribute.name is legal
but if you are talking about why self.initialValue = self.ownedAttribute.name does not work then
self.ownedAttribute.name - value of the expression is a collection of strings
self.initialValue - value of the expression is a string
string is not equal to a collection of strings.

Is this answers your question ?
rimvydas.vaidelis
Customer Support
Customer Support
 
Posts: 259
Posts Rating:15
Joined: Fri May 28, 2010 4:45 am

Re: Accessing Owned Attributes

Postby nadka123 » Thu Apr 09, 2015 7:59 am

I understand. Thank-you.
nadka123
Forum Expert
Forum Expert
 
Posts: 143
Posts Rating:0
Joined: Sun Jan 26, 2014 10:56 am

Re: Accessing Owned Attributes

Postby nadka123 » Wed Feb 10, 2016 8:47 am

I’m trying to collect all the ownedAttributes of an element that are stereotyped by S_InterconnectUse and check that there are only 2 of them for each element. I have tried all of these OCL rules but none of them work.

Code: Select all
self.ownedAttribute.oclIsKindOf(S_InterconnectUse) -> size() = 2    --wellformedness issue

Code: Select all
self.ownedAttribute -> size(self.oclIsKindOf(S_InterconnectUse) = true) = 2             --Sequence(property) issue

Code: Select all
self.ownedAttribute -> count(self.oclAsType(S_InterconnectUse)) -> size() = 2       --wellformedness issue with AsType

Code: Select all
self.ownedAttribute -> select(self.oclIsKindOf(S_InterconnectUse)) -> size() = 2         --Throws a error  for everything
nadka123
Forum Expert
Forum Expert
 
Posts: 143
Posts Rating:0
Joined: Sun Jan 26, 2014 10:56 am

Re: Accessing Owned Attributes

Postby rimvydas.vaidelis » Thu Feb 11, 2016 1:01 am

You should use qualified name of the stereotype in expression.

Your expression should be:

Code: Select all
self.ownedAttribute ->  select(oclIsTypeOf(com::MyProfile::MyStereotype)) -> size() = 2
rimvydas.vaidelis
Customer Support
Customer Support
 
Posts: 259
Posts Rating:15
Joined: Fri May 28, 2010 4:45 am


Return to Other

Who is online

Users browsing this forum: No registered users and 0 guests