且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从概念数据模型生成UML

更新时间:2023-01-09 10:59:10

Acceleo可以从使用基于任何基于EMF的元模型定义的任何模型中生成代码. Eclipse Foundation的UML项目定义了一个基于EMF的UML元模型,以便用户可以基于EMF创建UML模型,从而Acceleo可以从这些模型中生成代码.

如果您要使用另一个元模型,则可以这样做,因此,如果您要创建一个与您的数据结构更紧密匹配的元模型,请随时这样做.例如,您可以看到此处.您可以在此示例中看到Acceleo生成器是在我的scala元模型"http://github.com/sbegaudeau/acceleo/scalametamodel/2011/01"上定义的(与在UML上定义的Acceleo生成器相反,使用标准的UML元模型"http://www.eclipse.org/uml2/3.0.0/UML"),我可以在Acceleo中直接使用此元模型中的一些概念,例如特征(如果您熟悉Scala,则可以).>

因此您可以:

  1. 创建与您的概念匹配的元模型
  2. 在Java中创建一个小型转换器,以创建EMF模型(元模型的实例定义数据库的概念),然后将数据库中的数据转换为仅需保存的EMF模型.
  3. 在模型中使用Acceleo:)

此致

Stephane Begaudeau

免责声明:我是Acceleo的负责人.

I have an conceptual data model (Relational model) created using powerAMC for my database but i wanted to generate DAO from it using acceleo and for that i need it in UML , is there a way to generate UML from a conceptual data model model ?

Acceleo can generate code from any models defined with any EMF based metamodel. The UML project of the Eclipse Foundation defines an UML metamodel based on EMF so that users can create UML models based on EMF and Acceleo can thus generate code from those models.

If you want to use another metamodel, you can do it, so if you want to create a metamodel that matches more closely your data structure, feel free to do so. As an example, you can see here a metamodel that I have created of the Scala language and my generator uses models defined from this metamodel to generate the code. You can find an example of a generator using this metamodel here. You can see in this example that the Acceleo generator is defined on my scala metamodel "http://github.com/sbegaudeau/acceleo/scalametamodel/2011/01" (contrary to an Acceleo generator that would be defined on UML that would be using the standard UML metamodel "http://www.eclipse.org/uml2/3.0.0/UML") and I can manipulate in Acceleo some concepts from this metamodel directly like traits (if you are familiar with Scala).

So you can:

  1. create a metamodel that matches your concepts
  2. create a small converter in java to create an EMF model (instance of your metamodel defining the concepts of your database) and then transform the data in your database to an EMF model that you just have to save.
  3. use Acceleo with your models :)

Regards,

Stephane Begaudeau

Disclaimer: I am the leader of Acceleo.