5.1.1.6. Maps

<maps/> is a sub element of <personel-iom-project>. It is a collection of <map> elements.

A map element is used to alter the build-in type sets javaTypes or hibernateTypes mapping. The javaTypes is used by MetaFactory to map model object attribute types to actual Java types. The map functionality can also be used to create a custom set that maps the javaTypes to an equivalent type of a different language, such as typescript.

One could use the combination of the standard javaTypes mappings and custom types for instance to create an application with Angular 2 front end (using TypeScript) with a Java-based back end.

MetaFactory has default type mappings for JavaTypes but you can (partially) override those using this element.

Syntax

Listing 5.7 <maps> syntax
 1<personal-iom-project>
 2        ...
 3
 4        <maps>
 5           <map name=”MapOne”>
 6                  <entry key=”” value=””>
 7           </map>
 8           <map name=”MapTwo”>
 9                  <entry key=”” value=””>
10           </map>
11
12        </maps>
13
14        ...
15</personel-iom-project>

Available maps

MetaFactory contains 2 hardcoded maps:

  • javaTypes and

  • hibernateTypes

Loupe M For details see: Data type mappings

Attributes

There are no attributes for <maps/>.

Sub elements

Table 5.7 <maps/> sub elements

Name

Details

Number

map

map is used to customize a javatype mapping.

1

Sub element map (Eye S singular)

Table 5.8 <map/> attributes

Name

Details

name

Name of the map. Mandatory

Table 5.9 <map/> sub elements>

Name

Details

Attributes

Number

entry

Question S

key, Required

value, Required

0 or more

5.1.1.6.1. Examples

Listing 5.8 is an example of a project file with a mapping in order to override the mapping for Date with org.joda.time.LocalDate instead of java.util.Date.

Listing 5.8 <maps/> in project file
 1<personal-iom-project>
 2        ...
 3
 4        <maps>
 5                <!-- Update the default map with name javaTypes-->
 6
 7                <map name="javaTypes">
 8                        <!-- override the mapping for Date with org.joda.time.LocalDate instead of java.util.Date -->
 9
10                        <entry key="Date" value="org.joda.time.LocalDate"/>
11                </map>
12        </maps>
13
14        ...
15</personel-iom-project>

In the code_instruction a map can be used by applying the MetaFactory expression language (a simple version of el). The syntax is:

${map(mapName, key)}

Example

${map(javaTypes, big_decimal)}

which returns java.math.BigDecimal