5.11.1.1.3.2.1.1. create_entity_package_name.ftl

Listing 5.100 function/entity/create_entity_package_name.ftl
 1<#--
 2    THIS IS AN EXAMPLE
 3    This snippet creates the name of the java package for entities. It can differentiate between multiple model packages.
 4-->
 5<#compress>
 6<#--stop if $modelPackage is null-->
 7<#if !(modelPackage)??>  <#stop "modelPackage not found in context"> </#if>
 8
 9<#assign metadataKey = "model.implementation.package" />
10
11<#if (!modelPackage.hasMetaData(metadataKey))>
12    <#stop "Model package named ${modelPackage.name} doesn't have metadata <${metadataKey}> defined. Add metadata <${metadataKey}>set.your.java.packagename.for.entities</${metadataKey}>" />
13<#else >
14    <#-- Get it from the metadata of the modelPackage and raise an error if metadata not found-->
15    <#assign entityPackageName = modelPackage.getMetaData(metadataKey, true) />
16</#if>
17
18${entityPackageName}
19
20</#compress>