ParameterCatalogs2Creation.adoc 48 KB
Newer Older
1
2
3
== How to Implement Parameter Catalogs with Eclipse
:imagesdir: ParameterCatalogs2Images

4
5
6
7
8
9
At the end of this chapter, you should be able to build a running software prototype for creating and maintaining parameter catalogs based on a graphical data model of the domain you are an expert in.

To build data models and parameter catalogs from scratch, we first have to understand some basics about Eclipse, and then install the correct Eclipse package.
Thereafter, we can model our data with _Ecore_ considering some best practices, followed by the generation of Java classes and user interface (UI).
Finally, we will install some plug-ins to "pimp" our Eclipse installation in order to add units and quantities to the mix.

10
11
12
13
14
15
16
17
18
19
20
21
22
23

=== Eclipse Basics

https://en.wikipedia.org/wiki/Eclipse_(software)[Eclipse] was originally developed by IBM and became Open Source in 2001.
It is best known for its Integrated Development Environments (_Eclipse IDEs_), not only for Java, but also for C++, Python and many other programming languages.
These IDEs are created on top of the Eclipse Rich Client Platform (Eclipse RCP), an application framework and plug-in system based on Java and OSGi.
Eclipse RCP is foundation of a plethora of general-purpose applications, too.

First time users of Eclipse better understand the following concepts.

.Eclipse Packages

An Eclipse package is an Eclipse distribution dedicated to a specific type of task.footnote:[The notion of an Eclipse package has nothing to do with Java packages.]
A list of packages is available at https://www.eclipse.org/downloads/packages/[eclipse.org].
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
24
25
Beside others it contains _Eclipse IDE for Java Developers_, _Eclipse IDE for Scientific Computing_, and _Eclipse Modeling Tools_.
Note that third parties offer many other packages, e.g. _GAMA_ for multi-agent-simulation or _Obeo Designer Community_ for creating diagram and form editors. This is the package we will use later.
26
27
28
29
30
31
32
33
34
35
36
37

[NOTE]
====
Several Eclipse packages can be installed side by side, even different releases of the same package. Multiple Eclipse installations can run at the same time, each on its own _workspace_ (see below).
====

.Plug-ins / Features

An installed Eclipse package consists of a runtime core and a bunch of additional plug-ins.
Technically, a plug-in is just a special kind of Java archive (JAR file) that uses and can be used by other plug-ins with regard to OSGi specifications.
Groups of plug-ins that belong together are called a _feature_.

38
Sometimes, a user will add plug-ins or features to an Eclipse installation to add new capabilities.
39
40
E.g. writing this documentation within my Eclipse IDE is facilitated by the plug-in https://marketplace.eclipse.org/content/asciidoctor-editor[Asciidoctor Editor].
Plug-ins can easily be installed via main menu command `Help → Eclipse Marketplace...` or `Help → Install New Software...`.
41
Some plug-ins may be self-made like our _City Units_ plug-in that enables Ecore to deal with physical quantities.
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92

.Git

https://git-scm.com[Git] is the industry standard for collaborative work on, and versioning of, source code and other textual data.
Collaborative development of parameter catalogs benefits massively from using Git.
Git support is built into _Eclipse Modeling Tools_, the Eclipse package we will use.
However, if Eclipse needs to connect to a Git server that uses SSH protocol (not HTTPS with credentials), access configuration is more involved and may be dependent on your operating system.

Some users, anyway, prefer to use Git from the command line or with one of the client application listed https://git-scm.com/downloads/guis[here], e.g. https://tortoisegit.org[TortoiseGit] for Windows.

While it is required to get Git working at some point, we won't refer to it in this document and, for now, do not cover the installation of Git on your machine or configuration of Git in Eclipse.

.Workspaces

When you start a new Eclipse installation for the first time, you are asked to designate a new directory in your file system to store an _Eclipse workspace_.
Eclipse is always running with exact one workspace open.
As the name implies, a workspace stores everything needed in a given context of work, namely a set of related projects the user is working on as well as meta-data like preference settings, the current status of projects, to do lists, and more.
In case a user wants to work in different contexts, e.g. on different tasks, command `File -> Switch Workspace` allows to create additional workspaces and to switch between them.

[NOTE]
====
Any plug-in from the original Eclipse package or installed by the user later will be copied into the Eclipse installation directory, *not* in any workspace.
Configuration and current state of plug-ins, on the other hand, are stored in workspaces.
====

.Projects

An Eclipse project is a technical term for a directory that often contains:

* files of specific types for source code, scripts, XML files or other data
* build settings, configurations
* dependency definitions (remember the dependencies between plug-ins above?)
* other Eclipse projects.

