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
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
For details see: Data type mappings
Attributes
There are no attributes for <maps/>.
Sub elements
Name |
Details |
Number |
---|---|---|
map |
map is used to customize a javatype mapping. |
1 |
Name |
Details |
---|---|
name |
Name of the map. Mandatory |
Name |
Details |
Attributes |
Number |
---|---|---|---|
entry |
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.
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