From Ametys ODF 4.9
Code nomenclature Customize the bill of materials Display code Customize display code Code nomenclature Ametys ODF 4.9, allows you to choose the nomenclature to be used for ODF objects created in the back-office (training, course, container, list, ELP, teaching hours, component):
By default, 2 BOMs are possible:
Random code: random code based on system time in millisecondsIncremental code prefixed by type: FOR1, FOR2, ... PAR1, PAR2, ... CTN1, CTN2, ...LST1, LST2, .., ELP1, ELP2, ..., CMP1, CMP2, ..., HE1, HE2, ...
Customize the bill of materials You can define your own nomenclature by defining a new extension of type "org.ametys.odf.content.code.UniqueCodeGeneratorExtensionPoint"
Remember to declare the extension in a "safe" feature so that you can select your extension in the safe mode configuration parameters.
Example 1: Defining your own prefixes based on ODF objects
This example allows you to define a new BOM with its own prefixes by type and incremental code.
Oops! Copy to clipboard failed. Open the code and copy it manually.<feature name="custom.code.generator" safe="true">
<extensions>
<extension id="custom-code-generator"
point="org.ametys.odf.content.code.UniqueCodeGeneratorExtensionPoint"
class="org.ametys.odf.content.code.PrefixedIncrementalCodeGenerator">
<label i18n="false">Ma nomenclature</label>
<prefix type="org.ametys.plugins.odf.Content.program">PR</prefix>
<prefix type="org.ametys.plugins.odf.Content.subProgram">SP</prefix>
<prefix type="org.ametys.plugins.odf.Content.container">CT</prefix>
<prefix type="org.ametys.plugins.odf.Content.courseList">CL</prefix>
<prefix type="org.ametys.plugins.odf.Content.course">CO</prefix>
<prefix type="org.ametys.plugins.odf.Content.orgunit">OU</prefix>
<prefix type="org.ametys.plugins.odf.Content.coursepart">CP</prefix>
</extension>
</extensions>
</feature> <feature name="custom.code.generator" safe="true">
<extensions>
<extension id="custom-code-generator"
point="org.ametys.odf.content.code.UniqueCodeGeneratorExtensionPoint"
class="org.ametys.odf.content.code.PrefixedIncrementalCodeGenerator">
<label i18n="false">Ma nomenclature</label>
<prefix type="org.ametys.plugins.odf.Content.program">PR</prefix>
<prefix type="org.ametys.plugins.odf.Content.subProgram">SP</prefix>
<prefix type="org.ametys.plugins.odf.Content.container">CT</prefix>
<prefix type="org.ametys.plugins.odf.Content.courseList">CL</prefix>
<prefix type="org.ametys.plugins.odf.Content.course">CO</prefix>
<prefix type="org.ametys.plugins.odf.Content.orgunit">OU</prefix>
<prefix type="org.ametys.plugins.odf.Content.coursepart">CP</prefix>
</extension>
</extensions>
</feature> Voir le code
<feature name="custom.code.generator" safe="true">
<extensions>
<extension id="custom-code-generator"
point="org.ametys.odf.content.code.UniqueCodeGeneratorExtensionPoint"
class="org.ametys.odf.content.code.PrefixedIncrementalCodeGenerator">
<label i18n="false">Ma nomenclature</label>
<prefix type="org.ametys.plugins.odf.Content.program">PR</prefix>
<prefix type="org.ametys.plugins.odf.Content.subProgram">SP</prefix>
<prefix type="org.ametys.plugins.odf.Content.container">CT</prefix>
<prefix type="org.ametys.plugins.odf.Content.courseList">CL</prefix>
<prefix type="org.ametys.plugins.odf.Content.course">CO</prefix>
<prefix type="org.ametys.plugins.odf.Content.orgunit">OU</prefix>
<prefix type="org.ametys.plugins.odf.Content.coursepart">CP</prefix>
</extension>
</extensions>
</feature> Example 2: BOM based on a java class
Oops! Copy to clipboard failed. Open the code and copy it manually.<feature name="custom.code.generator" safe="true">
<extensions>
<extension id="custom-code-generator"
point="org.ametys.odf.content.code.UniqueCodeGeneratorExtensionPoint"
class="fr.ametys.project.CustomCodeGenerator">
<label i18n="false">Ma nomenclature</label>
</extension>
</extensions>
</feature> <feature name="custom.code.generator" safe="true">
<extensions>
<extension id="custom-code-generator"
point="org.ametys.odf.content.code.UniqueCodeGeneratorExtensionPoint"
class="fr.ametys.project.CustomCodeGenerator">
<label i18n="false">Ma nomenclature</label>
</extension>
</extensions>
</feature>
<feature name="custom.code.generator" safe="true">
<extensions>
<extension id="custom-code-generator"
point="org.ametys.odf.content.code.UniqueCodeGeneratorExtensionPoint"
class="fr.ametys.project.CustomCodeGenerator">
<label i18n="false">Ma nomenclature</label>
</extension>
</extensions>
</feature> Your class must extend the "org.ametys.odf.content.code.AbstractUniqueCodeGenerator" and implement its own generateUniqueCode(String cTypeId)
Please ensure that the code generated is unique!
Display code Starting with Ametys ODF 4.9, in the configuration parameters it is possible to choose the ODF content code used for display (layout, search tools, dashboards, etc.) and in exports or extractions.
By default, Ametys offers 5 possible display codes:
Ametys code : this is the internal, unique code. Its format depends on the nomenclature chosen (see above) .Apogee synchronization code (apogeeSyncCode) Pegasus synchronization code (pegaseSyncCode) CDMfr synchronization code (cdmfrSyncCode) Apogee code The latter is made up of the Apogée codes provided by the Pilotage plugin :
for courses and itineraries, it is composed of the fields DIP code (codeDIP) and VDI code (codeVSRVDI ) separated by a "-". for containers, it consists of the ETP Code (etpCode ) and VET Code (vsrEtpCode) fields separated by a "-" . for ELP , it is equal to the ELP Code field(elpCode)
If the code chosen for the display is empty, the Ametys code will be used.
In search engines, the "Code" criterion can be used to search on both the selected display code and the Ametys code.For the search to be functional, a complete re-indexing is necessary each time the "Display code" configuration parameter is modified.)
Customize display code You can define your own provider for the display code by defining a new extension of type "org.ametys.odf.content.code.DisplayCodeProviderExtensionPoint"
Remember to declare the extension in a "safe" feature so that you can select your extension in the safe mode configuration parameters.
Example 1: Code based on one or more model fields
For each type of content, list the fields to be included in the code, as in the 2 examples below:
Oops! Copy to clipboard failed. Open the code and copy it manually.<feature name="custom.display.code" safe="true">
<extensions>
<extension id="custom-display-code"
point="org.ametys.odf.content.code.DisplayCodeProviderExtensionPoint"
class="org.ametys.odf.content.code.AttributeBasedDisplayCodeProvider">
<label i18n="false">Mon code projet</label>
<!-- Tous les contenus ODF -->
<type id="org.ametys.plugins.odf.Content.odfContent">
<item ref="customCode"/>
</type>
</extension>
</extensions>
</feature> <feature name="custom.display.code" safe="true">
<extensions>
<extension id="custom-display-code"
point="org.ametys.odf.content.code.DisplayCodeProviderExtensionPoint"
class="org.ametys.odf.content.code.AttributeBasedDisplayCodeProvider">
<label i18n="false">Mon code projet</label>
<!-- Tous les contenus ODF -->
<type id="org.ametys.plugins.odf.Content.odfContent">
<item ref="customCode"/>
</type>
</extension>
</extensions>
</feature> Voir le code
<feature name="custom.display.code" safe="true">
<extensions>
<extension id="custom-display-code"
point="org.ametys.odf.content.code.DisplayCodeProviderExtensionPoint"
class="org.ametys.odf.content.code.AttributeBasedDisplayCodeProvider">
<label i18n="false">Mon code projet</label>
<!-- Tous les contenus ODF -->
<type id="org.ametys.plugins.odf.Content.odfContent">
<item ref="customCode"/>
</type>
</extension>
</extensions>
</feature>
Oops! Copy to clipboard failed. Open the code and copy it manually.<feature name="custom.display.code" safe="true">
<extensions>
<extension id="custom-display-code"
point="org.ametys.odf.content.code.DisplayCodeProviderExtensionPoint"
class="org.ametys.odf.content.code.AttributeBasedDisplayCodeProvider">
<label i18n="false">Mon code projet</label>
<!-- Formation et parcours -->
<type id="org.ametys.plugins.odf.Content.abstractProgram">
<item ref="customProgramCode1"/>
<item ref="customProgramCode2"/>
</type>
<!-- Conteneurs -->
<type id="org.ametys.plugins.odf.Content.container">
<item ref="customContainerCode"/>
</type>
<!-- ELP -->
<type id="org.ametys.plugins.odf.Content.course">
<item ref="customCourseCode"/>
</type>
</extension>
</extensions>
</feature> <feature name="custom.display.code" safe="true">
<extensions>
<extension id="custom-display-code"
point="org.ametys.odf.content.code.DisplayCodeProviderExtensionPoint"
class="org.ametys.odf.content.code.AttributeBasedDisplayCodeProvider">
<label i18n="false">Mon code projet</label>
<!-- Formation et parcours -->
<type id="org.ametys.plugins.odf.Content.abstractProgram">
<item ref="customProgramCode1"/>
<item ref="customProgramCode2"/>
</type>
<!-- Conteneurs -->
<type id="org.ametys.plugins.odf.Content.container">
<item ref="customContainerCode"/>
</type>
<!-- ELP -->
<type id="org.ametys.plugins.odf.Content.course">
<item ref="customCourseCode"/>
</type>
</extension>
</extensions>
</feature> Voir le code
<feature name="custom.display.code" safe="true">
<extensions>
<extension id="custom-display-code"
point="org.ametys.odf.content.code.DisplayCodeProviderExtensionPoint"
class="org.ametys.odf.content.code.AttributeBasedDisplayCodeProvider">
<label i18n="false">Mon code projet</label>
<!-- Formation et parcours -->
<type id="org.ametys.plugins.odf.Content.abstractProgram">
<item ref="customProgramCode1"/>
<item ref="customProgramCode2"/>
</type>
<!-- Conteneurs -->
<type id="org.ametys.plugins.odf.Content.container">
<item ref="customContainerCode"/>
</type>
<!-- ELP -->
<type id="org.ametys.plugins.odf.Content.course">
<item ref="customCourseCode"/>
</type>
</extension>
</extensions>
</feature> Example 2: Display code based on a java algorithm
You can define your java class for more complex display code calculations
Oops! Copy to clipboard failed. Open the code and copy it manually.<feature name="custom.display.code" safe="true">
<extensions>
<extension id="custom-display-code"
point="org.ametys.odf.content.code.DisplayCodeProviderExtensionPoint"
class="fr.ametys.project.CustomCodeProvider">
<label i18n="false">Mon code projet</label>
</extension>
</extensions>
</feature> <feature name="custom.display.code" safe="true">
<extensions>
<extension id="custom-display-code"
point="org.ametys.odf.content.code.DisplayCodeProviderExtensionPoint"
class="fr.ametys.project.CustomCodeProvider">
<label i18n="false">Mon code projet</label>
</extension>
</extensions>
</feature>
<feature name="custom.display.code" safe="true">
<extensions>
<extension id="custom-display-code"
point="org.ametys.odf.content.code.DisplayCodeProviderExtensionPoint"
class="fr.ametys.project.CustomCodeProvider">
<label i18n="false">Mon code projet</label>
</extension>
</extensions>
</feature> Your class must extend the "org.ametys.odf.content.code.AbstractStaticProgramItemDisplayCodeProvider" and implement its own getDisplayCode(Content content)