Map Call Statement


SYNTAX:
map_call_stmt = map_name [ actual_parameter_list ] .
Any named MAP can be called from any place in a mapping schema. The format of a map call is similar to a function call, i.e. the map is called by its name. The function return value is either a LIST aggregate containing all map instances created in the called map, or a single map instance if the receiving identifier is a simple identifier. The single map instance returned from the map call is always the map instance that was created first in the called map.
The number of arguments, the argument order and types must correspond to the number of entities, the order and the types specified in the FROM clause in the called map, i.e. the FROM clause in the called map defines the formal parameters of the map call.
A map call will invoke the called map with the exact set of instances given as arguments in the map call. If the called map has been executed with exactly this set of instances before, then the map call will return with the map instances (if any) created the first time the called map was executed with the same set of instances. This feature will avoid creation of duplicated map instances from the same set of instances.
In case no map instances are returned from the map call, indeterminate (question) will be returned, if the receiving identifier is a simple identifier. An empty LIST will be returned when the receiving identifier is an aggregate.
 
Example:
MAP a_calling_map FOR t:target::anEntity;
FROM (s:source::anotherEntity)
WHILE (TRUE);
BEGIN_MAP
 LOCAL
  mapInstances   : LIST OF GENERIC;
  firstMapInstance : GENERIC;
 END_LOCAL;
 (* map call returning a LIST of all relevant map instances *)
 mapInstances := map_one_to_many(s.human_being);
 (* return the first created map instance *)
 firstMapInstance := map_one_to_many(s.human_being);
 ...................................................
END_MAP;
 
(*
 Map must have a name to be callable. Map declaration does not define
  a map entity.
*)
 
MAP one_to_many FOR;
FROM (s:source::human_being)
WHILE (TRUE);
BEGIN_MAP
 LOCAL
  aMale  : tm::male;
  aFemale  : tm::female;
  aPerson  : GENERIC;
 END_LOCAL;
(*
 Each source instance of type Human_Being will be mapped to one  instance of male, female and person in the target model. These  instances will be stored in an implicit lIST in the map that can be  returned in a map_call.
*)
 xpxCreateMapInstance(tm::male, aMale);
 xpxCreateMapInstance(female, aFemale);
 xpxCreateMapInstance(tm:person, aPerson);
 (* Attribute mapping *)
 aMale.Name := s.Name;
 aPerson.person_number := person_id_number;
 ..........................................
END_MAP;