4.1.2.7. Maps

<maps/> is a sub element of <personel-iom-project>.

The MetaFactory project file element <maps/> is a sub element of <personal-iom-project>. Only one <maps/> element is allowed.

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

4.1.2.7.1. Syntax

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

4.1.2.7.2. Available maps

MetaFactory contains 2 hardcoded maps:

  • javaTypes and

  • hibernateTypes

Loupe M For details see: Data type mappings

4.1.2.7.3. Attributes

There are no attributes for <maps/>.

4.1.2.7.4. Sub elements

Table 4.5 <maps/> sub elements

Name

Details

Number

map

The map has a mandatory attribute “name”.

This map sub element is used to customize a javatype mapping.

1-n

4.1.2.7.5. Example

<maps/> in project file 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 4.8 <maps/> in project file
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="UTF-8"?>
<personal-iom-project xsi:schemaLocation="http://www.firstbase.nl/xsd/personaliom/project
                                                http://www.firstbase.nl/xsd/personaliom/project.xsd"
                                        xmlns="http://www.firstbase.nl/xsd/personaliom/project"
                                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        ...

        <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 pattern 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