Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » invoking workflow with XPandfacade causes problems with primitive types
invoking workflow with XPandfacade causes problems with primitive types [message #731519] Sat, 01 October 2011 15:09 Go to next message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
hello everbody
i want to invoke my xpand workflow with xpandfacade, to generate code for a uml-model. that works very well, but the problem is, that the primitives types are not recognized, there is only null in the code.

i found here a similar problem

https://bugs.eclipse.org/bugs/show_bug.cgi?id=333605

i tried the workaround but it does not work, maybe someone can help me? the code invoking the workflow is below

//put uml-model in a resource
...
resource = resourceSet.getResource(UMLuri, true);

//output
OutputImpl output = new OutputImpl();
Outlet outlet = new Outlet("src-gen");
outlet.setOverwrite(true);
output.addOutlet(outlet);

//protected regions
ProtectedRegionResolverImpl prs = new ProtectedRegionResolverImpl();
prs.setSrcPathes("src-gen");

//global variables
Map<String,Variable> globalVarsMap = new HashMap<String,Variable>();
Variable v = new Variable("Boolean", true);
globalVarsMap.put("naryAssociationFlag", v);


XpandExecutionContextImpl execCtx = new XpandExecutionContextImpl
(output, prs, globalVarsMap, null, null);

//tries the workaround from the link, but the primitive types are still
//null
execCtx.registerMetaModel(new ExtendedUML2Metamodell());
XpandFacade facade = XpandFacade.create(execCtx);
facade.evaluate("templateMiddle::Template::main",
resource.getContents().get(0));
Re: invoking workflow with XPandfacade causes problems with primitive types [message #731523 is a reply to message #731519] Sat, 01 October 2011 15:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
Hi,

my workaround requires you to do the additional mappings yourself by calling addmapping on the metamodel

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: invoking workflow with XPandfacade causes problems with primitive types [message #731527 is a reply to message #731523] Sat, 01 October 2011 15:22 Go to previous messageGo to next message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
hi christian
thanks for your fast reply!
i have no idea how this could work

maybe you can post a little example

best regards
stoehm
Re: invoking workflow with XPandfacade causes problems with primitive types [message #731531 is a reply to message #731527] Sat, 01 October 2011 15:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
Hi,

you should be able to transform the workflow code

<metaModel class="model.ExtendedUML2Metamodel">
            <mapping from="EcorePrimitiveTypes::EString" to="ecore::EString" />
        </metaModel>


to java (pseudo code)

ExtendedUML2Metamodel mm = new ExtendedUML2Metamodel ();
Mapping m1 = new Mapping("EcorePrimitiveTypes::EString","ecore::EString");
mm.addMapping(m1);
execCtx.registerMetaModel(mm)


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: invoking workflow with XPandfacade causes problems with primitive types [message #731541 is a reply to message #731519] Sat, 01 October 2011 16:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

On 01/10/2011 16:09, stoehm wrote:
> hello everbody
> i want to invoke my xpand workflow with xpandfacade, to generate code
> for a uml-model. that works very well, but the problem is, that the
> primitives types are not recognized, there is only null in the code.
You might be interested to know that Juno M2 contains a UML 2.4.1
targetted UML2 project. Since the base models come from OMG, they might
be right. UML 2.4 separates the primitives out into a separate package,
which is different but ultimately good news.

Regards

Ed Willink
Re: invoking workflow with XPandfacade causes problems with primitive types [message #731567 is a reply to message #731541] Sat, 01 October 2011 19:24 Go to previous messageGo to next message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
hi
thanks for your fast replys!

@ed, ah ok version 2.4 has some nice improvements, but for now we can't change the version Confused

@christian
for now i changed the code to this:


ExtendedUML2Metamodell metamodel = new ExtendedUML2Metamodell();
Mapping m1 = new Mapping("UMLPrimitiveTypes::String","ecore::EString");
Mapping m2 = new Mapping("JavaPrimitiveTypes::int","ecore::EInt");
metamodel.addMapping(m1);
metamodel.addMapping(m2);


but it does not work, i tried several other things but they don't work too. i read in the xpand-manual, that the thing ein have to map to depends on the metamodel. in my case this UML, so maybe i have to put "UMLPrimitiveTypes::String" as second parameter, but what is then the first parameter?

btw: it is interesting, when i had my own .mwe-file i could run my codegenerator without problems. the primitiveTypes were all corect, even if i had no mappings in my workflow

[Updated on: Sat, 01 October 2011 19:26]

Report message to a moderator

Re: invoking workflow with XPandfacade causes problems with primitive types [message #731570 is a reply to message #731567] Sat, 01 October 2011 19:30 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
Hi,

no! the patch is for the UML Metamodel. did you debugging into the code? what happens? are you sure you are suffering the bug you mentioned? did you call the uml setup class? can you share a executable reproducable example?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 01 October 2011 19:31]

Report message to a moderator

Re: invoking workflow with XPandfacade causes problems with primitive types [message #731574 is a reply to message #731570] Sat, 01 October 2011 19:52 Go to previous messageGo to next message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
i think, you are rigth
it maybe has nothing to do with bugreport, because in my workflow i set the org.eclipse.xtend.typesystem.uml2.Setup
but how can i do this with facade
i guess i have to use XpandExecutionContextImpl to set it, but i dont know the rigth call, because the methods has no meaningful parameters

greetings
stoehm
Re: invoking workflow with XPandfacade causes problems with primitive types [message #731575 is a reply to message #731574] Sat, 01 October 2011 19:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14664
Registered: July 2009
Senior Member
no

one more you can translate the workflow 1:1 to java
just call new Setup().setStandardUML2Setup(true)

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: invoking workflow with XPandfacade causes problems with primitive types [message #731577 is a reply to message #731575] Sat, 01 October 2011 20:04 Go to previous message
st oehm is currently offline st oehmFriend
Messages: 79
Registered: October 2009
Member
yeah it works now!
thanks a lot!
Previous Topic:[Acceleo 3.1] Metamodel loading issues
Next Topic:modul to filter classes
Goto Forum:
  


Current Time: Tue Apr 16 07:33:52 GMT 2024

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

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

Back to the top