Differences
This shows you the differences between two versions of the page.
— |
tutorial:customize_pagila_scenario [2020/04/16 10:56] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | The generation process is driven by <wrap adicode>Scenario Tree</wrap> provided by **Scenario.xml** file. | ||
+ | The <wrap adicode>Scenario Tree</wrap> describes how to drive automatic generation processes.\\ | ||
+ | Indeed, as explained in this [[tutorial:scenario|page]] a scenario transforms an input (XML files, Pojos) into a GENERATED XML file which describes the body of a part (Editor, Query, Detail UI...).\\ | ||
+ | For instance, The <wrap adicode>DetailScenario</wrap> class builds XML file like <wrap adicode>FilmDIGENERATED.axml</wrap> (see [[tutorial:scenario|Scenario architecture]]). | ||
+ | <WRAP indic>An example of <wrap adicode>Scenario Tree</wrap> can be see [[http://www.adichatz.org/document/Scenario.xml|here]].</WRAP> | ||
+ | \\ | ||
+ | However, only common cases can be dealt by the set of scenarios given by default.\\ | ||
+ | In order to get around this limitation, you can create your own scenario tree file which describes specific features for the generation processes. You can specify: | ||
+ | * 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. <wrap adicode>org.adichatz.scenario.generation.SuperPojoRewriter</wrap> 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. | ||
+ | |||
+ | These changes can be manually made by the developper inside the **Scenario.xml** file. | ||
+ | A other way is to assemble changes inside a new <wrap adicode>Scenario tree</wrap> stored in a specific <wrap adicode>xml file</wrap> | ||
+ | |||
+ | For example, open file <wrap adicode>[eclipse_dir]/plugins/org.adichatz.template/template/connectors/pagilaMappingOverride.xml</wrap>. | ||
+ | **Following XML elements:** | ||
+ | <sxh xml; highlight: [4,10,11,17,18,19,20,21,22,26,29,37,40,41,44,46,55]; first-line: 1; title: excerpt from 'pagilaMappingOverride.xml' file.> | ||
+ | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
+ | <scenarioTree xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.adichatz.org/xsd/v0.9.1/generator/scenarioTree.xsd"> | ||
+ | <pathElements> | ||
+ | <pathElement type="PROJECT" location="myscenario"/> | ||
+ | </pathElements> | ||
+ | <params> | ||
+ | <param id="devl.default.integer.pattern" value="#####"/> | ||
+ | </params> | ||
+ | <generators> | ||
+ | <generator treeClassName="org.adichatz.generator.wrapper.TableWrapper" generatorClassName="org.mycompany.myscenario.generator.MyTableGenerator"/> | ||
+ | <generator treeClassName="#CONTROLGENERATOR()" generatorClassName="org.mycompany.myscenario.generator.MyControlGenerator"/> | ||
+ | </generators> | ||
+ | <generationScenario> | ||
+ | <generationUnit scenarioClassName="org.mycompany.myscenario.scenario.MyDetailScenario" type="DETAIL"/> | ||
+ | <modelPart> | ||
+ | <pojoRewriters> | ||
+ | <pojoRewriter rewriterClassName="org.adichatz.scenario.generation.PgPojoIdRewriter"/> | ||
+ | <pojoRewriter rewriterClassName="org.adichatz.scenario.generation.SuperPojoRewriter" propertyRegex="lastUpdate"> | ||
+ | <params> | ||
+ | <param id="superClassURI" value="bundleclass://./..model.ASuperLastUpdateClass"/> | ||
+ | <param id="sourceURI" value="platform:/plugin/org.adichatz.template/template/src/ASuperLastUpdateClass.java"/> | ||
+ | </params> | ||
+ | </pojoRewriter> | ||
+ | </pojoRewriters> | ||
+ | </modelPart> | ||
+ | <propertyField id="lastUpdate"> | ||
+ | <controlField xsi:type="dateTextType" enabled="false" style="SWT.BORDER | SWT.TIME"/> | ||
+ | </propertyField> | ||
+ | <propertyField id="rating" pojoType="#ENUM(MpaaRatingEnum, {G, PG, PG-13, R, NC-17})"> | ||
+ | <controlField xsi:type="cComboType"> | ||
+ | <labelProvider> | ||
+ | <textCode>return ((#MODELPACKAGE().MpaaRatingEnum) element).getValue();</textCode> | ||
+ | </labelProvider> | ||
+ | <initValues>return java.util.Arrays.asList(#MODELPACKAGE().MpaaRatingEnum.values());</initValues> | ||
+ | </controlField> | ||
+ | </propertyField> | ||
+ | <propertyField id="fulltext" pojoType="tsvector"/> | ||
+ | <pluginEntity entityURI="adi://././FilmMM"> | ||
+ | <messages> | ||
+ | <message key="invalid.year.value" value="Invalid year '{0}'! Value must be between 1900 and 2155"/> | ||
+ | <message key="invalid.year.value" value="'{0}' n'est pas une année valide! La valeur doit être entre 1900 et 2155" language="fr"/> | ||
+ | </messages> | ||
+ | <params> | ||
+ | <param id="FULLTEXT_RESOURCE_URI" type="QUERY_ITEM" value="adi://org.adichatz.jpa/query/FullTextInclude"/> | ||
+ | </params> | ||
+ | <propertyField id="releaseYear" pojoType="int"> | ||
+ | <controlField xsi:type="formattedTextType" editPattern="####" format="Integer"> | ||
+ | <validators> | ||
+ | <validator key="invalidYear" errorMessage="#MSG(film, invalid.year.value, #FV())"> | ||
+ | <errorWhen>return #FV() < 1900 || #FV() > 2155;</errorWhen> | ||
+ | </validator> | ||
+ | </validators> | ||
+ | </controlField> | ||
+ | </propertyField> | ||
+ | <propertyField id="specialFeatures" pojoType="String[]"> | ||
+ | <controlField xsi:type="multiChoiceType" values="Trailers,Commentaries,Deleted Scenes,Behind the Scenes" multiChoiceType="Array" popupToolbar="true"> | ||
+ | <convertTargetToModel>return java.util.Arrays.copyOf((Object[]) value, ((Object[]) value).length, String[].class);</convertTargetToModel> | ||
+ | </controlField> | ||
+ | </propertyField> | ||
+ | </pluginEntity> | ||
+ | </generationScenario> | ||
+ | </scenarioTree> | ||
+ | </sxh>\\ | ||
+ | |||
+ | <WRAP indic><wrap adititle>Remarks</wrap>:\\ | ||
+ | |< 100% 10em - >| | ||
+ | ^ <html><small></html>Line 4<html></small></html>:|@#eff5fb:A new project containing resources (classes) is added to the path for generation processes.| | ||
+ | ^ <html><small></html>Lines 11-12<html></small></html>:|@#eff5fb:2 new **Generators** are used instead of standard generators.| | ||
+ | ^ <html><small></html>Lines 17-23<html></small></html>:|@#eff5fb:2 new <wrap adicode>pojo rewriters</wrap> are executed after **Pojos** are generated.| | ||
+ | ^ <html><small></html>Lines 26-28<html></small></html>:|@#eff5fb:The **controller** for <wrap adicode>lastUpdate</wrap> property will be a <wrap adicode>DateTextController</wrap> for any entity of the project.| | ||
+ | ^ <html><small></html>Lines 29-36<html></small></html>:|@#eff5fb:The <wrap adicode>rating</wrap> property has a <wrap adicode>enum</wrap> type (**PostgresSQL** database) and is displayed in a <wrap adicode>CComboController</wrap> controller for any entity of the project.| | ||
+ | ^ <html><small></html>Line 37<html></small></html>:|@#eff5fb:The <wrap adicode>fullText</wrap> property must be considered as a **tsvector** (fulltext feature in **PostgresSQL** database): that means it is not mapped in the client side.| | ||
+ | ^ <html><small></html>Lines 40-41<html></small></html>:|@#eff5fb:2 items are added to the message bundle file linked to the <wrap adicode>Film</wrap> entity (<wrap adicode>filmGENERATED.properties</wrap> file).| | ||
+ | ^ <html><small></html>Line 44<html></small></html>:|@#eff5fb:a new parameter is passed when building navigator. This item provides a Fulltext feature will be associated to the Query form of the <wrap adicode>Film</wrap> entity.| | ||
+ | ^ <html><small></html>Lines 46-54<html></small></html>:|@#eff5fb:Assumes that the value of the <wrap adicode>releaseYear</wrap> property must be between 1900 and 2155 (Client side).| | ||
+ | ^ <html><small></html>Lines 55-59<html></small></html>:|@#eff5fb:The value of the <wrap adicode>specialFeatures</wrap> property is an array of predetermined values (**PostgresSQL** database) and uses a [[controllers:multichoicecontroller|MultiChoiceController]] controller.| | ||
+ | </WRAP> | ||
+ | \\ \\ | ||
+ | <WRAP adihi> | ||
+ | <html><center></html> | ||
+ | This customized <wrap adicode>Scenario Tree</wrap> will be merged to the standard <wrap adicode>Scenario Tree</wrap> 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.</WRAP> | ||
+ | <html></center></html> |