`File -> New -> Project...` offers many different types of projects that the user can choose from, e.g. Java projects to create Java programs, Ecore modeling  projects, or general projects, that simple hold some arbitrary files.footnote:[Projects possess one or more _natures_ used to define a project's principal type.]

[WARNING]
====
Files that do not belong to a project are invisible for Eclipse!
====

The projects belonging to a workspace can either be directly stored within the workspace as sub-directories (the default offered to the user when creating a new project), or linked from it, that is the workspace just holds a link to the project directory that lives somewhere in the file system outside of the workspace.
Linking allows to work with the same projects in different workspaces.

While it sometimes makes sense to share or exchange workspaces between users,footnote:[Or even work on the same workspace provided in the cloud, see https://www.eclipse.org/che/technology/[Eclipse Che].], I do not recommend this for now.
Projects, in contrast, are shared between users most of the time, usually via Git.
In general, I would suggest to store Eclipse projects outside workspaces at dedicated locations in the user's file system.
That way, we can follow the convention that local Git repositories should all be located under 
`<userhome>/git`.


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
93
=== Setup Obeo Designer
94
95
96
97

.Install Java

Eclipse runs on 64-bit versions of Windows, Linux, and macOS and requires an according Java Development Kit (JDK), version 11 or higher, to be installed on your machine.
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
98
Even if such JDK is already installed on your machine, please download the OpenJDK version *16* or newer for your operating system from https://adoptium.net[Adoptium].
99
100
Installation process is straight forward, but you can also find links to exhaustive instructions for your operating system.

101
New Java versions appear every six months, so one could tend to stick with older version 11 that comes with long time support (LTE) until next LTE version 17 arrives in autumn 2021.
102
However, actual version 16 conforms to the latest security measures built into macOS Catalina, so it is a must if software we build here shall be deployed to these systems, too.
103
104
105
106

Note that different versions of Java coexist peacefully.


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
107
.Install Obeo Designer, Community Edition
108

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
109
110
111
112
Our graphical and form based modeling tools, e.g. Insel 9.0 and Parameter Catalogs, run on top of  https://www.obeodesigner.com/en/product/sirius[Eclipse Sirius].
Technically, the Eclipse Sirius project provides a set of open source features and plugins that can be added to any Eclipse package to transform it into a very flexible modeling workbench.
Instead of adding these software components manually, we start with a pre-configured Eclipse package named _Obeo Designer_.
Please download and install the latest version (11.5 at the time of writing) available at https://www.obeodesigner.com/en/download[Download Obeo Designer Community].
113
114
115

[NOTE]
====
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
116
117
118
Depending on the operating system, several security dialogs have to be acknowledged during installation and first launch of Obeo Designer.
====

119
After the 400 something MB package has arrived, unzip the downloaded file and move the resulting application named `ObeoDesigner-Community` to a suited directory. This would be `Applications` on macOS, similar on Linux, but **not** `Programs` or `Programs (x86)` on Windows!
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
120

121
122
123
124
125
126
127
[WARNING]
====
**Special installation note for Windows**: We found that no plug-ins can be added to Obeo Designer, **if** it is installed in folder _Programs_ or _Programs (x86)_. Since we have to add plug-ins for handling units and quantities below, please make sure to unzip the installation package elsewhere, e.g. the Desktop or the user's home directory.

====

[WARNING]
128
====
129
**Special installation note for macOS**: As Obeo Designer currently is not code-signed, macOS consideres it as damaged. To work around this security feature, remove the quarantine status of the program like so:
130

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
131
132
133
134
. Open a terminal in the folder containing the .app file
. Execute: xattr -d com.apple.quarantine ObeoDesigner-Community.app
. Double click the app to start.
====
135

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
136
After installation has finished launch the application for the first time and you will see a dialog for choosing a new empty directory as its workspace.
137
138
139
140

.Initial Dialog to Choose a Workspace Directory
image::SelectWorkspaceDirectory.gif[SelectWorkspaceDirectory, 500, role="thumb"]

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
141
142
143
More workspaces might come into existence later, so replace the proposed generic directory path and name with a more specific one, e.g.`ObeoDesignerWS`.
The main window appears with a Welcome Screen open.
Especially under `Documentation` you will find exhaustive documentation on Eclipse that might be of interest later, e.g.:
144

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
145
146
147
148
149
150
151
** Workbench User Guide
*** Concepts: perspectives, projects, views, editors, features, resources, ...
*** Tasks: Working with perspectives, views and editors, installing new software. ...
** EGit Documentation
*** Git for Eclipse Users
*** EGit User Guide
** Ecore Tools User Manual: Learn how to use the Ecore diagram editor.
152

153
For now, you can dismiss the welcome screen. It can be opened anytime by executing `Help -> Welcome`.
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177

Now you should see the initial window layout with _Model Explorer_ and _Outline_ on the left and a big empty editing area to the right with a _Properties_ view below.

[[quantity-plug-ins]]
.Add Plug-ins to deal with Quantities and Units

Parameter catalogs should be able to represent quantities, not just bare numbers.
See https://onlinelibrary.wiley.com/doi/full/10.1002/spe.2926[Unit of measurement libraries, their popularity and suitability] for a systematic account of open source solutions in the this area. 

Java provides an extensive framework to deal with quantities and their units defined in https://docs.google.com/document/d/12KhosAFriGCczBs6gwtJJDfg_QlANT92_lhxUWO2gCY/edit#heading=h.6698n7erex5o[Java Specification Request (JSR) 385].
The reference implementation for this framework is https://unitsofmeasurement.github.io/indriya/[Indriya]. Demos of its usage can be found at https://unitsofmeasurement.github.io/uom-demos/[].

To make Indriya available for use in Ecore data models, the author has created two plug-ins that can easily be added to Eclipse. To do so, open dialog `Help -> Install New Software...` and enter site `https://transfer.hft-stuttgart.de/pages/neqmodplus/indriya-p2/release_target_211/` like depicted below.

.Install Plug-in from Specific Update Site
image::AddUpdateSite.png[Install Plug-in , 500, role="thumb"]

Select Indriya plug-in, press `Next >` and acknowledge all following dialogs, including security warnings.

Do the same for the City Units plug-in available at site `https://transfer.hft-stuttgart.de/pages/neqmodplus/de.hft-stuttgart.cityunits/release_target_110/`
Finally, restart Eclipse to complete plug-in installation.

While the first plug-in installs Indriya, the second plug-in adds some specific units for urban simulation and Ecore types used for modeling quantities as attributes of classes.

178
Now you should see the initial layout of Eclipse with _Model Explorer_ and _Outline_ on the left and a big empty editing area to the right with a _Properties_ view below.
179
180


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
181
182
183
184
=== Exercise: Modeling a Parameter Catalog with Ecore

Before we start working on real catalog projects hosted in a Git repository in the next section, let us first create a demo project for playing around and learning basic modeling skills.

185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
[quote,Phil Karlton / N.N.]
____
There are two hard problems in computer science: cache invalidation, naming things, and off-by-1 errors.
____

It takes time and effort to come along with good names for model entities, projects, files, and so on.
Also, specific naming conventions are in place to enhance readability of models and program code.
Since it is not always clear where names provided during modeling are used later, I compiled a list of names important in Ecore projects and added examples and comments to elucidate their meaning and naming conventions.

.Naming
[width="100%",options="header"]
|====================
| Name             | Demo Catalog Example           | Real World Expample 
| Namespace URI    | http://example.org/democatalog | http://hft-stuttgart.de/buildingphysics 
| Namespace Prefix | democat                        | buildphys 
| Base Package (reverse domain)footnote:[https://en.wikipedia.org/wiki/Reverse_domain_name_notation]
201
                   | org.example                    | de.hftstuttgart 
202
203
| Main Package     | democatalog                    | buildingphysics 
| Eclipse Projectfootnote:[https://wiki.eclipse.org/Naming_Conventions#Eclipse_Workspace_Projects]
204
                   | org.example.democatalog.model  | de.hftstuttgart.buildingphysics
205
206
207
208
209
210
211
212
213
214
215
216
217
| Class Prefix     | Democatalog                    | Buildingphysics 
| XML File Suffix  | democatalog                    | buildingphysics 
| Classes          | e.g. SolarPanel                | e.g. WindowType 
| Attributes       | e.g. nominalPower              | e.g. id
| Associations     | e.g. solarPanels               | e.g. windowTypes 
|====================

Classes are written in https://en.wikipedia.org/wiki/Camel_case[Camel case notation] starting with an upper case letter. Associations and attributes are written the same way, but starting with a lower case letter.

All other names should be derived from the globally unique _name space_ of the project, in our example: `example.org/democatalog`.
It consists of a global unique domain name and a path to the project, unique within that domain.

Use the names of example _Demo Catalog_ to create your first Ecore modeling project:
218
219

. Execute `File -> New -> Ecore Modeling Project` from main menu -- not `Modeling Project`!
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
220
221
. Name the project `org.example.democatalog.model` and uncheck _Use default location_ so that the new project is *not* stored in workspace but a different directory you create/choose, then click `Next >`
. Provide `democatalog` as main Java package name, uncheck _Use default namespace parameter_ and provide `http://example.org/democatalog` as _Ns URI_ and `democat` as _Ns prefix_
222
. Click `Finish`.
223
224
225
226
227

Eclipse should look like below with an new empty graphical Ecore diagram editor opened.
The diagram is automatically named `democatalog` after the package name for the Java classes that will be generated from it (provided above).
The _Model Explorer_ shows the contents of the new Ecore modeling project.

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
228
[[fig-ecore-modeling-project]]
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
.New Ecore Modeling Project
image::DemoCatalogEmpty.png[DemoCatalogEmpty, role="thumb"]

To get your feet wet, do this:

. Drag a _Class_ from the palette on the right onto the editor's canvas: it will materialize as a rectangle labeled `NewEClass1`.
. The class symbol should be selected initially, so you can see its attributes in the _Properties_ view.
. In there replace `NewEClass1` by `EnergyComponentsCatalog` to rename the class.
. Click anywhere on the canvas and notice that the class symbol is deselected and the toolbar at the top adapts accordingly.
. In the toolbar change `100%` to `75%` to scale diagram.
. Execute `File -> Save` to save model and diagram on disk.
. Close diagram editor `democatalog` by closing its tab.
. Reopen saved diagram by double click on entry `democatalog` in _Model Explorer_. 

Technically, everything is in place now to begin modeling the data that the projected catalog shall contain.
Except ... understanding the basics of object-oriented modeling would be helpful.
This is why developers should support domain experts at this stage.

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
247

248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
.Model Data with Class Diagrams

Ecore diagrams are simplified UML class diagrams.
Here some resources on what this is all about:

* http://www.cs.toronto.edu/~sme/CSC340F/slides/11-objects.pdf[Toronto Lecture on Object Oriented Modeling]
* http://agilemodeling.com/artifacts/classDiagram.htm[UML 2 Class Diagrams: An Agile Introduction]
* https://www.amazon.de/UML-Classroom-Einführung-objektorientierte-Modellierung-ebook/dp/B00AIBE1QA/ref=sr_1_2?__mk_de_DE=ÅMÅŽÕÑ&dchild=1&keywords=UML&qid=1585854599&sr=8-2[UML @ Classroom: Eine Einführung in die objektorientierte Modellierung (German Book)]

[TIP]
====
Beginners are strongly encouraged to read the first two resources.
The first one contains a gentle introduction, especially suited for domain experts.
The second one can also serve as reference.
====

We will touch central object-oriented concepts _Class_, _Object_, _Attribute_, _Association_, _Composition_, and _Multiplicity_ in an example below, but work through above sources to get a deeper understanding and to enhance your modeling skills.

Note that above sources differentiate between _conceptual_ and _detailed_ models.
267
We go for detailed models, since only these contain enough information to generate code.
268
269
270
271
272
273
274
Having said this, it is usually a good idea to have two or three conceptual iterations at a white board to agree on the broad approach before going too much into detail.
But even if one starts with Ecore models right away, these also can be adapted any time to follow a new train of thought.

See here the essential and typical structure of a parameter catalog in a class diagram.
Instead of artificial example classes like _Foo_ and _Bar_ it shows classes from an existing catalog, albeit in very condensed form.

.Principle Structure of a Parameter Catalog
275
[plantuml, CatalogStructure, png, role="thumb"]
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
----
together {
  class SolarPanel
  class Inverter
}

class EnergyComponentsCatalog {
    author: String
}

abstract class EnergyComponent {
    modelName: String
    revisionYear: int
}

291
abstract class ChemicalDevice {
292
293
294
    installedThermalPower: double
}

295
296
297
298
abstract class ElectricalDevice {
    nominalPower : double
}

299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
class Boiler {
    type : BoilerType
}

class CombinedHeatPower {
    thermalEfficiency : double
    electricalEfficiency : double
}

class Manufacturer {
    name : String
}

enum BoilerType {
  LowTemperature
  Condensing
}

class SolarPanel {
    mppVoltage : double
    mppCurrent : double
}

class Inverter {
    maxDCVoltage : double
    maxDCCurrent : double
}

BoilerType -[hidden]- Boiler

329
330
331
332
333
334
ElectricalDevice --|> EnergyComponent
SolarPanel --|> ElectricalDevice
Inverter --|> ElectricalDevice
ChemicalDevice --|> EnergyComponent
Boiler --|> ChemicalDevice
CombinedHeatPower --|> ChemicalDevice
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355

EnergyComponentsCatalog *-- "0..*" Inverter: inverters
EnergyComponentsCatalog *-- "0..*" SolarPanel: solarPanels
EnergyComponentsCatalog *-- "0..*" Boiler: boilers
EnergyComponentsCatalog *-- "0..*" CombinedHeatPower: chps
EnergyComponentsCatalog *-- "0..*" Manufacturer: manufacturers
EnergyComponent -up-> "1..1" Manufacturer: producedBy
----

The diagram models four types of technical components whose data shall be stored in the catalog, e.g. for parameterization of simulation models later: _Boiler_, _CombinedHeatPower_, _SolarPanel_, and _Inverter_.

The catalog itself is represented by class _EnergyComponentsCatalog_.
Unlike dozens, hundreds, or even thousands of objects to be cataloged -- Boilers, Inverters etc. -- there will be just exactly *one* catalog object in the data representing the catalog itself.
Its "singularity" is not visible in the class diagram, but an _Ecore_ convention requires that all objects must form a composition hierarchy with only one root object.

.Composition
If, in the domain, one object is composed of others, this is expressed by a special kind of association called _composition_.
Compositions are depicted as a link with a diamond shape attached to the containing object. In the _Boiler_ case said link translates to: The _EnergyComponentsCatalog_ contains -- or is composed of -- zero or more (`0..*`) boiler objects stored in a list named `boilers`.

[IMPORTANT]
====
356
357
Note that class names -- despite the fact that they model a set of similar objects -- are always written in _singular_!
Names for list-like associations and attributes usually are written in plural form.
358
359
360
361
362
363
364
365
====

.Inheritance
Besides composition of *objects*, the model above shows another, completely different, kind of hierarchy: the inheritance hierarchy between *classes*.
Whenever classes of objects share the same attributes or associations, we don't like to repeat ourselves by adding that attribute or relation to all classes again and again.
Instead, we add a _super class_ to define common attributes and associations and connect it to _sub classes_ that will automatically _inherit_ all the features of their super class.

In our example above, common to all four energy components are attributes `modelName` and `revisionYear`, thus these are modeled by class `EnergyComponent` that is directly or indirectly a super class of _Boiler_, _CombinedHeatPower_, _SolarPanel_, and _Inverter_.
366
367
Similar, _Boiler_ and _CombinedHeatPower_ share attribute `installedThermalPower` factored out by class _ChemicalDevice_.
_SolarPanel_ and _Inverter_ share attribute `nominalPower` modeled in abstract class _ElectricalDevice_.
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417

.Associations
You probably noticed a fifth type of objects contained in the catalog, namely `Manufacturer` objects stored in list `manufactureres`.
How come? Ok, here is the story:

.Domain Expert Meets Developer
****
_Exp_: "`I'd like to store a component's manufacturer. Shall I add a String attribute `manufacturerName` to all classes like _Boiler_, _Inverter_ and so on to store the manufacturer's name?`"

_Dev_ shudders: "`Well, what do you mean by "... and so on"?`"

_Exp_: "`Basically, I mean all energy components.`"

_Dev_: "`Fine. We already have a class representing all those energy components, brilliantly named _EnergyComponent_. Thus, we can define `manfacturerName` there, following one of Developer's holy principles: "_DRY_ -- Don't repeat yourself!"
By the way: Is the name all you want to know about manufacturers?`"

_Exp_: "`Mhm, maybe we need to know if they are still in business ...`"

_Dev_: "`... or even since when they were out of business, if at all ...`"

_Exp_: "`... and the country or region they are active.`"

_Dev_: "`Ok, so it's not just the name -- we need a class `Manufacturer` to model all these information.`"

_Exp_ sighs.

_Dev_: "`Come on, its not that hard to add a class to our data model, isn't it?`"

_Exp_: "`Ok, but how can we express what components a manufacturer produces?`"

_Dev_: "`Wasn't it the other way around? I thought, you just wanted to know the manufacturer of a component?`"

_Exp_: "`What is the difference?`"

_Dev_: "`In data modeling, it is the difference between a uni-directional and a bi-directional association.`"

_Exp_: "`...?`"

_Dev_: "`Let's put it that way: The difference between a link with an arrow on one side or on both sides.`"

_Exp_: "`Ok. We don't need a list of components per manufacturer, but simply a reference from the component to its manufacturer.`"

_Dev_: "`Fine, then in Ecore please create a simple reference from class `EnergyComponent` to class `Manufacturer`, maybe named `producedBy`.`"

_Exp_: "`I will try this and get back to you.`"

_Dev_: "`Fine ... good meeting.`"
****

Observe in our data model, reference `producedBy` points _from_ `EnergyComponent` _to_ `Manufacturer` making it uni-directional reference.
418
One can simply query the manufacturer of a product, but not the other way around.
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
With a bi-directional reference both queries would be available.

Observe also the annotations `0..*` and `1..1` near class `Manufacturer`.
These are _multiplicities_ of associations: An `EnergyComponentsCatalog` contains zero, one, or many objects of class `Manufacturer` and an `EnergyComponent` must reference exactly one manufacturer -- not less, not more.

[.float-group]
--
.Ecore Relations
image::EcoreRelations.gif[EcoreRelations, 200, float="right", role="thumb"]

To recapitulate: Our example parameter catalog already exhibits all four types of relations provided by Ecore.
You find these in the Ecore editor's palette shown here.
To create a relation between a sub class and a super class use tool `SuperType`.
Use the other tools to create an association between classes, may it be a simple (uni-directional) reference, a bi-directional reference, or a composition.
--

.Attributes and Enumerations

Obviously, attributes are central in data modeling.
Create one by dragging it from the palette onto our one and only class so far: `EnergyComponentsCatalog`.
The class symbol will turn red to indicate an error.
Hover with the mouse pointer over the new attribute and a tooltip with a more or less helpful error message will appear.
Current error is caused by that no data type was set for the new attribute.
Data types for attributes can be integer or floating point numbers, strings, dates, booleans, and more.
To get rid of the error:

. If not already selected, select new attribute by clicking at it in the editor.
. In view _Properties_ find `EType` and click button `...` to see a quite long list of available data types.
. Choose `EString [java.lang:String]` from the list and the error is gone.

[.float-group]
--
.Class with Attribute
image::EcoreClassWithAttribute.png[EcoreClassWithAttribute, 200, float="right", role="thumb"]

Change the attribute's name to `author` and the class should look like shown here.

Most data types to choose from begin with letter *E* like in **E**core.
These are just Ecore enabled variants of the respective Java types, thus, choose EInt for an int, EFloat for a 32 bit floating point number, EDouble for a 64 bit one, and so on.

Ecore allows to introduce new data types.
We employ this feature later to enable data models with physical units and quantities.  
--

There exists one other means to define the values an attribute can take, namely enumerations of distinct literals. Take _Monday_, _Tuesday_, _Wednesday_, ... as a typical example for representing weekdays.
In our example data model you'll find one _Enumeration_ named `BoilerType` with values `LowTemperature` and `Condensing`.

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
466

467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
.Homework

The next section deals with generation of Java code from data models. To have more to play with, please implement our example model in Ecore now.

[.float-group]
--
.Abstract Class
image::EcoreClassifier.png[EcoreClassifier, 200, float="right", role="thumb"]

To do this, there is one more thing to know about classes: the difference between ordinary classes and abstract classes.
'Ordinary class' doesn't sound nice, therefore, classes that are not abstract are called _concrete_ classes.
Our example diagram depicts abstract classes with letter *A* while concrete classes are labeled with *C*. You add abstract classes to a model with a special palette tool shown here.

The thing is: Objects can be created for concrete classes only!

In our example, it makes no sense to create an object from class _EnergyComponent_, because there is not such a thing like an energy component _per se_.
Therefore, this class is _abstract_.
It is true that an inverter _is_ an energy component, thus inheriting all its features, but it was _created_ as _Inverter_, not as _EnergyComponent_.

Super classes will be abstract most of the time.
So my advice is: Model a super class as abstract class unless you convince yourself that there exist real objects in the domain that belong to the super class but, at the same time, do not belong to any of its sub classes.
In the Ecore editor properties view, you can specify if a class is abstract or not, simply by toggling check box `Abstract`.
--

Two more tips and you are ready to rock and roll! -- At least with your homework.

[TIP]
====
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
495
An exhaustive user manual for Ecore diagram editor is available at `Help -> Welcome -> Documentation -> EcoreTools User Manual`.
496
497
498
499
500
501
502
503
504
====

[TIP]
====
If Ecore models get bigger, you may find it more convenient to work with a form based UI instead of, or in addition to, the diagram editor.
Open this kind of editor via command `Open With -> Ecore Editor` from the context menu over entry `democatalog.ecore` in the _Model Explorer_ view.
Note that Eclipse synchronizes different editors of the same content automatically.
====

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
505
That's it for the data modeling part. By now, your Ecore model should look like this:
506
507

.Example Model (Homework)
508
image::Homework.png[Homework, role="thumb"]
509
510


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
511
=== Making an Application to Create and Edit Data
512

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
513
In this section you will get a glimpse on how to create an application to create and edit data conforming to the Ecore data model of our demo parameters catalog.
514

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
515
Topics described here (and much more) are discussed in this https://wiki.eclipse.org/Sirius/Tutorials/StarterTutorial/[Sirius Starter Tutorial].
516

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
517
If you are less interested in the details of UI creation, but more in working on already existing parameter catalog software and data, you may skip this section for now and proceed with <<Working with Git Hosted Catalogs>>.
518

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
519
520
521
522
523
524
525

.Generation of Java Code from Data Model 

Let us bring the Ecore data model to life, that is, generate code from it that allows to create, read, update, and delete (CRUD) concrete data objects of modeled classes in computers:

. Make sure all files are saved (`File -> Save All`)
. Execute `Generate -> All` from the context menu of Ecore editor `democatalog`
526
527
528
529
530
531

[.float-group]
--
.Generated Classes
image::GeneratedClasses.png[GeneratedClasses, 260, float="right", role="thumb"]

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
532
`Generate -> All` creates classes that represent the modeled data in code at first. These classes are located in three packages under directory `src-gen` in `org.example.democatalog.model`. Then, the command generates `Edit Code` and `Editor Code` within two new Eclipse projects named `org.example.democatalog.edit` and `org.example.democatalog.editor`, again with generated classes in `src-gen`.
533
534
535

You may have a look at some Java classes for curiosity by double clicking at them in _Model Explorer_. There is no point in trying to understand the code in detail, but observe token `@generated` present in the comments of all classes, fields and methods. Classes, fields and methods marked with this token are (re)generated whenever above commands are executed.

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
536
Sometimes it is required to manually adapt generated code -- after all our concern is "low code", not "no code" development. In that case, we will replace `@generated` by `@generated NOT` to prevent code regeneration of the respective item.
537
538
539
540
541
542
543
544
545
546

After code generation, you may have noticed some warnings showed up in view _Problems_.

.Warnings
image::Warnings.gif[Warnings, 500, role="thumb"]

In general, it is highly recommended to resolve warnings, and errors of course, but we will make an exception from the rule, since the warnings are uncritical and would reappear each time code is regenerated.
--


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
547
.Create a Prototype Application for Data Editing and UI Design
548

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
549
Firstly, launch a new instance of the running _Obeo Designer_ application:
550

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
551
552
553
. Execute `Run -> Run Configurations...` from the main menu and double click on _Eclipse Application_ to get a _New_configuration_. You may want to rename _New_configuration_ to _DemoCatalog_ or the like.
. Press `Run` to start the new Eclipse application that is basically a copy of your running _Obeo Designer_ application but with a different workspace.
. In the new application window close the welcome screen and open the Sirius perspective using the suited button in the top right corner of the main window. This perspective provides specific Sirius menus and new project types.
554

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
555
Secondly, create a project that will contain catalog data (remember Eclipse can only handle files that are part of a project):
556

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
557
558
559
. From main menu execute `File -> New -> Modeling Project` -- not `Ecore Modeling Project`!
. Name the project `org.example.democatalog.data` and uncheck _Use default location_ so that the new project -- again -- is *not* stored in workspace but a different directory you create/choose, usually a directory named like the project and sitting side by side to the model, edit and editor project directories created above.
. Click `Finish`.
560

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
561
Thirdly, create a first XML file for catalog data:
562

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
563
564
565
566
567
. From main menu execute `File -> New -> Other...` and type `demo` into search field _Wizards:_
. Select `Example EMF Model Creation Wizards -> DemoCatalog Model` and click `Next >`
. Select `org.example.democatalog.data` as parent directory and name the data file `First.democatalog`
. Click `Next >` and choose `Energy Component Catalog` as the root data object that will be created initially
. Click `Finish`.
568

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
569
570
571
572
A new entry named _First.democatalog_ should appear in the _Model Explorer_.
Double-click it and a *generic* editor will open.
In principle, one could use this editor to add new data to the catalog via `New Child >` in the context menu over entry `Energy Component Catalog`.
Data of a selected entry can be edited in view _Properties_ that is generic, too.
573

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
574
[[add-example-data]]Please add two or three boilers this way to have some data to play with below.
575

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
576
When done, you may save _First.democatalog_ so that after closing the application data will reappear if it is opened again as described above.
577

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
578
The generic editors don't get as far. Usually, one would like to have tables, custom property sheets, input validation, and more. Well, Sirius is all about creating nice graphical and form-based editors for data models specified in Ecore. To do this we need one more Eclipse project.
579
580


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
581
.UI Design Project
582

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
583
Like the *data* of our catalog is modeled as an Ecore file using a dedicated graphical editor, so will the *user interface* (tables, trees, diagrams, property views) be modeled in a Sirius `.odesign` file that lives in a special Eclipse project that we create while still in the (second) Eclipse application that hosts the data:
584

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
585
586
587
. Execute `File -> New -> ViewPoint Specification Project`
. Name the project `org.example.democatalog.design`, uncheck _Use default location_ as always and  create/choose a directory with the same name as the project besides to the model, edit, editor, and data project directories
. Click `Finish`.
588

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
589
590
591
A special editor for file `democatalog.odesign` appears automatically.
In it select `MyViewpoint` and rename it in _Properties_ to `Catalog`.
A viewpoint provides a set of representations (tables, trees, diagrams, property views) that end-users can instantiate.
592
593


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
594
.Adding a Table to the UI
595
 
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
596
597
In what follows, we work with the _democatalog.odesign_ editor.
Say, we want to add a table for boilers to the UI:
598

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
599
600
601
602
. From context menu over viewpoint _Catalogs_ execute `New Representation -> Edition Table Description` to create a new description that is automatically selected and shown in view _Properties_
. To connect the table with its data model, choose tab _Metamodels_ in _Properties_, click on _Add from registry_ and select `http://example.org/democatalog`.
. Go back to tab _General_ and enter `Boiler_table` as _Id_.
. In the green input field _Domain Class_ press key ctrl-space and choose `democatalog::EnergyComponentCatalog` from the list.
603

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
604
From the above _Boiler_tables_ know that they present data conforming to our `http://example.org/democatalog` data model and that boiler data are found as part -- or "below" -- the Energy Component Catalog.
605

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
606
Next, specify the lines to be displayed in the table:
607

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
608
609
610
. From context menu over _Boiler_table_ create `New Table Element -> Line`
. In tab _General_ in _Properties_, enter `Boiler_line` as _Id_:
. In the green input field _Domain Class_ press key ctrl-space and choose `democatalog::Boiler` from the list.
611

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
612
And now for the columns:
613

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
614
615
616
617
. From context menu over _Boiler_table_ create `New Table Element -> Feature Column`
. In tab _General_ in _Properties_, enter `Name_col` as _Id_:
. In the green input field _Feature Name_ press key ctrl-space and choose `modelName` from the list
. Repeat the above steps for `boilerType` and `installedThermalPower` accordingly.
618

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
619
After addition of some foreground and background styles, the design of the UI looks like this.
620

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
621
622
.Boiler Tables Design
image::BoilerTableDesign.png[BoilerTableAndProperties, role="thumb"]
623

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
624
Save it!
625

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
626
To create an instance of the table just designed double-click on `representations.aird` in the data project:
627

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
628
629
.Administration of Model and Representations
image::BoilerRepresentations.png[BoilerRepresentations, role="thumb"]
630

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
631
In case viewpoint `Catalogs` under header _Representations_ is still disabled as shown above, select it and press `Enable`. Then:
632

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
633
634
635
636
. Press `New...` to open a _Create Representation Wizard_
. Choose `Boiler_table` and click `Next >`
. Select `Energy Components Catalog` as data source and click `Finish`
. You are prompted for the new tables name: simply confirm the proposed name with `OK`.
637

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
638
[.float-group]
639
--
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
640
641
.Boiler Table with Properties View
image::BoilerTableAndProperties.png[BoilerTableAndProperties, 350, float="right", role="thumb"]
642

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
643
The screenshot on the right shows _new Boiler_table_ with just two entries. Details of the selected entry are editable in _Properties_.
644

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
645
646
Is your table empty? In this case you probably did not add example data using the default editor as described xref:add-example-data[above].
But you can add new Boilers any time via command `New child -> Boiler` in the context menu of `Energy Component Catalog` in section _Models_ of the representations editor depicted above.
647
648
--

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
649
650
Note, that you can delete boilers from the table's context menu, but currently there is no button or menu entry to create new boilers.
Such a command would have to be described in `democatalog.odesign` first.
651

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
652
653
654
Be aware that applications with UI design and example data launched from _Obeo Designer_ are meant to be prototypes for the final software only.
In fact, any saved changes in the design file are instantly reflected in the UI.
During refinement of model and UI, data sets can be created, edited, and tested for usability without the need to built deployable software component. (On deployment, see parts _Accessing and Using Parameter Catalogs_ and _Build (Parameter Catalog) Applications with Eclipse Tycho_ below.)
655

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
656
657
Iteratively the UI design must be adapted to changes in data model, although some changes are automatically reflected in the generated UI, at least for default forms.
Data model changes can also can render existing XML data incompatible. There are tools for data migration, but for now, recreation of test data or manual editing of XML file is the way to go.
658

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
659
660
661
As you may imagine, this is just the tip of the iceberg of what can be done with the Sirius framework for designing graphical UIs.
While domain experts should be capable to create and to refine Ecore data models, the UI design of a parameter catalogs will mainly be done by software developers.
However, since the UI is not implemented by program code, but a description in an `.odesign` file, domain experts can easily enhance and tweak it, e.g. by adding or reordering columns of a table.
662
663


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
664
=== Working with Git Hosted Parameter Catalogs
665

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
666
667
Ecore data models and Sirius based UI design are used to create parameter catalog software hosted in Git repositories.
To work with these, all you need is Jave 16 and the _Obeo Designer_ with plug-ins for handling of Units installed (see <<Setup Obeo Designer>> for details.)
668
669


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
670
.Import Modeling Projects from Git
671

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
672
To connect to a Git repository open the _Import Projects from Git_ wizard via `File -> Import... -> Git -> Projects from Git -> Clone URI`. Then:
673

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
674
675
676
677
678
679
680
. Copy the URI of the git repository into the according input field, e.g.:
https://rs-loy-gitlab.concordia.ca/parameter-catalogs-ecore/greenery-catalog.git and provide your credentials in fields _User_ and _Password_. *Tick check box _Store in Secure Store_ and provide a master password if required!* If you don't, be prepared to be prompted for your credentials over and over again
. Click `Next >` and select a repository branch to check out, usually _master_
. Click `Next >` and choose the directory on your file system where to store the repository, e.g.
`<user home>/git/greenery-catalog`. Here, we adhere to the convention is to have all git repositories stored in `<user home>/git/`
. After data transfer has completed, the wizard offers to _Import existing Eclipse projects_. Click `Next >` and select the project with suffix `.model`,  `.edit` and `.editor` for import, e.g. `ca.concordia.usp.greenerycatalog.model` etc.
. Click `Finish`.
681

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
682
Now you can work on the data model like you did with the demo catalog. Find it under `model` in `ca.concordia.usp.greenerycatalog.model` (compare fig. <<fig-ecore-modeling-project>>).
683
684


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
685
.Catalog Data and UI Design
686

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
687
688
For data inspection and editing -- and possibly modifying the UI -- launch a new instance of the running Obeo Designer application by executing `Run -> Run Configurations...`, double-click on _Eclipse Application_ to get a _New_configuration_ and give it a meaningful name (e.g. _GreeneryCatalog_).
Then, press `Run` to start the application, close the welcome screen and open the Sirius perspective using the suited button in the top right corner of the main window.
689

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
690
691
692
693
[TIP]
====
Simply reuse the _Run Configuration_ specified above, when starting the application next time!
====
694

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
695
Now, import the projects that contain data and UI design, respectively:
696

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
697
698
699
. Execute `File -> Import...` for the import wizard
. Browse to the directory containing the projects (e.g. `<user home>/git/greenery-catalog`) and check just the projects with suffixes `.data` and `.design` for import, e.g. `ca.concordia.usp.greenerycatalog.data` , `ca.concordia.usp.greenerycatalog.design`
. Click `Finish`.
700

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
701
When closing the application, it asks to store or dismiss any changes in data or UI design. You can also save these any time with `File -> Save All`.
702
703


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
704
.Declare Quantities
705

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
706
707
For simplicity, the demo catalog only used built-in attribute types like `EDouble`, `EInt`, or `EString`.
On the other hand, real-world parameter catalogs use a custom type named _Quantity_ that combines a numerical (double) value with a unit.
708

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
709
710
Symbols for defining units follow SI and other standards, including decimal prefixes like `m` for Milli or `G` for Giga as well as derived units, that is: `mV`, `GV` or `kW·h/m³` are all valid unit definitions.
This is all documented well in the resources mentioned in section xref:quantity-plug-ins[Add Plug-ins to deal with Quantities and Units] above, but for convenience, a table with valid units, including some specific units for urban simulation, is compiled in link:UnitsExamples.md[].
711

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
712
713
To set an attribute's type to _Quantity_ just select it in the model, choose tab _Semantic_ in view _Properties_, click on _EType_ and select _Quantity_ from the list of available types.
In the figure below, this was already done.
714

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
715
716
.Quantity Default Values
image::QuantityDefaultValues.png[QuantityDefaultValues , 400, role="thumb"]
717

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
718
The red arrow shows how a unit is defined in field _Default Value Literal_. E.g., attribute `densityOfDrySoil` has unit `kg/m³` assigned to it.
719

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
720
721
Note that, for this attribute, no numerical default value is given.
In contrast, `conductivityOfDrySoil` is given a unit and a default numerical value: `1.0 W/(m*K)`.
722

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
723
724
725
726
[IMPORTANT]
====
The unit of a _Quantity_ is definied by the sub-string that follows the first space character in the string given in _Default Value Literal_. The sub-string before that space is interpreted as default numerical value of the _Quantity_.
====
727

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
728
The rules for how a _Quantity_ default value is converted to its unit and default (initial) numerical value are very "forgiving":
729

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
730
731
732
* If no unit is given or it cannot be parsed to a valid unit, it will be regarded as _dimensionless_. E.g., index values, fractions and percentages are dimensionless quantities by purpose. While units may be displayed in the UI like `[kg]`, a dimensionless quantity will show up as `[]`, that is as the empty string.
* If no numerical default value is present, then the numerical value is regarded as undefined.
* You may choose to specify a quantity as dimensionless and without numeric default by leaving field _Default Value Literal_ empty (or provide some non-sensical string).
733

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
734
By this rules, any string -- including the empty string -- will be interpreted as a _Quantity_ somehow.
735
736


Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
737
.Declare Ranges
738

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
739
What is the point in declaring a dimensionless quantity for an attribute, anyway, instead of just declare it `EDouble` or `EInt`? The answer is that quantities can -- and most of the time will -- have a range of valid values defined.
740

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
741
742
[.float-group]
--
743

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
744
745
.Quantity Range Definition
image::QuantityRange.png[Quantity Range , 250, float="right", role="thumb"]
746

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
747
748
749
As you can see in the screenshot, the allowed range of attribute values is defined by a so called Ecore annotation named `UomQuantities`.
It provides the minimal and/or maximal value for the attribute, inclusively.
If a minimal or maximal value is omitted or invalid, the range is not limited on that side.
750

751
One could add annotations to an attribute in the graphical Ecore editor under tab _Annotation_ in _Properties_, but it may be more convenient to do this in the standard editor that is opened by `Open With -> Sample Ecore Model Editor` from the context menu over the Ecore model file in _Model Explorer_.
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
752
--
753

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
754
In this editor, define a range like this:
755

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
756
757
. From the context menu of the attribute of interest execute `New Child -> EAnnotation` and type `http://www.hft-stuttgart.de/UomQuantities` into field `Source` as depicted above
. From the context menu of the new `UomQuantities` annotation execute `New Child -> Details Entry` and provide values for keys `min` and `max`, respectively.
758

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
759
[TIP]
760
====
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
761
The above typing is a one time effort only, since for defining further ranges, one simply copies an existing `UomQuantity` annotation from one attribute to another one and just edits the values for `min` and `max`.
762
====
763

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
764
765
766
767
If a catalog's end user tries to enter a number outside the given range in the UI, it will be adapted automatically to a valid value.


.Declare Tooltips for Help
768

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
769
770
771
772
Again, domain experts use a specific annotation to provide short help texts that inform end-users about an attribute's purpose, range and so on.
(These texts are displayed as tooltips when the users mouse stays on top of a question mark.)
And again, this is possible only in another kind of editor -- this time the editor that is opened on a `.genmodel` in _Model Explorer_.
Each Ecore model is accompanied by a `.genmodel` that lives besides the respective `.ecore` file. Open the required editor from its context menu with `Open With -> EMF Generator`.
773

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
774
The picture below shows the details. Just open the `.genmodel` tree until you can select the attribute that shall be documented.
775

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
776
777
778
779
780
781
782
.Quantity Documentation
image::QuantityDocumentation.png[Quantity Documentation, role="thumb"]

In its `Properties` provide the tooltip in field `Edit -> Property Description`.
In this example, the same text was also copied to `Model -> Documentation`.
These texts are automatically inserted into comments in the generated program code, so that they 
can inform a programmer that wants to use the generated API.
783
784


785
=== Summary
786

787
788
Congratulations on making it this far. What have we achieved?

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
789
We get to know the _Obeo Designer_ IDE and created a graphical Ecore data model with one catalog class and five classes/types of domain objects therein.
790
791
792
793
794
Classes have been defined by name, attributes, and relationships between them, often with cardinalities.
Whenever classes shared some attributes or relationships we factored these out into super classes.
An enumeration introduced a new attribute type as a set of named values.

From this data model, we issued commands to create Java code for representing the data in memory as well as to store and retrieve them on and from disk. Methods to create, read, update and delete data objects (CRUD) were generated, too.
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
795
We implemented a prototypical user interface for this data with _Eclipse Sirius_ by providing a `.odesign` model for that very UI.
796

Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
797
Lastly, we started working on real world parameter catalogs hosted in git repositories and introduced _Quantity_ as a custom attribute type to model quantities as numerical values with defined units.