Ignore:
Timestamp:
23/11/11 09:37:57 (8 years ago)
Author:
mnagni
Message:

This commit is Just before the refactoring to the new get/set approach

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/xmi2sqlalchemy/trunk/src/main/resources/velocity/python/mapping.vm

    r7978 r7996  
    66${tab}if (target.${tm}_id is None): 
    77${tab}${tab}target.${tm}_id = next_id(connection, '${tm}_id_seq') 
    8 ##if($tableModel.hasChildren) 
    9 ##${tab}target.${tm}_type = '${tm}' 
    10 ##end 
    118#foreach( $parent in $tableModel.inherited) 
    129#set ($tp = $parent.associatedClass.name.toLowerCase()) 
    13 ##${tab}target.${tp}_type = '${tp}' 
    1410${tab}target.${tp}_id = next_id(connection, '${tp}_id_seq') 
    1511${tab}target.${tm}_${tp}_id = target.${tp}_id 
     
    1713#end 
    1814 
    19 #macro( joinClass $class, $parents) 
     15#macro( joinInheritedClasses $tableModel) 
    2016#if($tableModel.inherited.size() > 0) 
    2117#foreach( $parent in $parents).join(${parent.associatedClass.name.toLowerCase()}_table)#end 
     
    2319#end 
    2420 
    25 #macro( generateProperties $tableModel) 
    26         #if($tableModel.relationship.size() > 0 && $tableModel.oa.size() > 0) 
    27 , properties  = { 
    28 #identicalAttributes($tableModel), #relationColumns($tableModel)} 
    29         #elseif($tableModel.relationship.size() > 0) 
    30 , properties  ={ 
    31 #relationColumns($tableModel)} 
    32         #elseif($tableModel.oa.size() > 0) 
    33 , properties  = { 
    34 #identicalAttributes($tableModel)} 
     21#macro( identicalAttributes $tableModel) 
     22#if($tableModel.oa.size() > 0) 
     23        #foreach( $oa in $tableModel.oa) 
     24                '${oa.attributeName}': [#tableName($tableModel.associatedClass.name).c.${oa.attributeName} 
     25                #foreach( $ovAttTable in $oa.models) 
     26                        , #tableName($ovAttTable.associatedClass.name).c.${oa.attributeName} 
     27                #end]  
     28                #if($foreach.hasNext),#end                       
     29                #end 
    3530        #end 
    3631#end 
    3732 
    38 mapper($tableModel.associatedClass.name, #tableName($tableModel.associatedClass.name)#joinClass($tableModel.associatedClass.name, $tableModel.inherited)  
     33#macro( generateProperties $tableModel) 
     34        #if($tableModel.relationship.size() > 0 && $tableModel.oa.size() > 0) 
     35, properties  = {#identicalAttributes($tableModel), #relationColumns($tableModel)} 
     36        #elseif($tableModel.relationship.size() > 0) 
     37, properties  = {#relationColumns($tableModel)} 
     38##      #elseif($tableModel.oa.size() > 0) 
     39##, properties  = {#identicalAttributes($tableModel)} 
     40        #end 
     41#end 
     42 
     43mapper($tableModel.associatedClass.name, #tableName($tableModel)#inheritedClasses($tableModel)  
    3944#generateProperties($tableModel)) 
    4045 
    41 #if($tableModel.inherited.size() > 0 || $tableModel.hasChildren) 
    42 #beforeInsertListener($tableModel) 
    43  
    44 event.listen($tableModel.associatedClass.name, 'before_insert', ${tableModel.associatedClass.name}_before_insert_listener) 
    45 #end 
Note: See TracChangeset for help on using the changeset viewer.