ParameterCatalogs.html 117 KB
Newer Older
Kai-Holger Brassel's avatar
Kai-Holger Brassel committed
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
<ul>
<li>
<p>Concepts: features, resources, perspectives, views, editors</p>
</li>
<li>
<p>Opening perspectives and views</p>
</li>
<li>
<p>Installing new software manually</p>
</li>
</ul>
</div>
</li>
<li>
<p>Team support with Git</p>
</li>
</ul>
</div>
</li>
<li>
<p>Learn how to use the Ecore diagram editor</p>
</li>
<li>
<p>Launch the Eclipse Marketplace</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>For now, you can dismiss the welcome screen. It can be opened anytime by executing <code>Help &#8594; Welcome</code></p>
</div>
</div>
<div class="sect2">
<h3 id="truemodeling-parameter-catalogs-for-simulation-with-ecore"><a class="anchor" href="#truemodeling-parameter-catalogs-for-simulation-with-ecore"></a>Modeling Parameter Catalogs for Simulation with Ecore</h3>
<div class="paragraph">
<p>Now you should see the initial layout of Eclipse with <em>Model Explorer</em> and <em>Outline</em> on the left and a big empty editing area with <em>Properties</em> view below to the right.</p>
</div>
<div class="paragraph">
<p>Since we will use Ecore diagrams for data modeling, create your first Ecore modeling project now:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Execute <code>File &#8594; New &#8594; Ecore Modeling Project</code> from main menu&#8201;&#8212;&#8201;not <code>Modeling Project</code>!</p>
</li>
<li>
<p>Name it <code>demo.catalog</code> and click <code>Next &gt;</code></p>
</li>
<li>
<p>Uncheck <code>Use Default Location</code> so that the new project is <strong>not</strong> stored in workspace, but a different directory you create/choose, then click <code>Next &gt;</code></p>
</li>
<li>
<p>Provide <code>democatalog</code> as main Java package name and click <code>Finish</code>.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Eclipse should look like below with an new empty graphical Ecore diagram editor opened.
The diagram is automatically named <code>democatalog</code> after the package name for the Java classes that will be generated from it (provided above).
The <em>Model Explorer</em> shows the contents of the new Ecore modeling project.</p>
</div>
<div class="imageblock thumb">
<div class="content">
<img src="ParameterCatalogs2Images/DemoCatalogEmpty.png" alt="DemoCatalogEmpty">
</div>
<div class="title">Figure 3. New Ecore Modeling Project</div>
</div>
<div class="paragraph">
<p>To get your feet wet, do this:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Drag a <em>Class</em> from the palette on the right onto the editor&#8217;s canvas: it will materialize as a rectangle labeled <code>NewEClass1</code>.</p>
</li>
<li>
<p>The class symbol should be selected initially, so you can see its attributes in the <em>Properties</em> view.</p>
</li>
<li>
<p>In there replace <code>NewEClass1</code> by <code>EnergyComponentsCatalog</code> to rename the class.</p>
</li>
<li>
<p>Click anywhere on the canvas and notice that the class symbol is deselected and the toolbar at the top adapts accordingly.</p>
</li>
<li>
<p>In the toolbar change <code>100%</code> to <code>75%</code> to scale diagram.</p>
</li>
<li>
<p>Execute <code>File &#8594; Save</code> to save model and diagram on disk.</p>
</li>
<li>
<p>Close diagram editor <code>democatalog</code> by closing its tab.</p>
</li>
<li>
<p>Reopen saved diagram by double click on entry <code>democatalog</code> in <em>Model Explorer</em>.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>Technically, everything is in place now to begin modeling the data that the projected catalog shall contain.
Except &#8230;&#8203; understanding the basics of object-oriented modeling would be helpful.
This is why developers should support domain experts at this stage.</p>
</div>
<div class="paragraph">
<div class="title">Model Data with Class Diagrams</div>
<p>Ecore diagrams are simplified UML class diagrams.
Here some resources on what this is all about:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><a href="http://www.cs.toronto.edu/~sme/CSC340F/slides/11-objects.pdf">Toronto Lecture on Object Oriented Modeling</a></p>
</li>
<li>
<p><a href="http://agilemodeling.com/artifacts/classDiagram.htm">UML 2 Class Diagrams: An Agile Introduction</a></p>
</li>
<li>
<p><a href="https://www.amazon.de/UML-Classroom-Einführung-objektorientierte-Modellierung-ebook/dp/B00AIBE1QA/ref=sr_1_2?__mk_de_DE=ÅMÅŽÕÑ&amp;dchild=1&amp;keywords=UML&amp;qid=1585854599&amp;sr=8-2">UML @ Classroom: Eine Einführung in die objektorientierte Modellierung (German Book)</a></p>
</li>
</ul>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>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.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>We will touch central object-oriented concepts <em>Class</em>, <em>Object</em>, <em>Attribute</em>, <em>Association</em>, <em>Composition</em>, and <em>Multiplicity</em> in an example below, but work through above sources to get a deeper understanding and to enhance your modeling skills.</p>
</div>
<div class="paragraph">
<p>Note that above sources differentiate between <em>conceptual</em> and <em>detailed</em> models.
All in all we go for detailed models, since only these contain enough information to generate code.
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.</p>
</div>
<div class="paragraph">
<p>See here the essential and typical structure of a parameter catalog in a class diagram.
Instead of artificial example classes like <em>Foo</em> and <em>Bar</em> it shows classes from an existing catalog, albeit in very condensed form.</p>
</div>
<div class="imageblock thumb">
<div class="content">
<img src="http://localhost:56397/afx/cache/8068a4d732d1847a062d97696687b38f.png" alt="8068a4d732d1847a062d97696687b38f">
</div>
<div class="title">Figure 4. Principle Structure of a Parameter Catalog</div>
</div>
<div class="paragraph">
<p>The diagram models four types of technical components whose data shall be stored in the catalog, e.g. for parameterization of simulation models later: <em>Boiler</em>, <em>CombinedHeatPower</em>, <em>SolarPanel</em>, and <em>Inverter</em>.</p>
</div>
<div class="paragraph">
<p>The catalog itself is represented by class <em>EnergyComponentsCatalog</em>.
Unlike dozens, hundreds, or even thousands of objects to be cataloged&#8201;&#8212;&#8201;Boilers, Inverters etc.&#8201;&#8212;&#8201;there will be just exactly <strong>one</strong> catalog object in the data representing the catalog itself.
Its "singularity" is not visible in the class diagram, but an <em>Ecore</em> convention requires that all objects must form a composition hierarchy with only one root object.</p>
</div>
<div class="paragraph">
<div class="title">Composition</div>
<p>If, in the domain, one object is composed of others, this is expressed by a special kind of association called <em>composition</em>.
Compositions are depicted as a link with a diamond shape attached to the containing object. In the <em>Boiler</em> case said link translates to: The <em>EnergyComponentsCatalog</em> contains&#8201;&#8212;&#8201;or is composed of&#8201;&#8212;&#8201;zero or more (<code>0..*</code>) boiler objects stored in a list named <code>boilers</code>.</p>
</div>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Note that class names&#8201;&#8212;&#8201;despite the fact that they model a set of similar objects&#8201;&#8212;&#8201;are always written in <em>singular</em>! They are written in <a href="https://en.wikipedia.org/wiki/Camel_case">Camel case notation</a> starting with an upper case letter. Associations and attributes are written the same way, but starting with a lower case letter. Names for list-like associations and attributes usually are written in plural form.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<div class="title">Inheritance</div>
<p>Besides composition of <strong>objects</strong>, the model above shows another, completely different, kind of hierarchy: the inheritance hierarchy between <strong>classes</strong>.
Whenever classes of objects share the same attributes or associations, we don&#8217;t like to repeat ourselves by adding that attribute or relation to all classes again and again.
Instead, we add a <em>super class</em> to define common attributes and associations and connect it to <em>sub classes</em> that will automatically <em>inherit</em> all the features of their super class.</p>
</div>
<div class="paragraph">
<p>In our example above, common to all four energy components are attributes <code>modelName</code> and <code>revisionYear</code>, thus these are modeled by class <code>EnergyComponent</code> that is directly or indirectly a super class of <em>Boiler</em>, <em>CombinedHeatPower</em>, <em>SolarPanel</em>, and <em>Inverter</em>.
Similar, <em>Boiler</em> and <em>CombinedHeatPower</em> share attribute <code>installedThermalPower</code> factored out by class <em>ChemicalEnergyDevice</em>.</p>
</div>
<div class="paragraph">
<div class="title">Associations</div>
<p>You probably noticed a fifth type of objects contained in the catalog, namely <code>Manufacturer</code> objects stored in list <code>manufactureres</code>.
How come? Ok, here is the story:</p>
</div>
<div class="sidebarblock">
<div class="content">
<div class="title">Domain Expert Meets Developer</div>
<div class="paragraph">
<p><em>Exp</em>: &#8220;I&#8217;d like to store a component&#8217;s manufacturer. Shall I add a String attribute <code>manufacturerName</code> to all classes like <em>Boiler</em>, <em>Inverter</em> and so on to store the manufacturer&#8217;s name?&#8221;</p>
</div>
<div class="paragraph">
<p><em>Dev</em> shudders: &#8220;Well, what do you mean by "&#8230;&#8203; and so on"?&#8221;</p>
</div>
<div class="paragraph">
<p><em>Exp</em>: &#8220;Basically, I mean all energy components.&#8221;</p>
</div>
<div class="paragraph">
<p><em>Dev</em>: &#8220;Fine. We already have a class representing all those energy components, brilliantly named <em>EnergyComponent</em>. Thus, we can define <code>manfacturerName</code> there, following one of Developer&#8217;s holy principles: "<em>DRY</em>&#8201;&#8212;&#8201;Don&#8217;t repeat yourself!"
By the way: Is the name all you want to know about manufacturers?&#8221;</p>
</div>
<div class="paragraph">
<p><em>Exp</em>: &#8220;Mhm, maybe we need to know if they are still in business &#8230;&#8203;&#8221;</p>
</div>
<div class="paragraph">
<p><em>Dev</em>: &#8220;&#8230;&#8203; or even since when they were out of business, if at all &#8230;&#8203;&#8221;</p>
</div>
<div class="paragraph">
<p><em>Exp</em>: &#8220;&#8230;&#8203; and the country or region they are active.&#8221;</p>
</div>
<div class="paragraph">
<p><em>Dev</em>: &#8220;Ok, so it&#8217;s not just the name&#8201;&#8212;&#8201;we need a class <code>Manufacturer</code> to model all these information.&#8221;</p>
</div>
<div class="paragraph">
<p><em>Exp</em> sighs.</p>
</div>
<div class="paragraph">
<p><em>Dev</em>: &#8220;Come on, its not that hard to add a class to our data model, isn&#8217;t it?&#8221;</p>
</div>
<div class="paragraph">
<p><em>Exp</em>: &#8220;Ok, but how can we express what components a manufacturer produces?&#8221;</p>
</div>
<div class="paragraph">
<p><em>Dev</em>: &#8220;Wasn&#8217;t it the other way around? I thought, you just wanted to know the manufacturer of a component?&#8221;</p>
</div>
<div class="paragraph">
<p><em>Exp</em>: &#8220;What is the difference?&#8221;</p>
</div>
<div class="paragraph">
<p><em>Dev</em>: &#8220;In data modeling, it is the difference between a uni-directional and a bi-directional association.&#8221;</p>
</div>
<div class="paragraph">
<p><em>Exp</em>: &#8220;&#8230;&#8203;?&#8221;</p>
</div>
<div class="paragraph">
<p><em>Dev</em>: &#8220;Let&#8217;s put it that way: The difference between a link with an arrow on one side or on both sides.&#8221;</p>
</div>
<div class="paragraph">
<p><em>Exp</em>: &#8220;Ok. We don&#8217;t need a list of components per manufacturer, but simply a reference from the component to its manufacturer.&#8221;</p>
</div>
<div class="paragraph">
<p><em>Dev</em>: &#8220;Fine, then in Ecore please create a simple reference from class <code>EnergyComponent</code> to class <code>Manufacturer</code>, maybe named <code>producedBy</code>.&#8221;</p>
</div>
<div class="paragraph">
<p><em>Exp</em>: &#8220;I will try this and get back to you.&#8221;</p>
</div>
<div class="paragraph">
<p><em>Dev</em>: &#8220;Fine &#8230;&#8203; good meeting.&#8221;</p>
</div>
</div>
</div>
<div class="paragraph">
<p>Observe in our data model, reference <code>producedBy</code> points <em>from</em> <code>EnergyComponent</code> <em>to</em> <code>Manufacturer</code> making it uni-directional reference.
One can simply query the manufacturer of a product, but not so the other way around.
With a bi-directional reference both queries would be available.</p>
</div>
<div class="paragraph">
<p>Observe also the annotations <code>0..*</code> and <code>1..1</code> near class <code>Manufacturer</code>.
These are <em>multiplicities</em> of associations: An <code>EnergyComponentsCatalog</code> contains zero, one, or many objects of class <code>Manufacturer</code> and an <code>EnergyComponent</code> must reference exactly one manufacturer&#8201;&#8212;&#8201;not less, not more.</p>
</div>
<div class="openblock float-group">
<div class="content">
<div class="imageblock right thumb">
<div class="content">
<img src="ParameterCatalogs2Images/EcoreRelations.gif" alt="EcoreRelations" width="200">
</div>
<div class="title">Figure 5. Ecore Relations</div>
</div>
<div class="paragraph">
<p>To recapitulate: Our example parameter catalog already exhibits all four types of relations provided by Ecore.
You find these in the Ecore editor&#8217;s palette shown here.
To create a relation between a sub class and a super class use tool <code>SuperType</code>.
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.</p>
</div>
</div>
</div>
<div class="paragraph">
<div class="title">Attributes and Enumerations</div>
<p>Obviously, attributes are central in data modeling.
Create one by dragging it from the palette onto our one and only class so far: <code>EnergyComponentsCatalog</code>.
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:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>If not already selected, select new attribute by clicking at it in the editor.</p>
</li>
<li>
<p>In view <em>Properties</em> find <code>EType</code> and click button <code>&#8230;&#8203;</code> to see a quite long list of available data types.</p>
</li>
<li>
<p>Choose <code>EString [java.lang:String]</code> from the list and the error is gone.</p>
</li>
</ol>
</div>
<div class="openblock float-group">
<div class="content">
<div class="imageblock right thumb">
<div class="content">
<img src="ParameterCatalogs2Images/EcoreClassWithAttribute.png" alt="EcoreClassWithAttribute" width="200">
</div>
<div class="title">Figure 6. Class with Attribute</div>
</div>
<div class="paragraph">
<p>Change the attribute&#8217;s name to <code>author</code> and the class should look like shown here.</p>
</div>
<div class="paragraph">
<p>Most data types to choose from begin with letter <strong>E</strong> like in <strong>E</strong>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.</p>
</div>
<div class="paragraph">
<p>Ecore allows to introduce new data types.
We employ this feature later to enable data models with physical units and quantities.</p>
</div>
</div>
</div>
<div class="paragraph">
<p>There exists one other means to define the values an attribute can take, namely enumerations of distinct literals. Take <em>Monday</em>, <em>Tuesday</em>, <em>Wednesday</em>, &#8230;&#8203; as a typical example for representing weekdays.
In our example data model you&#8217;ll find one <em>Enumeration</em> named <code>BoilerType</code> with values <code>LowTemperature</code> and <code>Condensing</code>.</p>
</div>
<div class="paragraph">
<div class="title">Homework</div>
<p>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.</p>
</div>
<div class="openblock float-group">
<div class="content">
<div class="imageblock right thumb">
<div class="content">
<img src="ParameterCatalogs2Images/EcoreClassifier.png" alt="EcoreClassifier" width="200">
</div>
<div class="title">Figure 7. Abstract Class</div>
</div>
<div class="paragraph">
<p>To do this, there is one more thing to know about classes: the difference between ordinary classes and abstract classes.
'Ordinary class' doesn&#8217;t sound nice, therefore, classes that are not abstract are called <em>concrete</em> classes.
Our example diagram depicts abstract classes with letter <strong>A</strong> while concrete classes are labeled with <strong>C</strong>. You add abstract classes to a model with a special palette tool shown here.</p>
</div>
<div class="paragraph">
<p>The thing is: Objects can be created for concrete classes only!</p>
</div>
<div class="paragraph">
<p>In our example, it makes no sense to create an object from class <em>EnergyComponent</em>, because there is not such a thing like an energy component <em>per se</em>.
Therefore, this class is <em>abstract</em>.
It is true that an inverter <em>is</em> an energy component, thus inheriting all its features, but it was <em>created</em> as <em>Inverter</em>, not as <em>EnergyComponent</em>.</p>
</div>
<div class="paragraph">
<p>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 <code>Abstract</code>.</p>
</div>
</div>
</div>
<div class="paragraph">
<p>Two more tips and you are ready to rock and roll!&#8201;&#8212;&#8201;At least with your homework.</p>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>An exhaustive user manual for Ecore diagram editor is available. Execute <code>Help &#8594; Welcome</code> and follow link <code>Learn how to use the diagram editor</code>.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>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 <code>Open With &#8594; Ecore Editor</code> from the context menu over entry <code>democatalog.ecore</code> in the <em>Model Explorer</em> view.
Note that Eclipse synchronizes different editors of the same content automatically.</p>
</div>
</td>
</tr>
</table>
</div>
</div>
<div class="sect2">
<h3 id="truegeneration-of-java-code-from-data-model"><a class="anchor" href="#truegeneration-of-java-code-from-data-model"></a>Generation of Java Code from Data Model</h3>
<div class="paragraph">
<p>By now, your Ecore model should look like this:</p>
</div>
<div id="fig-example-model" class="imageblock thumb">
<div class="content">
<img src="ParameterCatalogs2Images/Homework.gif" alt="Homework">
</div>
<div class="title">Figure 8. Example Model (Homework)</div>
</div>
<div class="paragraph">
<p>Let us bring the model to life, that is, generate code from it that creates, reads, updates, and deletes concrete data objects of modeled classes in computers.
I would like to tell you that this is done with just one click but, actually, you need two or three:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Make sure all files are saved (<code>File &#8594; Save All</code>)</p>
</li>
<li>
<p>Execute <code>Generate &#8594; Model Code</code> from context menu over <code>democatalog.ecore</code></p>
</li>
<li>
<p>Execute <code>Generate &#8594; Edit Code</code> from context menu over <code>democatalog.ecore</code></p>
</li>
</ol>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Please do <strong>not</strong> execute <code>Generate &#8594; All</code> or <code>Generate &#8594; Editor Code</code>.</p>
</div>
<div class="imageblock thumb">
<div class="content">
<img src="ParameterCatalogs2Images/GenerateMenu.png" alt="GeneratedClasses" width="260">
</div>
</div>
<div class="paragraph">
<p>This would create code for a simple user interface, but we use more advanced EMF Forms for that later.
If, by mistake, project <code>demo.catalog.editor</code> was created, just delete it from <em>Model Explorer</em> and do not forget to check <code>Delete project contents on disk</code> in confirmation dialog.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="openblock float-group">
<div class="content">
<div class="imageblock right thumb">
<div class="content">
<img src="ParameterCatalogs2Images/GeneratedClasses.png" alt="GeneratedClasses" width="260">
</div>
<div class="title">Figure 9. Generated Classes</div>
</div>
<div class="paragraph">
<p><code>Generate &#8594; Model Code</code> creates classes that represent the modeled data in code. These classes are located in three packages under directory <code>src-gen</code> in <code>demo.catalog</code>.</p>
</div>
<div class="paragraph">
<p><code>Generate &#8594; Edit Code</code> creates a whole new Eclipse project named <code>demo.catalog.edit</code>, again with generated classes under directory <code>src-gen</code>.</p>
</div>
<div class="paragraph">
<p>You may have a look at some Java classes for curiosity by double clicking at them in <em>Model Explorer</em>. There is no point in trying to understand the code in detail, but observe token <code>@generated</code> 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.</p>
</div>
<div class="paragraph">
<p>Sometimes it maybe required to manually adapt generated code&#8201;&#8212;&#8201;after all our concern is "low code", not "no code" development. In that case, we will replace <code>@generated</code> by <code>@generated NOT</code> to prevent code regeneration.</p>
</div>
<div class="paragraph">
<p>After code generation, you may have noticed some warnings showed up in view <em>Problems</em>.</p>
</div>
<div class="imageblock thumb">
<div class="content">
<img src="ParameterCatalogs2Images/Warnings.gif" alt="Warnings" width="500">
</div>
<div class="title">Figure 10. Warnings</div>
</div>
<div class="paragraph">
<p>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.</p>
</div>
</div>
</div>
</div>
<div class="sect2">
<h3 id="truegeneration-and-tweaking-of-user-interface"><a class="anchor" href="#truegeneration-and-tweaking-of-user-interface"></a>Generation and Tweaking of User Interface</h3>
<div class="paragraph">
<p>In this section you will learn how to generate and tweak a CRUD user interface based on Ecore data model and Java classes created for our demo parameters catalog above. Topics described here are discussed in more detail in tutorial <a href="https://eclipsesource.com/blogs/tutorials/getting-started-with-EMF-Forms/">Getting started with EMF Forms</a>.
To find out what user interface controls and layouts are provided by this framework have a look at <a href="https://eclipsesource.com/blogs/tutorials/emf-forms-view-model-elements/">EMF Forms – View Model Elements</a>. <em>EMF Forms</em> is already part of package <em>Eclipse Modeling Tools</em>, so we can create a third Eclipse project/plugin that implements a user interface for editing catalog data without further ado:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>From context menu over <code>democatalog.ecore</code> execute <code>EMF Forms &#8594; Create View Model Project</code></p>
</li>
<li>
<p>Leave project name <code>demo.catalog.viewmodel</code> as is but uncheck <code>Use default location</code>&#8201;&#8212;&#8201;as we always do&#8201;&#8212;&#8201;and browse to the directory containing <code>demo.catalog</code></p>
</li>
<li>
<p>Click <code>Next &gt;</code> and select <code>EnergyComponentsCatalog</code> as data element we want to create a user interface for</p>
</li>
<li>
<p>Leave <code>Fill view model with default layout</code> checked and click <code>Finish</code>.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>According to these inputs a new project is created with file <code>EnergyComponentsCatalog.view</code> under directory <code>view models</code>.
This file opens automatically in a special <em>View Editor</em>.</p>
</div>
<div class="imageblock thumb">
<div class="content">
<img src="ParameterCatalogs2Images/ViewModel.png" alt="ViewModel1">
</div>
<div class="title">Figure 11. New View Model</div>
</div>
<div class="paragraph">
<p>Like the <strong>data</strong> of our catalog are modeled as Ecore file using a dedicated graphical editor, so will our catalog’s <strong>user interface</strong> be modeled in <code>.view</code> files, again using a special editor.</p>
</div>
<div class="paragraph">
<p>Since we opted for <code>Fill view model with default layout</code> the catalog&#8217;s UI is filled initially with default controls for all data items assigned to Ecore type <code>EnergyComponentsCatalog</code> like a string control for <code>author</code> or list controls for <code>boilers</code>, <code>chps</code>, and so on.</p>
</div>
<div class="paragraph">
<p>See red arrow in the above screen-shot?
It points to a button that opens a functional preview of the modeled user interface.</p>
</div>
<div class="imageblock thumb">
<div class="content">
<img src="ParameterCatalogs2Images/ViewEditorPreview.png" alt="ViewModel1" width="500">
</div>
<div class="title">Figure 12. User Interface Preview</div>
</div>
<div class="admonitionblock tip">
<table>
<tr>
<td class="icon">
<i class="fa icon-tip" title="Tip"></i>
</td>
<td class="content">
<div class="paragraph">
<p>Double click on tab <em>EMF Forms Preview</em> to enlarge view for better handling&#8201;&#8212;&#8201;double click again to get back.</p>
</div>
<div class="paragraph">
<p>Enable auto refresh mode <span class="image"><img src="ParameterCatalogs2Images/ViewModelAutomaticRefresh.gif" alt="ViewModelAutomaticRefresh" width="40"></span> to let each change in the view model instantly be reflected in the preview.</p>
</div>
<div class="paragraph">
<p>Given your screen is big enough, you may want to dock-out the preview by dragging tab <em>EMF Forms Preview</em> out of Eclipse&#8217;s main window.
Seeing editor and preview side by side is a great way to explore the possibilities of view models.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Red input field and exclamation mark in the preview signal missing or inconsistent data.
Ecore data model specifies attribute <code>author</code> with a lower bound of one, meaning it is a mandatory attribute.
As soon as an author&#8217;s name is provided, the error indication disappears.
This is what <em>functional</em> preview means.
You can even create new boilers or other objects in lists provided, with all forms created "automagically" with respect to our underlying Ecore data model.</p>
</div>
<div class="paragraph">
<p>Of course, such automatic approach has its limits.
In our case, to have a long list of lists is not very user-friendly, because one has to scroll up and down to find a specific list.
Also, no specific object data are shown in the list and data can only be edited in a pop-up form (no inline editing).</p>
</div>
<div class="paragraph">
<p>How should a better UI look and feel like?</p>
</div>
<div class="paragraph">
<p>If there are many lists (types) of entities&#8201;&#8212;&#8201;the normal case for parameter catalogs&#8201;&#8212;&#8201;users should select what list they want to work with by selecting it from a list or tree view that is always visible, the <em>master view</em>.
Once a type is selected in the master view, a table with all objects of this list/type shall appear sidelong in a <em>detail view</em>, ready for editing.</p>
</div>
<div class="paragraph">
<p>In <em>EMF Forms</em> master-detail-views can be modeled either with <em>Categorization</em> or <em>Tree Master Detail</em> UI components.
The latter not only allows to edit information displayed in the detail view, but also the tree of elements in the master view.
Opposed to that, a <em>Categorization</em> presents a fixed hierarchy of elements to choose from.
This is exactly what we need as there are only a fixed number of types of objects to be edited in a parameters catalog.</p>
</div>
<div class="sect3">
<h4 id="trueadding-tables-to-the-ui"><a class="anchor" href="#trueadding-tables-to-the-ui"></a>Adding Tables to the UI</h4>
<div class="openblock float-group">
<div class="content">
<div class="imageblock right thumb">
<div class="content">
<img src="ParameterCatalogs2Images/ViewModelDeleteControls.gif" alt="ViewModelDeleteControls" width="300">
</div>
<div class="title">Figure 13. Delete default list controls</div>
</div>
<div class="paragraph">
<p>But first, we replace the default controls for lists of boilers, chps, and so on by tables. As shown here, select all list controls in the view model and execute <code>Delete</code> from context menu. Refresh <em>View Editor Preview</em> to verify that only field <code>Author*</code> is left.</p>
</div>
</div>
</div>
<div class="openblock float-group">
<div class="content">
<div class="imageblock right thumb">
<div class="content">
<img src="ParameterCatalogs2Images/ViewModelCreateTable.gif" alt="ViewModelCreateTable" width="300">
</div>
<div class="title">Figure 14. Create Table Control</div>
</div>
<div class="paragraph">
<p>Next, create a table that shall display all boilers in a catalog:
Select <code>EnergyComponentsCatalog</code>, activate context menu and choose <code>TableControl</code> from the list of available UI elements.
(EnergyComponentsCatalog represents the root view of the UI and, as such, accepts quite a lot of different UI components as child components.)</p>
</div>
<div class="paragraph">
<p>Entry <code>TableControl</code> was inserted into the list of interface elements below <code>Control author</code>.
Checking updated preview reveals no table but a message basically saying that a reference to the domain model is missing, in other words: <em>EMF Forms</em> does not know yet what data to present in table.
Click on entry <code>TableControl</code> to see its details.
A red exclamation mark indicates the missing <code>Domain Model Reference*</code>.
Click on <span class="image"><img src="ParameterCatalogs2Images/ButtonLinkPlus.gif" alt="ButtonLinkPlus" width="40"></span> and be ready to chase a sequence of dialogs:</p>
</div>
</div>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Click on another <span class="image"><img src="ParameterCatalogs2Images/ButtonLinkPlus.gif" alt="ButtonLinkPlus" width="40"></span> in dialog <code>Configure TableDomainModelReference</code></p>
</li>
<li>
<p>In wizard <code>New Reference Element</code> select <code>model &#8594; FeaturePathDomainModelReference</code> and click <code>Next &gt;</code></p>
</li>
<li>
<p>Click <code>Link Domain Model EFeature</code> and in appearing pop-up list choose reference to list of objects you want to edit in the table, e.g. <code>boilers</code>; confirm with <code>OK</code> safely ignoring warning about missing <code>PropertyDescriptor</code>.</p>
</li>
<li>
<p><code>Finish</code> wizard <code>New Reference Element</code></p>
</li>
<li>
<p><code>Finish</code> dialog <code>Configure TableDomainModelReference</code>.</p>
</li>
</ol>
</div>
<div class="paragraph">
<p>This was some work, but as reward we get a fully specified table control in <em>View Editor</em> that "translates" into a preview where we can create, read, update, and delete boilers.</p>
</div>
<div class="imageblock thumb">
<div class="content">
<img src="ParameterCatalogs2Images/ViewModelWithTable.gif" alt="ViewModelWithTable.gif">
</div>
<div class="title">Figure 15. Table for Boilers</div>
</div>
<div class="paragraph">
<p>Moreover, clicking at a table header sorts all objects in it (rows) according to the values in this column.
Column widths can adapted, too.</p>
</div>
<div class="openblock float-group">
<div class="content">
<div class="imageblock right thumb">
<div class="content">
<img src="ParameterCatalogs2Images/ViewModelTweakTable.gif" alt="ViewModelTweakTable" width="300">
</div>
<div class="title">Figure 16. Modify Table Control</div>
</div>
<div class="paragraph">
<p>Table UIs can be tweaked in many ways, e.g. selection and sequence of columns can be declared via list <code>Column Domain Model References</code>. To fill this list with defaults, execute <code>Generate Columns</code> from table control&#8217;s context menu. Reorder them as you like or delete columns that are not important to the user.</p>
</div>
<div class="paragraph">
<p>Notice here an important overall feature of <em>EMF Forms</em>: If something is left unspecified, be it the view model for an Ecore object type or the specification of table columns, <em>EMF Forms</em> will always find a default solution! Applied to columns specification this means we get default columns automatically back in the moment the last column is removed from list <code>Column Domain Model References</code>.</p>
</div>
<div class="paragraph">
<p>If explicit column specifications are present further configurations can be added to a table control from its context menu, e.g. initial column widths or read-only status of columns. See <a href="https://eclipsesource.com/de/blogs/2018/01/31/emf-forms-1-15-0-feature-enhanced-table-renderer/">here</a> for details.</p>
</div>
</div>
</div>
<div class="paragraph">
<p>By default only attributes are displayed and directly editable in tables while references to other objects&#8201;&#8212;&#8201;in our case the reference to a manufacturer&#8201;&#8212;&#8201;are not.</p>
</div>
<div class="openblock float-group">
<div class="content">
<div class="imageblock right thumb">
<div class="content">
<img src="ParameterCatalogs2Images/ViewModelWithPanel.gif" alt="ViewModelWithPanel" width="300">
</div>
<div class="title">Figure 17. Default  Panel for Boilers</div>
</div>
<div class="paragraph">
<p>To get the default (<em>sic!</em>) editing panel for an selected table row, in <em>View Editor</em> just set <code>Detail Editing*</code> from <code>None</code> to <code>WithPanel</code>, <strong>press <em>Tab</em></strong>, and save. For boilers, <em>EMF Forms</em> will create the editing panel shown here. Regardless wether users edit data in the panel or directly in the table&#8201;&#8212;&#8201;both will stay in sync any time.</p>
</div>
</div>
</div>
<div class="admonitionblock warning">
<table>
<tr>
<td class="icon">
<i class="fa icon-warning" title="Warning"></i>
</td>
<td class="content">
<div class="paragraph">
<p><em>View editor</em> exhibits an irritating behavior: With preview auto-refresh turned on, any change in the details view is reflected instantly in the preview, even without saving the form or leaving the edited field.</p>
</div>
<div class="paragraph">
<p>On the other hand, <strong>saving</strong> an updated view editor only takes into account edited fields after they have lost focus, e.g. by pressing <em>Tab</em> key or clicking with the mouse into another field.
So, saving a form before the focus has shifted from the last edited field won&#8217;t honor this edit, that is you won&#8217;t necessarily get what you see.</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>One last thing: Enter <code>boilers</code> as name for the table control so we can distinguish it from the other four table controls to come.</p>
</div>
<div class="paragraph">
<p>Yes! &#8230;&#8203; Please repeat above procedure to create table controls for chps, solar panels, inverters and manufacturers, too. I did this in about 3 minutes. ;-)</p>
</div>
</div>
<div class="sect3">
<h4 id="truemaster-detail-view-with-categories"><a class="anchor" href="#truemaster-detail-view-with-categories"></a>Master-Detail View with Categories</h4>
<div class="paragraph">
<p>In last section we improved our catalog&#8217;s UI by replacing simple object lists by tables that can be sorted, customized and edited inline as well as in an associated panel.
Alas, instead a list of lists we have got an even bigger list of tables.</p>
</div>
<div class="paragraph">
<p>High time to introduce a master-detail view that presents categories of object types in a master view and, after one is selected, the according object table as detail.</p>
</div>
<div class="openblock float-group">
<div class="content">
<div class="imageblock right thumb">
<div class="content">
<img src="ParameterCatalogs2Images/ViewModelCatgorization1.gif" alt="ViewModelCatgorization1" width="180">
</div>
<div class="title">Figure 18. Category Tree</div>
</div>
<div class="paragraph">
<p>Add a <em>Categorization</em> view to the list of UI elements in <em>View Editor</em> by selecting <code>EnergyComponentsCatalog</code> and choose <code>Categorization</code> from its contect menu.</p>
</div>
<div class="paragraph">
<p>Now add two <code>Composite Category</code> elements and one <code>Leaf Category</code> to <code>Categorization</code> from according context menu. This gives us three top level entries in the hierarchy.</p>
</div>
<div class="paragraph">
<p>In the same way add two <code>Leaf Category</code> elements to each <code>Composite Category</code> resulting in the hierarchy depicted here.</p>
</div>
</div>
</div>
<div class="openblock float-group">
<div class="content">
<div class="imageblock right thumb">
<div class="content">
<img src="ParameterCatalogs2Images/ViewModelCatgorization2.gif" alt="ViewModelCatgorization2" width="260">
</div>
<div class="title">Figure 19. Completed View Model</div>
</div>
<div class="paragraph">
<p>This screen shot shows the view model of our UI when finished. To get there:</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Select UI element <code>Categorization</code> and rename it to <code>Categories</code></p>
</li>
<li>
<p>Rename composite and leaf categories as depicted here</p>
</li>
<li>
<p>Drag all table controls one by one into the suited leaf category</p>
</li>
<li>
<p>Confirm master-detail view works as expected in the preview.</p>
</li>
</ol>
</div>
</div>
</div>
<div class="admonitionblock important">
<table>
<tr>
<td class="icon">
<i class="fa icon-important" title="Important"></i>
</td>
<td class="content">
<div class="paragraph">
<p>The UI hierarchy to access tables for entity types is independent, and usually will differ, from aggregation and inheritance hierarchies present in Ecore data model (compare fig. <a href="#fig-example-model">Example Model</a>).</p>
</div>
</td>
</tr>
</table>
</div>
<div class="paragraph">
<p>Note that <em>EMF Forms Preview</em> provides these buttons <span class="image"><img src="ParameterCatalogs2Images/ViewModelPersistence.gif" alt="PreviewPersistanceButtons" width="68"></span> to clear, load and store edited data.
In fact, this feature gives us a fully functional prototype.
At least during refinement of model and UI, data sets can be created, edited, and tested for usability without the need to built a full blown, deployable application&#8201;&#8212;&#8201;see parts <em>Accessing and Using Parameter Catalogs</em> and <em>Build (Parameter Catalog) Applications with Eclipse Tycho</em> below.</p>
</div>
<div class="paragraph">
<p>Be aware that in some cases the view model must adapt to changes in the data model, e.g. a new leaf category and table component has to be created for a new catalog object type.
Other changes are automatically reflected in the generated UI, at least for default forms and other UI elements.
To our convenience, view model specifications incompatible with data model are indicated by error badges in the <em>View Editor</em>.</p>
</div>
<div class="paragraph">
<p>Changes in data model also can make 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.</p>
</div>
</div>
<div class="sect3">
<h4 id="truesummary"><a class="anchor" href="#truesummary"></a>Summary</h4>
<div class="paragraph">
<p>What have we achieved so far?</p>
</div>
<div class="paragraph">
<p>We created a graphical Ecore data model with a catalog class and five classes/types of objects therein.
Classes have been defined by name, attributes, and relations between, often with cardinalities.
Whenever classes shared some attributes or references we factored these out into super classes.
An enumeration introduced a new attribute type from a set of named values.</p>
</div>
<div class="paragraph">
<p>From this data model, we issued commands to create matching 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.</p>
</div>
<div class="paragraph">
<p>Lastly, we thought about a good user interface for this data and used <em>EMF Forms</em> to model and prototype it.</p>
</div>
</div>
</div>
<div class="sect2">
<h3 id="truebonus-solutions-for-specific-modeling-problems"><a class="anchor" href="#truebonus-solutions-for-specific-modeling-problems"></a>Bonus: Solutions for Specific Modeling Problems</h3>
<div class="sect3">
<h4 id="trueadd-units-to-the-mix"><a class="anchor" href="#trueadd-units-to-the-mix"></a>Add Units to the Mix</h4>
<div class="paragraph">
<p><strong>TBD</strong></p>
</div>
<div class="paragraph">
<p>As mentioned earlier, parameter catalogs for simulations should be able to represent quantities, not just bare integer and real numbers.</p>
</div>
<div class="paragraph">
<p>using Indrya, the reference implementation for Units of Measurement in Java (JSR 385)</p>
</div>
<div class="paragraph">
<p>To this end, the author has created two Eclipse plug-in projects providing this feature to be used by Ecore and EMF Forms.</p>
</div>
<div class="paragraph">
<p>Third-party libraries like Indrya, usually, are not distributed as plug-ins, but <em>Tycho</em> can wrap them automatically as OSGi plug-ins that can added directly to our application.</p>
</div>
<div class="paragraph">
<p>Another plug-in, created by the author connects the Ecore and Indrya. We will compile it from source code, simply by importing the projects.</p>
</div>
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Copy to file system &#8230;&#8203;</p>
</li>
<li>
<p>Import project but <strong>not</strong> copying it in the workspace (just linking)</p>
</li>
</ol>
</div>
</div>
<div class="sect3">
<h4 id="truerepresent-functions-in-a-parameter-catalog"><a class="anchor" href="#truerepresent-functions-in-a-parameter-catalog"></a>Represent Functions in a Parameter Catalog</h4>
<div class="paragraph">
<p><strong>TBD</strong></p>
</div>
<div class="paragraph">
<p>for creating custom UI labels:</p>
</div>
<div class="ulist">
<ul>
<li>
<p><code>ExponentialFunctionItemProvider.java</code></p>
</li>
<li>
<p><code>LinearFunctionItemProvider.java</code></p>
</li>
<li>
<p><code>TableFunctionItemProvider.java</code></p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Custom code marked with <code>@generated NOT</code> in <code>de.hftstuttgart.energycomponents.provider</code> in project <code>de.hftstuttgart.energycomponents.edit</code></p>
</div>
</div>
<div class="sect3">
<h4 id="truehow-to-model-derived-references-and-attributes"><a class="anchor" href="#truehow-to-model-derived-references-and-attributes"></a>How to Model Derived References and Attributes</h4>
<div class="paragraph">
<p><strong>TBD</strong></p>
</div>
<div class="paragraph">
<p>We haven&#8217;t used derived references or attributes by now. But if one has to implement some by providing a getter, it is necessary to return an unmodifiable list like BasicEList.UnmodifiableEList or EcoreUtil.unmodifiableList(&#8230;&#8203;) instead of EList as described here: <a href="https://www.ntnu.no/wiki/plugins/servlet/mobile?contentId=112269388#content/view/112269388" class="bare">https://www.ntnu.no/wiki/plugins/servlet/mobile?contentId=112269388#content/view/112269388</a> .</p>
</div>
<div style="page-break-after: always;"></div>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="trueaccessing-and-using-parameter-catalogs"><a class="anchor" href="#trueaccessing-and-using-parameter-catalogs"></a>Accessing and Using Parameter Catalogs</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="trueaccessing-xml-catalogs"><a class="anchor" href="#trueaccessing-xml-catalogs"></a>Accessing XML-Catalogs</h3>
<div class="paragraph">
<div class="title">Add Ecore data model to a third-party Java application</div>
<p><strong>TBD</strong></p>
</div>
<div class="literalblock">
<div class="content">
<pre>import java.util.Collection;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import de.hftstuttgart.energycomponents.EnCompPackage;
import de.hftstuttgart.energycomponents.HeatPump;</pre>
</div>
</div>
<div class="literalblock">
<div class="content">
<pre>ResourceSet resSet = new ResourceSetImpl();
Resource resource = resSet.getResource(URI.createURI("catalog.xml"), true);
Collection&lt;HeatPump&gt; allHeatPumps = EcoreUtil.getObjectsByType(
		resource.getContents(), EnCompPackage.eINSTANCE.getHeatPump());</pre>
</div>
</div>
<div class="paragraph">
<p>catalog.xml muss durch den richtigen Pfad zum XML-Katalog ersetzt werden.</p>
</div>
<div class="paragraph">
<div class="title">Load XML Data Catalog and Access Corresponding Java Objects in Code</div>
<p><strong>TBD</strong></p>
</div>
<div class="paragraph">
<div class="title">Access from Python?</div>
<p><strong>TBD</strong></p>
</div>
</div>
<div class="sect2">
<h3 id="truecreate-insel-models-with-handlebars-templates"><a class="anchor" href="#truecreate-insel-models-with-handlebars-templates"></a>Create Insel Models with Handlebars Templates</h3>
<div class="paragraph">
<p>Handlebar templates to access data catalogs and create/parameterize textual simulation models.</p>
</div>
<div class="paragraph">
<div class="title">Parameterization of blocks</div>
<p><strong>TBD</strong></p>
</div>
<div class="paragraph">
<div class="title">Creation of submodels, e.g. computing parameterized functions</div>
<p><strong>TBD</strong></p>
</div>
<div style="page-break-after: always;"></div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="truebuild-parameter-catalog-applications-with-eclipse-tycho"><a class="anchor" href="#truebuild-parameter-catalog-applications-with-eclipse-tycho"></a>Build (Parameter Catalog) Applications with Eclipse Tycho</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Three plugins so for for the content and UI.</p>
</div>
<div class="paragraph">
<p>Missing: Deployable application and inclusion to third party libraries.</p>
</div>
<div class="paragraph">
<p>Building an application "around" the three plugins for Ecore data model and UI specification model.</p>
</div>
<div class="paragraph">
<p>See template.</p>
</div>
<div class="sect2">
<h3 id="truecreate-an-eclipse-application"><a class="anchor" href="#truecreate-an-eclipse-application"></a>Create an Eclipse Application</h3>
<div class="paragraph">
<p><strong>TBD</strong></p>
</div>
</div>
<div class="sect2">
<h3 id="trueuse-maven-and-tycho-as-build-system"><a class="anchor" href="#trueuse-maven-and-tycho-as-build-system"></a>Use Maven and Tycho as Build System</h3>
<div class="paragraph">
<div class="title">Install Maven Support</div>
<p>We are going to create a complete Eclipse desktop application from generated code.
We also want to deploy this application for Linux, macOS and Windows operating systems.
Eclipse offers several approaches for compiling and deploying such an application, traditionally with <em>Ant</em> scripts.</p>
</div>
<div class="paragraph">
<p>Creation and maintenance of these scripts turned out to be tedious and error prone.
For quite some years now, the proposed&#8201;&#8212;&#8201;and mostly supported&#8201;&#8212;&#8201;method for building Eclipse applications is to use <em>Maven</em> build system, more specifically, a couple of Maven plug-ins, subsumed under the name <em>Tycho</em>.</p>
</div>
<div class="paragraph">
<p>Many Eclipse platforms have Maven support <a href="https://www.eclipse.org/m2e/"><em>M2Eclipse</em></a> already built in, not so our <em>Eclipse Modeling Tools</em>.
But don&#8217;t worry: Installation of required Eclipse feature is easy and straight forward.
And, by the way, you will acquire the indispensable skill of how to install new plug-ins/features to Eclipse.</p>
</div>
<div class="paragraph">
<p>First, tell your Eclipse installation where to look for the new software.
Execute <code>Help &#8594; Install new Software&#8230;&#8203;</code> to invoke dialog <em>Available Software</em> and press <code>Add&#8230;&#8203;</code>.
Sub-dialog <code>Add Repository</code> pops up.</p>
</div>
<div class="imageblock thumb">
<div class="content">
<img src="ParameterCatalogs2Images/InstallMaven1.gif" alt="InstallMaven1">
</div>
<div class="title">Figure 20. Add update site m2e</div>
</div>
<div class="paragraph">
<p>In there provide <code>m2e</code> as name and</p>
</div>
<div class="literalblock">
<div class="content">
<pre>http://download.eclipse.org/technology/m2e/releases</pre>
</div>
For faster browsing, not all history is shown. View entire blame