SlideShare a Scribd company logo
1 of 26
Download to read offline
EMF Notebook
Pierre Lindenbaum
@yokofakun
http://plindenbaum.blogspot.com
September 10, 2013
Abstract
EMF (The Eclipse Modeling Framework) is a Java framework and
code generation facility for building tools and other applications based
on a structured model. Once you specify an EMF model, the EMF
generator can create a corresponding set of Java implementation classes.
In the following tutorial I’m going to generate a simple-and-stupid LIMS.
We’re going to create an interface for a simple-and-stupid LIMS.
1
• A laboratory contains a list of Families
• A laboratory contains a list of Sequencers
• a family contains a list of Individuals
• an Individual contains a list of Samples
• a Sequencer contains a list of Runs
• a Run contains a list of Sequenced which links to a Sample.
At the end of this tutorial, we’re going to generate the following heavy client
for our model:
1 Install the EMF plugins for Eclipse
see http://wiki.eclipse.org/EMF/Installation#Install_EMF.
2 Creating the Model
A model is created and defined in the Ecore format, which is basically a
sub-set of UML Class diagrams.
2
2.1 Create the Project
• Open Eclipse
• Menu File → New → New Project... → Empty EMF Project
• Name the project EMF03-Model
2.2 Create the ECore model
create a new ’ECore’ file in the model folder in your new modeling project.
• Menu File → New → Other.. → ECore Model
• Wizard: select the folder EMF03-Model/model.
• Wizard: set the filename as lims.ecore.
• Wizard: set Model Object as EPackage.
• Menu Window → Show View → Other → Properties
An EPackage named Lims is created. The package contains 7 EClass and 1
EEnum(s). The EPackage Lims is defined as below:
Key Value
name Lims
nsURI http://univ-nantes.fr/lims/
nsPrefix lims
Next, were going to create the EEnum and the EClass:
• In the tree view right click on the node EPackage ”Lims” , create a new
EEnum and set the name property to ”Gender”.
• In the tree view right click on the node EPackage ”Lims” , create a new
EClass and set the name property to ”Family”.
• In the tree view right click on the node EPackage ”Lims” , create a new
EClass and set the name property to ”Laboratory”.
• In the tree view right click on the node EPackage ”Lims” , create a new
EClass and set the name property to ”Individual”.
• In the tree view right click on the node EPackage ”Lims” , create a new
EClass and set the name property to ”Sequencer”.
• In the tree view right click on the node EPackage ”Lims” , create a new
EClass and set the name property to ”Run”.
• In the tree view right click on the node EPackage ”Lims” , create a new
EClass and set the name property to ”Sample”.
3
• In the tree view right click on the node EPackage ”Lims” , create a new
EClass and set the name property to ”Sequenced”.
Then, we complete the structure of each classifier:
2.3 Gender
In the tree view, right-click on the node EEnum ”Gender” and add the
following 3 eLiterals:
Name Literal Value
UNKNOWN UNKNOWN
MALE MALE 1
FEMALE FEMALE 2
2.4 Family
In the tree view, select the node EClass ”Lims” and set the following prop-
erties:
Key Value
name Family
We add some structural features to the EClass ”Family”:
2.4.1 Family:name
In the tree view, right click on the node EClass ”Family” Create a new
EAttribute named ”name” and set its properties:
Key Value
name name
lowerBound 1
eType EString
2.4.2 Family:individuals
In the tree view, right click on the node EClass ”Family” Create a new
EReference named ”individuals” and set its properties:
Key Value
name individuals
upperBound -1 (unbounded)
eType -//Individual
containment true
eOpposite -//Individual/family
4
2.4.3 Family:laboratory
In the tree view, right click on the node EClass ”Family” Create a new
EReference named ”laboratory” and set its properties:
Key Value
name laboratory
lowerBound 1
eType -//Laboratory
eOpposite -//Laboratory/families
2.5 Laboratory
In the tree view, select the node EClass ”Lims” and set the following prop-
erties:
Key Value
name Laboratory
We add some structural features to the EClass ”Laboratory”:
2.5.1 Laboratory:families
In the tree view, right click on the node EClass ”Laboratory” Create a
new EReference named ”families” and set its properties:
Key Value
name families
upperBound -1 (unbounded)
eType -//Family
containment true
eOpposite -//Family/laboratory
2.5.2 Laboratory:sequencers
In the tree view, right click on the node EClass ”Laboratory” Create a
new EReference named ”sequencers” and set its properties:
Key Value
name sequencers
upperBound -1 (unbounded)
eType -//Sequencer
containment true
eOpposite -//Sequencer/laboratory
5
2.6 Individual
In the tree view, select the node EClass ”Lims” and set the following prop-
erties:
Key Value
name Individual
We add some structural features to the EClass ”Individual”:
2.6.1 Individual:gender
In the tree view, right click on the node EClass ”Individual” Create a new
EAttribute named ”gender” and set its properties:
Key Value
name gender
ordered false
unique false
lowerBound 1
eType -//Gender
defaultValueLiteral
2.6.2 Individual:family
In the tree view, right click on the node EClass ”Individual” Create a new
EReference named ”family” and set its properties:
Key Value
name family
unique false
lowerBound 1
eType -//Family
eOpposite -//Family/individuals
2.6.3 Individual:Father
In the tree view, right click on the node EClass ”Individual” Create a new
EReference named ”Father” and set its properties:
Key Value
name Father
eType -//Individual
6
2.6.4 Individual:name
In the tree view, right click on the node EClass ”Individual” Create a new
EAttribute named ”name” and set its properties:
Key Value
name name
eType EString
2.6.5 Individual:Mother
In the tree view, right click on the node EClass ”Individual” Create a new
EReference named ”Mother” and set its properties:
Key Value
name Mother
eType -//Individual
2.6.6 Individual:samples
In the tree view, right click on the node EClass ”Individual” Create a new
EReference named ”samples” and set its properties:
Key Value
name samples
upperBound -1 (unbounded)
eType -//Sample
containment true
eOpposite -//Sample/individual
2.7 Sequencer
In the tree view, select the node EClass ”Lims” and set the following prop-
erties:
Key Value
name Sequencer
We add some structural features to the EClass ”Sequencer”:
7
2.7.1 Sequencer:name
In the tree view, right click on the node EClass ”Sequencer” Create a new
EAttribute named ”name” and set its properties:
Key Value
name name
lowerBound 1
eType EString
2.7.2 Sequencer:runs
In the tree view, right click on the node EClass ”Sequencer” Create a new
EReference named ”runs” and set its properties:
Key Value
name runs
upperBound -1 (unbounded)
eType -//Run
containment true
eOpposite -//Run/sequencer
2.7.3 Sequencer:laboratory
In the tree view, right click on the node EClass ”Sequencer” Create a new
EReference named ”laboratory” and set its properties:
Key Value
name laboratory
lowerBound 1
eType -//Laboratory
eOpposite -//Laboratory/sequencers
2.8 Run
In the tree view, select the node EClass ”Lims” and set the following prop-
erties:
Key Value
name Run
We add some structural features to the EClass ”Run”:
8
2.8.1 Run:name
In the tree view, right click on the node EClass ”Run” Create a new EAt-
tribute named ”name” and set its properties:
Key Value
name name
lowerBound 1
eType EString
2.8.2 Run:date
In the tree view, right click on the node EClass ”Run” Create a new EAt-
tribute named ”date” and set its properties:
Key Value
name date
unique false
eType EDate
2.8.3 Run:sequenced
In the tree view, right click on the node EClass ”Run” Create a new ERef-
erence named ”sequenced” and set its properties:
Key Value
name sequenced
upperBound -1 (unbounded)
eType -//Sequenced
containment true
eOpposite -//Sequenced/run
2.8.4 Run:sequencer
In the tree view, right click on the node EClass ”Run” Create a new ERef-
erence named ”sequencer” and set its properties:
Key Value
name sequencer
lowerBound 1
eType -//Sequencer
eOpposite -//Sequencer/runs
9
2.9 Sample
In the tree view, select the node EClass ”Lims” and set the following prop-
erties:
Key Value
name Sample
We add some structural features to the EClass ”Sample”:
2.9.1 Sample:id
In the tree view, right click on the node EClass ”Sample” Create a new
EAttribute named ”id” and set its properties:
Key Value
name id
lowerBound 1
eType EString
2.9.2 Sample:individual
In the tree view, right click on the node EClass ”Sample” Create a new
EReference named ”individual” and set its properties:
Key Value
name individual
lowerBound 1
eType -//Individual
eOpposite -//Individual/samples
2.10 Sequenced
In the tree view, select the node EClass ”Lims” and set the following prop-
erties:
Key Value
name Sequenced
We add some structural features to the EClass ”Sequenced”:
10
2.10.1 Sequenced:run
In the tree view, right click on the node EClass ”Sequenced” Create a new
EReference named ”run” and set its properties:
Key Value
name run
unique false
lowerBound 1
eType -//Run
eOpposite -//Run/sequenced
2.10.2 Sequenced:sample
In the tree view, right click on the node EClass ”Sequenced” Create a new
EReference named ”sample” and set its properties:
Key Value
name sample
unique false
lowerBound 1
eType -//Sample
All in one, the file lims.ecore looks like this:
1 <?xml version=” 1.0 ” encoding=”UTF−8”?>
2 <ecore:EPackage xmi:version=” 2.0 ”
3 xmlns:xmi=” http: //www. omg . org /XMI” xmlns:xsi=” http: //
www. w3 . org /2001/XMLSchema−instance ”
4 xmlns:ecore=” http: //www. e c l i p s e . org /emf/2002/ Ecore”
name=”Lims”
5 nsURI=” http: //univ−nantes . f r / lims /” nsPrefix=” lims ”>
6 <e C l a s s i f i e r s x s i : t y p e=”ecore:EEnum” name=”Gender”>
7 <e L i t e r a l s name=”UNKNOWN” l i t e r a l=”UNKNOWN”/>
8 <e L i t e r a l s name=”MALE” value=”1” l i t e r a l=”MALE”/>
9 <e L i t e r a l s name=”FEMALE” value=”2” l i t e r a l=”FEMALE”/>
10 </ e C l a s s i f i e r s>
11 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=”Family”>
12 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name
=”name” lowerBound=”1” eType=”ecore:EDataType
http: //www. e c l i p s e . org /emf/2002/ Ecore#//EString ”/>
13 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=” i n d i v i d u a l s ” upperBound=”−1”
14 eType=”#//Individual ” containment=” true ”
eOpposite=”#//Individual / family ”/>
11
15 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=” laboratory ” lowerBound=”1”
16 eType=”#//Laboratory ” eOpposite=”#//Laboratory /
f a m i l i e s ”/>
17 </ e C l a s s i f i e r s>
18 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=” Laboratory ”
>
19 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=” f a m i l i e s ” upperBound=”−1”
20 eType=”#//Family” containment=” true ” eOpposite=”
#//Family/ laboratory ”/>
21 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=” sequencers ” upperBound=”−1”
22 eType=”#//Sequencer ” containment=” true ” eOpposite
=”#//Sequencer / laboratory ”/>
23 </ e C l a s s i f i e r s>
24 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=” Individual ”
>
25 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name
=” gender ” ordered=” f a l s e ”
26 unique=” f a l s e ” lowerBound=”1” eType=”#//Gender”
defaultValueLiteral=””/>
27 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=” family ” unique=” f a l s e ”
28 lowerBound=”1” eType=”#//Family” eOpposite=”#//
Family/ i n d i v i d u a l s ”/>
29 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=”Father” eType=”#//Individual ”/>
30 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name
=”name” eType=”ecore:EDataType http: //www. e c l i p s e .
org /emf/2002/ Ecore#//EString ”/>
31 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=”Mother” eType=”#//Individual ”/>
32 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=” samples ” upperBound=”−1”
33 eType=”#//Sample” containment=” true ” eOpposite=”
#//Sample/ individual ”/>
34 </ e C l a s s i f i e r s>
35 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=” Sequencer ”>
36 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name
=”name” lowerBound=”1” eType=”ecore:EDataType
http: //www. e c l i p s e . org /emf/2002/ Ecore#//EString ”/>
37 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=” runs ” upperBound=”−1” eType=”#//Run”
38 containment=” true ” eOpposite=”#//Run/ sequencer ”/>
12
39 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=” laboratory ” lowerBound=”1”
40 eType=”#//Laboratory ” eOpposite=”#//Laboratory /
sequencers ”/>
41 </ e C l a s s i f i e r s>
42 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=”Run”>
43 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name
=”name” lowerBound=”1” eType=”ecore:EDataType
http: //www. e c l i p s e . org /emf/2002/ Ecore#//EString ”/>
44 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name
=” date ” unique=” f a l s e ” eType=”ecore:EDataType
http: //www. e c l i p s e . org /emf/2002/ Ecore#//EDate”/>
45 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=” sequenced ” upperBound=”−1”
46 eType=”#//Sequenced” containment=” true ” eOpposite
=”#//Sequenced/run”/>
47 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=” sequencer ” lowerBound=”1”
48 eType=”#//Sequencer ” eOpposite=”#//Sequencer / runs
”/>
49 </ e C l a s s i f i e r s>
50 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=”Sample”>
51 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name
=” id ” lowerBound=”1” eType=”ecore:EDataType http:
//www. e c l i p s e . org /emf/2002/ Ecore#//EString ”/>
52 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=” individual ” lowerBound=”1”
53 eType=”#//Individual ” eOpposite=”#//Individual /
samples ”/>
54 </ e C l a s s i f i e r s>
55 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=”Sequenced”>
56 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=”run” unique=” f a l s e ” lowerBound=”1”
57 eType=”#//Run” eOpposite=”#//Run/ sequenced ”/>
58 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name
=”sample” unique=” f a l s e ”
59 lowerBound=”1” eType=”#//Sample”/>
60 </ e C l a s s i f i e r s>
61 </ ecore:EPackage>
3 GenModel
We’re going to generate the Genmodel for our model. The Genmodel
contains additional information for the codegeneration, e.g. the path and file
13
information.
3.1 Create the GenModel Project
• Menu File → New → New Project... → EMF Generator Project
• Select the folder EMF03-Model/model
• Set the file name to lims.genmodel
• select a "Model Importer": "Ecore model"
• import the model ”URI: platform:/resource/EMF03/model/lims.ecore”
3.2 Edit the GenModel Project
In the tree view of the Genmodel, click on the root node and edit its
properties:
• set All → Runtime Platform → to ”RCP”.
click on the package node ’Lims’ and edit its properties:
• set All → BasePackage → to ”com.github.lindenb.lims”.
1 <?xml version=” 1.0 ” encoding=”UTF−8”?>
2 <genmodel:GenModel xmi:version=” 2.0 ”
3 xmlns:xmi=” http: //www. omg . org /XMI” xmlns:ecore=” http:
//www. e c l i p s e . org /emf/2002/ Ecore”
4 xmlns:genmodel=” http: //www. e c l i p s e . org /emf/2002/
GenModel” copyrightText=” Pierre Lindenbaum PhD
2013”
5 modelDirectory=”/EMF03/ src ” modelPluginID=”EMF03”
modelName=”Lims” importerID=” org . e c l i p s e . emf .
importer . ecore ”
6 complianceLevel=” 6.0 ” copyrightFields=” f a l s e ”
language=”en” classNamePattern=””
7 runtimePlatform=”RCP”>
8 <foreignModel>lims . ecore</ foreignModel>
9 <genPackages p r e f i x=”Lims” basePackage=”com . github .
lindenb . lims ” disposableProviderFactory=” true ”
10 ecorePackage=” lims . ecore#/”>
11 <genEnums typeSafeEnumCompatible=” f a l s e ” ecoreEnum=”
lims . ecore#//Gender”>
12 <genEnumLiterals ecoreEnumLiteral=” lims . ecore#//
Gender/UNKNOWN”/>
13 <genEnumLiterals ecoreEnumLiteral=” lims . ecore#//
Gender/MALE”/>
14
14 <genEnumLiterals ecoreEnumLiteral=” lims . ecore#//
Gender/FEMALE”/>
15 </genEnums>
16 <genClasses ecoreClass=” lims . ecore#//Family”>
17 <genFeatures createChild=” f a l s e ” ecoreFeature=”
ecore:EAttribute lims . ecore#//Family/name”/>
18 <genFeatures property=”None” children=” true ”
createChild=” true ” ecoreFeature=”
ecore:EReference lims . ecore#//Family/ i n d i v i d u a l s
”/>
19 <genFeatures property=”None” no tify=” f a l s e ”
createChild=” f a l s e ” ecoreFeature=”
ecore:EReference lims . ecore#//Family/ laboratory ”
/>
20 </ genClasses>
21 <genClasses ecoreClass=” lims . ecore#//Laboratory ”>
22 <genFeatures property=”None” children=” true ”
createChild=” true ” ecoreFeature=”
ecore:EReference lims . ecore#//Laboratory /
f a m i l i e s ”/>
23 <genFeatures property=”None” children=” true ”
createChild=” true ” ecoreFeature=”
ecore:EReference lims . ecore#//Laboratory /
sequencers ”/>
24 </ genClasses>
25 <genClasses ecoreClass=” lims . ecore#//Individual ”>
26 <genFeatures createChild=” f a l s e ” ecoreFeature=”
ecore:EAttribute lims . ecore#//Individual / gender ”
/>
27 <genFeatures property=”None” no tify=” f a l s e ”
createChild=” f a l s e ” ecoreFeature=”
ecore:EReference lims . ecore#//Individual / family ”
/>
28 <genFeatures n otify=” f a l s e ” createChild=” f a l s e ”
propertySortChoices=” true ” ecoreFeature=”
ecore:EReference lims . ecore#//Individual /Father”
/>
29 <genFeatures createChild=” f a l s e ” ecoreFeature=”
ecore:EAttribute lims . ecore#//Individual /name”/>
30 <genFeatures n otify=” f a l s e ” createChild=” f a l s e ”
propertySortChoices=” true ” ecoreFeature=”
ecore:EReference lims . ecore#//Individual /Mother”
/>
31 <genFeatures property=”None” children=” true ”
createChild=” true ” ecoreFeature=”
ecore:EReference lims . ecore#//Individual / samples
15
”/>
32 </ genClasses>
33 <genClasses ecoreClass=” lims . ecore#//Sequencer ”>
34 <genFeatures n otify=” f a l s e ” createChild=” f a l s e ”
propertyDescription=”” ecoreFeature=”
ecore:EAttribute lims . ecore#//Sequencer /name”/>
35 <genFeatures property=”None” children=” true ”
createChild=” true ” ecoreFeature=”
ecore:EReference lims . ecore#//Sequencer / runs ”/>
36 <genFeatures property=”None” no tify=” f a l s e ”
createChild=” f a l s e ” ecoreFeature=”
ecore:EReference lims . ecore#//Sequencer /
laboratory ”/>
37 </ genClasses>
38 <genClasses ecoreClass=” lims . ecore#//Run”>
39 <genFeatures createChild=” f a l s e ” ecoreFeature=”
ecore:EAttribute lims . ecore#//Run/name”/>
40 <genFeatures createChild=” f a l s e ” ecoreFeature=”
ecore:EAttribute lims . ecore#//Run/ date ”/>
41 <genFeatures property=”None” children=” true ”
createChild=” true ” ecoreFeature=”
ecore:EReference lims . ecore#//Run/ sequenced ”/>
42 <genFeatures property=”None” children=” true ”
createChild=” true ” ecoreFeature=”
ecore:EReference lims . ecore#//Run/ sequencer ”/>
43 </ genClasses>
44 <genClasses ecoreClass=” lims . ecore#//Sample”>
45 <genFeatures createChild=” f a l s e ” ecoreFeature=”
ecore:EAttribute lims . ecore#//Sample/ id ”/>
46 <genFeatures property=”None” no tify=” f a l s e ”
createChild=” f a l s e ” ecoreFeature=”
ecore:EReference lims . ecore#//Sample/ individual ”
/>
47 </ genClasses>
48 <genClasses ecoreClass=” lims . ecore#//Sequenced”>
49 <genFeatures n otify=” f a l s e ” createChild=” f a l s e ”
propertySortChoices=” true ” ecoreFeature=”
ecore:EReference lims . ecore#//Sequenced/run”/>
50 <genFeatures n otify=” f a l s e ” createChild=” f a l s e ”
propertySortChoices=” true ” ecoreFeature=”
ecore:EReference lims . ecore#//Sequenced/sample”/
>
51 </ genClasses>
52 </genPackages>
53 </genmodel:GenModel>
16
4 Generating the code
In the tree view of the Genmodel, right click the root node: Generate All :
four new Eclipse plugins have been created:
• Model: contains the classes to create the instances of our model.
• EMF03.edit : classes to display a model in a UI (labels... )
• EMF03.editor: The editor plugin is a generated example editor to create
and modify instances of a model.
• EMF03.tests: The test plugin contains templates to write tests for a
model.
Here is an example of the interface com.github.lindenb.lims.Lims.Family
generated by EMF:
1 package com . github . l i n d e n b . l i m s . Lims ;
2
3 import org . e c l i p s e . emf . common . u t i l . EList ;
4
5 import org . e c l i p s e . emf . e c o r e . EObject ;
6
7 /∗∗
8 ∗ A r e p r e s e n t a t i o n o f t h e m o d e l o b j e c t ’<em><b>F a m i l y </b></em > ’.
9 ∗
10 ∗ The f o l l o w i n g f e a t u r e s a r e s u p p o r t e d :
11 ∗ <u l >
12 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . F a m i l y#g e t N a m e <em>Name</em>}</ l i >
13 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . F a m i l y# g e t I n d i v i d u a l s <em>I n d i v i d u a l s </
em>}</ l i >
14 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . F a m i l y# g e t L a b o r a t o r y <em>L a b o r a t o r y </em
>}</ l i >
15 ∗ </ u l >
16 ∗
17 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . L i m s P a c k a g e# g e t F a m i l y ( )
18 ∗ @model
19 ∗ @ g e n e r a t e d
20 ∗/
21 public i n t e r f a c e Family extends EObject
22 {
23 /∗∗
24 ∗ R e t u r n s t h e v a l u e o f t h e ’<em><b>Name</b></em>’ a t t r i b u t e .
25 ∗ I f t h e m e a n i n g o f t h e ’<em>Name</em>’ a t t r i b u t e i s n ’ t c l e a r ,
26 ∗ t h e r e r e a l l y s h o u l d b e more o f a d e s c r i p t i o n h e r e . . .
27 ∗ @ r e t u r n t h e v a l u e o f t h e ’<em>Name</em>’ a t t r i b u t e .
28 ∗ @ s e e #s e t N a m e ( S t r i n g )
29 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . L i m s P a c k a g e#g e t F a m i l y N a m e ( )
30 ∗ @model r e q u i r e d =” t r u e ”
31 ∗ @ g e n e r a t e d
32 ∗/
33 S t r i n g getName ( ) ;
34
35 /∗∗
36 ∗ S e t s t h e v a l u e o f t h e ’{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . F a m i l y#g e t N a m e
<em>Name</em>}’ a t t r i b u t e .
37 ∗ @param v a l u e t h e new v a l u e o f t h e ’<em>Name</em>’ a t t r i b u t e .
38 ∗ @ s e e #g e t N a m e ( )
39 ∗ @ g e n e r a t e d
40 ∗/
41 void setName ( S t r i n g v a l u e ) ;
42
43 /∗∗
44 ∗ R e t u r n s t h e v a l u e o f t h e ’<em><b>I n d i v i d u a l s </b></em>’ c o n t a i n m e n t
r e f e r e n c e l i s t .
45 ∗ The l i s t c o n t e n t s a r e o f t y p e { @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims .
I n d i v i d u a l } .
46 ∗ I t i s b i d i r e c t i o n a l and i t s o p p o s i t e i s ’{ @ l i n k com . g i t h u b . l i n d e n b . l i m s .
Lims . I n d i v i d u a l # g e t F a m i l y <em>F a m i l y </em >} ’.
47 ∗ I f t h e m e a n i n g o f t h e ’<em>I n d i v i d u a l s </em>’ c o n t a i n m e n t r e f e r e n c e l i s t
i s n ’ t c l e a r ,
48 ∗ t h e r e r e a l l y s h o u l d b e more o f a d e s c r i p t i o n h e r e . . .
49 ∗ @ r e t u r n t h e v a l u e o f t h e ’<em>I n d i v i d u a l s </em>’ c o n t a i n m e n t r e f e r e n c e
l i s t .
50 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . L i m s P a c k a g e# g e t F a m i l y I n d i v i d u a l s ( )
51 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . I n d i v i d u a l # g e t F a m i l y
52 ∗ @model o p p o s i t e =” f a m i l y ” c o n t a i n m e n t =” t r u e ”
17
53 ∗ @ g e n e r a t e d
54 ∗/
55 EList<I n d i v i d u a l > g e t I n d i v i d u a l s ( ) ;
56
57 /∗∗
58 ∗ R e t u r n s t h e v a l u e o f t h e ’<em><b>L a b o r a t o r y </b></em>’ c o n t a i n e r r e f e r e n c e
.
59 ∗ I t i s b i d i r e c t i o n a l and i t s o p p o s i t e i s ’{ @ l i n k com . g i t h u b . l i n d e n b . l i m s .
Lims . L a b o r a t o r y # g e t F a m i l i e s <em>F a m i l i e s </em >} ’.
60 ∗ I f t h e m e a n i n g o f t h e ’<em>L a b o r a t o r y </em>’ c o n t a i n e r r e f e r e n c e i s n ’ t
c l e a r ,
61 ∗ t h e r e r e a l l y s h o u l d b e more o f a d e s c r i p t i o n h e r e . . .
62 ∗ @ r e t u r n t h e v a l u e o f t h e ’<em>L a b o r a t o r y </em>’ c o n t a i n e r r e f e r e n c e .
63 ∗ @ s e e # s e t L a b o r a t o r y ( L a b o r a t o r y )
64 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . L i m s P a c k a g e# g e t F a m i l y L a b o r a t o r y ( )
65 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . L a b o r a t o r y # g e t F a m i l i e s
66 ∗ @model o p p o s i t e =” f a m i l i e s ” r e q u i r e d =” t r u e ” t r a n s i e n t =” f a l s e ”
67 ∗ @ g e n e r a t e d
68 ∗/
69 Laboratory g e t L a b o r a t o r y ( ) ;
70
71 /∗∗
72 ∗ S e t s t h e v a l u e o f t h e ’{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . F a m i l y#
g e t L a b o r a t o r y <em>L a b o r a t o r y </em>}’ c o n t a i n e r r e f e r e n c e .
73 ∗ @param v a l u e t h e new v a l u e o f t h e ’<em>L a b o r a t o r y </em>’ c o n t a i n e r
r e f e r e n c e .
74 ∗ @ s e e # g e t L a b o r a t o r y ( )
75 ∗ @ g e n e r a t e d
76 ∗/
77 void s e t L a b o r a t o r y ( Laboratory v a l u e ) ;
78
79 } // F a m i l y
and the implementation of the interface: com.github.lindenb.lims.Lims.impl.FamilyImpl
:
1 package com . github . l i n d e n b . l i m s . Lims . impl ;
2
3 import com . github . l i n d e n b . l i m s . Lims . Family ;
4 import com . github . l i n d e n b . l i m s . Lims . I n d i v i d u a l ;
5 import com . github . l i n d e n b . l i m s . Lims . Laboratory ;
6 import com . github . l i n d e n b . l i m s . Lims . LimsPackage ;
7
8 import j a v a . u t i l . C o l l e c t i o n ;
9
10 import org . e c l i p s e . emf . common . n o t i f y . N o t i f i c a t i o n ;
11 import org . e c l i p s e . emf . common . n o t i f y . N o t i f i c a t i o n C h a i n ;
12
13 import org . e c l i p s e . emf . common . u t i l . EList ;
14
15 import org . e c l i p s e . emf . e c o r e . EClass ;
16 import org . e c l i p s e . emf . e c o r e . I n t e r n a l E O b j e c t ;
17
18 import org . e c l i p s e . emf . e c o r e . impl . E N o t i f i c a t i o n I m p l ;
19 import org . e c l i p s e . emf . e c o r e . impl . EObjectImpl ;
20
21 import org . e c l i p s e . emf . e c o r e . u t i l . EObjectContainmentWithInverseEList ;
22 import org . e c l i p s e . emf . e c o r e . u t i l . E c o r e U t i l ;
23 import org . e c l i p s e . emf . e c o r e . u t i l . I n t e r n a l E L i s t ;
24
25 /∗∗
26 ∗ An i m p l e m e n t a t i o n o f t h e m o d e l o b j e c t ’<em><b>F a m i l y </b></em > ’.
27 ∗ The f o l l o w i n g f e a t u r e s a r e i m p l e m e n t e d :
28 ∗ <u l >
29 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . i m p l . F a m i l y I m p l#g e t N a m e <em>Name</em
>}</ l i >
30 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . i m p l . F a m i l y I m p l# g e t I n d i v i d u a l s <em>
I n d i v i d u a l s </em>}</ l i >
31 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . i m p l . F a m i l y I m p l# g e t L a b o r a t o r y <em>
L a b o r a t o r y </em>}</ l i >
32 ∗ </ u l >
33 ∗
34 ∗ @ g e n e r a t e d
35 ∗/
36 public c l a s s FamilyImpl extends EObjectImpl implements Family
37 {
38 /∗∗
39 ∗ The d e f a u l t v a l u e o f t h e ’{ @ l i n k #g e t N a m e ( ) <em>Name</em>}’ a t t r i b u t e .
40 ∗ @ s e e #g e t N a m e ( )
41 ∗ @ g e n e r a t e d
42 ∗ @ o r d e r e d
43 ∗/
44 protected s t a t i c f i n a l S t r i n g NAME EDEFAULT = null ;
45
46 /∗∗
47 ∗ The c a c h e d v a l u e o f t h e ’{ @ l i n k #g e t N a m e ( ) <em>Name</em>}’ a t t r i b u t e .
48 ∗ @ s e e #g e t N a m e ( )
49 ∗ @ g e n e r a t e d
18
50 ∗ @ o r d e r e d
51 ∗/
52 protected S t r i n g name = NAME EDEFAULT;
53
54 /∗∗
55 ∗ The c a c h e d v a l u e o f t h e ’{ @ l i n k # g e t I n d i v i d u a l s ( ) <em>I n d i v i d u a l s </em>}’
c o n t a i n m e n t r e f e r e n c e l i s t .
56 ∗ @ s e e # g e t I n d i v i d u a l s ( )
57 ∗ @ g e n e r a t e d
58 ∗ @ o r d e r e d
59 ∗/
60 protected EList<I n d i v i d u a l > i n d i v i d u a l s ;
61
62 /∗∗
63 ∗ @ g e n e r a t e d
64 ∗/
65 protected FamilyImpl ( )
66 {
67 super ( ) ;
68 }
69
70 /∗∗
71 ∗ @ g e n e r a t e d
72 ∗/
73 @Override
74 protected EClass e S t a t i c C l a s s ( )
75 {
76 return LimsPackage . L i t e r a l s .FAMILY;
77 }
78
79 /∗∗
80 ∗ @ g e n e r a t e d
81 ∗/
82 public S t r i n g getName ( )
83 {
84 return name ;
85 }
86
87 /∗∗
88 ∗ @ g e n e r a t e d
89 ∗/
90 public void setName ( S t r i n g newName)
91 {
92 S t r i n g oldName = name ;
93 name = newName ;
94 i f ( e N o t i f i c a t i o n R e q u i r e d ( ) )
95 e N o t i f y (new E N o t i f i c a t i o n I m p l ( this , N o t i f i c a t i o n . SET,
LimsPackage . FAMILY NAME, oldName , name ) ) ;
96 }
97
98 /∗∗
99 ∗ @ g e n e r a t e d
100 ∗/
101 public EList<I n d i v i d u a l > g e t I n d i v i d u a l s ( )
102 {
103 i f ( i n d i v i d u a l s == null )
104 {
105 i n d i v i d u a l s = new EObjectContainmentWithInverseEList<
I n d i v i d u a l >( I n d i v i d u a l . class , this , LimsPackage .
FAMILY INDIVIDUALS , LimsPackage . INDIVIDUAL FAMILY) ;
106 }
107 return i n d i v i d u a l s ;
108 }
109
110 /∗∗
111 ∗ @ g e n e r a t e d
112 ∗/
113 public Laboratory g e t L a b o r a t o r y ( )
114 {
115 i f ( eContainerFeatureID ( ) != LimsPackage .FAMILY LABORATORY) return
null ;
116 return ( Laboratory ) eContainer ( ) ;
117 }
118
119 /∗∗
120 ∗ @ g e n e r a t e d
121 ∗/
122 public N o t i f i c a t i o n C h a i n b a s i c S e t L a b o r a t o r y ( Laboratory newLaboratory ,
N o t i f i c a t i o n C h a i n msgs )
123 {
124 msgs = e B a s i c S e t C o n t a i n e r ( ( I n t e r n a l E O b j e c t ) newLaboratory ,
LimsPackage .FAMILY LABORATORY, msgs ) ;
125 return msgs ;
126 }
127
128 /∗∗
129 ∗ @ g e n e r a t e d
130 ∗/
131 public void s e t L a b o r a t o r y ( Laboratory newLaboratory )
132 {
19
133 i f ( newLaboratory != e I n t e r n a l C o n t a i n e r ( ) | | ( eContainerFeatureID ( )
!= LimsPackage .FAMILY LABORATORY && newLaboratory != null ) )
134 {
135 i f ( E c o r e U t i l . i s A n c e s t o r ( this , newLaboratory ) )
136 throw new I l l e g a l A r g u m e n t E x c e p t i o n ( ” R e c u r s i v e
containment not a l l o w e d f o r ” + t o S t r i n g ( ) ) ;
137 N o t i f i c a t i o n C h a i n msgs = null ;
138 i f ( e I n t e r n a l C o n t a i n e r ( ) != null )
139 msgs = eBasicRemoveFromContainer ( msgs ) ;
140 i f ( newLaboratory != null )
141 msgs = ( ( I n t e r n a l E O b j e c t ) newLaboratory ) . eInverseAdd (
this , LimsPackage . LABORATORY FAMILIES,
Laboratory . class , msgs ) ;
142 msgs = b a s i c S e t L a b o r a t o r y ( newLaboratory , msgs ) ;
143 i f ( msgs != null ) msgs . d i s p a t c h ( ) ;
144 }
145 e l s e i f ( e N o t i f i c a t i o n R e q u i r e d ( ) )
146 e N o t i f y (new E N o t i f i c a t i o n I m p l ( this , N o t i f i c a t i o n . SET,
LimsPackage .FAMILY LABORATORY, newLaboratory ,
newLaboratory ) ) ;
147 }
148
149 /∗∗
150 ∗ @ g e n e r a t e d
151 ∗/
152 @SuppressWarnings ( ” unchecked ” )
153 @Override
154 public N o t i f i c a t i o n C h a i n eInverseAdd ( I n t e r n a l E O b j e c t otherEnd , int f e a t u r e I D
, N o t i f i c a t i o n C h a i n msgs )
155 {
156 switch ( f e a t u r e I D )
157 {
158 case LimsPackage . FAMILY INDIVIDUALS :
159 return ( ( I n t e r n a l E L i s t <I n t e r n a l E O b j e c t >)(
I n t e r n a l E L i s t <?>) g e t I n d i v i d u a l s ( ) ) . basicAdd (
otherEnd , msgs ) ;
160 case LimsPackage .FAMILY LABORATORY:
161 i f ( e I n t e r n a l C o n t a i n e r ( ) != null )
162 msgs = eBasicRemoveFromContainer ( msgs ) ;
163 return b a s i c S e t L a b o r a t o r y ( ( Laboratory ) otherEnd , msgs
) ;
164 }
165 return super . eInverseAdd ( otherEnd , f e a t u r e I D , msgs ) ;
166 }
167
168 /∗∗
169 ∗ @ g e n e r a t e d
170 ∗/
171 @Override
172 public N o t i f i c a t i o n C h a i n eInverseRemove ( I n t e r n a l E O b j e c t otherEnd , int
f e a t u r e I D , N o t i f i c a t i o n C h a i n msgs )
173 {
174 switch ( f e a t u r e I D )
175 {
176 case LimsPackage . FAMILY INDIVIDUALS :
177 return ( ( I n t e r n a l E L i s t <?>) g e t I n d i v i d u a l s ( ) ) .
basicRemove ( otherEnd , msgs ) ;
178 case LimsPackage .FAMILY LABORATORY:
179 return b a s i c S e t L a b o r a t o r y ( null , msgs ) ;
180 }
181 return super . eInverseRemove ( otherEnd , f e a t u r e I D , msgs ) ;
182 }
183
184 /∗∗
185 ∗ @ g e n e r a t e d
186 ∗/
187 @Override
188 public N o t i f i c a t i o n C h a i n eBasicRemoveFromContainerFeature ( N o t i f i c a t i o n C h a i n
msgs )
189 {
190 switch ( eContainerFeatureID ( ) )
191 {
192 case LimsPackage .FAMILY LABORATORY:
193 return e I n t e r n a l C o n t a i n e r ( ) . eInverseRemove ( this ,
LimsPackage . LABORATORY FAMILIES, Laboratory .
class , msgs ) ;
194 }
195 return super . eBasicRemoveFromContainerFeature ( msgs ) ;
196 }
197
198 /∗∗
199 ∗ @ g e n e r a t e d
200 ∗/
201 @Override
202 public Object eGet ( int f e a t u r e I D , boolean r e s o l v e , boolean coreType )
203 {
204 switch ( f e a t u r e I D )
205 {
206 case LimsPackage . FAMILY NAME :
207 return getName ( ) ;
208 case LimsPackage . FAMILY INDIVIDUALS :
20
209 return g e t I n d i v i d u a l s ( ) ;
210 case LimsPackage .FAMILY LABORATORY:
211 return g e t L a b o r a t o r y ( ) ;
212 }
213 return super . eGet ( f e a t u r e I D , r e s o l v e , coreType ) ;
214 }
215
216 /∗∗
217 ∗ @ g e n e r a t e d
218 ∗/
219 @SuppressWarnings ( ” unchecked ” )
220 @Override
221 public void e S e t ( int f e a t u r e I D , Object newValue )
222 {
223 switch ( f e a t u r e I D )
224 {
225 case LimsPackage . FAMILY NAME :
226 setName ( ( S t r i n g ) newValue ) ;
227 return ;
228 case LimsPackage . FAMILY INDIVIDUALS :
229 g e t I n d i v i d u a l s ( ) . c l e a r ( ) ;
230 g e t I n d i v i d u a l s ( ) . addAll ( ( C o l l e c t i o n <? extends
I n d i v i d u a l >)newValue ) ;
231 return ;
232 case LimsPackage .FAMILY LABORATORY:
233 s e t L a b o r a t o r y ( ( Laboratory ) newValue ) ;
234 return ;
235 }
236 super . e S e t ( f e a t u r e I D , newValue ) ;
237 }
238
239 /∗∗
240 ∗ @ g e n e r a t e d
241 ∗/
242 @Override
243 public void eUnset ( int f e a t u r e I D )
244 {
245 switch ( f e a t u r e I D )
246 {
247 case LimsPackage . FAMILY NAME :
248 setName (NAME EDEFAULT) ;
249 return ;
250 case LimsPackage . FAMILY INDIVIDUALS :
251 g e t I n d i v i d u a l s ( ) . c l e a r ( ) ;
252 return ;
253 case LimsPackage .FAMILY LABORATORY:
254 s e t L a b o r a t o r y ( ( Laboratory ) null ) ;
255 return ;
256 }
257 super . eUnset ( f e a t u r e I D ) ;
258 }
259
260 /∗∗
261 ∗ @ g e n e r a t e d
262 ∗/
263 @Override
264 public boolean e I s S e t ( int f e a t u r e I D )
265 {
266 switch ( f e a t u r e I D )
267 {
268 case LimsPackage . FAMILY NAME :
269 return NAME EDEFAULT == null ? name != null : !
NAME EDEFAULT. e q u a l s ( name ) ;
270 case LimsPackage . FAMILY INDIVIDUALS :
271 return i n d i v i d u a l s != null && ! i n d i v i d u a l s . isEmpty ( )
;
272 case LimsPackage .FAMILY LABORATORY:
273 return g e t L a b o r a t o r y ( ) != null ;
274 }
275 return super . e I s S e t ( f e a t u r e I D ) ;
276 }
277
278 /∗∗
279 ∗ @ g e n e r a t e d
280 ∗/
281 @Override
282 public S t r i n g t o S t r i n g ( )
283 {
284 i f ( eIsProxy ( ) ) return super . t o S t r i n g ( ) ;
285
286 S t r i n g B u f f e r r e s u l t = new S t r i n g B u f f e r ( super . t o S t r i n g ( ) ) ;
287 r e s u l t . append ( ” ( name : ” ) ;
288 r e s u l t . append ( name ) ;
289 r e s u l t . append ( ’ ) ’ ) ;
290 return r e s u l t . t o S t r i n g ( ) ;
291 }
292
293 } // F a m i l y I m p l
21
5 Create a new eclipse product
• Menu File → New → Other... → Product Configuration
• Wizard: set parent folder: EMF03/model
• Wizard: set the file name: ”lims.product”.
• Wizard: Ask to create a basic config
Open the editor for ’lims.product”.
• in Overview/Product Definition/Product → create a new product .
Defining plugin :”EMF03”, product ID : ”lims”, Application : "EMF03.editor.LimsEditorEdito
• in Depedencies/Plugins and fragments: add EMF03, EMF03.edit, EMF03.editor
• check "include optional dependencies"
• click "Add required plug-in"
• in Lauching/Program Launcher set Launcher Name to ”lims”.
The content of the product file is displayed below:
1 <?xml version=” 1.0 ” encoding=”UTF−8”?>
2 <?pde version=” 3.5 ”?>
3
4 <product name=”Lims” uid=”LIMS” id=”EMF03. lims ”
application=”EMF03. editor . LimsEditorAdvisorApplication
” version=” 1 . 0 . 0 ” useFeatures=” f a l s e ” includeLaunchers
=” true ”>
5
6 <c o n f i g I n i use=” default ”>
7 </ c o n f i g I n i>
8
9 <launcherArgs>
10 <vmArgsMac>−XstartOnFirstThread −Dorg . e c l i p s e . swt .
i n t e r n a l . carbon . smallFonts</vmArgsMac>
11 </ launcherArgs>
12
13 <launcher name=” lims ”>
14 <s o l a r i s />
15 <win useIco=” f a l s e ”>
16 <bmp/>
17 </win>
18 </ launcher>
19
22
20 <vm>
21 </vm>
22
23 <plugins>
24 <plugin id=”EMF03”/>
25 <plugin id=”EMF03. edit ”/>
26 <plugin id=”EMF03. editor ”/>
27 <plugin id=”com . ibm . icu ”/>
28 <plugin id=” javax . s e r v l e t ”/>
29 <plugin id=” javax . transaction ” fragment=” true ”/>
30 <plugin id=” org . e c l i p s e . ant . core ”/>
31 <plugin id=” org . e c l i p s e . core . commands”/>
32 <plugin id=” org . e c l i p s e . core . contenttype ”/>
33 <plugin id=” org . e c l i p s e . core . databinding ”/>
34 <plugin id=” org . e c l i p s e . core . databinding . observable
”/>
35 <plugin id=” org . e c l i p s e . core . databinding . property ”/
>
36 <plugin id=” org . e c l i p s e . core . expressions ”/>
37 <plugin id=” org . e c l i p s e . core . f i l e s y s t e m ”/>
38 <plugin id=” org . e c l i p s e . core . f i l e s y s t e m . linux . x86”
fragment=” true ”/>
39 <plugin id=” org . e c l i p s e . core . jobs ”/>
40 <plugin id=” org . e c l i p s e . core . resources ”/>
41 <plugin id=” org . e c l i p s e . core . runtime”/>
42 <plugin id=” org . e c l i p s e . core . runtime . compatibility .
auth”/>
43 <plugin id=” org . e c l i p s e . core . runtime . compatibility .
r e g i s t r y ” fragment=” true ”/>
44 <plugin id=” org . e c l i p s e . core . v a r i a b l e s ”/>
45 <plugin id=” org . e c l i p s e . emf . common”/>
46 <plugin id=” org . e c l i p s e . emf . common . ui ”/>
47 <plugin id=” org . e c l i p s e . emf . ecore ”/>
48 <plugin id=” org . e c l i p s e . emf . ecore . change”/>
49 <plugin id=” org . e c l i p s e . emf . ecore . xmi”/>
50 <plugin id=” org . e c l i p s e . emf . edit ”/>
51 <plugin id=” org . e c l i p s e . emf . edit . ui ”/>
52 <plugin id=” org . e c l i p s e . equinox . app”/>
53 <plugin id=” org . e c l i p s e . equinox . common”/>
54 <plugin id=” org . e c l i p s e . equinox . p2 . core ”/>
55 <plugin id=” org . e c l i p s e . equinox . p2 . engine ”/>
56 <plugin id=” org . e c l i p s e . equinox . p2 . metadata”/>
57 <plugin id=” org . e c l i p s e . equinox . p2 . metadata .
repository ”/>
58 <plugin id=” org . e c l i p s e . equinox . p2 . repository ”/>
59 <plugin id=” org . e c l i p s e . equinox . preferences ”/>
23
60 <plugin id=” org . e c l i p s e . equinox . r e g i s t r y ”/>
61 <plugin id=” org . e c l i p s e . equinox . s e c u r i t y ”/>
62 <plugin id=” org . e c l i p s e . help ”/>
63 <plugin id=” org . e c l i p s e . j f a c e ”/>
64 <plugin id=” org . e c l i p s e . j f a c e . databinding ”/>
65 <plugin id=” org . e c l i p s e . j f a c e . text ”/>
66 <plugin id=” org . e c l i p s e . osgi ”/>
67 <plugin id=” org . e c l i p s e . osgi . s e r v i c e s ”/>
68 <plugin id=” org . e c l i p s e . swt”/>
69 <plugin id=” org . e c l i p s e . swt . gtk . linux . x86” fragment
=” true ”/>
70 <plugin id=” org . e c l i p s e . text ”/>
71 <plugin id=” org . e c l i p s e . ui ”/>
72 <plugin id=” org . e c l i p s e . ui . forms”/>
73 <plugin id=” org . e c l i p s e . ui . ide ”/>
74 <plugin id=” org . e c l i p s e . ui . views ”/>
75 <plugin id=” org . e c l i p s e . ui . workbench”/>
76 </ plugins>
77
78
79 </ product>
6 Generating the Eclipse Product
• File → Export → Eclipse Product .
• Set configuration : ”EMF03/model/lims.product” .
• Set the destination directory .
• Uncheck "Generate metadata repository" .
• "Finish"
Congratulations, your client has been generated.
7 Running the Lims editor
Go to the generated application directory and run:
$ cd /path/ to /GENERATED
$ ./ lims &
Here is a screenshot of the generated ’lims’ application:
24
Here is an example of a data file handled by the ’lims’ application:
1 <?xml version=” 1.0 ” encoding=”UTF−8”?>
2 <lims:Laboratory xmi:version=” 2.0 ” xmlns:xmi=” http: //www.
omg . org /XMI” xmlns:lims=” http: //univ−nantes . f r / lims /”>
3 <f a m i l i e s name=”Family1”>
4 <i n d i v i d u a l s name=” indi1 ”/>
5 <i n d i v i d u a l s Father=”// @families .0/ @individuals .0 ”
name=” indi2 ”>
6 <samples id=”CD00001”/>
7 </ i n d i v i d u a l s>
8 </ f a m i l i e s>
9 <sequencers name=”HiSeq”>
10 <runs name=”CD1786CXX”>
11 <sequenced sample=”// @families .0/ @individuals .1/
@samples .0 ”/>
12 </ runs>
13 </ sequencers>
14 <sequencers name=”miseq”>
15 <runs name=”CXX01”>
16 <sequenced sample=”// @families .0/ @individuals .1/
@samples .0 ”/>
17 </ runs>
18 </ sequencers>
19 </ lims:Laboratory>
That’s it,
Pierre
25
8 References
• Source for this tutorial: https://github.com/lindenb/courses/tree/
master/about.emf
• The Eclipse Modeling Framework Overview : http://help.eclipse.
org/juno/index.jsp?topic=%2Forg.eclipse.emf.doc%2Freferences%
2Foverview%2FEMF.html
• Eclipse Modeling Framework (EMF) - Tutorial : http://www.vogella.
com/articles/EclipseEMF/article.html
26

More Related Content

More from Pierre Lindenbaum (20)

Next Generation Sequencing file Formats ( 2017 )
Next Generation Sequencing file Formats ( 2017 )Next Generation Sequencing file Formats ( 2017 )
Next Generation Sequencing file Formats ( 2017 )
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
Mum, I 3D printed a gel comb !
Mum, I 3D printed a gel comb !Mum, I 3D printed a gel comb !
Mum, I 3D printed a gel comb !
 
Make
MakeMake
Make
 
XML for bioinformatics
XML for bioinformaticsXML for bioinformatics
XML for bioinformatics
 
20120423.NGS.Rennes
20120423.NGS.Rennes20120423.NGS.Rennes
20120423.NGS.Rennes
 
Sketching 20120412
Sketching 20120412Sketching 20120412
Sketching 20120412
 
Introduction to mongodb for bioinformatics
Introduction to mongodb for bioinformaticsIntroduction to mongodb for bioinformatics
Introduction to mongodb for bioinformatics
 
Biostar17037
Biostar17037Biostar17037
Biostar17037
 
Tweeting for the BioStar Paper
Tweeting for the BioStar PaperTweeting for the BioStar Paper
Tweeting for the BioStar Paper
 
Variation Toolkit
Variation ToolkitVariation Toolkit
Variation Toolkit
 
Bioinformatician 2.0
Bioinformatician 2.0Bioinformatician 2.0
Bioinformatician 2.0
 
Analyzing Exome Data with KNIME
Analyzing Exome Data with KNIMEAnalyzing Exome Data with KNIME
Analyzing Exome Data with KNIME
 
NOTCH2 backstage
NOTCH2 backstageNOTCH2 backstage
NOTCH2 backstage
 
Bioinfo tweets
Bioinfo tweetsBioinfo tweets
Bioinfo tweets
 
Post doctoriales 2011
Post doctoriales 2011Post doctoriales 2011
Post doctoriales 2011
 
20110114 Next Generation Sequencing Course
20110114 Next Generation Sequencing Course20110114 Next Generation Sequencing Course
20110114 Next Generation Sequencing Course
 
MyWordle.java
MyWordle.javaMyWordle.java
MyWordle.java
 
Biblio2.0
Biblio2.0Biblio2.0
Biblio2.0
 
Me & Biohackathon 2010
Me & Biohackathon 2010Me & Biohackathon 2010
Me & Biohackathon 2010
 

Recently uploaded

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Recently uploaded (20)

How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

Building a Simple LIMS with the Eclipse Modeling Framework (EMF) ,my notebook

  • 1. EMF Notebook Pierre Lindenbaum @yokofakun http://plindenbaum.blogspot.com September 10, 2013 Abstract EMF (The Eclipse Modeling Framework) is a Java framework and code generation facility for building tools and other applications based on a structured model. Once you specify an EMF model, the EMF generator can create a corresponding set of Java implementation classes. In the following tutorial I’m going to generate a simple-and-stupid LIMS. We’re going to create an interface for a simple-and-stupid LIMS. 1
  • 2. • A laboratory contains a list of Families • A laboratory contains a list of Sequencers • a family contains a list of Individuals • an Individual contains a list of Samples • a Sequencer contains a list of Runs • a Run contains a list of Sequenced which links to a Sample. At the end of this tutorial, we’re going to generate the following heavy client for our model: 1 Install the EMF plugins for Eclipse see http://wiki.eclipse.org/EMF/Installation#Install_EMF. 2 Creating the Model A model is created and defined in the Ecore format, which is basically a sub-set of UML Class diagrams. 2
  • 3. 2.1 Create the Project • Open Eclipse • Menu File → New → New Project... → Empty EMF Project • Name the project EMF03-Model 2.2 Create the ECore model create a new ’ECore’ file in the model folder in your new modeling project. • Menu File → New → Other.. → ECore Model • Wizard: select the folder EMF03-Model/model. • Wizard: set the filename as lims.ecore. • Wizard: set Model Object as EPackage. • Menu Window → Show View → Other → Properties An EPackage named Lims is created. The package contains 7 EClass and 1 EEnum(s). The EPackage Lims is defined as below: Key Value name Lims nsURI http://univ-nantes.fr/lims/ nsPrefix lims Next, were going to create the EEnum and the EClass: • In the tree view right click on the node EPackage ”Lims” , create a new EEnum and set the name property to ”Gender”. • In the tree view right click on the node EPackage ”Lims” , create a new EClass and set the name property to ”Family”. • In the tree view right click on the node EPackage ”Lims” , create a new EClass and set the name property to ”Laboratory”. • In the tree view right click on the node EPackage ”Lims” , create a new EClass and set the name property to ”Individual”. • In the tree view right click on the node EPackage ”Lims” , create a new EClass and set the name property to ”Sequencer”. • In the tree view right click on the node EPackage ”Lims” , create a new EClass and set the name property to ”Run”. • In the tree view right click on the node EPackage ”Lims” , create a new EClass and set the name property to ”Sample”. 3
  • 4. • In the tree view right click on the node EPackage ”Lims” , create a new EClass and set the name property to ”Sequenced”. Then, we complete the structure of each classifier: 2.3 Gender In the tree view, right-click on the node EEnum ”Gender” and add the following 3 eLiterals: Name Literal Value UNKNOWN UNKNOWN MALE MALE 1 FEMALE FEMALE 2 2.4 Family In the tree view, select the node EClass ”Lims” and set the following prop- erties: Key Value name Family We add some structural features to the EClass ”Family”: 2.4.1 Family:name In the tree view, right click on the node EClass ”Family” Create a new EAttribute named ”name” and set its properties: Key Value name name lowerBound 1 eType EString 2.4.2 Family:individuals In the tree view, right click on the node EClass ”Family” Create a new EReference named ”individuals” and set its properties: Key Value name individuals upperBound -1 (unbounded) eType -//Individual containment true eOpposite -//Individual/family 4
  • 5. 2.4.3 Family:laboratory In the tree view, right click on the node EClass ”Family” Create a new EReference named ”laboratory” and set its properties: Key Value name laboratory lowerBound 1 eType -//Laboratory eOpposite -//Laboratory/families 2.5 Laboratory In the tree view, select the node EClass ”Lims” and set the following prop- erties: Key Value name Laboratory We add some structural features to the EClass ”Laboratory”: 2.5.1 Laboratory:families In the tree view, right click on the node EClass ”Laboratory” Create a new EReference named ”families” and set its properties: Key Value name families upperBound -1 (unbounded) eType -//Family containment true eOpposite -//Family/laboratory 2.5.2 Laboratory:sequencers In the tree view, right click on the node EClass ”Laboratory” Create a new EReference named ”sequencers” and set its properties: Key Value name sequencers upperBound -1 (unbounded) eType -//Sequencer containment true eOpposite -//Sequencer/laboratory 5
  • 6. 2.6 Individual In the tree view, select the node EClass ”Lims” and set the following prop- erties: Key Value name Individual We add some structural features to the EClass ”Individual”: 2.6.1 Individual:gender In the tree view, right click on the node EClass ”Individual” Create a new EAttribute named ”gender” and set its properties: Key Value name gender ordered false unique false lowerBound 1 eType -//Gender defaultValueLiteral 2.6.2 Individual:family In the tree view, right click on the node EClass ”Individual” Create a new EReference named ”family” and set its properties: Key Value name family unique false lowerBound 1 eType -//Family eOpposite -//Family/individuals 2.6.3 Individual:Father In the tree view, right click on the node EClass ”Individual” Create a new EReference named ”Father” and set its properties: Key Value name Father eType -//Individual 6
  • 7. 2.6.4 Individual:name In the tree view, right click on the node EClass ”Individual” Create a new EAttribute named ”name” and set its properties: Key Value name name eType EString 2.6.5 Individual:Mother In the tree view, right click on the node EClass ”Individual” Create a new EReference named ”Mother” and set its properties: Key Value name Mother eType -//Individual 2.6.6 Individual:samples In the tree view, right click on the node EClass ”Individual” Create a new EReference named ”samples” and set its properties: Key Value name samples upperBound -1 (unbounded) eType -//Sample containment true eOpposite -//Sample/individual 2.7 Sequencer In the tree view, select the node EClass ”Lims” and set the following prop- erties: Key Value name Sequencer We add some structural features to the EClass ”Sequencer”: 7
  • 8. 2.7.1 Sequencer:name In the tree view, right click on the node EClass ”Sequencer” Create a new EAttribute named ”name” and set its properties: Key Value name name lowerBound 1 eType EString 2.7.2 Sequencer:runs In the tree view, right click on the node EClass ”Sequencer” Create a new EReference named ”runs” and set its properties: Key Value name runs upperBound -1 (unbounded) eType -//Run containment true eOpposite -//Run/sequencer 2.7.3 Sequencer:laboratory In the tree view, right click on the node EClass ”Sequencer” Create a new EReference named ”laboratory” and set its properties: Key Value name laboratory lowerBound 1 eType -//Laboratory eOpposite -//Laboratory/sequencers 2.8 Run In the tree view, select the node EClass ”Lims” and set the following prop- erties: Key Value name Run We add some structural features to the EClass ”Run”: 8
  • 9. 2.8.1 Run:name In the tree view, right click on the node EClass ”Run” Create a new EAt- tribute named ”name” and set its properties: Key Value name name lowerBound 1 eType EString 2.8.2 Run:date In the tree view, right click on the node EClass ”Run” Create a new EAt- tribute named ”date” and set its properties: Key Value name date unique false eType EDate 2.8.3 Run:sequenced In the tree view, right click on the node EClass ”Run” Create a new ERef- erence named ”sequenced” and set its properties: Key Value name sequenced upperBound -1 (unbounded) eType -//Sequenced containment true eOpposite -//Sequenced/run 2.8.4 Run:sequencer In the tree view, right click on the node EClass ”Run” Create a new ERef- erence named ”sequencer” and set its properties: Key Value name sequencer lowerBound 1 eType -//Sequencer eOpposite -//Sequencer/runs 9
  • 10. 2.9 Sample In the tree view, select the node EClass ”Lims” and set the following prop- erties: Key Value name Sample We add some structural features to the EClass ”Sample”: 2.9.1 Sample:id In the tree view, right click on the node EClass ”Sample” Create a new EAttribute named ”id” and set its properties: Key Value name id lowerBound 1 eType EString 2.9.2 Sample:individual In the tree view, right click on the node EClass ”Sample” Create a new EReference named ”individual” and set its properties: Key Value name individual lowerBound 1 eType -//Individual eOpposite -//Individual/samples 2.10 Sequenced In the tree view, select the node EClass ”Lims” and set the following prop- erties: Key Value name Sequenced We add some structural features to the EClass ”Sequenced”: 10
  • 11. 2.10.1 Sequenced:run In the tree view, right click on the node EClass ”Sequenced” Create a new EReference named ”run” and set its properties: Key Value name run unique false lowerBound 1 eType -//Run eOpposite -//Run/sequenced 2.10.2 Sequenced:sample In the tree view, right click on the node EClass ”Sequenced” Create a new EReference named ”sample” and set its properties: Key Value name sample unique false lowerBound 1 eType -//Sample All in one, the file lims.ecore looks like this: 1 <?xml version=” 1.0 ” encoding=”UTF−8”?> 2 <ecore:EPackage xmi:version=” 2.0 ” 3 xmlns:xmi=” http: //www. omg . org /XMI” xmlns:xsi=” http: // www. w3 . org /2001/XMLSchema−instance ” 4 xmlns:ecore=” http: //www. e c l i p s e . org /emf/2002/ Ecore” name=”Lims” 5 nsURI=” http: //univ−nantes . f r / lims /” nsPrefix=” lims ”> 6 <e C l a s s i f i e r s x s i : t y p e=”ecore:EEnum” name=”Gender”> 7 <e L i t e r a l s name=”UNKNOWN” l i t e r a l=”UNKNOWN”/> 8 <e L i t e r a l s name=”MALE” value=”1” l i t e r a l=”MALE”/> 9 <e L i t e r a l s name=”FEMALE” value=”2” l i t e r a l=”FEMALE”/> 10 </ e C l a s s i f i e r s> 11 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=”Family”> 12 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name =”name” lowerBound=”1” eType=”ecore:EDataType http: //www. e c l i p s e . org /emf/2002/ Ecore#//EString ”/> 13 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =” i n d i v i d u a l s ” upperBound=”−1” 14 eType=”#//Individual ” containment=” true ” eOpposite=”#//Individual / family ”/> 11
  • 12. 15 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =” laboratory ” lowerBound=”1” 16 eType=”#//Laboratory ” eOpposite=”#//Laboratory / f a m i l i e s ”/> 17 </ e C l a s s i f i e r s> 18 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=” Laboratory ” > 19 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =” f a m i l i e s ” upperBound=”−1” 20 eType=”#//Family” containment=” true ” eOpposite=” #//Family/ laboratory ”/> 21 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =” sequencers ” upperBound=”−1” 22 eType=”#//Sequencer ” containment=” true ” eOpposite =”#//Sequencer / laboratory ”/> 23 </ e C l a s s i f i e r s> 24 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=” Individual ” > 25 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name =” gender ” ordered=” f a l s e ” 26 unique=” f a l s e ” lowerBound=”1” eType=”#//Gender” defaultValueLiteral=””/> 27 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =” family ” unique=” f a l s e ” 28 lowerBound=”1” eType=”#//Family” eOpposite=”#// Family/ i n d i v i d u a l s ”/> 29 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =”Father” eType=”#//Individual ”/> 30 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name =”name” eType=”ecore:EDataType http: //www. e c l i p s e . org /emf/2002/ Ecore#//EString ”/> 31 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =”Mother” eType=”#//Individual ”/> 32 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =” samples ” upperBound=”−1” 33 eType=”#//Sample” containment=” true ” eOpposite=” #//Sample/ individual ”/> 34 </ e C l a s s i f i e r s> 35 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=” Sequencer ”> 36 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name =”name” lowerBound=”1” eType=”ecore:EDataType http: //www. e c l i p s e . org /emf/2002/ Ecore#//EString ”/> 37 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =” runs ” upperBound=”−1” eType=”#//Run” 38 containment=” true ” eOpposite=”#//Run/ sequencer ”/> 12
  • 13. 39 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =” laboratory ” lowerBound=”1” 40 eType=”#//Laboratory ” eOpposite=”#//Laboratory / sequencers ”/> 41 </ e C l a s s i f i e r s> 42 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=”Run”> 43 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name =”name” lowerBound=”1” eType=”ecore:EDataType http: //www. e c l i p s e . org /emf/2002/ Ecore#//EString ”/> 44 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name =” date ” unique=” f a l s e ” eType=”ecore:EDataType http: //www. e c l i p s e . org /emf/2002/ Ecore#//EDate”/> 45 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =” sequenced ” upperBound=”−1” 46 eType=”#//Sequenced” containment=” true ” eOpposite =”#//Sequenced/run”/> 47 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =” sequencer ” lowerBound=”1” 48 eType=”#//Sequencer ” eOpposite=”#//Sequencer / runs ”/> 49 </ e C l a s s i f i e r s> 50 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=”Sample”> 51 <eStructuralFeatures x s i : t y p e=” ecore:EAttribute ” name =” id ” lowerBound=”1” eType=”ecore:EDataType http: //www. e c l i p s e . org /emf/2002/ Ecore#//EString ”/> 52 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =” individual ” lowerBound=”1” 53 eType=”#//Individual ” eOpposite=”#//Individual / samples ”/> 54 </ e C l a s s i f i e r s> 55 <e C l a s s i f i e r s x s i : t y p e=” ecore:EClass ” name=”Sequenced”> 56 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =”run” unique=” f a l s e ” lowerBound=”1” 57 eType=”#//Run” eOpposite=”#//Run/ sequenced ”/> 58 <eStructuralFeatures x s i : t y p e=” ecore:EReference ” name =”sample” unique=” f a l s e ” 59 lowerBound=”1” eType=”#//Sample”/> 60 </ e C l a s s i f i e r s> 61 </ ecore:EPackage> 3 GenModel We’re going to generate the Genmodel for our model. The Genmodel contains additional information for the codegeneration, e.g. the path and file 13
  • 14. information. 3.1 Create the GenModel Project • Menu File → New → New Project... → EMF Generator Project • Select the folder EMF03-Model/model • Set the file name to lims.genmodel • select a "Model Importer": "Ecore model" • import the model ”URI: platform:/resource/EMF03/model/lims.ecore” 3.2 Edit the GenModel Project In the tree view of the Genmodel, click on the root node and edit its properties: • set All → Runtime Platform → to ”RCP”. click on the package node ’Lims’ and edit its properties: • set All → BasePackage → to ”com.github.lindenb.lims”. 1 <?xml version=” 1.0 ” encoding=”UTF−8”?> 2 <genmodel:GenModel xmi:version=” 2.0 ” 3 xmlns:xmi=” http: //www. omg . org /XMI” xmlns:ecore=” http: //www. e c l i p s e . org /emf/2002/ Ecore” 4 xmlns:genmodel=” http: //www. e c l i p s e . org /emf/2002/ GenModel” copyrightText=” Pierre Lindenbaum PhD 2013” 5 modelDirectory=”/EMF03/ src ” modelPluginID=”EMF03” modelName=”Lims” importerID=” org . e c l i p s e . emf . importer . ecore ” 6 complianceLevel=” 6.0 ” copyrightFields=” f a l s e ” language=”en” classNamePattern=”” 7 runtimePlatform=”RCP”> 8 <foreignModel>lims . ecore</ foreignModel> 9 <genPackages p r e f i x=”Lims” basePackage=”com . github . lindenb . lims ” disposableProviderFactory=” true ” 10 ecorePackage=” lims . ecore#/”> 11 <genEnums typeSafeEnumCompatible=” f a l s e ” ecoreEnum=” lims . ecore#//Gender”> 12 <genEnumLiterals ecoreEnumLiteral=” lims . ecore#// Gender/UNKNOWN”/> 13 <genEnumLiterals ecoreEnumLiteral=” lims . ecore#// Gender/MALE”/> 14
  • 15. 14 <genEnumLiterals ecoreEnumLiteral=” lims . ecore#// Gender/FEMALE”/> 15 </genEnums> 16 <genClasses ecoreClass=” lims . ecore#//Family”> 17 <genFeatures createChild=” f a l s e ” ecoreFeature=” ecore:EAttribute lims . ecore#//Family/name”/> 18 <genFeatures property=”None” children=” true ” createChild=” true ” ecoreFeature=” ecore:EReference lims . ecore#//Family/ i n d i v i d u a l s ”/> 19 <genFeatures property=”None” no tify=” f a l s e ” createChild=” f a l s e ” ecoreFeature=” ecore:EReference lims . ecore#//Family/ laboratory ” /> 20 </ genClasses> 21 <genClasses ecoreClass=” lims . ecore#//Laboratory ”> 22 <genFeatures property=”None” children=” true ” createChild=” true ” ecoreFeature=” ecore:EReference lims . ecore#//Laboratory / f a m i l i e s ”/> 23 <genFeatures property=”None” children=” true ” createChild=” true ” ecoreFeature=” ecore:EReference lims . ecore#//Laboratory / sequencers ”/> 24 </ genClasses> 25 <genClasses ecoreClass=” lims . ecore#//Individual ”> 26 <genFeatures createChild=” f a l s e ” ecoreFeature=” ecore:EAttribute lims . ecore#//Individual / gender ” /> 27 <genFeatures property=”None” no tify=” f a l s e ” createChild=” f a l s e ” ecoreFeature=” ecore:EReference lims . ecore#//Individual / family ” /> 28 <genFeatures n otify=” f a l s e ” createChild=” f a l s e ” propertySortChoices=” true ” ecoreFeature=” ecore:EReference lims . ecore#//Individual /Father” /> 29 <genFeatures createChild=” f a l s e ” ecoreFeature=” ecore:EAttribute lims . ecore#//Individual /name”/> 30 <genFeatures n otify=” f a l s e ” createChild=” f a l s e ” propertySortChoices=” true ” ecoreFeature=” ecore:EReference lims . ecore#//Individual /Mother” /> 31 <genFeatures property=”None” children=” true ” createChild=” true ” ecoreFeature=” ecore:EReference lims . ecore#//Individual / samples 15
  • 16. ”/> 32 </ genClasses> 33 <genClasses ecoreClass=” lims . ecore#//Sequencer ”> 34 <genFeatures n otify=” f a l s e ” createChild=” f a l s e ” propertyDescription=”” ecoreFeature=” ecore:EAttribute lims . ecore#//Sequencer /name”/> 35 <genFeatures property=”None” children=” true ” createChild=” true ” ecoreFeature=” ecore:EReference lims . ecore#//Sequencer / runs ”/> 36 <genFeatures property=”None” no tify=” f a l s e ” createChild=” f a l s e ” ecoreFeature=” ecore:EReference lims . ecore#//Sequencer / laboratory ”/> 37 </ genClasses> 38 <genClasses ecoreClass=” lims . ecore#//Run”> 39 <genFeatures createChild=” f a l s e ” ecoreFeature=” ecore:EAttribute lims . ecore#//Run/name”/> 40 <genFeatures createChild=” f a l s e ” ecoreFeature=” ecore:EAttribute lims . ecore#//Run/ date ”/> 41 <genFeatures property=”None” children=” true ” createChild=” true ” ecoreFeature=” ecore:EReference lims . ecore#//Run/ sequenced ”/> 42 <genFeatures property=”None” children=” true ” createChild=” true ” ecoreFeature=” ecore:EReference lims . ecore#//Run/ sequencer ”/> 43 </ genClasses> 44 <genClasses ecoreClass=” lims . ecore#//Sample”> 45 <genFeatures createChild=” f a l s e ” ecoreFeature=” ecore:EAttribute lims . ecore#//Sample/ id ”/> 46 <genFeatures property=”None” no tify=” f a l s e ” createChild=” f a l s e ” ecoreFeature=” ecore:EReference lims . ecore#//Sample/ individual ” /> 47 </ genClasses> 48 <genClasses ecoreClass=” lims . ecore#//Sequenced”> 49 <genFeatures n otify=” f a l s e ” createChild=” f a l s e ” propertySortChoices=” true ” ecoreFeature=” ecore:EReference lims . ecore#//Sequenced/run”/> 50 <genFeatures n otify=” f a l s e ” createChild=” f a l s e ” propertySortChoices=” true ” ecoreFeature=” ecore:EReference lims . ecore#//Sequenced/sample”/ > 51 </ genClasses> 52 </genPackages> 53 </genmodel:GenModel> 16
  • 17. 4 Generating the code In the tree view of the Genmodel, right click the root node: Generate All : four new Eclipse plugins have been created: • Model: contains the classes to create the instances of our model. • EMF03.edit : classes to display a model in a UI (labels... ) • EMF03.editor: The editor plugin is a generated example editor to create and modify instances of a model. • EMF03.tests: The test plugin contains templates to write tests for a model. Here is an example of the interface com.github.lindenb.lims.Lims.Family generated by EMF: 1 package com . github . l i n d e n b . l i m s . Lims ; 2 3 import org . e c l i p s e . emf . common . u t i l . EList ; 4 5 import org . e c l i p s e . emf . e c o r e . EObject ; 6 7 /∗∗ 8 ∗ A r e p r e s e n t a t i o n o f t h e m o d e l o b j e c t ’<em><b>F a m i l y </b></em > ’. 9 ∗ 10 ∗ The f o l l o w i n g f e a t u r e s a r e s u p p o r t e d : 11 ∗ <u l > 12 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . F a m i l y#g e t N a m e <em>Name</em>}</ l i > 13 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . F a m i l y# g e t I n d i v i d u a l s <em>I n d i v i d u a l s </ em>}</ l i > 14 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . F a m i l y# g e t L a b o r a t o r y <em>L a b o r a t o r y </em >}</ l i > 15 ∗ </ u l > 16 ∗ 17 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . L i m s P a c k a g e# g e t F a m i l y ( ) 18 ∗ @model 19 ∗ @ g e n e r a t e d 20 ∗/ 21 public i n t e r f a c e Family extends EObject 22 { 23 /∗∗ 24 ∗ R e t u r n s t h e v a l u e o f t h e ’<em><b>Name</b></em>’ a t t r i b u t e . 25 ∗ I f t h e m e a n i n g o f t h e ’<em>Name</em>’ a t t r i b u t e i s n ’ t c l e a r , 26 ∗ t h e r e r e a l l y s h o u l d b e more o f a d e s c r i p t i o n h e r e . . . 27 ∗ @ r e t u r n t h e v a l u e o f t h e ’<em>Name</em>’ a t t r i b u t e . 28 ∗ @ s e e #s e t N a m e ( S t r i n g ) 29 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . L i m s P a c k a g e#g e t F a m i l y N a m e ( ) 30 ∗ @model r e q u i r e d =” t r u e ” 31 ∗ @ g e n e r a t e d 32 ∗/ 33 S t r i n g getName ( ) ; 34 35 /∗∗ 36 ∗ S e t s t h e v a l u e o f t h e ’{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . F a m i l y#g e t N a m e <em>Name</em>}’ a t t r i b u t e . 37 ∗ @param v a l u e t h e new v a l u e o f t h e ’<em>Name</em>’ a t t r i b u t e . 38 ∗ @ s e e #g e t N a m e ( ) 39 ∗ @ g e n e r a t e d 40 ∗/ 41 void setName ( S t r i n g v a l u e ) ; 42 43 /∗∗ 44 ∗ R e t u r n s t h e v a l u e o f t h e ’<em><b>I n d i v i d u a l s </b></em>’ c o n t a i n m e n t r e f e r e n c e l i s t . 45 ∗ The l i s t c o n t e n t s a r e o f t y p e { @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . I n d i v i d u a l } . 46 ∗ I t i s b i d i r e c t i o n a l and i t s o p p o s i t e i s ’{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . I n d i v i d u a l # g e t F a m i l y <em>F a m i l y </em >} ’. 47 ∗ I f t h e m e a n i n g o f t h e ’<em>I n d i v i d u a l s </em>’ c o n t a i n m e n t r e f e r e n c e l i s t i s n ’ t c l e a r , 48 ∗ t h e r e r e a l l y s h o u l d b e more o f a d e s c r i p t i o n h e r e . . . 49 ∗ @ r e t u r n t h e v a l u e o f t h e ’<em>I n d i v i d u a l s </em>’ c o n t a i n m e n t r e f e r e n c e l i s t . 50 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . L i m s P a c k a g e# g e t F a m i l y I n d i v i d u a l s ( ) 51 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . I n d i v i d u a l # g e t F a m i l y 52 ∗ @model o p p o s i t e =” f a m i l y ” c o n t a i n m e n t =” t r u e ” 17
  • 18. 53 ∗ @ g e n e r a t e d 54 ∗/ 55 EList<I n d i v i d u a l > g e t I n d i v i d u a l s ( ) ; 56 57 /∗∗ 58 ∗ R e t u r n s t h e v a l u e o f t h e ’<em><b>L a b o r a t o r y </b></em>’ c o n t a i n e r r e f e r e n c e . 59 ∗ I t i s b i d i r e c t i o n a l and i t s o p p o s i t e i s ’{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . L a b o r a t o r y # g e t F a m i l i e s <em>F a m i l i e s </em >} ’. 60 ∗ I f t h e m e a n i n g o f t h e ’<em>L a b o r a t o r y </em>’ c o n t a i n e r r e f e r e n c e i s n ’ t c l e a r , 61 ∗ t h e r e r e a l l y s h o u l d b e more o f a d e s c r i p t i o n h e r e . . . 62 ∗ @ r e t u r n t h e v a l u e o f t h e ’<em>L a b o r a t o r y </em>’ c o n t a i n e r r e f e r e n c e . 63 ∗ @ s e e # s e t L a b o r a t o r y ( L a b o r a t o r y ) 64 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . L i m s P a c k a g e# g e t F a m i l y L a b o r a t o r y ( ) 65 ∗ @ s e e com . g i t h u b . l i n d e n b . l i m s . Lims . L a b o r a t o r y # g e t F a m i l i e s 66 ∗ @model o p p o s i t e =” f a m i l i e s ” r e q u i r e d =” t r u e ” t r a n s i e n t =” f a l s e ” 67 ∗ @ g e n e r a t e d 68 ∗/ 69 Laboratory g e t L a b o r a t o r y ( ) ; 70 71 /∗∗ 72 ∗ S e t s t h e v a l u e o f t h e ’{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . F a m i l y# g e t L a b o r a t o r y <em>L a b o r a t o r y </em>}’ c o n t a i n e r r e f e r e n c e . 73 ∗ @param v a l u e t h e new v a l u e o f t h e ’<em>L a b o r a t o r y </em>’ c o n t a i n e r r e f e r e n c e . 74 ∗ @ s e e # g e t L a b o r a t o r y ( ) 75 ∗ @ g e n e r a t e d 76 ∗/ 77 void s e t L a b o r a t o r y ( Laboratory v a l u e ) ; 78 79 } // F a m i l y and the implementation of the interface: com.github.lindenb.lims.Lims.impl.FamilyImpl : 1 package com . github . l i n d e n b . l i m s . Lims . impl ; 2 3 import com . github . l i n d e n b . l i m s . Lims . Family ; 4 import com . github . l i n d e n b . l i m s . Lims . I n d i v i d u a l ; 5 import com . github . l i n d e n b . l i m s . Lims . Laboratory ; 6 import com . github . l i n d e n b . l i m s . Lims . LimsPackage ; 7 8 import j a v a . u t i l . C o l l e c t i o n ; 9 10 import org . e c l i p s e . emf . common . n o t i f y . N o t i f i c a t i o n ; 11 import org . e c l i p s e . emf . common . n o t i f y . N o t i f i c a t i o n C h a i n ; 12 13 import org . e c l i p s e . emf . common . u t i l . EList ; 14 15 import org . e c l i p s e . emf . e c o r e . EClass ; 16 import org . e c l i p s e . emf . e c o r e . I n t e r n a l E O b j e c t ; 17 18 import org . e c l i p s e . emf . e c o r e . impl . E N o t i f i c a t i o n I m p l ; 19 import org . e c l i p s e . emf . e c o r e . impl . EObjectImpl ; 20 21 import org . e c l i p s e . emf . e c o r e . u t i l . EObjectContainmentWithInverseEList ; 22 import org . e c l i p s e . emf . e c o r e . u t i l . E c o r e U t i l ; 23 import org . e c l i p s e . emf . e c o r e . u t i l . I n t e r n a l E L i s t ; 24 25 /∗∗ 26 ∗ An i m p l e m e n t a t i o n o f t h e m o d e l o b j e c t ’<em><b>F a m i l y </b></em > ’. 27 ∗ The f o l l o w i n g f e a t u r e s a r e i m p l e m e n t e d : 28 ∗ <u l > 29 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . i m p l . F a m i l y I m p l#g e t N a m e <em>Name</em >}</ l i > 30 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . i m p l . F a m i l y I m p l# g e t I n d i v i d u a l s <em> I n d i v i d u a l s </em>}</ l i > 31 ∗ <l i >{ @ l i n k com . g i t h u b . l i n d e n b . l i m s . Lims . i m p l . F a m i l y I m p l# g e t L a b o r a t o r y <em> L a b o r a t o r y </em>}</ l i > 32 ∗ </ u l > 33 ∗ 34 ∗ @ g e n e r a t e d 35 ∗/ 36 public c l a s s FamilyImpl extends EObjectImpl implements Family 37 { 38 /∗∗ 39 ∗ The d e f a u l t v a l u e o f t h e ’{ @ l i n k #g e t N a m e ( ) <em>Name</em>}’ a t t r i b u t e . 40 ∗ @ s e e #g e t N a m e ( ) 41 ∗ @ g e n e r a t e d 42 ∗ @ o r d e r e d 43 ∗/ 44 protected s t a t i c f i n a l S t r i n g NAME EDEFAULT = null ; 45 46 /∗∗ 47 ∗ The c a c h e d v a l u e o f t h e ’{ @ l i n k #g e t N a m e ( ) <em>Name</em>}’ a t t r i b u t e . 48 ∗ @ s e e #g e t N a m e ( ) 49 ∗ @ g e n e r a t e d 18
  • 19. 50 ∗ @ o r d e r e d 51 ∗/ 52 protected S t r i n g name = NAME EDEFAULT; 53 54 /∗∗ 55 ∗ The c a c h e d v a l u e o f t h e ’{ @ l i n k # g e t I n d i v i d u a l s ( ) <em>I n d i v i d u a l s </em>}’ c o n t a i n m e n t r e f e r e n c e l i s t . 56 ∗ @ s e e # g e t I n d i v i d u a l s ( ) 57 ∗ @ g e n e r a t e d 58 ∗ @ o r d e r e d 59 ∗/ 60 protected EList<I n d i v i d u a l > i n d i v i d u a l s ; 61 62 /∗∗ 63 ∗ @ g e n e r a t e d 64 ∗/ 65 protected FamilyImpl ( ) 66 { 67 super ( ) ; 68 } 69 70 /∗∗ 71 ∗ @ g e n e r a t e d 72 ∗/ 73 @Override 74 protected EClass e S t a t i c C l a s s ( ) 75 { 76 return LimsPackage . L i t e r a l s .FAMILY; 77 } 78 79 /∗∗ 80 ∗ @ g e n e r a t e d 81 ∗/ 82 public S t r i n g getName ( ) 83 { 84 return name ; 85 } 86 87 /∗∗ 88 ∗ @ g e n e r a t e d 89 ∗/ 90 public void setName ( S t r i n g newName) 91 { 92 S t r i n g oldName = name ; 93 name = newName ; 94 i f ( e N o t i f i c a t i o n R e q u i r e d ( ) ) 95 e N o t i f y (new E N o t i f i c a t i o n I m p l ( this , N o t i f i c a t i o n . SET, LimsPackage . FAMILY NAME, oldName , name ) ) ; 96 } 97 98 /∗∗ 99 ∗ @ g e n e r a t e d 100 ∗/ 101 public EList<I n d i v i d u a l > g e t I n d i v i d u a l s ( ) 102 { 103 i f ( i n d i v i d u a l s == null ) 104 { 105 i n d i v i d u a l s = new EObjectContainmentWithInverseEList< I n d i v i d u a l >( I n d i v i d u a l . class , this , LimsPackage . FAMILY INDIVIDUALS , LimsPackage . INDIVIDUAL FAMILY) ; 106 } 107 return i n d i v i d u a l s ; 108 } 109 110 /∗∗ 111 ∗ @ g e n e r a t e d 112 ∗/ 113 public Laboratory g e t L a b o r a t o r y ( ) 114 { 115 i f ( eContainerFeatureID ( ) != LimsPackage .FAMILY LABORATORY) return null ; 116 return ( Laboratory ) eContainer ( ) ; 117 } 118 119 /∗∗ 120 ∗ @ g e n e r a t e d 121 ∗/ 122 public N o t i f i c a t i o n C h a i n b a s i c S e t L a b o r a t o r y ( Laboratory newLaboratory , N o t i f i c a t i o n C h a i n msgs ) 123 { 124 msgs = e B a s i c S e t C o n t a i n e r ( ( I n t e r n a l E O b j e c t ) newLaboratory , LimsPackage .FAMILY LABORATORY, msgs ) ; 125 return msgs ; 126 } 127 128 /∗∗ 129 ∗ @ g e n e r a t e d 130 ∗/ 131 public void s e t L a b o r a t o r y ( Laboratory newLaboratory ) 132 { 19
  • 20. 133 i f ( newLaboratory != e I n t e r n a l C o n t a i n e r ( ) | | ( eContainerFeatureID ( ) != LimsPackage .FAMILY LABORATORY && newLaboratory != null ) ) 134 { 135 i f ( E c o r e U t i l . i s A n c e s t o r ( this , newLaboratory ) ) 136 throw new I l l e g a l A r g u m e n t E x c e p t i o n ( ” R e c u r s i v e containment not a l l o w e d f o r ” + t o S t r i n g ( ) ) ; 137 N o t i f i c a t i o n C h a i n msgs = null ; 138 i f ( e I n t e r n a l C o n t a i n e r ( ) != null ) 139 msgs = eBasicRemoveFromContainer ( msgs ) ; 140 i f ( newLaboratory != null ) 141 msgs = ( ( I n t e r n a l E O b j e c t ) newLaboratory ) . eInverseAdd ( this , LimsPackage . LABORATORY FAMILIES, Laboratory . class , msgs ) ; 142 msgs = b a s i c S e t L a b o r a t o r y ( newLaboratory , msgs ) ; 143 i f ( msgs != null ) msgs . d i s p a t c h ( ) ; 144 } 145 e l s e i f ( e N o t i f i c a t i o n R e q u i r e d ( ) ) 146 e N o t i f y (new E N o t i f i c a t i o n I m p l ( this , N o t i f i c a t i o n . SET, LimsPackage .FAMILY LABORATORY, newLaboratory , newLaboratory ) ) ; 147 } 148 149 /∗∗ 150 ∗ @ g e n e r a t e d 151 ∗/ 152 @SuppressWarnings ( ” unchecked ” ) 153 @Override 154 public N o t i f i c a t i o n C h a i n eInverseAdd ( I n t e r n a l E O b j e c t otherEnd , int f e a t u r e I D , N o t i f i c a t i o n C h a i n msgs ) 155 { 156 switch ( f e a t u r e I D ) 157 { 158 case LimsPackage . FAMILY INDIVIDUALS : 159 return ( ( I n t e r n a l E L i s t <I n t e r n a l E O b j e c t >)( I n t e r n a l E L i s t <?>) g e t I n d i v i d u a l s ( ) ) . basicAdd ( otherEnd , msgs ) ; 160 case LimsPackage .FAMILY LABORATORY: 161 i f ( e I n t e r n a l C o n t a i n e r ( ) != null ) 162 msgs = eBasicRemoveFromContainer ( msgs ) ; 163 return b a s i c S e t L a b o r a t o r y ( ( Laboratory ) otherEnd , msgs ) ; 164 } 165 return super . eInverseAdd ( otherEnd , f e a t u r e I D , msgs ) ; 166 } 167 168 /∗∗ 169 ∗ @ g e n e r a t e d 170 ∗/ 171 @Override 172 public N o t i f i c a t i o n C h a i n eInverseRemove ( I n t e r n a l E O b j e c t otherEnd , int f e a t u r e I D , N o t i f i c a t i o n C h a i n msgs ) 173 { 174 switch ( f e a t u r e I D ) 175 { 176 case LimsPackage . FAMILY INDIVIDUALS : 177 return ( ( I n t e r n a l E L i s t <?>) g e t I n d i v i d u a l s ( ) ) . basicRemove ( otherEnd , msgs ) ; 178 case LimsPackage .FAMILY LABORATORY: 179 return b a s i c S e t L a b o r a t o r y ( null , msgs ) ; 180 } 181 return super . eInverseRemove ( otherEnd , f e a t u r e I D , msgs ) ; 182 } 183 184 /∗∗ 185 ∗ @ g e n e r a t e d 186 ∗/ 187 @Override 188 public N o t i f i c a t i o n C h a i n eBasicRemoveFromContainerFeature ( N o t i f i c a t i o n C h a i n msgs ) 189 { 190 switch ( eContainerFeatureID ( ) ) 191 { 192 case LimsPackage .FAMILY LABORATORY: 193 return e I n t e r n a l C o n t a i n e r ( ) . eInverseRemove ( this , LimsPackage . LABORATORY FAMILIES, Laboratory . class , msgs ) ; 194 } 195 return super . eBasicRemoveFromContainerFeature ( msgs ) ; 196 } 197 198 /∗∗ 199 ∗ @ g e n e r a t e d 200 ∗/ 201 @Override 202 public Object eGet ( int f e a t u r e I D , boolean r e s o l v e , boolean coreType ) 203 { 204 switch ( f e a t u r e I D ) 205 { 206 case LimsPackage . FAMILY NAME : 207 return getName ( ) ; 208 case LimsPackage . FAMILY INDIVIDUALS : 20
  • 21. 209 return g e t I n d i v i d u a l s ( ) ; 210 case LimsPackage .FAMILY LABORATORY: 211 return g e t L a b o r a t o r y ( ) ; 212 } 213 return super . eGet ( f e a t u r e I D , r e s o l v e , coreType ) ; 214 } 215 216 /∗∗ 217 ∗ @ g e n e r a t e d 218 ∗/ 219 @SuppressWarnings ( ” unchecked ” ) 220 @Override 221 public void e S e t ( int f e a t u r e I D , Object newValue ) 222 { 223 switch ( f e a t u r e I D ) 224 { 225 case LimsPackage . FAMILY NAME : 226 setName ( ( S t r i n g ) newValue ) ; 227 return ; 228 case LimsPackage . FAMILY INDIVIDUALS : 229 g e t I n d i v i d u a l s ( ) . c l e a r ( ) ; 230 g e t I n d i v i d u a l s ( ) . addAll ( ( C o l l e c t i o n <? extends I n d i v i d u a l >)newValue ) ; 231 return ; 232 case LimsPackage .FAMILY LABORATORY: 233 s e t L a b o r a t o r y ( ( Laboratory ) newValue ) ; 234 return ; 235 } 236 super . e S e t ( f e a t u r e I D , newValue ) ; 237 } 238 239 /∗∗ 240 ∗ @ g e n e r a t e d 241 ∗/ 242 @Override 243 public void eUnset ( int f e a t u r e I D ) 244 { 245 switch ( f e a t u r e I D ) 246 { 247 case LimsPackage . FAMILY NAME : 248 setName (NAME EDEFAULT) ; 249 return ; 250 case LimsPackage . FAMILY INDIVIDUALS : 251 g e t I n d i v i d u a l s ( ) . c l e a r ( ) ; 252 return ; 253 case LimsPackage .FAMILY LABORATORY: 254 s e t L a b o r a t o r y ( ( Laboratory ) null ) ; 255 return ; 256 } 257 super . eUnset ( f e a t u r e I D ) ; 258 } 259 260 /∗∗ 261 ∗ @ g e n e r a t e d 262 ∗/ 263 @Override 264 public boolean e I s S e t ( int f e a t u r e I D ) 265 { 266 switch ( f e a t u r e I D ) 267 { 268 case LimsPackage . FAMILY NAME : 269 return NAME EDEFAULT == null ? name != null : ! NAME EDEFAULT. e q u a l s ( name ) ; 270 case LimsPackage . FAMILY INDIVIDUALS : 271 return i n d i v i d u a l s != null && ! i n d i v i d u a l s . isEmpty ( ) ; 272 case LimsPackage .FAMILY LABORATORY: 273 return g e t L a b o r a t o r y ( ) != null ; 274 } 275 return super . e I s S e t ( f e a t u r e I D ) ; 276 } 277 278 /∗∗ 279 ∗ @ g e n e r a t e d 280 ∗/ 281 @Override 282 public S t r i n g t o S t r i n g ( ) 283 { 284 i f ( eIsProxy ( ) ) return super . t o S t r i n g ( ) ; 285 286 S t r i n g B u f f e r r e s u l t = new S t r i n g B u f f e r ( super . t o S t r i n g ( ) ) ; 287 r e s u l t . append ( ” ( name : ” ) ; 288 r e s u l t . append ( name ) ; 289 r e s u l t . append ( ’ ) ’ ) ; 290 return r e s u l t . t o S t r i n g ( ) ; 291 } 292 293 } // F a m i l y I m p l 21
  • 22. 5 Create a new eclipse product • Menu File → New → Other... → Product Configuration • Wizard: set parent folder: EMF03/model • Wizard: set the file name: ”lims.product”. • Wizard: Ask to create a basic config Open the editor for ’lims.product”. • in Overview/Product Definition/Product → create a new product . Defining plugin :”EMF03”, product ID : ”lims”, Application : "EMF03.editor.LimsEditorEdito • in Depedencies/Plugins and fragments: add EMF03, EMF03.edit, EMF03.editor • check "include optional dependencies" • click "Add required plug-in" • in Lauching/Program Launcher set Launcher Name to ”lims”. The content of the product file is displayed below: 1 <?xml version=” 1.0 ” encoding=”UTF−8”?> 2 <?pde version=” 3.5 ”?> 3 4 <product name=”Lims” uid=”LIMS” id=”EMF03. lims ” application=”EMF03. editor . LimsEditorAdvisorApplication ” version=” 1 . 0 . 0 ” useFeatures=” f a l s e ” includeLaunchers =” true ”> 5 6 <c o n f i g I n i use=” default ”> 7 </ c o n f i g I n i> 8 9 <launcherArgs> 10 <vmArgsMac>−XstartOnFirstThread −Dorg . e c l i p s e . swt . i n t e r n a l . carbon . smallFonts</vmArgsMac> 11 </ launcherArgs> 12 13 <launcher name=” lims ”> 14 <s o l a r i s /> 15 <win useIco=” f a l s e ”> 16 <bmp/> 17 </win> 18 </ launcher> 19 22
  • 23. 20 <vm> 21 </vm> 22 23 <plugins> 24 <plugin id=”EMF03”/> 25 <plugin id=”EMF03. edit ”/> 26 <plugin id=”EMF03. editor ”/> 27 <plugin id=”com . ibm . icu ”/> 28 <plugin id=” javax . s e r v l e t ”/> 29 <plugin id=” javax . transaction ” fragment=” true ”/> 30 <plugin id=” org . e c l i p s e . ant . core ”/> 31 <plugin id=” org . e c l i p s e . core . commands”/> 32 <plugin id=” org . e c l i p s e . core . contenttype ”/> 33 <plugin id=” org . e c l i p s e . core . databinding ”/> 34 <plugin id=” org . e c l i p s e . core . databinding . observable ”/> 35 <plugin id=” org . e c l i p s e . core . databinding . property ”/ > 36 <plugin id=” org . e c l i p s e . core . expressions ”/> 37 <plugin id=” org . e c l i p s e . core . f i l e s y s t e m ”/> 38 <plugin id=” org . e c l i p s e . core . f i l e s y s t e m . linux . x86” fragment=” true ”/> 39 <plugin id=” org . e c l i p s e . core . jobs ”/> 40 <plugin id=” org . e c l i p s e . core . resources ”/> 41 <plugin id=” org . e c l i p s e . core . runtime”/> 42 <plugin id=” org . e c l i p s e . core . runtime . compatibility . auth”/> 43 <plugin id=” org . e c l i p s e . core . runtime . compatibility . r e g i s t r y ” fragment=” true ”/> 44 <plugin id=” org . e c l i p s e . core . v a r i a b l e s ”/> 45 <plugin id=” org . e c l i p s e . emf . common”/> 46 <plugin id=” org . e c l i p s e . emf . common . ui ”/> 47 <plugin id=” org . e c l i p s e . emf . ecore ”/> 48 <plugin id=” org . e c l i p s e . emf . ecore . change”/> 49 <plugin id=” org . e c l i p s e . emf . ecore . xmi”/> 50 <plugin id=” org . e c l i p s e . emf . edit ”/> 51 <plugin id=” org . e c l i p s e . emf . edit . ui ”/> 52 <plugin id=” org . e c l i p s e . equinox . app”/> 53 <plugin id=” org . e c l i p s e . equinox . common”/> 54 <plugin id=” org . e c l i p s e . equinox . p2 . core ”/> 55 <plugin id=” org . e c l i p s e . equinox . p2 . engine ”/> 56 <plugin id=” org . e c l i p s e . equinox . p2 . metadata”/> 57 <plugin id=” org . e c l i p s e . equinox . p2 . metadata . repository ”/> 58 <plugin id=” org . e c l i p s e . equinox . p2 . repository ”/> 59 <plugin id=” org . e c l i p s e . equinox . preferences ”/> 23
  • 24. 60 <plugin id=” org . e c l i p s e . equinox . r e g i s t r y ”/> 61 <plugin id=” org . e c l i p s e . equinox . s e c u r i t y ”/> 62 <plugin id=” org . e c l i p s e . help ”/> 63 <plugin id=” org . e c l i p s e . j f a c e ”/> 64 <plugin id=” org . e c l i p s e . j f a c e . databinding ”/> 65 <plugin id=” org . e c l i p s e . j f a c e . text ”/> 66 <plugin id=” org . e c l i p s e . osgi ”/> 67 <plugin id=” org . e c l i p s e . osgi . s e r v i c e s ”/> 68 <plugin id=” org . e c l i p s e . swt”/> 69 <plugin id=” org . e c l i p s e . swt . gtk . linux . x86” fragment =” true ”/> 70 <plugin id=” org . e c l i p s e . text ”/> 71 <plugin id=” org . e c l i p s e . ui ”/> 72 <plugin id=” org . e c l i p s e . ui . forms”/> 73 <plugin id=” org . e c l i p s e . ui . ide ”/> 74 <plugin id=” org . e c l i p s e . ui . views ”/> 75 <plugin id=” org . e c l i p s e . ui . workbench”/> 76 </ plugins> 77 78 79 </ product> 6 Generating the Eclipse Product • File → Export → Eclipse Product . • Set configuration : ”EMF03/model/lims.product” . • Set the destination directory . • Uncheck "Generate metadata repository" . • "Finish" Congratulations, your client has been generated. 7 Running the Lims editor Go to the generated application directory and run: $ cd /path/ to /GENERATED $ ./ lims & Here is a screenshot of the generated ’lims’ application: 24
  • 25. Here is an example of a data file handled by the ’lims’ application: 1 <?xml version=” 1.0 ” encoding=”UTF−8”?> 2 <lims:Laboratory xmi:version=” 2.0 ” xmlns:xmi=” http: //www. omg . org /XMI” xmlns:lims=” http: //univ−nantes . f r / lims /”> 3 <f a m i l i e s name=”Family1”> 4 <i n d i v i d u a l s name=” indi1 ”/> 5 <i n d i v i d u a l s Father=”// @families .0/ @individuals .0 ” name=” indi2 ”> 6 <samples id=”CD00001”/> 7 </ i n d i v i d u a l s> 8 </ f a m i l i e s> 9 <sequencers name=”HiSeq”> 10 <runs name=”CD1786CXX”> 11 <sequenced sample=”// @families .0/ @individuals .1/ @samples .0 ”/> 12 </ runs> 13 </ sequencers> 14 <sequencers name=”miseq”> 15 <runs name=”CXX01”> 16 <sequenced sample=”// @families .0/ @individuals .1/ @samples .0 ”/> 17 </ runs> 18 </ sequencers> 19 </ lims:Laboratory> That’s it, Pierre 25
  • 26. 8 References • Source for this tutorial: https://github.com/lindenb/courses/tree/ master/about.emf • The Eclipse Modeling Framework Overview : http://help.eclipse. org/juno/index.jsp?topic=%2Forg.eclipse.emf.doc%2Freferences% 2Foverview%2FEMF.html • Eclipse Modeling Framework (EMF) - Tutorial : http://www.vogella. com/articles/EclipseEMF/article.html 26