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
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
<personal-iom-project>
        ...

        <maps>
           <map name=”MapOne”>
                  <entry key=”” value=””>
           </map>
           <map name=”MapTwo”>
                  <entry key=”” value=””>
           </map>

        </maps>

        ...
</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
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
<personal-iom-project>
        ...

        <maps>
                <!-- Update the default map with name javaTypes-->

                <map name="javaTypes">
                        <!-- override the mapping for Date with org.joda.time.LocalDate instead of java.util.Date -->

                        <entry key="Date" value="org.joda.time.LocalDate"/>
                </map>
        </maps>

        ...
</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