Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » a problem with wrappers which have parameters
a problem with wrappers which have parameters [message #1225555] Mon, 30 December 2013 01:04 Go to next message
duke vah is currently offline duke vah
Messages: 17
Registered: December 2013
Junior Member
Hi,
I wanna write a wrapper with java but I have a problem when I want to add a parameter.
In following code the function TestCheck works but TestCheck2 doesn't work.
what should I do? The compiler says that "... doesn't exist for service ..."
Thanks in advance

------------------------------------------
package AUTCPP.javaWrapper.files;
import org.eclipse.uml2.uml.*;

public class Test {

public boolean TestCheck (Boolean t) {
return t;
}

public boolean TestCheck2 (Boolean t, StateMachine aSM) {
return t;
}
}
-------------------------------------------

[Updated on: Mon, 30 December 2013 01:04]

Report message to a moderator

Re: problem with wrapper [message #1225608 is a reply to message #1225555] Mon, 30 December 2013 04:29 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi

"what should I do?"

Provide enough information so that we know what on earth you are talking
about.

This is the M2T newsgroup. Are you using Xpand/Acceleo/... ?

How do you invoke your code?

What does "doesn't work" mean? Did your machine catch fire?

Regards

Ed Willink


On 30/12/2013 06:04, duke vah wrote:
> Hi,
> I wanna write a wrapper with java but I have a problem when I want to
> add a parameter.
> In following code the function TestCheck works but TestCheck2 doesn't
> work.
> what should I do? The compiler says that "... doesn't exist for
> service ..."
> Thanks in advance
>
> ------------------------------------------
> package AUTCPP.javaWrapper.files;
> import org.eclipse.uml2.uml.*;
>
> public class Test {
>
> public boolean TestCheck (Boolean t) {
> return t;
> }
>
> public boolean TestCheck2 (Boolean t, StateMachine aSM) {
> return t;
> }
> }
> -------------------------------------------
Re: problem with wrapper [message #1225880 is a reply to message #1225608] Mon, 30 December 2013 21:58 Go to previous messageGo to next message
duke vah is currently offline duke vah
Messages: 17
Registered: December 2013
Junior Member
Sorry Smile
I am using Acceleo.
I create a .mtl file from .java file and call the queries inside of a template. The following code shows the .mtl file. As I mentioned TestCheck works but TestCheck2 doesn't work.

-----------------------------------------------------------
[comment encoding = Cp1252 /]
[module test2('http://www.eclipse.org/uml2/4.0.0/UML')/]

[query public TestCheck(arg0 : Boolean) : Boolean
= invoke('AUTCPP.javaWrapper.files.Test', 'TestCheck(java.lang.Boolean)', Sequence{arg0}) /]

[query public TestCheck2(arg0 : Boolean, arg1 : StateMachine) : Boolean
= invoke('AUTCPP.javaWrapper.files.Test', 'TestCheck2(java.lang.Boolean, org.eclipse.uml2.uml.StateMachine)', Sequence{arg0, arg1}) /]
------------------------------------------------------------

I don't know when I add some parameters form UML metamodel, this issue happens. The indicated error is shown in eclipse environment when I call TestCkeck2 in a template.

Thanks

Re: problem with wrapper [message #1226044 is a reply to message #1225880] Tue, 31 December 2013 09:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
HI

You might care to note the advice in
http://wiki.eclipse.org/OCL/ForumNetiquette

Your code looks sensible, but it is very confusing to have to guess at
all the information you don't provide.

Regards

Ed Willink


On 31/12/2013 02:58, duke vah wrote:
> Sorry :)
> I am using Acceleo.
> I create a .mtl file from .java file and call the queries inside of a
> template. The following code shows the .mtl file. As I mentioned
> TestCheck works but TestCheck2 doesn't work.
>
> -----------------------------------------------------------
> [comment encoding = Cp1252 /]
> [module test2('http://www.eclipse.org/uml2/4.0.0/UML')/]
>
> [query public TestCheck(arg0 : Boolean) : Boolean
> = invoke('AUTCPP.javaWrapper.files.Test',
> 'TestCheck(java.lang.Boolean)', Sequence{arg0}) /]
>
> [query public TestCheck2(arg0 : Boolean, arg1 : StateMachine) : Boolean
> = invoke('AUTCPP.javaWrapper.files.Test',
> 'TestCheck2(java.lang.Boolean, org.eclipse.uml2.uml.StateMachine)',
> Sequence{arg0, arg1}) /]
> ------------------------------------------------------------
>
> I don't know when I add some parameters form UML metamodel, this issue
> happens. The indicated error is shown in eclipse environment when I
> call TestCkeck2 in a template.
>
> Thanks
>
>
Re: problem with wrapper [message #1226641 is a reply to message #1226044] Thu, 02 January 2014 04:33 Go to previous messageGo to next message
duke vah is currently offline duke vah
Messages: 17
Registered: December 2013
Junior Member
This is my Java code :
------------------------------------------
public boolean TestCheck2 (Behavior bh, StateMachine aSM) {
for (Region rg : aSM.getRegions()) {
for(Vertex vt : rg.getSubvertices()) {
if (vt instanceof State && ((State)vt).getEntry() == bh ) {
return true;
}
}
}
return false;
}
------------------------------------------
I do following steps:
1) I create a .mtl file with the Acceleo wizard.
2) Import the created .mtl file inside of other files and call the quesry.
However, it doesn't work. I have other wrappers but they work( I have aleady existed). I think I miss something like adding a wrapper to somewhere.
The process is easy but I don't know why it doesn't work.
BTW, I added my project to new workspace in Eclipse and I compiled it, it worked but as soon as I changed it and created a new .mtl file it didn't work.
It shows me that I should do sth to tell the compiler which this is new .mtl file or sth like this.
I hope this makes clear.
Thanks

Re: problem with wrapper [message #1226662 is a reply to message #1226641] Thu, 02 January 2014 05:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi

No it's as thick as mud.

You provide no repro of what does or doesn't work.

You don't identify any software versions.

You give no clarification of what "doesn't work" means.

Regards

Ed Willink


On 02/01/2014 09:33, duke vah wrote:
> This is my Java code : ------------------------------------------
> public boolean TestCheck2 (Behavior bh, StateMachine aSM) {
> for (Region rg : aSM.getRegions()) {
> for(Vertex vt : rg.getSubvertices()) {
> if (vt instanceof State && ((State)vt).getEntry() == bh ) {
> return true;
> }
> }
> }
> return false;
> }
> ------------------------------------------
> I do following steps:
> 1) I create a .mtl file with the Acceleo wizard.
> 2) Import the created .mtl file inside of other files and call the
> quesry.
> However, it doesn't work. I have other wrappers but they work( I have
> aleady existed). I think I miss something like adding a wrapper to
> somewhere.
> The process is easy but I don't know why it doesn't work.
> BTW, I added my project to new workspace in Eclipse and I compiled it,
> it worked but as soon as I changed it and created a new .mtl file it
> didn't work.
> It shows me that I should do sth to tell the compiler which this is
> new .mtl file or sth like this.
> I hope this makes clear.
> Thanks
>
>
Re: problem with wrapper [message #1226673 is a reply to message #1226662] Thu, 02 January 2014 06:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4003
Registered: July 2009
Senior Member
Hi

I've added a "Rationale for not relying on telepathy" to
https://wiki.eclipse.org/OCL/ForumNetiquette. Perhaps it will help you
to help yourself.

Regards

Ed Willink

On 02/01/2014 10:42, Ed Willink wrote:
> Hi
>
> No it's as thick as mud.
>
> You provide no repro of what does or doesn't work.
>
> You don't identify any software versions.
>
> You give no clarification of what "doesn't work" means.
>
> Regards
>
> Ed Willink
>
>
> On 02/01/2014 09:33, duke vah wrote:
>> This is my Java code : ------------------------------------------
>> public boolean TestCheck2 (Behavior bh, StateMachine aSM) {
>> for (Region rg : aSM.getRegions()) {
>> for(Vertex vt : rg.getSubvertices()) {
>> if (vt instanceof State && ((State)vt).getEntry() == bh ) {
>> return true;
>> }
>> }
>> }
>> return false;
>> }
>> ------------------------------------------
>> I do following steps:
>> 1) I create a .mtl file with the Acceleo wizard.
>> 2) Import the created .mtl file inside of other files and call the
>> quesry.
>> However, it doesn't work. I have other wrappers but they work( I have
>> aleady existed). I think I miss something like adding a wrapper to
>> somewhere.
>> The process is easy but I don't know why it doesn't work.
>> BTW, I added my project to new workspace in Eclipse and I compiled
>> it, it worked but as soon as I changed it and created a new .mtl file
>> it didn't work.
>> It shows me that I should do sth to tell the compiler which this is
>> new .mtl file or sth like this.
>> I hope this makes clear.
>> Thanks
>>
>>
>
Re: problem with wrapper [message #1227354 is a reply to message #1226673] Sat, 04 January 2014 03:29 Go to previous messageGo to next message
duke vah is currently offline duke vah
Messages: 17
Registered: December 2013
Junior Member
I think there is no more thing to be said.
Everything is clear.
I just want to know how to write a wrapper with parameters from UML metamodel.
Indeed, I want to know exact steps for doing this.
Re: problem with wrapper [message #1227356 is a reply to message #1226673] Sat, 04 January 2014 03:34 Go to previous messageGo to next message
duke vah is currently offline duke vah
Messages: 17
Registered: December 2013
Junior Member
BTW, This is a complete information

----------java wrapper------------
package AUTCPP.javaWrapper.files;

import org.eclipse.uml2.uml.*;

public class Test {

public Boolean CheckBehavior(Behavior bh, StateMachine aStateMachine) {
for (Region rg : aStateMachine.getRegions()) {
for(Vertex vt : rg.getSubvertices()) {
if (vt instanceof State && ((State)vt).getExit().getName() == bh.getName()) {
return true;
}
}
}
return false;
}
}
------------------------------------
-------------mtl file---------------
[comment encoding = Cp1252 /]
[module test('http://www.eclipse.org/uml2/4.0.0/UML')/]

[query public CheckBehavior(arg0 : Behavior, arg1 : StateMachine) : Boolean
= invoke('AUTCPP.javaWrapper.files.Test', 'CheckBehavior(org.eclipse.uml2.uml.Behavior, org.eclipse.uml2.uml.StateMachine)', Sequence{arg0, arg1})
/]
------------------------------------
--------the part of used code-------
[template public generateSMEntries(aStateMachine : StateMachine) post (trim())]
[for (aRegion : Region | region) separator ('\n')]
[if (subvertex->filter(State)->select(entry->isEmpty() = false )->size()>0)]
[for (aState : State | subvertex->filter(State)->select(entry->isEmpty() = false )) separator ('\n')]
[generateSMEntry(aState.entry)/][/for]
[/if][/for]
[/template]
-------------------------------------
----------------error----------------
Method CheckBehavior(org.eclipse.uml2.uml.Behavior, org.eclipse.uml2.uml.StateMachine) doesn't exist for service AUTCPP.javaWrapper.files.Test.
-------------------------------------

Is there any missing thing?
Thanks
Re: problem with wrapper [message #1227359 is a reply to message #1226673] Sat, 04 January 2014 03:35 Go to previous message
duke vah is currently offline duke vah
Messages: 17
Registered: December 2013
Junior Member
Moreover, Your link doesn't work.
Previous Topic:generate code out of metamodel(.ecore file ) using xpandfacade
Next Topic:[Acceleo]available juno repo?
Goto Forum:
  


Current Time: Thu Jul 24 21:42:50 EDT 2014

Powered by FUDForum. Page generated in 0.02302 seconds