Hi Pieter,
ok I'll try to answer your questions ;)
Let me start with the consistency constraints. These constraints will be encapsulated
in a Java class (I think
one per constraint).
Please Allow me to adapt your example.
Lets assume that you have a UML model with some classes which are stereotyped with
"Entity" and many other
classes. The target model is a (very) simple MOF based model for databases. That means
you have Tables which
have a "contains" Relationship to a list of Columns. That's all. (Well, I said it
would be simple). ;) The constraint
should ensure that after a transformation for each of these entity classes in the UML
model a Table is existent
in the target model which contains a Colunm for each Attribute of the entity class.
OK the code fragment for the consistency check could look like this:
public void check() throw SomeException {
UMLMetaModelAdapter adpter = createUMLMetaModelAdapter();
SimpleRdbModelAdapter targetAdapter = createSimpleRdbAdapter();
Model sourceModel = adapter.findModelByName("MyModel");
//Search for the Stereotype
Stereotype stereotype = adapter.findStereotype("Entity", sourceModel);
//Find all entity classes
UMLClass[] entities = adapter.findUmlClass(sourceModel, stereotype);
//Iterate through the classes
for (int i=0; i<entities.length(); i++) {
//The code here depends on your transformation rules
//e.g. the names of target and source model elements are equal
Table t = targetAdapter.findTableByName(entities[i].getName());
//Do some assertions and look for the attributes
...
//Alternative: use the tracability strategy based on MofIds (see the answer to
your tracability question)
}
}
As you can see the code is very simple due to the MetaModelAdapter. If a constraint
violation is detected an
exception is thrown that has to be handled somehow, e.g. a rollback on the
transformation.
These use the query-by-example mechanism to find the objects. Lets have a look on
findUMLClass:
public UMLCLass[] findUMLClass(Model m, Stereotype s) {
//Obtain a reference to the repository Adapter which provides the reflective query
repAdapter = getRepositoryAdapter();
//Query classes are containers for search criteria
UMLCLassQuery query = new UMLClassQuery();
query.setModel(m);
query.setStereotype(s);
//the descriptor contains the information needed for reflective query
//the modelRoot is the extent in metadata repository that contains the UML models
return
(UMLClass[])repAdapter.queryRefObjects(query.getDescriptor(),getModelRoot(), query);
}
That's how you find objects in a metamodel. Fill a special Query object that contains
an descriptor and let the
adapter do the main work.
Now lets have a look on traceability: I am going to solve it by writing MofId pairs
(source->target) to a
persistent storage. This way you know which model element was generated from which
one. This allows the
framework to decide whether model element's have been deleted or added or already have
been transformed. I
think here's still some brain work to do.
Observers or Listeners? Recovery in Transformations? Uhm, well ... that's something
that is currently not
planned, but maybe the constrint check after a transformation that throws an exception
in case of violation is
enough for the moment.
Puh... I hope these answers are satisfactory to you.
Best regards,
Matthias�
------- Urspr�ngliche Nachricht -------�
Von: Pieter Van Gorp <[EMAIL PROTECTED]>�
Datum: Thu, 25 Mar 2004 17:54:01 +0100�
Betreff: Re: Antworten: Re: [Andromda-devel] Framework for model transformations�
Hi Matthias,
indeed concepts like packaging, attributes, methods and inheritance are
needed in transformation languages as well. A framework on top of JMI
is very attractive for the reasons you mention.
> For example the query module of the framework will be based on Java
> reflection, the JMI reflective interfaces and a
> query-by-example mechanism.
You make me very curious... Sorry, I'll have to spam you with a lot of
questions right now :-)
I wonder how you specify consistency constraints across abstraction
layers. Could you post a code fragment that states something like "for
every Entity in the source metamodel, there always needs to be a
Component in the target metamodel that shares the name and list of
attributes"?
How do you attach observers (listeners) that are fired when the
consistency constraint is violated and some transformation logic needs
to recover the consistency?
How does your traceability API look like? I.e. how can I navigate from
source to target (or vice versa) for model elements that have already
been transformed?
Could you also explain your use of a "query-by-example" mechanism?
Sincerely,
Pieter Van Gorp
FOrmal Techniques in Software engineering (FOTS)
Lab On Re-Engineering (LORE)
University of Antwerp
Middelheimlaan 1
2020 Antwerpen - Belgium
Office G.304 (+32 3 265 38 71)
http://win-www.uia.ac.be/u/fots/
http://win-www.uia.ac.be/u/lore/
http://www.pietervangorp.com/
On donderdag, maa 25, 2004, at 17:02 Europe/Brussels, Matthias Bartels
wrote:
> Hi Peter,
>
> AFAIK the MTL approach uses its own language and OCL to do
> transformations. From my point of view this is not
> pragmatic enough (Well, it is compared to QVT).
>
> I want to use a well known language that provides all advantages of OO
> programming, so why not use Java. We have a
> standard (JMI) that allows to abstract from repositories and
> metamodels.
> The usage of Java implies the possibility to build flexibel
> transformations that can be easily adapted or extended
> to your needs by derivation, the availability of powerful IDEs, that
> allow you to easily develop and debug your
> transformations and not less important a very large developer
> community that is already familiar with the language
> is out there.
> For example the query module of the framework will be based on Java
> reflection, the JMI reflective interfaces and a
> query-by-example mechanism. Above this layer convenience layers will
> exist that encapsulate complex metamodels(e.g.
> UML) and allow easy access to model elements.
>
> I think Java as a well known OO language and the JMI spec. are a
> really good basis for a pragmatic approach to
> model transformations.
>
> Best regards,
> Matthias
>
> -------
> Urspr�ngliche
> Nachricht -------
> Von: Pieter Van Gorp
>
> Datum: Thu, 25 Mar
> 2004 14:17:40 +0100
> Betreff: Re:
> [Andromda-devel]
> Framework for model
> transformations
>
> Hi Matthias,
>> The framework I am
> developing is based
> on JMI, it is a
> pragmatic
>> approach to model
> transformations.
> That means I
>> don't plan to
> implement a solution
> for OMGs QVT RFP.
> Could you perhaps
> outline the
> difference in goals
> and results between
> your framework and
> MTL
> (http://modelware.inria.fr/)?
> AFAIK, MTL (in
> contrast to ATL) is
> also a pragmatic
> framework approach
> instead of a
> QVT language
> approach.
>
> Best regards,
> Pieter Van Gorp
> FOrmal Techniques
> in Software
> engineering (FOTS)
> Lab On
> Re-Engineering
> (LORE)
> University of
> Antwerp
> Middelheimlaan 1
> 2020 Antwerpen -
> Belgium
> Office G.304 (+32 3
> 265 38 71)
> http://win-www.uia.ac.be/u/fots/
> http://win-www.uia.ac.be/u/lore/
> http://www.pietervangorp.com/
>
> On donderdag, maa
> 25, 2004, at 10:09
> Europe/Brussels,
> Matthias Bartels
> wrote:
>
>> Hi,
>>
>> I am currently
> developing a
> framework that
> allows model
>> transformations.
> Because of the
> existence of open
> source
>> tools like
> AndroMDA it would be
> nonsense to develop
> a complete MDA
>> framework on my
> own. Are there any
> plans to
>> integrate model
> transformations into
> AndroMDA? If so we
> could maybe
>> join our forces.
>>
>> The framework I am
> developing is based
> on JMI, it is a
> pragmatic
>> approach to model
> transformations.
> That means I
>> don't plan to
> implement a solution
> for OMGs QVT RFP.
> Due to the fact
>> that the framework
> is based on JMI it
> will be
>> useable with any
> MOF based Metamodel
> and any JMI based
> metadata
>> repository
> (currently Netbeans
> MDR).
>>
>> I'm going to
> realize a working
> prototype till the
> middle of april.
>>
>> Best regards,
>> Matthias
>>
>> Lycos empfiehlt:
> Erhalten Sie hier
> eine kostenlose
> Unfallversicherung
>> von Lycos f�r 12
> Monate! Infos unter:
>
>>
> http://www.lycos.de/service/ace/landingpage/index.html
>>
>>
>
> Sichern Sie sich Ihre Premium E-Mail-Adresse bei Lycos: eigene Domain,
> 500MB Mailspeicher, 25 free SMS, POP3, Weiterleitung und Hightech
> Spamschutz: http://mail.lycos.de
>
>
Lycos empfiehlt: Erhalten Sie hier eine kostenlose Unfallversicherung von Lycos f�r 12
Monate! Infos unter: http://www.lycos.de/service/ace/landingpage/index.html