Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DTP » Re: [dtp-dev] CCE during Annotated Java Import
Re: [dtp-dev] CCE during Annotated Java Import [message #14917] Thu, 25 May 2006 06:32 Go to next message
Anil Samuel is currently offline Anil SamuelFriend
Messages: 108
Registered: July 2009
Senior Member
Figured this out. Steps followed

1. File->New->Ecore Model
2. Load sqlmodel.ecore
3. Add your EPackage, EClass etc.
4. File->New->EMF Model->Next->Ecore Model
5. Check the required boxes -> Finish
6. This generated the .genmodel
7. Right click on the .genmodel top level node and Generate Code.

More later
Anthos
Re: [dtp-dev] CCE during Annotated Java Import [message #14942 is a reply to message #14917] Thu, 25 May 2006 21:17 Go to previous messageGo to next message
Brian Payton is currently offline Brian PaytonFriend
Messages: 154
Registered: July 2009
Senior Member
Expanding on the steps outlined by Anthos, here is a detailed
step-by-step guide to generating an extension of the SQL model without
using Rational Rose. In this example I will generate a model for Derby
that includes a single class Synonym, which derives from the Table class
in the base SQL Model. The class Synonym contains a single reference
attribute "table" (with accessors getTable and setTable) that is the
table with which the synonym is associated. (I am using Eclipse 3.2 RC5
with EMF 2.2.)

1. Create a model plugin project
a. File -> New -> Project...
b. Select Plug-in Project, click Next
c. Enter a project name (org.eclipse.datatools.modelbase.derby in this
example), click Next
d. Uncheck "generate an activator" and uncheck "This plug-in makes
contributions to the UI", click Finish
e. In the new project, expand the META-INF folder and double-click the
MANIFEST.MF file to edit it.
f. In the editor, click the MANIFEST.MF tab. At the end of the
"Bundle-SymbolicName" line, add "; singleton:=true" (semi-colon, space,
"singleton", colon, equal sign, "true").
(I don't know why this wasn't added by default when the plugin was
created. Perhaps there is some setting in the wizard that I missed.)
g. Click on the Dependencies tab. Click the Add... button.
h. In the Plug-In Selection dialog, select the org.eclipse.emf.ecore
plugin and click the OK button
i. Click the Add... button again.
j. In the Plug-In Selection dialog, select the
org.eclipse.datatools.modelbase.sql plugin and click the OK button
h. Save and close the MANIFEST.MF editor

2. Add a model folder to the project
a. Right-click on the new project in the project explorer and select
New -> Folder
b. Enter "model" for the folder name and click Finish

3. Create an ecore model
a. Right-click on the model folder and select New -> Other...
b. In the New dialog expand the Example EMF Model Creation Wizards
node, select Ecore Model, and click Next
c. Change the file name from "My.ecore" to whatever you want
(derby.ecore in this example), click Next
d. Make sure that the Model Object entry is "EPackage". Click
Finish. The new ecore file should open in the Sample Ecore Model Editor

4. Customize the ecore model
a. In the Ecore editor, expand the xxx.ecore entry
(platform:/resource/org.eclipse.datatools.modelbase.derby/mo del/derby.ecore
in this example). You should see an child entry named "null" under it
b. Click on the "null" entry, then click on the "Properties" view
c. Click on the Value column of the Name row and enter a name ("derby")
d. Back up in the Ecore editor, right-click in the edit area and
select Load Resource...
e. In the Load Resource dialog, click the Browse Workspace... button
f. In the File Selection dialog, find and expand the
org.eclipse.datatools.modelbase.sql entry
g. Expand the model folder, select sqlmodel.ecore, and click OK
h. In the Load Resource dialog, click OK. This should add the entry
" platform:/resource/org.eclipse.datatools.modelbase.sql/model /sqlmodel.ecore "
to the Ecore editor
i. Right-click on the model name entry formerly shown as "null" (and
now "derby" in this example) and select New Child -> EClass
j. Click on the new (unnamed) entry appearing under the model entry.
In the Properties view, click on the Value entry of the Name row and
enter a name ("Synonym" in this example).
k. Click on the "..." button at the end of the Value entry of the
ESuperTypes row
l. In the ESuper Types dialog, select the super class of the new class
(Table -> SQLObject in this example)
m. Right-click on the new class object (Synonym -> Table) in the Ecore
editor and select New Child -> EReference. In the Properties view click
on the Value column of the Name row and give the reference a name
("Table" in this example).
n. Click on the Value column of the Lower Bound row and change the
value from 0 to 1 to indicate that this reference is required
o. Click on the Value column of the EType row, scroll through the
drop-down list of types to find the type for the reference (Table ->
SQLObject in this case)
(At this point you can repeat the last three steps to add whatever
attributes and references are needed in your new class.)
p. When you are done, save and close the Ecore edit session.

5. Create a genmodel
a. Right-click on the model folder and select New -> Other...
b. In the New dialog, expand the Eclipse Modeling Framework node,
select EMF Model, and click Next
c. Change the file name from "My.genmodel" to a name that makes sense
("derby.genmodel" in this example) and click Next
d. Select Ecore model from the Model Importers list, click Next
e. On the Ecore Import page, click the Browse Workspace... button
f. In the File Selection dialog, expand your model plugin (i.e.,
org.eclipse.datatools.modelbase.derby), expand the model folder, and
select the ecore file (derby.ecore) and click OK
g. On the Ecore Import page, click Next
h. On the Package Selection page, click the Browse... button
i. In the File Selection dialog, find and expand the
org.eclipse.datatools.modelbase.sql node, expand the model folder, and
select sqlmodel.genmodel and click OK
j. In the Referenced generator models area of the Package Selection
page, click the check boxes next to the "org.eclipse.emf.ecore" and
"sqlmodel" entries. The corresponding ecore and sqlmodel entries should
disappear from the Root packages area.
(Note: these two steps are very important. You want to generate code
only for your new model classes, not the SQL Model or Ecore model classes.)
k. In the Root packages area, click the checkbox next to your new
package ("derby") and click Finish. The new genmodel file should open in
the EMF Generator editor

6. Customize the genmodel
a. In the genmodel editor, click on the model node (Derby) under the
top level node (Derby)
b. In the Properties view, click on the Value column of the Base
Package row and enter the package name you want to use for generating
code, omitting the last part. In this example, I enter
"org.eclipse.datatools.modelbase". (The last part of the package name,
"derby", comes from the ecore name model name.)
c. Save the genmodel

7. Generate model code
a. In the genmodel editor, right-click on the top level node and
select Generate Model Code. Code will be generated into the base, impl,
and util classes in the src folder.
This completes the steps for creating and generating a model extension
to the SQL model.

Note: I get an odd error in the generated code of the xxxSwitch.java
(DerbySwitch.java) in the util package. There are two calls in the
doSwitch method to methods that don't exist. I don't know if this is an
EMF generation bug or something I'm doing wrong.

Anil T Samuel wrote:
> Figured this out. Steps followed
>
> 1. File->New->Ecore Model
> 2. Load sqlmodel.ecore
> 3. Add your EPackage, EClass etc.
> 4. File->New->EMF Model->Next->Ecore Model
> 5. Check the required boxes -> Finish
> 6. This generated the .genmodel
> 7. Right click on the .genmodel top level node and Generate Code.
>
> More later
> Anthos
Re: [dtp-dev] CCE during Annotated Java Import [message #15168 is a reply to message #14942] Fri, 26 May 2006 00:38 Go to previous messageGo to next message
Anil Samuel is currently offline Anil SamuelFriend
Messages: 108
Registered: July 2009
Senior Member
Hi Brian

Highly appreciate your step-by-step guide and thanks a ton.

It would be good to publish this in the DTP Wiki site; rather than being
lost in the news site.

Regards
Anthos
Re: [dtp-dev] CCE during Annotated Java Import [message #15264 is a reply to message #15168] Fri, 26 May 2006 18:05 Go to previous message
Brian Payton is currently offline Brian PaytonFriend
Messages: 154
Registered: July 2009
Senior Member
Anthos,

Yes I will once I get some details worked out, particularly the EMF code
generation question. (I've asked about it on the EMF newsgroup.)

Brian

Anil T Samuel wrote:
> Hi Brian
>
> Highly appreciate your step-by-step guide and thanks a ton.
>
> It would be good to publish this in the DTP Wiki site; rather than
> being lost in the news site.
>
> Regards
> Anthos
Re: [dtp-dev] CCE during Annotated Java Import [message #578297 is a reply to message #14917] Thu, 25 May 2006 21:17 Go to previous message
Brian Payton is currently offline Brian PaytonFriend
Messages: 154
Registered: July 2009
Senior Member
Expanding on the steps outlined by Anthos, here is a detailed
step-by-step guide to generating an extension of the SQL model without
using Rational Rose. In this example I will generate a model for Derby
that includes a single class Synonym, which derives from the Table class
in the base SQL Model. The class Synonym contains a single reference
attribute "table" (with accessors getTable and setTable) that is the
table with which the synonym is associated. (I am using Eclipse 3.2 RC5
with EMF 2.2.)

1. Create a model plugin project
a. File -> New -> Project...
b. Select Plug-in Project, click Next
c. Enter a project name (org.eclipse.datatools.modelbase.derby in this
example), click Next
d. Uncheck "generate an activator" and uncheck "This plug-in makes
contributions to the UI", click Finish
e. In the new project, expand the META-INF folder and double-click the
MANIFEST.MF file to edit it.
f. In the editor, click the MANIFEST.MF tab. At the end of the
"Bundle-SymbolicName" line, add "; singleton:=true" (semi-colon, space,
"singleton", colon, equal sign, "true").
(I don't know why this wasn't added by default when the plugin was
created. Perhaps there is some setting in the wizard that I missed.)
g. Click on the Dependencies tab. Click the Add... button.
h. In the Plug-In Selection dialog, select the org.eclipse.emf.ecore
plugin and click the OK button
i. Click the Add... button again.
j. In the Plug-In Selection dialog, select the
org.eclipse.datatools.modelbase.sql plugin and click the OK button
h. Save and close the MANIFEST.MF editor

2. Add a model folder to the project
a. Right-click on the new project in the project explorer and select
New -> Folder
b. Enter "model" for the folder name and click Finish

3. Create an ecore model
a. Right-click on the model folder and select New -> Other...
b. In the New dialog expand the Example EMF Model Creation Wizards
node, select Ecore Model, and click Next
c. Change the file name from "My.ecore" to whatever you want
(derby.ecore in this example), click Next
d. Make sure that the Model Object entry is "EPackage". Click
Finish. The new ecore file should open in the Sample Ecore Model Editor

4. Customize the ecore model
a. In the Ecore editor, expand the xxx.ecore entry
(platform:/resource/org.eclipse.datatools.modelbase.derby/mo del/derby.ecore
in this example). You should see an child entry named "null" under it
b. Click on the "null" entry, then click on the "Properties" view
c. Click on the Value column of the Name row and enter a name ("derby")
d. Back up in the Ecore editor, right-click in the edit area and
select Load Resource...
e. In the Load Resource dialog, click the Browse Workspace... button
f. In the File Selection dialog, find and expand the
org.eclipse.datatools.modelbase.sql entry
g. Expand the model folder, select sqlmodel.ecore, and click OK
h. In the Load Resource dialog, click OK. This should add the entry
" platform:/resource/org.eclipse.datatools.modelbase.sql/model /sqlmodel.ecore "
to the Ecore editor
i. Right-click on the model name entry formerly shown as "null" (and
now "derby" in this example) and select New Child -> EClass
j. Click on the new (unnamed) entry appearing under the model entry.
In the Properties view, click on the Value entry of the Name row and
enter a name ("Synonym" in this example).
k. Click on the "..." button at the end of the Value entry of the
ESuperTypes row
l. In the ESuper Types dialog, select the super class of the new class
(Table -> SQLObject in this example)
m. Right-click on the new class object (Synonym -> Table) in the Ecore
editor and select New Child -> EReference. In the Properties view click
on the Value column of the Name row and give the reference a name
("Table" in this example).
n. Click on the Value column of the Lower Bound row and change the
value from 0 to 1 to indicate that this reference is required
o. Click on the Value column of the EType row, scroll through the
drop-down list of types to find the type for the reference (Table ->
SQLObject in this case)
(At this point you can repeat the last three steps to add whatever
attributes and references are needed in your new class.)
p. When you are done, save and close the Ecore edit session.

5. Create a genmodel
a. Right-click on the model folder and select New -> Other...
b. In the New dialog, expand the Eclipse Modeling Framework node,
select EMF Model, and click Next
c. Change the file name from "My.genmodel" to a name that makes sense
("derby.genmodel" in this example) and click Next
d. Select Ecore model from the Model Importers list, click Next
e. On the Ecore Import page, click the Browse Workspace... button
f. In the File Selection dialog, expand your model plugin (i.e.,
org.eclipse.datatools.modelbase.derby), expand the model folder, and
select the ecore file (derby.ecore) and click OK
g. On the Ecore Import page, click Next
h. On the Package Selection page, click the Browse... button
i. In the File Selection dialog, find and expand the
org.eclipse.datatools.modelbase.sql node, expand the model folder, and
select sqlmodel.genmodel and click OK
j. In the Referenced generator models area of the Package Selection
page, click the check boxes next to the "org.eclipse.emf.ecore" and
"sqlmodel" entries. The corresponding ecore and sqlmodel entries should
disappear from the Root packages area.
(Note: these two steps are very important. You want to generate code
only for your new model classes, not the SQL Model or Ecore model classes.)
k. In the Root packages area, click the checkbox next to your new
package ("derby") and click Finish. The new genmodel file should open in
the EMF Generator editor

6. Customize the genmodel
a. In the genmodel editor, click on the model node (Derby) under the
top level node (Derby)
b. In the Properties view, click on the Value column of the Base
Package row and enter the package name you want to use for generating
code, omitting the last part. In this example, I enter
"org.eclipse.datatools.modelbase". (The last part of the package name,
"derby", comes from the ecore name model name.)
c. Save the genmodel

7. Generate model code
a. In the genmodel editor, right-click on the top level node and
select Generate Model Code. Code will be generated into the base, impl,
and util classes in the src folder.
This completes the steps for creating and generating a model extension
to the SQL model.

Note: I get an odd error in the generated code of the xxxSwitch.java
(DerbySwitch.java) in the util package. There are two calls in the
doSwitch method to methods that don't exist. I don't know if this is an
EMF generation bug or something I'm doing wrong.

Anil T Samuel wrote:
> Figured this out. Steps followed
>
> 1. File->New->Ecore Model
> 2. Load sqlmodel.ecore
> 3. Add your EPackage, EClass etc.
> 4. File->New->EMF Model->Next->Ecore Model
> 5. Check the required boxes -> Finish
> 6. This generated the .genmodel
> 7. Right click on the .genmodel top level node and Generate Code.
>
> More later
> Anthos
Re: [dtp-dev] CCE during Annotated Java Import [message #578316 is a reply to message #14942] Fri, 26 May 2006 00:38 Go to previous message
Anil Samuel is currently offline Anil SamuelFriend
Messages: 108
Registered: July 2009
Senior Member
Hi Brian

Highly appreciate your step-by-step guide and thanks a ton.

It would be good to publish this in the DTP Wiki site; rather than being
lost in the news site.

Regards
Anthos
Re: [dtp-dev] CCE during Annotated Java Import [message #578395 is a reply to message #15168] Fri, 26 May 2006 18:05 Go to previous message
Brian Payton is currently offline Brian PaytonFriend
Messages: 154
Registered: July 2009
Senior Member
Anthos,

Yes I will once I get some details worked out, particularly the EMF code
generation question. (I've asked about it on the EMF newsgroup.)

Brian

Anil T Samuel wrote:
> Hi Brian
>
> Highly appreciate your step-by-step guide and thanks a ton.
>
> It would be good to publish this in the DTP Wiki site; rather than
> being lost in the news site.
>
> Regards
> Anthos
Previous Topic:Synonym not appearing in DSE for Derby connection
Next Topic:Dependency Problem in 0.9RC3
Goto Forum:
  


Current Time: Thu Mar 28 08:58:48 GMT 2024

Powered by FUDForum. Page generated in 0.02916 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top