Home » Modeling » OCL » Using sortedBy
Using sortedBy [message #1573311] |
Mon, 19 January 2015 17:15 |
Eclipse User |
|
|
|
Hi all,
I have defined two stereotypes (A and B), and a stereotype for a
dependency (RelationshipC) in a profile to relate A and B stereotypes.
RelationshipC has an attribute 'Order' that is supposed to be used to
specify an ordering between the several instances of RelationshipC that
an A element could have with several Bs (please, see the images attached).
I've written some OCL that gets the relationships from a specific A
element and it works.
self.clientDependency->select(p : UML::Dependency |
p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))
However, I would like to get the dependencies sorted according to its
'Order' attribute. I guess I should use something like:
self.clientDependency->select(p : UML::Dependency |
p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))->sortedBy(Order)
But I can't find examples on how to use sortedBy.
Could anybody help me?
Please, find attached also the project with the profile and the model
that uses it.
Greetings,
Víctor
|
|
|
Re: Using sortedBy [message #1573370 is a reply to message #1573311] |
Mon, 19 January 2015 18:02 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
What you are doing is nearly right, but because you are using the UML2
project Java API you have lost type information, which you could
re-instate with an oclAsType(profile::RelationshipC).
The new Povot-based Xtext support in the OCL project is moving to
supporting stereotype navigation in a type-safe fashion as hinted at by
the UML specification.
Something like (untested) might be better
self.clientDependency->selectByKind(UML::Dependency).extension_RelationshipC->sortedBy(Order)
Traditionally sortedBy takes an expression that computes a
String/Integer that determines the sort order. The Pivot-based support
introduces an OclComparable type for use as the sortedBy argument type
so that it is extensible to arbitrary user types such as Date.
Regards
Ed Willink
On 19/01/2015 17:15, "V. López" wrote:
> Hi all,
> I have defined two stereotypes (A and B), and a stereotype for a
> dependency (RelationshipC) in a profile to relate A and B stereotypes.
> RelationshipC has an attribute 'Order' that is supposed to be used to
> specify an ordering between the several instances of RelationshipC that
> an A element could have with several Bs (please, see the images attached).
>
> I've written some OCL that gets the relationships from a specific A
> element and it works.
>
> self.clientDependency->select(p : UML::Dependency |
> p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))
>
>
> However, I would like to get the dependencies sorted according to its
> 'Order' attribute. I guess I should use something like:
>
> self.clientDependency->select(p : UML::Dependency |
> p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))->sortedBy(Order)
>
>
> But I can't find examples on how to use sortedBy.
>
> Could anybody help me?
>
> Please, find attached also the project with the profile and the model
> that uses it.
>
>
> Greetings,
>
> Víctor
|
|
|
Re: Using sortedBy [message #1574764 is a reply to message #1573370] |
Tue, 20 January 2015 12:17 |
Eclipse User |
|
|
|
Thanks for the quick answer Ed, it worked in the console.
However, I would like to use it also in Acceleo.
Thus, "extension_RelationC" nor oclAsType(profile::RelationshipC) syntax
work with my own profile, at least without registering the profile by
creating a plug-in.
Is there a workaround to use sortBy in that situation or an alternative
way of ordering?
Greeting,
Víctor
El 19/01/2015 a las 19:02, Ed Willink escribió:
> Hi
>
> What you are doing is nearly right, but because you are using the UML2
> project Java API you have lost type information, which you could
> re-instate with an oclAsType(profile::RelationshipC).
>
> The new Povot-based Xtext support in the OCL project is moving to
> supporting stereotype navigation in a type-safe fashion as hinted at by
> the UML specification.
>
> Something like (untested) might be better
>
> self.clientDependency->selectByKind(UML::Dependency).extension_RelationshipC->sortedBy(Order)
>
>
> Traditionally sortedBy takes an expression that computes a
> String/Integer that determines the sort order. The Pivot-based support
> introduces an OclComparable type for use as the sortedBy argument type
> so that it is extensible to arbitrary user types such as Date.
>
> Regards
>
> Ed Willink
>
>
> On 19/01/2015 17:15, "V. López" wrote:
>> Hi all,
>> I have defined two stereotypes (A and B), and a stereotype for a
>> dependency (RelationshipC) in a profile to relate A and B stereotypes.
>> RelationshipC has an attribute 'Order' that is supposed to be used to
>> specify an ordering between the several instances of RelationshipC that
>> an A element could have with several Bs (please, see the images
>> attached).
>>
>> I've written some OCL that gets the relationships from a specific A
>> element and it works.
>>
>> self.clientDependency->select(p : UML::Dependency |
>> p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))
>>
>>
>>
>> However, I would like to get the dependencies sorted according to its
>> 'Order' attribute. I guess I should use something like:
>>
>> self.clientDependency->select(p : UML::Dependency |
>> p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))->sortedBy(Order)
>>
>>
>>
>> But I can't find examples on how to use sortedBy.
>>
>> Could anybody help me?
>>
>> Please, find attached also the project with the profile and the model
>> that uses it.
>>
>>
>> Greetings,
>>
>> Víctor
>
|
|
|
Re: Using sortedBy [message #1574765 is a reply to message #1573370] |
Tue, 20 January 2015 12:18 |
Eclipse User |
|
|
|
Thanks for the quick answer Ed, it worked in the console.
However, I would like to use it also in Acceleo.
Thus, "extension_RelationC" nor oclAsType(profile::RelationshipC) syntax
work with my own profile, at least without registering the profile by
creating a plug-in.
Is there a workaround to use sortBy in that situation or an alternative
way of ordering?
Greeting,
Víctor
El 19/01/2015 a las 19:02, Ed Willink escribió:
> Hi
>
> What you are doing is nearly right, but because you are using the UML2
> project Java API you have lost type information, which you could
> re-instate with an oclAsType(profile::RelationshipC).
>
> The new Povot-based Xtext support in the OCL project is moving to
> supporting stereotype navigation in a type-safe fashion as hinted at by
> the UML specification.
>
> Something like (untested) might be better
>
> self.clientDependency->selectByKind(UML::Dependency).extension_RelationshipC->sortedBy(Order)
>
>
> Traditionally sortedBy takes an expression that computes a
> String/Integer that determines the sort order. The Pivot-based support
> introduces an OclComparable type for use as the sortedBy argument type
> so that it is extensible to arbitrary user types such as Date.
>
> Regards
>
> Ed Willink
>
>
> On 19/01/2015 17:15, "V. López" wrote:
>> Hi all,
>> I have defined two stereotypes (A and B), and a stereotype for a
>> dependency (RelationshipC) in a profile to relate A and B stereotypes.
>> RelationshipC has an attribute 'Order' that is supposed to be used to
>> specify an ordering between the several instances of RelationshipC that
>> an A element could have with several Bs (please, see the images
>> attached).
>>
>> I've written some OCL that gets the relationships from a specific A
>> element and it works.
>>
>> self.clientDependency->select(p : UML::Dependency |
>> p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))
>>
>>
>>
>> However, I would like to get the dependencies sorted according to its
>> 'Order' attribute. I guess I should use something like:
>>
>> self.clientDependency->select(p : UML::Dependency |
>> p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))->sortedBy(Order)
>>
>>
>>
>> But I can't find examples on how to use sortedBy.
>>
>> Could anybody help me?
>>
>> Please, find attached also the project with the profile and the model
>> that uses it.
>>
>>
>> Greetings,
>>
>> Víctor
>
|
|
|
Re: Using sortedBy [message #1574861 is a reply to message #1574765] |
Tue, 20 January 2015 13:34 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
You're unlikely to get this working in Acceleo.
Use it's ability to invoke some Java code. If you've not used it yet,
it's worth learning.
Regards
Ed Willink
On 20/01/2015 12:18, "V. López" wrote:
> Thanks for the quick answer Ed, it worked in the console.
> However, I would like to use it also in Acceleo.
> Thus, "extension_RelationC" nor oclAsType(profile::RelationshipC) syntax
> work with my own profile, at least without registering the profile by
> creating a plug-in.
> Is there a workaround to use sortBy in that situation or an alternative
> way of ordering?
>
> Greeting,
>
> Víctor
>
> El 19/01/2015 a las 19:02, Ed Willink escribió:
>> Hi
>>
>> What you are doing is nearly right, but because you are using the UML2
>> project Java API you have lost type information, which you could
>> re-instate with an oclAsType(profile::RelationshipC).
>>
>> The new Povot-based Xtext support in the OCL project is moving to
>> supporting stereotype navigation in a type-safe fashion as hinted at by
>> the UML specification.
>>
>> Something like (untested) might be better
>>
>> self.clientDependency->selectByKind(UML::Dependency).extension_RelationshipC->sortedBy(Order)
>>
>>
>>
>> Traditionally sortedBy takes an expression that computes a
>> String/Integer that determines the sort order. The Pivot-based support
>> introduces an OclComparable type for use as the sortedBy argument type
>> so that it is extensible to arbitrary user types such as Date.
>>
>> Regards
>>
>> Ed Willink
>>
>>
>> On 19/01/2015 17:15, "V. López" wrote:
>>> Hi all,
>>> I have defined two stereotypes (A and B), and a stereotype for a
>>> dependency (RelationshipC) in a profile to relate A and B stereotypes.
>>> RelationshipC has an attribute 'Order' that is supposed to be used to
>>> specify an ordering between the several instances of RelationshipC that
>>> an A element could have with several Bs (please, see the images
>>> attached).
>>>
>>> I've written some OCL that gets the relationships from a specific A
>>> element and it works.
>>>
>>> self.clientDependency->select(p : UML::Dependency |
>>> p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))
>>>
>>>
>>>
>>>
>>> However, I would like to get the dependencies sorted according to its
>>> 'Order' attribute. I guess I should use something like:
>>>
>>> self.clientDependency->select(p : UML::Dependency |
>>> p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))->sortedBy(Order)
>>>
>>>
>>>
>>>
>>> But I can't find examples on how to use sortedBy.
>>>
>>> Could anybody help me?
>>>
>>> Please, find attached also the project with the profile and the model
>>> that uses it.
>>>
>>>
>>> Greetings,
>>>
>>> Víctor
>>
>
|
|
|
Re: Using sortedBy [message #1575102 is a reply to message #1574861] |
Tue, 20 January 2015 16:25 |
Eclipse User |
|
|
|
Thanks Ed. I'll give it a try.
El 20/01/2015 a las 14:34, Ed Willink escribió:
> Hi
>
> You're unlikely to get this working in Acceleo.
>
> Use it's ability to invoke some Java code. If you've not used it yet,
> it's worth learning.
>
> Regards
>
> Ed Willink
>
>
> On 20/01/2015 12:18, "V. López" wrote:
>> Thanks for the quick answer Ed, it worked in the console.
>> However, I would like to use it also in Acceleo.
>> Thus, "extension_RelationC" nor oclAsType(profile::RelationshipC) syntax
>> work with my own profile, at least without registering the profile by
>> creating a plug-in.
>> Is there a workaround to use sortBy in that situation or an alternative
>> way of ordering?
>>
>> Greeting,
>>
>> Víctor
>>
>> El 19/01/2015 a las 19:02, Ed Willink escribió:
>>> Hi
>>>
>>> What you are doing is nearly right, but because you are using the UML2
>>> project Java API you have lost type information, which you could
>>> re-instate with an oclAsType(profile::RelationshipC).
>>>
>>> The new Povot-based Xtext support in the OCL project is moving to
>>> supporting stereotype navigation in a type-safe fashion as hinted at by
>>> the UML specification.
>>>
>>> Something like (untested) might be better
>>>
>>> self.clientDependency->selectByKind(UML::Dependency).extension_RelationshipC->sortedBy(Order)
>>>
>>>
>>>
>>>
>>> Traditionally sortedBy takes an expression that computes a
>>> String/Integer that determines the sort order. The Pivot-based support
>>> introduces an OclComparable type for use as the sortedBy argument type
>>> so that it is extensible to arbitrary user types such as Date.
>>>
>>> Regards
>>>
>>> Ed Willink
>>>
>>>
>>> On 19/01/2015 17:15, "V. López" wrote:
>>>> Hi all,
>>>> I have defined two stereotypes (A and B), and a stereotype for a
>>>> dependency (RelationshipC) in a profile to relate A and B stereotypes.
>>>> RelationshipC has an attribute 'Order' that is supposed to be used to
>>>> specify an ordering between the several instances of RelationshipC that
>>>> an A element could have with several Bs (please, see the images
>>>> attached).
>>>>
>>>> I've written some OCL that gets the relationships from a specific A
>>>> element and it works.
>>>>
>>>> self.clientDependency->select(p : UML::Dependency |
>>>> p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> However, I would like to get the dependencies sorted according to its
>>>> 'Order' attribute. I guess I should use something like:
>>>>
>>>> self.clientDependency->select(p : UML::Dependency |
>>>> p.getAppliedStereotypes().qualifiedName->includes('profile::RelationshipC'))->sortedBy(Order)
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> But I can't find examples on how to use sortedBy.
>>>>
>>>> Could anybody help me?
>>>>
>>>> Please, find attached also the project with the profile and the model
>>>> that uses it.
>>>>
>>>>
>>>> Greetings,
>>>>
>>>> Víctor
>>>
>>
>
|
|
|
Goto Forum:
Current Time: Fri Apr 19 13:04:06 GMT 2024
Powered by FUDForum. Page generated in 0.02026 seconds
|