Nicolas: Rational Software Architect .emx files are Ecore-based models. So, yes, JET
can read .emx (and for that matter .uml/.uml2) models. Here are some tips
for doing it...
1) Open plugin.xml on your JET transformation, switch the the Extensions
tab, expand 'org.eclipse.jet.transform', click '(transform)', and set the
modelLoader field to 'org.eclipse.jet.emf'.
2) The UML2 meta model is very large, and I find must users are not
intimately familiar with the navigation features. JET has a special XPath
enhancement to make life a little easier. An XPath step such as $parent/foo
is interpreted as "the contents of the EReference named 'foo' on the object
identified by $parent". But, if there is not 'foo' feature, JET will then
attempt to find a contained class of $parent (i.e. something in eContents())
whose eClass name is 'foo'. So, the following are equivalent:
/contents/nestedPackages/ownedTypes[@name =
'Person']/ownedAttributes[@name = 'address']/type/@name
/Model/Package/Class[@name = 'Person']/Property[@name =
'address']/type/@name
3) JET doesn't cannot access stereotypes or steroetype properties. If you
need, custom XPath functions could be created to access these.
But, one word of caution. Our (IBMs) best practices on code generation
recommends against writing code generators directly against UML models. The
reasons:
* Code generators (at least JET-based code generators) work best with models
tuned to the structure of the output (you could call this an Intermediate
Model). Things like 'flattened' package structures, and simplifications of
UML constructs (have you ever looked at how UML handles documentation of an
Element) are common.
* Often, an Intermediate Model is developed 'bottom up' from the artifacts
that need to be generated. In our experience, all but the most UML literate
have trouble mapping code generation requirements directly to UML. Indeed,
there are often multiple validate representations.
To turn this around, this is the best practice we recommend:
1) Separate the concerns of code generation from the concern of representing
the code generation abstractions to the user.
2) Create a code generator specific 'Intermediate Model' that represents
concepts needed to produce the desired artifacts.
3) Build a JET transformation that consumes this model. Once done, you have
a code generator that can be validated, and an abstraction of the code
generator concepts (the intermediate model). For many users, this is enough!
4) (If necessary) Establish a UI representation of the code generator
abstractions (as expressed in the intermediate model). Since you are
thinking UML, this would be a mapping from UML constructs to the
intermediate model. But, UML is not the only possibility. The ambious might
choose to implement a domain specific language (DSL) using GMF. Or, a wizard
might be the right tool.
5) Implement a mapping transformation from the UI representation to the
intermediate model, and then chain in the JET transformation as the last
step (so that user's do not have to see, or be aware of the JET
transformation).
Paul
P.S. I've created a few FAQ articles for posterity:
http://wiki.eclipse.org/JET_FAQ_Should_I_write_my_JET_code_g enerator_directly_against_UML2%3F
http://wiki.eclipse.org/JET_FAQ_What_kind_of_input_model_can _JET_handle%3F
http://wiki.eclipse.org/JET_FAQ_Can_JET_handle_UML_models_as _input%3F
> Nicolas Toublanc wrote:
>> Hi,
>>
>> I'm trying to transform a RSA model using standard Eclipse
>> transformation.
>>
>> With an ecore model (.emf) generated from a RSA model (.emx), that's
>> working:
>>
>> "package mypackage;
>> <%-- import the ecore namespace --%>
>> <%@jet imports="org.eclipse.emf.ecore.*"%>
>>
>> <%-- import model helpers --%>
>> <%@jet imports="mypackage.util.JavaJetUtil"%>
>> /**
>> * DTO that represents '<c:get select="$currentClass/@name" />' entity.
>> *
>> */
>> public class <c:get select="$currentClass/@name" /> ..."
>>
>>
>>
>> What should I do to make it work directly with my .emx model?
>>
>>
>>
>> Regards,
>>
>> Nicolas
0 Response to "In Which Format Rational Software Architect Designer Can Publish Report"
Post a Comment