0

GWT を使用して jboss errai でプロジェクトを作成する必要がありますが、eclipse モデリング フレームワーク .ecore モデルを使用して acceleo を使用してモデル コードのマストを生成したいと考えています。私はこのようなことをしました。

  1. コマンドを使用して作成されたmavenプロジェクト

mvn archetype:generate -DarchetypeGroupId=org.jboss.errai.archetypes -DarchetypeArtifactId=cdi-quickstart -DarchetypeVersion=2.2.0.Final

  1. 既存の Maven プロジェクトとして Eclipse にインポートされたプロジェクト。

  2. Acceleo->Convert Project to Acceleo Generator Project に移動しますが、何も得られません。

  3. 次に、Acceleo->Convert to Acceleo MTL Projects に移動し、新しい acceleo プロジェクトを作成し、.ecore モデルを使用して以前のプロジェクトにモデルを生成しましたが、EString を String で取得し、その他を E-datatype として取得しているため、モデル クラスでエラーが発生します。 jboss errai maven プロジェクトで acceleo 機能を使用する方法を教えてください。

私のテンプレートファイルは次のとおりです:

[comment encoding = UTF-8 /]
[module main('http://www.eclipse.org/emf/2002/Ecore')  ]



[template public generateElement(anEClass : EClass)]
[comment @main /]
[file (anEClass.name.concat('.java'), false, 'UTF-8')]
    public class [anEClass.name.toUpperFirst()/]{
[ for (p:EAttribute|anEClass.eAttributes) separator('\n')]
private [p.eAttributeType.name/] [p.name/];
[/for]

[ for (p:EAttribute|anEClass.eAttributes)  separator('\n')]
public  [p.eAttributeType.name/]  get[p.name.toUpperFirst()/]()
{

    return this.[p.name/];


}
[/for]

[ for (p:EAttribute|anEClass.eAttributes) separator('\n')]
public  void set[p.name.toUpperFirst()/]([p.eAttributeType.name/] [p.name/])
{
 this.[p.name/]=[p.name/];
}
[/for]


[protected ('protected')]

[/protected]

}



[/file]
[/template]

.ecore モデルから生成されたモデルの 1 つは次のとおりです。

public class UserRegistration {
    private EString strFirstName;
    private EString strSurName;
    private EString strOccupation;
    private EString strQualificaion;
    private EString strFotherName;
    private EString strMotherName;
    private EEList chMaritalStatus;
    private EDouble dblAnnualIncome;
    private EDate dtDOB;
    private EString strAbout;
    private EJavaClass objAcceleo;

    public EString getStrFirstName() {
        return this.strFirstName;
    }

    public EString getStrSurName() {
        return this.strSurName;
    }

    public EString getStrOccupation() {
        return this.strOccupation;
    }

    public EString getStrQualificaion() {
        return this.strQualificaion;
    }

    public EString getStrFotherName() {
        return this.strFotherName;
    }

    public EString getStrMotherName() {
        return this.strMotherName;
    }

    public EEList getChMaritalStatus() {
        return this.chMaritalStatus;
    }

    public EDouble getDblAnnualIncome() {
        return this.dblAnnualIncome;
    }

    public EDate getDtDOB() {
        return this.dtDOB;
    }

    public EString getStrAbout() {
        return this.strAbout;
    }

    public EJavaClass getObjAcceleo() {
        return this.objAcceleo;
    }

    public void setStrFirstName(EString strFirstName) {
        this.strFirstName = strFirstName;
    }

    public void setStrSurName(EString strSurName) {
        this.strSurName = strSurName;
    }

    public void setStrOccupation(EString strOccupation) {
        this.strOccupation = strOccupation;
    }

    public void setStrQualificaion(EString strQualificaion) {
        this.strQualificaion = strQualificaion;
    }

    public void setStrFotherName(EString strFotherName) {
        this.strFotherName = strFotherName;
    }

    public void setStrMotherName(EString strMotherName) {
        this.strMotherName = strMotherName;
    }

    public void setChMaritalStatus(EEList chMaritalStatus) {
        this.chMaritalStatus = chMaritalStatus;
    }

    public void setDblAnnualIncome(EDouble dblAnnualIncome) {
        this.dblAnnualIncome = dblAnnualIncome;
    }

    public void setDtDOB(EDate dtDOB) {
        this.dtDOB = dtDOB;
    }

    public void setStrAbout(EString strAbout) {
        this.strAbout = strAbout;
    }

    public void setObjAcceleo(EJavaClass objAcceleo) {
        this.objAcceleo = objAcceleo;
    }

    //Start of user code protected
    //End of user code
}

ここでは、String の代わりに EString を取得し、他のプリミティブ データ型を E-Data 型として取得しています。

Plzは解決策を提案しますどうすればJavaデータと他のプロセッサを同じように入手できますか

4

1 に答える 1

0

実際、mtlファイルで変更したばかりの質問に対するコアな回答を得ました

[comment encoding = UTF-8 /]
[module main('http://www.eclipse.org/emf/2002/Ecore')/]  
[template public generateElement(anEClass : EClass)]
[comment @main /]
[file (anEClass.name.concat('.java'), false, 'UTF-8')]
package com.garvityWeb.main.migrated.models;
@Portable
public class [anEClass.name.toUpperFirst()/]
{
[ for (p:EAttribute|anEClass.eAttributes) separator('\n')]
@Inject
@DataField
private [p.eAttributeType.instanceClassName/] [p.name/];
[/for]

[ for (p:EAttribute|anEClass.eAttributes)  separator('\n')]
public  [p.eAttributeType.instanceClassName/]  get[p.name.toUpperFirst()/]()
{
    return this.[p.name/];
}
[/for]
[ for (p:EAttribute|anEClass.eAttributes) separator('\n')]
public  void set[p.name.toUpperFirst()/]([p.eAttributeType.instanceClassName/] [p.name/])
{
 this.[p.name/]=[p.name/];
}
[/for]
}
[/file]
[/template]
于 2013-04-04T15:46:50.173 に答える