Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Invoke method cannot used for OrderedSet ?
Invoke method cannot used for OrderedSet ? [message #1805615] Thu, 18 April 2019 19:59 Go to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
[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 #1805620 is a reply to message #1805615] Fri, 19 April 2019 04:34 Go to previous messageGo to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Is there anyone :(
Re: Invoke method cannot used for OrderedSet ? [message #1805621 is a reply to message #1805620] Fri, 19 April 2019 05:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

IIRC, the Acceleo documentaion identifies the appropriate Java types to use as OCL equivalents. ?? LinkedHashSet ??

Regards

Ed Willink
Re: Invoke method cannot used for OrderedSet ? [message #1805625 is a reply to message #1805615] Fri, 19 April 2019 07:29 Go to previous messageGo to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Tag EClass is defined as OrderedSet in metamodel, so in Java do i define Tag[] tag as LinkedHashSet<Tag> ?
Re: Invoke method cannot used for OrderedSet ? [message #1805638 is a reply to message #1805621] Fri, 19 April 2019 09:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 Go to previous messageGo to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
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]

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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
[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 Go to previous message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
[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]

Report message to a moderator

Previous Topic:[xpand + xtend]: how to access MWE workflow properties in Xpand templates, with xtend 2.17.x?
Next Topic:a difficult query to solve
Goto Forum:
  


Current Time: Fri Apr 19 19:26:57 GMT 2024

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

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

Back to the top