[MWE2] Accessing Models within a model [message #675724] |
Wed, 01 June 2011 10:01 |
Sundeep Ramesh Messages: 8 Registered: May 2011 Location: Bangalore, India |
Junior Member |
|
|
Hi, I am a newbie in MWE and XPand. I have 3 ecore files, one service.ecore containing a Service DSL, one requiredinterface.ecore for Required Interface and one Mapping ecore to map the attributes from the service DSL to the Required interface dsl. (Please find the files as attachements)
I have 3 models modeled from the respective metamodels (Please find attached the model files CIFS_GetDetailForCifs_1.corba and customer.requiredinterface) and the third mapping model
<?xml version="1.0" encoding="UTF-8"?>
<bom2servicesmapping:BOM2ServicesMapping
.........
<requiredInterface href="platform:/resource/com.csg.crs.carat.customer/model/customer.requiredinterface#/"/>
<services href="platform:/resource/com.csg.cifs.getdetailforcifs.service/model/CIFS_GetDetailForCifs_1.corba#/0"/>
<attributeMapping identifier="bom2servicemapping.customerBomServiceMapper.cifNumber" localIdentifier="cifNumber" name="Cif Number">
<interfaceAttribute href="platform:/resource/com.csg.crs.carat.customer/model/customer.requiredinterface#//@attributes.1"/>
<serviceAttribute href="platform:/resource/com.csg.cifs.getdetailforcifs.service/model/CIFS_GetDetailForCifs_1.corba#/0/@output/@structureReferences.0/@structure/@subStructureReferences.0/@structure/@subStructureReferences.0/@structure/@attributes.0"/>
</attributeMapping>
</bom2servicesmapping:BOM2ServicesMapping>
The template file
«IMPORT bom2servicesmapping»
«DEFINE main FOR bom2servicesmapping::BOM2ServicesMapping»
«FILE "com/csg/crs/carat/customer/mapping/" + localIdentifier.toFirstUpper() + ".java"»
package com.csg.crs.carat.customer.mapping;
public class «name.toFirstUpper()» {
«FOREACH this.attributeMapping AS e»
private String «e.localIdentifier»;
«ENDFOREACH»
}
«ENDFILE»
«ENDDEFINE»
and the workflow file
module template.CustomerGenerator
Workflow {
bean = org.eclipse.emf.mwe.utils.StandaloneSetup {
platformUri =".."
scanClassPath = true
}
component = org.eclipse.emf.mwe.utils.DirectoryCleaner {
directory = "src-gen"
}
component = org.eclipse.emf.mwe.utils.Reader{
uri = "platform:/resource/com.csg.crs.carat.customerbomservicemapper/model/CustomerBomServiceMapper.bom2servicesmapping"
modelSlot = "model"
}
component = org.eclipse.xpand2.Generator {
metaModel = org.eclipse.xtend.typesystem.emf.EmfMetaModel{
metaModelFile = "platform:/resource/com.csg.crs.carat.requiredinterface.mapping/src/metamodel/BOM2ServicesMapping.ecore"
}
expand = "template::CustomerMappingTemplate::main FOR model"
outlet = {
path = "src-gen"
postprocessor =org.eclipse.xpand2.output.JavaBeautifier{
configFile = "eclipse-formatter.xml"
}
}
}
}
The mapping model has references to two other models. The issue is that in the template I get access to their metamodels but when I try to generate code using MWE2 the reference models return null i.e. no data, I do not get any exception so I am not clear on what I need to do.
Any help here would be greatly appreciated.
Thanking you in advance.
[Updated on: Wed, 01 June 2011 10:03] Report message to a moderator
|
|
|
|
|
|
(no subject) [message #676204 is a reply to message #676193] |
Fri, 03 June 2011 07:37 |
|
Hi,
Update: I guess you need a workflow like
Workflow {
bean = org.eclipse.emf.mwe.utils.StandaloneSetup {
platformUri = ".."
registerEcoreFile="platform:/resource/com.csg.dsl.fw.base/model/base.ecore"
registerEcoreFile="platform:/resource/com.csg.dsl.corba/model/corba.ecore"
registerEcoreFile="platform:/resource/com.csg.crs.carat.dsl.requiredinterface/model/requiredinterface.ecore"
registerEcoreFile="platform:/resource/com.csg.crs.carat.requiredinterface.mapping/model/BOM2ServicesMapping.ecore"
}
component = org.eclipse.emf.mwe.utils.Reader {
uri = "platform:/resource/com.csg.crs.carat.requiredinterface.mapping/model/CustomerBomServiceMapper.bom2servicesmapping"
modelSlot = "model"
}
component = org.eclipse.xpand2.Generator {
metaModel = org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel {}
expand = "templates::template::Main FOR model"
outlet = {
path = "src-gen"
}
}
}
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Fri, 03 June 2011 08:36] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03117 seconds