Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Error while generating A UML code
Error while generating A UML code [message #1785102] Mon, 09 April 2018 13:45 Go to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
Good morning,

I've been trying to generate a .qml code from a model, I'm almost close to doing it but there is this error that I dnt knw how to fix it, u'll find below my code :
[comment encoding = UTF-8 /]
[module generate('http://www.eclipse.org/uml2/5.0.0/UML', 'http://www.eclipse.org/papyrus/sysml/1.4/SysML', 'http://www.eclipse.org/papyrus/sysml/1.4/SysML/Blocks')]


[template public generate(m : Model)]
[comment @main/]
[file (m.name + '.qml', false, 'UTF-8')]
[for (b:uml::Class|m.eAllContents())]
[if(b.hasStereotype('Block'))]
[GenerateClass(b)/]
[/if]
[/for]
[/file]
[/template]

[template public GenerateClass(b:uml::Class)]
import QtQuick 2.2
[b.name/]
{
[allAttributes(b)/]
}

[/template]

[template public allAttributes(b:uml::Class)]
[for (a :uml::Property|b.getAllAttributes())]
[if(not a.oclIsKindOf(Port))]
[a.type.name/] [a.name/];
[/if]
[/for]
[/template]


[query public hasStereotype (e:uml ::Element, value :String) : Boolean
= not e.getAppliedStereotypes()->select(e:uml ::Stereotype |e.name =value )-> isEmpty()
/]

and this is the error :

org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid type for iteration at line 8 in Module generate for block for (m.eAllContents()). org.eclipse.uml2.uml.internal.impl.PackageImportImpl was not an instanceof Class.
at generate.generate(Model)(generate.mtl:8)
at generate.generate(Model)(generate.mtl:7)
at generate.generate(Model)(generate.mtl:5)

I'm using eclipse oxygen 3 and my model is created with papyrusand is composed of 2 blocks connected with a composite association(directed)

Thank u ^^
Re: Error while generating A UML code [message #1785105 is a reply to message #1785102] Mon, 09 April 2018 14:15 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7681
Registered: July 2009
Senior Member
Hi

You need to provide a zipped repro project. How can I be sure where line 7 is?

"org.eclipse.uml2.uml.internal.impl.PackageImportImpl was not an instanceof Class" could be a simple programming error but without a repro it is hard to follow the program flow, or animate your data.

"org.eclipse.uml2.uml.internal.impl.PackageImportImpl was not an instanceof Class" could be a metamodel schizophrenia nightmare, but without a repro how can I help?

Regards

Ed Willink
Re: Error while generating A UML code [message #1785113 is a reply to message #1785105] Mon, 09 April 2018 15:30 Go to previous messageGo to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
hey;
Yeah ofc, u'r right ^^^

here is the link to the model :
https://drive.google.com/drive/folders/1SeNh-smntQIeWBEwgAiGz1F3pfgOqVYN?usp=sharing
and here is the link of the acceleo project :
https://drive.google.com/open?id=1na6tfxrM09Osc7w_UpXQ2C8QthsjQ_4W

thank u ^^
Re: Error while generating A UML code [message #1785117 is a reply to message #1785113] Mon, 09 April 2018 16:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7681
Registered: July 2009
Senior Member
Hi

"You need to provide a zipped repro project." I do not have time to copy files one at a time.

Regards

Ed Willink
Re: Error while generating A UML code [message #1785118 is a reply to message #1785117] Mon, 09 April 2018 16:45 Go to previous messageGo to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
Hey,
I dnt knw how to do it "zipped repro project" that's why I sent u the links!
Sry!
Re: Error while generating A UML code [message #1785150 is a reply to message #1785118] Tue, 10 April 2018 05:36 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7681
Registered: July 2009
Senior Member
Hi

File->Export...->General->Archive File within Eclipse.

Your favourite ZIP/archive tool outside Eclipse.

Regards

Ed Willink
Re: Error while generating A UML code [message #1785168 is a reply to message #1785150] Tue, 10 April 2018 08:48 Go to previous messageGo to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
Hey,

You'll find attached the zipped repro projects,

Kind regards,
Re: Error while generating A UML code [message #1785172 is a reply to message #1785168] Tue, 10 April 2018 09:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7681
Registered: July 2009
Senior Member
Hi

In your original report you had "[for (b:uml::Class|m.eAllContents())]" but in your ZIP you have "[for (b:uml::Class|m.eAllContents(Class))]".

The former is sure to crash with a "not an instanceof Class" just as you reported => "a simple programming error"

The latter is a type filtering issue => "a metamodel schizophrenia nightmare"

Which is it?

Regards

Ed Willink
Re: Error while generating A UML code [message #1785174 is a reply to message #1785172] Tue, 10 April 2018 09:50 Go to previous messageGo to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
hey,

when using this line [for (b:uml::Class|m.eAllContents())]" i had an error I couldn't generate my code, but with adding class to eAllContents, no more error but my generated file is empty!

regards,
Re: Error while generating A UML code [message #1785181 is a reply to message #1785174] Tue, 10 April 2018 10:34 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7681
Registered: July 2009
Senior Member
Hi

A nice feature of M2T is that 'printf' debugging can be really easy. You just generate some extra output so if you think that

[for (b:uml::Class|m.eAllContents(Class))]
[if(b.hasStereotype('Block'))]
[GenerateClass(b)/]
[/if]
[/for]

generates no output you need to determine whether there was no content at all or no suitable content.

[for (b:uml::Class|m.eAllContents(Class))]
processing [\b]
[if(b.hasStereotype('Block'))]
processing Block [\b]
[GenerateClass(b)/]
[/if]
[/for]

(You will probably find out that it is the if that is failing because you have not qualified the stereotype, so you will need to print out the applied stereotypes to correct it.

Regards

Ed Willink
Re: Error while generating A UML code [message #1785182 is a reply to message #1785181] Tue, 10 April 2018 10:55 Go to previous messageGo to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
Hey,

Thank u fo ur solution but it seems like it's not executing this function " [GenerateClass(b)/] " and regarding what u said about I have not qualified he stereotpe, what do u mean i need to print out the applied stereoptype, I thought by addinng "Block" to this line " b.hasStereotype('Block') " I did so!


Thnk u
Re: Error while generating A UML code [message #1785186 is a reply to message #1785182] Tue, 10 April 2018 12:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7681
Registered: July 2009
Senior Member
Hi

Well if it's not executing [GenerateClass(b)/] it obviously is getting a true value from hasStereotype so my expectation that you might need a qualification such as 'sysml::blocks::Block' is wrong.

You now need to find out how much of GenerateClass executes and where the executes/not-executes barrier is.

This is all pretty much debugging 101.

Regards

Ed Willink
Re: Error while generating A UML code [message #1785191 is a reply to message #1785186] Tue, 10 April 2018 13:40 Go to previous messageGo to next message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
Hey,

I'm not very familiar with what you're suggesting, I don't really understand it, so could you please explain more what do you mean "you need a qualification such as 'sysml::block::Block' ?
And I added not in this command line " [if(b.hasStereotype('Block'))] " => [if(not (b.hasStereotype('Block')))] , and it worked, now it's generating my function : [GenerateClass(b)/]

Kind regards,
Re: Error while generating A UML code [message #1785214 is a reply to message #1785191] Wed, 11 April 2018 05:40 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7681
Registered: July 2009
Senior Member
Hi

In Java, as with many languages, you are probably familiar with referring to java.util.List, rather than java.awt.List, either explicitly using its full name or via an import that makes the name available without further java.util qualification. So too for models, Block is not an unambiguous top level name, so you may need to qualify it by its containing package hierarchy.

Regards

Ed Willink
Re: Error while generating A UML code [message #1785222 is a reply to message #1785214] Wed, 11 April 2018 07:27 Go to previous message
khouloud AYARI is currently offline khouloud AYARIFriend
Messages: 49
Registered: March 2018
Member
Hey,

Thank you for explaining it to me.

Kind regards
Previous Topic:Acceleo Code
Next Topic:Retrieve target folder during generation
Goto Forum:
  


Current Time: Sat Dec 21 16:39:03 GMT 2024

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

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

Back to the top