model.doxy
1 /*!
2 \page model Model
3 <div class="has-toc"></div>
4 
5 # Model # {#model_main}
6 
7 wCMF applications are based on a model. The model defines the key aspects of the
8 application on a higher abstraction level than code does. You can think of it as
9 a condensed description of the application.
10 
11 A template based code generator transforms the model into source code that will
12 run inside the wCMF framework. Where necessary, the code can then be enhanced
13 manually inside pre-defined regions. Further generation runs will protect these
14 manual additions.
15 
16 We believe that this approach helps to develop a clear concept of the application
17 and improves code quality and maintainability dramatically.
18 
19 ## Modeling ## {#model_create}
20 
21 Technically the model is an [UML](http://en.wikipedia.org/wiki/Unified_Modeling_Language)
22 model that uses the _Chronos_ [profile](http://en.wikipedia.org/wiki/Profile_%28UML%29)
23 from the [Olympos](http://sourceforge.net/projects/olympos/) project. It is stored
24 in an [Eclipse MDT/UML2](http://wiki.eclipse.org/MDT-UML2) compatible XML file
25 (e.g. `model.uml`). This file can be directly edited using
26 [Eclipse Papyrus](http://www.eclipse.org/papyrus/) or any other [compatible UML
27 modeling tool](http://wiki.eclipse.org/MDT-UML2-Tool-Compatibility). Alternatively
28 you can use the [Chronos Web Modeler](http://sourceforge.net/projects/olympos/)
29 that allows browser based collaborative modeling. wCMF uses a minimized version
30 of the code generator from the Olympos project with wCMF specific templates.
31 
32 The following diagram shows the workflow of the generator.
33 
34 \image html generator.png "Generator workflow"
35 
36 ### Chronos profile ### {#model_profile}
37 
38 _Profiles_ are used to extend UML for different domains. They consist of __stereotypes__
39 and __tags__ that are applied to model elements to express domain specific
40 features. The following sections describe the stereotypes and tags of the _Chronos_
41 profile that are used to define various aspects of a wCMF application. The complete
42 [Chronos profile](https://raw.githubusercontent.com/iherwig/wcmf-default-app/master/model/chronos.profile.uml)
43 is available on GitHub.
44 
45 You will notice that only a small part of UML is used to define the application
46 and not all aspects of the application are defined in the model. Especially the
47 actual behavior of controllers and domain classes is omitted, since we believe
48 that this is more efficiently expressed in code. For simplicity and compatibility
49 reasons all aspects can be modeled in __class diagrams__ using __classes__,
50 __attributes__ and __associations__.
51 
52 \note UML elements and concepts that are not mentioned in the following sections
53 are most likely not supported by the generator and will be ignored.
54 
55 ### Domain classes ### {#model_classes}
56 
57 The following __stereotypes__ are used to model persistent domain classes and their relations.
58 
59 | Name | UML meta class | Description | Example
60 |------|----------------|-------------|--------
61 | _ChiNode_ | Class | Persistent domain class, must inherit from \link wcmf::lib::model::Node `Node`\endlink | _Article_
62 | _ChiValue_ | Attribute | Persistent attribute in a _ChiNode_ | _headline_ of Article
63 | _ChiValueRef_ | Attribute | ReadOnly-reference to an attribute of another _ChiNode_ | _author_name_ in Article references _name_ in Author
64 | _ChiManyToMany_ | Class | Connection class in a many to many relation between _ChiNode_ classes, must inherit from \link wcmf::lib::model::Node `Node`\endlink | One _Author_ writes nultiple _Articles_ and one _Article_ has multiple _Authors_
65 | _ChiAssociation_ | Association | Optional, e.g. used to define a foreign key name in a relation between _ChiNode_ instances | _author_id_ in Article as foreign key to Author table
66 
67 #### ChiNode / ChiManyToMany #### {#model_chinode}
68 
69 The following __tags__ are defined on the _ChiNode_ / _ChiManyToMany_ stereotypes.
70 
71 | Tag | Description | Example | Default value
72 |-----|-------------|---------|--------------
73 | _initparams_ | Name of the configuration section, which defines initialization parameters for the \link wcmf::lib::persistence::PersistenceMapper `PersistenceMapper`\endlink instance | _database_ | _database_
74 | _display_value_ | Attributes to display in a list view: A single attribute name or comma separated list of attribute names | _name,date_ | |
75 | _orderby_ | Definition of default sorting: _none_ (no order), _sortkey_ (generates a _sortkey_ column, that is used for explicit sorting) or the name of any attribute optionally followed by _ASC_ or _DESC_ | _name ASC_ | _none_
76 | _is_searchable_ | Boolean, indicating whether this type should be included in the default search | _true_ | _true_
77 | _is_soap_ | Boolean, indicating whether this type should be exposed to the SOAP interface | _true_ | _true_
78 | _table_name_ | The name of the database table in which instances will be stored | _Author_ | Class name
79 | _pk_name_ | The name of the primary key column: A single value or comma separated list of values (the generator will add this automatically, if there is no appropriate attribute) | _fk_user_id,fk_role_id_ | _id_
80 | _child_order_ | The order of the associated relations: A comma separated list of role names | _Author,Publisher,Image,Textblock,Attachment_ in Article type | |
81 | _parent_order_ | _not used_ | | |
82 
83 \note Some of these tags are accessible in the application through the
84 \link wcmf::lib::persistence::PersistentObject::getProperty `PersistentObject::getProperty`\endlink
85 method.
86 
87 #### ChiValue #### {#model_chivalue}
88 
89 The following __tags__ are defined on the _ChiValue_ stereotype.
90 
91 | Tag | Description | Example | Default value
92 |-----|-------------|---------|--------------
93 | _app_data_type_ | Application specific attribute tags: A single value or comma separated list of values (see \ref pers_values) | _TAG_A,TAG_B_ | _DATATYPE_ATTRIBUTE_
94 | _db_data_type_ | The attribute's database type | _TEXT_ | _VARCHAR(255)_ |
95 | _is_editable_ | Boolean, indicating whether this attribute is editable | _true_ | _true_
96 | _input_type_ | Name of the attribute's input control as listed in the _InputTypes_ configuration section and additional configuration encoded as JSON string | _filebrowser_ or _ckeditor:{"toolbarSet":"full"}_ | _text_
97 | _display_type_ | Name of the attribute's display type as listed in the _DisplayTypes_ configuration section | _image_ | _text_
98 | _restrictions_match_ | Name of the attribute's validation type or comma separated list of validation types as listed in the _Validator_ configuration section (see \ref pers_validation) and additional configuration encoded as JSON string | _date,required_ or _regexp:{"pattern":"^[0-9]*$"}_ or _image:{"height":[300,0]}_ | |
99 | _restrictions_not_match_ | _not used_ | | |
100 | _restrictions_description_ | Validation description used in case of a validation error | _The value must be an integer or empty_ | |
101 | _column_name_ | The name of the database column in which the attribute will be stored | _name_ | Attribute name
102 
103 \note Some of these tags are accessible in the application through the
104 \link wcmf::lib::persistence::PersistentObject::getValueProperty `PersistentObject::getValueProperty`\endlink
105 method.
106 
107 #### ChiValueRef #### {#model_chivalueref}
108 
109 The following __tags__ are defined on the _ChiValueRef_ stereotype.
110 
111 | Tag | Description | Example | Default value
112 |-----|-------------|---------|--------------
113 | _reference_type_ | Type, that owns the referenced attribute | _Author_ | |
114 | _reference_value_ | Name of the references attribute | _name_ | |
115 
116 #### Transient properties #### {#model_transient}
117 
118 All class properties without a _ChiValue_ or _ChiValueRef_ stereotype are considered
119 to be <strong>transient</strong>/<strong>computed</strong> properties.
120 
121 #### ChiAssociation #### {#model_association}
122 
123 The following __tags__ are defined on the _ChiAssociation_ stereotype.
124 
125 | Tag | Description | Example | Default value
126 |-----|-------------|---------|--------------
127 | _fk_name_ | Name of the foreign key attribute (the generator will add this automatically, if there is no appropriate attribute) | _author_id_ | _fk_\_type\_ _id_ |
128 
129 #### Example class diagram #### {#model_class_example}
130 
131 A simple data model is shown in the diagram below. Each of the domain classes
132 _Author_, _Article_ and _Image_ is modeled with _ChiNode_ stereotype, their
133 attributes with _ChiValue_ stereotype. The only exception is the _author_name_ attribute,
134 which is a reference to the _name_ attribute of _Author_ and therefore uses the
135 stereotype _ChiValueRef_. As the relations between the classes show, one _Author_
136 can own several _Articles_ and each _Article_ in turn can contain several _Images_.
137 
138 All \link wcmf::lib::persistence::PersistenceMapper `PersistenceMapper`\endlink instances
139 are initialized using the parameters defined in the _database_ configuration section.
140 
141 In list views _Author_ instances are sorted by _name_ while _Article_ and _Image_
142 instances get an attribute _sortkey_ which is used to define an explicit order.
143 
144 \image html model.png "Example class diagram"
145 
146 #### Associations #### {#model_associations}
147 
148 Relations between domain classes - e.g. parent-child relations - are modeled as
149 associations. Three different __types of associations__ are supported: _compositions_,
150 _aggregations_ and _one-directional associations_ as shown in the following
151 diagram.
152 
153 \image html associations.png "Association types"
154 
155 It is important to understand how wCMF recognizes __parents and children__ in an
156 association. In case of compositions and aggregations the parent is always
157 the class, that is connected with the diamond end of the association. Other
158 associations are treated as parent-child relation, if they are only navigable
159 in one direction, which is then defined as the child to parent direction.
160 
161 The association types differ in the treatment of children in case of __deletion__
162 of the parent. In aggregations and normal associations children are not deleted,
163 while composite children are deleted on parent deletion. On the other hand the
164 \ref app "default application" allows __creation__ of child instances in a
165 composition, while the other two types only allow adding existing instances.
166 
167 The following table summarizes the behavior of the different association types
168 regarding the operations allowed on child instances:
169 
170 | Association type | Delete children | Create children | Associate children
171 |------------------|-----------------|-----------------|-------------------
172 | Composition | Yes | Yes | No
173 | Aggregation | No | Yes | Yes
174 | Association | No | No | Yes
175 
176 ##### Multiplicity #####
177 
178 The multiplicity at the association ends limits the amount of instances that
179 are allowed at that relation end. In a typical parent-child relation the parent
180 end has a value of `1` and the child end has a value of `0..*` meaning that a
181 child instance is connected to exactly one parent instance, while any number
182 of child instances can be connected to the parent instance (including zero).
183 This kind of relation is called __one-to-many relation__ and is easy to realize
184 in a database by using a _foreign key_ column.
185 
186 __Many-to-many relations__ on the other hand allow an arbitrary number of
187 instances at both ends and are typically realized in an database using a
188 _junction table_. The Chronos profile allows for this by providing the `ChiManyToMany`
189 stereotype. The following diagram shows how to model a many-to-many relation:
190 
191 \image html many-to-many.png "Many-to-many relation"
192 
193 Using compositions ensures that many-to-many instances are deleted correctly,
194 when the parent instances are deleted.
195 
196 ##### Navigability #####
197 
198 Another aspect of associations is the use of __arrow ends__ that define the
199 navigability. If an arrow end is omitted on one end, instances at that end
200 are not accessible from the other end. Regarding the database schema all three
201 association types will result in the creation of a foreign key column in the
202 child table that points to the parent table.
203 
204 ##### Role names #####
205 
206 Each end of an association can have a _role name_ assigned. It describes how the
207 element at that end participates in the relation. Generally the role name
208 defaults to the element's name, but there are two cases where it is necessary to
209 assign a dedicated name:
210 
211 - _Multiple associations_
212 - _Self associations_
213 
214 Sometimes __multiple associations__ have to be defined between two domain classes.
215 For example if there are `Person` and `Task` domain classes and tasks should be
216 associated with persons. If each task should have an owner and a creator, there
217 will be two aggregations between the two domain classes. To allow wCMF to know
218 which role a person has in relation to a given task, role names have to be
219 assigned to the association ends.
220 
221 The following diagram illustrates the given example:
222 
223 \image html multiple-associations.png "Role names in multiple associations"
224 
225 To build a hierarchy where one item contains items of the same type, an
226 association from the domain class to itself is required. An example would be a file
227 system with nested directories. In this case, role names are required at each end
228 of this __self association__.
229 
230 The following diagram illustrates the given example:
231 
232 \image html self-associations.png "Role names in self associations"
233 
234 #### Inheritance #### {#model_inheritance}
235 
236 If different domain classes should have the same attributes, a common base class
237 can make these available to inheriting classes. An example would be an `EntityBase` type,
238 which defines meta information like creation date and last modification date for
239 all domain classes. The diagram below illustrates the concept.
240 
241 \image html inheritance.png "Inheritance"
242 
243 Inheritance will cause the generator to create new relations in the following cases:
244 
245 <div class="image-table">
246 | Parent relations | Child relations
247 |------------------|----------------
248 \image html inherited-relation1.png "Subclass B becomes parent of A" | \image html inherited-relation3.png "Subclass B becomes child of A"
249 \image html inherited-relation2.png "Parent class of B becomes parent of A" | \image html inherited-relation4.png "Child class of B becomes child of A"
250 </div>
251 
252 ### Application flow ### {#model_flow}
253 
254 Since a wCMF application is based on the Model-View-Controller pattern, application
255 flow is defined in terms of _controllers_ and _views_. Controller execution is triggered
256 by _actions_ which are initiated by the application user.
257 
258 The following __stereotypes__ are used to model user interaction.
259 
260 | Name | UML meta class | Description | Example
261 |------|----------------|-------------|--------
262 | _ChiController_ | Class | Controller class, must inherit from the \link wcmf::lib::presentation::Controller `Controller`\endlink | _LoginController_
263 | _ChiView_ | Class | View assigned to a _ChiController_ | _login_
264 | _ChiActionKey_ | Association | Associates two _ChiController_ instances (to define a control flow) or a _ChiView_ with a _ChiController_ (to define a view attachment), must be _one directional_ | |
265 
266 \note _ChiActionKey_ realizes the concept of _action keys_ (see \ref arch_actionkey).
267 Multiple action keys can be defined between controllers or controllers and views
268 each one used in a different context and/or for a different action.
269 
270 #### ChiController #### {#model_chicontroller}
271 
272 No __tags__ are defined on the _ChiController_ stereotype.
273 
274 #### ChiView #### {#model_chiview}
275 
276 No __tags__ are defined on the _ChiView_ stereotype.
277 
278 #### ChiActionKey #### {#model_chiactionkey}
279 
280 The following __tags__ are defined on the _ChiActionKey_ stereotype.
281 
282 | Tag | Description | Example | Default value
283 |-----|-------------|---------|--------------
284 | _action_ | The action, which is triggered by this association. If empty, any action is valid | _save_ | |
285 | _context_ | The context, in which this association is valid. If empty, any context is valid | _author_ | |
286 | _config_ | The configuration, in which this association is defined | _config.ini_ | _config.ini_ |
287 
288 #### Example application flow #### {#model_example_flow}
289 
290 An example for a simple interaction model is given in the diagram below. The
291 controllers are modeled with the stereotype _ChiController_, the associations with
292 _ChiActionKey_ stereotype. Each association's tagged values are displayed in an
293 attached note. Since the association between _AuthorController_ and _author_ view
294 does not define the tagged values _action_ and _context_, _AuthorController_
295 displays this view for every action and context. The same applies to _ArticleController_
296 and the _article_ view. _SaveController_ does not display a view, it only stores
297 the data passed to it and returns to the next controller.
298 
299 For associations, which link controllers, at least the tagged value _action_ is set.
300 Since obviously all _save_ actions result in the execution of _SaveController_,
301 no context is necessary. The context is helpful, when we want to solve the
302 ambiguousness of the action _ok_ upon termination of _SaveController_.
303 We define, that the context is _author_ when editing the author and _article_
304 when editing articles. By this the application always knows to which controller it
305 should return to after executing _SaveController_.
306 
307 \image html flow.png "Example application flow"
308 
309 \note If the _controller_ value of the action key should be empty, meaning that the
310 action can be triggered from _any_ controller, the source of the _ChiActionKey_
311 association must be the \link wcmf::lib::presentation::Controller `Controller`\endlink
312 base class.
313 
314 #### Controller methods #### {#model_controller_methods}
315 
316 By default the framework calls the method _doExecute_ on the current controller
317 instance for any _context_ and _action_ value. For this reason an empty implementation
318 of this method will be added by the generator.
319 
320 To distinguish different actions or contexts it is also possible to model several
321 operations inside the controller class. To connect an action key to a controller
322 method, the action key's end that points to the controller must be named like
323 the method. The following diagram illustrates the concept:
324 
325 \image html controller-methods.png "Controller methods"
326 
327 #### Request parameters #### {#model_controller_parameters}
328 
329 Parameters can be added to controller methods. The generator will create code
330 that extracts and validates the input parameters from the requests or sets
331 default values if they are absent. Output parameters will be added to the response.
332 
333 #### Routes #### {#model_controller_routes}
334 
335 If an action should be available in the public API of the application, it must be
336 mapped to a request uri in the `Routes` configuration section (see \ref pres_routingext).
337 
338 This can be easily achieved by setting a request uri pattern on the action key's
339 source end. The following diagram illustrates the concept:
340 
341 \image html controller-routes.png "Controller routes"
342 
343 ### Configuration ### {#model_config}
344 
345 The following __stereotypes__ are used to model the application configuration.
346 
347 | Name | UML meta class | Description | Example
348 |------|----------------|-------------|--------
349 | _ChiSystem_ | Class | A configuration section, class members and their default values become key-value pairs inside the section | _Database_
350 
351 #### ChiSystem #### {#model_chisystem}
352 
353 The following __tags__ are defined on the _ChiSystem_ stereotype.
354 
355 | Tag | Description | Example | Default value
356 |-----|-------------|---------|--------------
357 | _platform_ | The platform to which the configuration settings apply | _wcmf_ | |
358 | _config_ | The configuration, in which the settings are defined | _config.ini_ | _config.ini_ |
359 
360 #### Example configuration #### {#model_example_config}
361 
362 The following diagram shows the configuration of a database connection. The
363 connection parameters can be accessed later using the
364 \link wcmf::lib::config::Configuration::getSection `Configuration::getSection`\endlink
365 method and passing _database_ as `section` paramter.
366 
367 \image html config.png "Example configuration"
368 
369 ### Default model ### {#model_default}
370 
371 The \ref app "default application" includes a demo UML model located in
372 `model/model.uml`. It is a good starting point for custom applications. For those who
373 want to start from scratch there are also base models in _model/base/cwm/_ (for
374 [Chronos Web Modeler](http://sourceforge.net/projects/olympos/)) and
375 _model/base/papyrus/_ (for [Eclipse Papyrus](http://www.eclipse.org/papyrus/)).
376 
377 The default model has the following package structure:
378 
379 - _model_
380  - _wcmf test_
381  - _root_
382  - _wcmf_ Framework packages with useful (base-)classes
383  - _Primitive types_
384  - _configuration_ Base configuration
385  - _config.ini_
386  - `«ChiSystem» Config`
387  - ...
388  - ...
389  - _application_
390  - _controller_ Existing controllers
391  - `«ChiController» AssociateController`
392  - ...
393  - _lib_
394  - _presentation_
395  - `«ChiController» Controller` Base class for all controller classes
396  - _model_
397  - `«ChiNode» Node` Base class for all domain classes
398  - _security_
399  - _principal_
400  - _impl_
401  - `AbstractUser` Base class for custom user class
402  - `AbstractRole` Base class for custom role class
403  - _app_ Application specific packages
404  - __configuration__ Application specific configuration
405  - _backend.ini_
406  - _server.ini_ Deployment specific configuration
407  - _src_
408  - __model__ Domain class package
409  - _wcmf_ Default framework classes
410  - `«ChiNode» DBSequence`
411  - ...
412  - `«ChiNode» EntityBase` Base class for domain classes with audit info
413  - ...
414  - __controller__ Controller package
415  - `«ChiController» RootController` Main controller of \ref app "default application"
416  - __views__ Views package
417  - `«ChiView» cms` Main view of \ref app "default application"
418 
419 Application specific model elements will mostly reside in the __emphasized__ packages.
420 
421 ## Generator ## {#model_generator}
422 
423 wCMF uses the code generator from the [Olympos](http://sourceforge.net/projects/olympos/)
424 project which is originally based on _openArchitectureWare_. The generator is
425 a JAVA application that executes user defined workflows. Workflows are organized in
426 cartridges one of which is the wCMF cartridge. Cartridges are written in the
427 _Xtent/Xpand_ language.
428 
429 If you are using [Composer](https://getcomposer.org/), the generator will be installed
430 as a dependency in the directory _vendor/olympos/chronos-generator_. It is also
431 available at [SourceForge](https://sourceforge.net/projects/olympos/files/ChronosGenerator-wCMF/).
432 
433 ### Configuration ### {#generator_config}
434 
435 The configuration of the generator is stored as key-value pairs in a file called
436 `workflow.properties` in the _model_ directory. It contains the following __variables__:
437 
438 | Variable | Description | Default value
439 |----------|-------------|--------------
440 | _profilename_ | Name of the used UML profile | _Chronos_ |
441 | _profileUmlFile_ | Path to the profile file | <em>${basePath}/metamodel/chronos.profile.uml</em> |
442 | _modelUmlFile_ | Model file to generate code from | _model.uml_ |
443 | _transformedModelUmlFile_ | Location for the model transformed into the generator's internal format (used for debug purposes) | _model-transformed_ |
444 | _rootPackage_ | Model package containing _libraryPackage_ and _applicationPackage_. It's name will be stripped from paths to classes | _wcmf test::root_ |
445 | _libraryPackage_ | Model package, in which the wCMF framework is defined. From this package no files will be generated | _wcmf_ |
446 | _applicationPackage_ | Model package, in which the application is modeled | _app_ |
447 | _doCheck_ | Indicates whether the generator should run checks on the model | _true_ |
448 | _preCheckFile_ | Check file, that should be used before the transformation into the internal model format | _cartridge::Wcmf::checks::pre_ |
449 | _postCheckFile_ | Check file, that should be used after the transformation into the internal model format | _cartridge::Wcmf::checks::post_ |
450 | _requiredControllerSuperclass_ | Controller base class, from which all controllers must inherit, used in the checks | _model::${rootPackage}::${libraryPackage}::lib::presentation::Controller_ |
451 | _requiredNodeSuperclass_ | Domain base class, from which all domain classes must inherit, used in the checks | _model::${rootPackage}::${libraryPackage}::lib::model::Node_ |
452 | _doBackup_ | Indicates whether the generator should do a backup of the application, before generating any files | _false_ |
453 | _expand_ | Template definition to start the generation from | _cartridge::Wcmf::templates::Root::root_ |
454 | _outputEncoding_ | Encoding of the generated files | _UTF-8_ |
455 | _configFileDefault_ | Name of the default configuration file, general properties like type mapping are declared here | _config.ini_ |
456 | _projectname_ | Name of the application | _wcmf testapp_ |
457 | _targetDir_ | Directory, in which the application is created | _targetDir_ |
458 | _prExcludes_ | File patterns to be excluded when searching for protected regions | <em>*.svn-base, .git, vendor</em> |
459 | _printGenerateDate_ | Indicates whether the generation date should be printed in generated file headers | _false_ |
460 | _headerText_ | Text to be prepended to generated files | |
461 
462 The variables `${basePath}` (generator location) and `${targetDir}` (generated code
463 location) must be provided as __command line__ arguments when running the generator
464 (see \ref generator_run).
465 
466 ### Running ### {#generator_run}
467 
468 The generator is started using the __command__
469 
470 <div class="shell">
471 ```
472 $ java -Djava.library.path=libPath -jar ChronosGenerator.jar workflowFile -basePath=basePath -propertyFile=propertyFile -targetDir=targetDir
473 ```
474 </div>
475 
476 The __parameters__ are explained in the following table.
477 
478 | Parameter | Description | Default value
479 |-----------|-------------|--------------
480 | _libPath_ | Path to the generator libraries | <em>../vendor/olympos/chronos-generator/lib</em> |
481 | _workflowFile_ | Workflow definition file | <em>../vendor/olympos/chronos-generator/cartridge/Wcmf/workflow/wcmf.oaw</em> |
482 | _basePath_ | Path to the generator installation | <em>../vendor/olympos/chronos-generator/</em> |
483 | _propertyFile_ | Workflow configuration file | <em>../model/workflow.properties</em> |
484 | _targetDir_ | Path to the generated files | <em>../</em> |
485 
486 The __default values__ apply, if the generator is run from the _build_ directory of
487 the \ref app "default application".
488 
489 Since the code generator is integrated into the __ant deployment script__ of the
490 application, it's also sufficient to run the following command in the _build_
491 directory:
492 
493 <pre>
494 ant generate
495 </pre>
496 
497 ### Artefacts ### {#generator_artefacts}
498 
499 The generator creates the following files:
500 
501 #### Configuration #### {#generator_artefacts_config}
502 
503 - __SQL scripts__ are generated in the _install_ directory. They contain the
504  table definitions for [MySQL](http://www.mysql.com) databases (`install/tables_mysql.sql`)
505  and [SQLite](https://sqlite.org) databases (`install/tables_sqlite.sql`). For each domain
506  class one table is created, inherited attributes are stored in each table
507  ([Concrete Table Inheritance] (http://martinfowler.com/eaaCatalog/concreteTableInheritance.html)).
508 
509 - __Configuration files__ in the [INI file](http://en.wikipedia.org/wiki/INI_file)
510  format are generated in the _app/config_ directory. Configuration files are
511  implicitly defined in the model by the `ChiActionKey.config` and `ChiSystem.config`
512  tags. For each name mentioned in these tags, one configuration file will be
513  created, containing all definitions related to it. Furthermore, the default
514  configuration file (_config.ini_ per default) contains the domain class
515  mapping definitions.
516 
517 #### PHP Code #### {#generator_artefacts_php}
518 
519 - __Mapper classes__ are generated in directories corresponding to the
520  model packages (_app/src/model_, if the default model packages are used). For
521  each `ChiNode`/`ChiManyToMany` class one subclass of
522  \link wcmf::lib::model::mapper::NodeUnifiedRDBMapper `NodeUnifiedRDBMapper`\endlink
523  is created (e.g. `AuthorRDBMapper`).
524 
525 - __Domain classes__ are generated in the same directories as the mapper classes.
526  For each `ChiNode`/`ChiManyToMany` class two classes are created, one base class
527  that contains all generated code (e.g. `AuthorBase`) and one empty subclass,
528  that is used to add custom code (e.g. `Author`). The base class inherits from
529  \link wcmf::lib::model::Node `Node`\endlink or one of it's subclasses. Getter
530  methods are generated for transient/computed properties.
531 
532 - __Controller classes__ are generated in directories corresponding to the
533  model packages (_app/src/controller_, if the default model packages are used). For
534  each `ChiController` class two classes are created, one base class that contains
535  all generated code and one subclass that contains the methods to be implemented.
536  The base class inherits from
537  \link wcmf::lib::presentation::Controller `Controller`\endlink or one of it's
538  subclasses.
539 
540 - The __SOAP interface__ is generated in the file _app/public/soap-interface.php_.
541  \link wcmf::application::controller::SOAPController `SOAPController`\endlink
542  uses this file to configure the \link wcmf::lib::service::SoapServer `SoapServer`\endlink.
543 
544 #### Template Code #### {#generator_artefacts_tpl}
545 
546 - __View templates__ are generated in directories corresponding to the
547  model packages (_app/src/views_, if the default model packages are used). For
548  each `ChiView` class one empty template file will be created.
549 
550 #### JavaScript Code #### {#generator_artefacts_js}
551 
552 - __Domain classes__ are generated in a subdirectory of _public/js_
553  (_app/public/js/app/src/model_, if the default model packages are used).
554  For each `ChiNode`/`ChiManyToMany` one subclass of `Entity` is created.
555 
556 - An [AMD](http://en.wikipedia.org/wiki/Asynchronous_module_definition) file
557  referencing all domain classes is created in _public/js/model_
558  (_app/public/js/model/_TypeList.js_, if the default model packages are used).
559 
560 #### Protected regions #### {#generator_pr}
561 
562 The generator creates functional code, but of course __custom code__ must be added
563 to implement domain specific functionality. For this reason
564 the generator adds sections that are enclosed in `PROTECTED REGION` tags,
565 between which the user is supposed to place custom code. When re-generating
566 the code later (e.g. because of model changes), this custom code will be preserved.
567 
568 An example of a class file containing protected regions is shown below.
569 
570 <div class="php">
571 ```
572 <?php
573 /**
574  * This file was generated by ChronosGenerator from model.uml.
575  * Manual modifications should be placed inside the protected regions.
576  */
577 namespace app\src\model;
578 
579 use app\src\model\AuthorBase;
580 // PROTECTED REGION ID(app/src/model/Author.php/Import) ENABLED START
581 // PROTECTED REGION END
582 
583 /**
584  * Author description:
585  *
586  * @author
587  * @version 1.0
588  */
589 class Author extends AuthorBase {
590 // PROTECTED REGION ID(app/src/model/Author.php/Body) ENABLED START
591 // PROTECTED REGION END
592 }
593 ?>
594 ```
595 </div>
596 */