|
|
Re: Evaluating "If" condition in Acceleo/Sirius [message #1776452 is a reply to message #1776422] |
Thu, 16 November 2017 14:32 |
|
Hello,
In your VSM, on the parent representation description, containing your expression, have you set the metamodel (in the metamodel tab)? Is it possible that you have another metamodel with a class also named Vocabulary? In your expression, you can prefix the class name with the metamodel name in this pattern "metamodelName::className" so if your metamodel (or the package containing the Vocabulary eclass) is called "dictionnary" then you should have: ...select(v: dictionnary::Vocabulary...
Also, note that you do not need the parenthesis in the if block and that size()=0 can be replace by isEmpty like this: [if loadedVocabularies->isEmpty() then ...
Regards,
Steve
Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
Re: Evaluating "If" condition in Acceleo/Sirius [message #1776819 is a reply to message #1776452] |
Tue, 21 November 2017 23:01 |
Jad El-khoury Messages: 61 Registered: August 2015 |
Member |
|
|
It is odd that the operation works as expected if loadedVocabularies is not empty, so it cannot be that Vocabulary is not imported.
Worth noting also that loadedVocabularies is a result of a java service call that is to return a list of Vocabulary eClass instances.
Could it be that when the returned list is empty, the compiler does not recognise that the (empty) list is expected to be of type Vocabulary, hence it complains "Unknown type (Vocabulary)"?
In the end, what worked is the following:
[loadedVocabularies->select(v | v.oclAsType(vocabulary::Vocabulary).terms->select(t | t.oclIsTypeOf(vocabulary::Class))->notEmpty() ) /]
1. As suggested above, we replaced "v : Vocabulary" with simply 'v', to avoid the compilation error.
2. But then we need to replace "v.terms" with " v.oclAsType(vocabulary::Vocabulary).terms", since the compiler complained that it did not recognise 'terms', unless we tell it what the type of 'v' is first.
This change works for both empty, and non-empty loadedVocabularies.
But it is still not 100% clear why the compiler fails.
|
|
|
Powered by
FUDForum. Page generated in 0.03177 seconds