This step is optional. If you used examples given by Adichatz (pagila/PosgreSQL or sakila/MySQL), an customization file if automatically proposed to you when creating project.

Customization of the generation processes issues

Scenario Tree describes how to drive automatic generation processes.
Indeed, a scenario transforms an input (XML files, Pojos) into a GENERATED XML file which describes the body of a part (Editor, Query, Detail UI…).
The default generation process which is driven by Scenario Tree provided by Scenario.xml file (see Scenario architecture), may contain defects. For instance, in our case, we want to make 3 improvements:

  1. For Film entity, Hibernate generates a Pojo which maps the year property to a date. The property must be changed to an int which can have a value between 1900 and 2155.
  2. For Film entity, property specialFeatures is a string corresponding to a set of values. MultiChoice control to display value is more appropriate.
  3. All POJOs that contain a lastUpdate property must extend a ASuperLastUpdate class that initializes the property value to the current date when creating or modifying entity.

Making changes to Scenario Tree file means update the generation processes. The belowing example shows differents possiblities:

  • New scenarios, generators, path elements, parameters can be specified or added to the Scenario Tree before launching or relaunching generation processes.
  • Pojo rewriter for injecting changes in Pojos (e.g. org.adichatz.scenario.generation.SuperPojoRewriter is a java class for rewrite Pojo in order to add a super class).
  • Specific features as new item value, validators or listeners can be added to the scenario tree.

Store scheduled changes inside an XML file

These changes can be manually made by the developper inside the Scenario.xml file. A other way is to assemble changes inside a new Scenario tree stored in a specific xml file, inject these changes inside the current Scenario.xml file and launch needed generation processes.
In the example below, previously described needed change are incorparated.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<scenarioTree xmlns:xsi="" xsi:noNamespaceSchemaLocation="">
        <pathElement type="PROJECT" location="myscenario"/>
    	<param id="devl.default.integer.pattern" value="#####"/>
        <generator treeClassName="org.adichatz.generator.wrapper.TableWrapper" generatorClassName="org.mycompany.myscenario.generator.MyTableGenerator"/>
        <generator treeClassName="#CONTROLGENERATOR()" generatorClassName="org.mycompany.myscenario.generator.MyControlGenerator"/>
    <generationScenario scenarioClassName="org.adichatz.scenario.impl.PluginEntityScenario">
	    		<pojoRewriter rewriterClassName="org.adichatz.scenario.generation.SuperPojoRewriter" propertyRegex="lastUpdate">
	    				<param id="superClassURI" value="bundleclass://./#PACKAGENAME().model.ASuperLastUpdate"/>
	    				<param id="sourceURI" value="platform:/plugin/org.adichatz.template/template/src/"/>
		<propertyField id="lastUpdate">
        	<controlField xsi:type="dateTextType" enabled="false" style="SWT.BORDER | SWT.TIME"/>
        	<columnField xsi:type="tableColumnType" property="lastUpdate" sorted="true" style="SWT.CENTER"/>
        <pluginEntity entityURI="adi://././FilmMM">
        		<message key="invalid.year.value" value="Invalid year '{0}'! Value must be between 1900 and 2155"/>
            <propertyField id="releaseYear" pojoType="short">
		        <controlField xsi:type="formattedTextType" editPattern="####" format="Integer">
	           			<validator key="invalidYear" errorMessage="#MSG(film, invalid.year.value, #FV())">
	           				<errorWhen>return #FV() &lt; 1900 ||  #FV() &gt; 2155;</errorWhen>
            <propertyField id="specialFeatures">
		        <controlField xsi:type="multiChoiceType" multiChoiceType="String" values="Trailers,Commentaries,Deleted Scenes,Behind the Scenes" popupToolbar="true"/>
        <generationUnit scenarioClassName="org.adichatz.scenario.impl.GroupListNavigatorScenario" adiResourceURI="adi://groupNavigator/GroupNavigatorContent" type="NAVIGATOR"/>
    <customPostAction injectInsideScenarioFile="true" generatePojo="true" generateEJB="true" generatePersistenceXml="true" deployEJB="true">
        <customGenerationUnit type="ENTITY" propertyRegex="lastUpdate"/>
        <customGenerationUnit type="DETAIL" propertyRegex="lastUpdate"/>
        <customGenerationUnit type="TABLE" entityRegex="Film"/>
        <customGenerationUnit type="MESSAGE_BUNDLE" entityRegex="Film"/>


Line 4:A new project containing resources (classes) is added to the path for generation processes.
Lines 10-11:2 new Generators are used instead of standard generators.
Lines 16-21:2 new pojo rewriters are executed after Pojos are generated.
Lines 25-26:The controller for lastUpdate property will be a DateTextController for any entity of the project.
Line 30:An item is added to the message bundle file linked to the Film entity ( file).
Lines 33-39:Assumes that the value of the releaseYear property must be between 1900 and 2155 (Client side).
Line 42 :The value of the specialFeatures property is an array of predetermined values and uses a MultiChoiceController controller.
Line 45:A new navigator will be generated which provide List/Detail query editor.
Line 48:Regenerate Entity MetaModel (e.g. ActorMM) for all entity having a lastUpdate property.
Line 49:Regenerate Detail Include (e.g. ActorDI) for all entity having a lastUpdate property.
Line 50:Regenerate Table Include (e.g. FilmTI) for Film entity.
Line 51:Regenerate Message Bundle (e.g. for Film entity.

Specify a customization file for a data source

When defining a datasource, a Customization file can be specified linked to this data source. Each time this data source is chosen, the customization file is suggested to bring changes to the scenario tree before launching the generation process.

Datasource window is open by clicking on the Data source hyperlink field of the page Model of the Scenario Tree editor.

Inject scheduled changes inside Scenario.xml file

  1. Open file $projectDirectory/resources/xml/Scenario.xml with Adichatz editor, choose Customizations page.
  2. Select a Customization File. For example, open file [eclipse_dir]/plugins/org.adichatz.template/template/connectors/pagilaNewOverride.xml

  • Open file $projectDirectory/resources/xml/Scenario.xml with Adichatz editor, choose Customizations page.
  • Select Merge customizations Merge customizations to scenario at top right of the page.
  • Choose the right options and launch the generation process.

This customized Scenario Tree will be merged to the standard Scenario Tree in order to inject the aboved described features in the project.
So, Developpers can build and share powerfull aspects to easily enrich the generation processes.

Initial and final Scenario.xml can be respectively seen here and here.: