Invoke method cannot used for OrderedSet ? [message #1805615] |
Thu, 18 April 2019 19:59  |
Eclipse User |
|
|
|
[query public getAll(arg0:OrderedSet(Tag)):OrderedSet(Tag)= invoke('ContikiOS.acceleo.module.deneme','getAll(org.eclipse.sirius.contikiOS.Tag)' ,Sequence{arg0}) /]
public class deneme {
public Tag[] getAll(Tag[] tag) {
Tag a[]=new Tag[30];
return a;
}
As a parameter i can pass a Tag object and return a Tag object however in java when i define them as arrays and in acceleo query, when i define as OrderedSet(Tag) i get this error;
Method getAll(org.eclipse.sirius.contikiOS.Tag) doesn't exist for service ContikiOS.acceleo.module.deneme.
I think that i add someting getAll(org...) , however i am stuck.
Thanks.
|
|
|
|
|
|
Re: Invoke method cannot used for OrderedSet ? [message #1805638 is a reply to message #1805621] |
Fri, 19 April 2019 09:51   |
Eclipse User |
|
|
|
Ed Willink wrote on Fri, 19 April 2019 01:07
IIRC, the Acceleo documentaion identifies the appropriate Java types to use as OCL equivalents.
It seems I remember wrong. All that I find in the Acceleo documentation is
Quote:If your Java service is returning a collection, the return type of your query should match the type of the return type ofyour collection. We are recommending that in the case of a Java service returning an ArrayList, you should use aSequence(Type) and if you a returning a LinkedHashSet, you should use an OrderedSet(Type).
I do recall that the lack of wizards/diagnosis around "invoke" makes it really hard. If you're not confident using the debugger, you should start with a simple example that works and change one concept at a time until you have what you want.
Looking at your example there is a very obvious mistake. You have defined a java function getAll(Tag[]) and told Acceleo to invoke getAll(Tag) with the not surprising result that Acceleo complains that getAll(Tag) is undefined.
You can find out how clever Acceleo is at matching up OCL and Java types by temporarily declaring and invoking agetAll(Object) and/or getAll(Collection) and see what you can pass and receive.
Regards
Ed Willink
|
|
|
Re: Invoke method cannot used for OrderedSet ? [message #1805645 is a reply to message #1805638] |
Fri, 19 April 2019 13:23   |
Eclipse User |
|
|
|
Respect to your comment, I defined my query like this
[query public getAll(arg0:OrderedSet(Tag)):OrderedSet(Tag)= invoke('ContikiOS.acceleo.module.deneme',' getAll(org.eclipse.sirius.contikiOS.Tag)' ,Sequence{arg0}) /]
And i edit my code from Tag[] to LinkedHashSet<Tag>
However there are still errors.
import java.util.LinkedHashSet;
import org.eclipse.sirius.contikiOS.*;
public class deneme {
public LinkedHashSet<Tag> getAll(LinkedHashSet<Tag> tag) {
return tag;
}[/code]
I just send tag.getAll(tags) in Acceleo and there is no error.
When i run the code output as follows.
org.eclipse.acceleo.engine.AcceleoEvaluationException: Method getAll(org.eclipse.sirius.contikiOS.Tag) doesn't exist for service ContikiOS.acceleo.module.deneme.
at org.eclipse.acceleo.engine.internal.environment.AcceleoLibraryOperationVisitor.invoke(AcceleoLibraryOperationVisitor.java:1215)
at org.eclipse.acceleo.engine.internal.environment.AcceleoLibraryOperationVisitor.callNonStandardOperation(AcceleoLibraryOperationVisitor.java:136)
at org.eclipse.acceleo.engine.internal.evaluation.AcceleoEvaluationVisitor.visitOperationCallExp(AcceleoEvaluationVisitor.java:1220)
at org.eclipse.ocl.ecore.impl.OperationCallExpImpl.accept(OperationCallExpImpl.java:386)
[Updated on: Fri, 19 April 2019 13:30] by Moderator Report message to a moderator
|
|
|
Re: Invoke method cannot used for OrderedSet ? [message #1805648 is a reply to message #1805638] |
Fri, 19 April 2019 14:37   |
Eclipse User |
|
|
|
[quote title=Ed Willink wrote on Fri, 19 April 2019 05:51]Ed Willink wrote on Fri, 19 April 2019 01:07
You can find out how clever Acceleo is at matching up OCL and Java types by temporarily declaring and invoking agetAll(Object) and/or getAll(Collection) and see what you can pass and receive.
|
|
|
Re: Invoke method cannot used for OrderedSet ? [message #1805649 is a reply to message #1805648] |
Fri, 19 April 2019 15:07  |
Eclipse User |
|
|
|
[query public getAll( arg0:OrderedSet(Tag), arg1: Integer ):OrderedSet(Tag)= invoke('ContikiOS.acceleo.module.deneme','getAll(java.util.Collection,int)' ,Sequence{arg0,arg1}) /]
public class deneme {
public LinkedHashSet<Tag> getAll(Collection tag,int size) {
//codes
}
Respect the your comment i changed it to java.util.Collection and it did worked.
Then i called, tag.getClass() it printed java.util.LinkedHashSet however, i can call java.util.Collection but java.util.LinkedHashSet does not matched. ( By the way i solved my problem by collection.)
[Updated on: Fri, 19 April 2019 16:58] by Moderator Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02829 seconds