source: mauRepo/xmi2sqlalchemy/trunk/src/main/resources/velocity/python/mapping.vm @ 8013

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/xmi2sqlalchemy/trunk/src/main/resources/velocity/python/mapping.vm@8013
Revision 8013, 711 bytes checked in by mnagni, 8 years ago (diff)

At first run MOLES3 Editor uses correctly all the python classes and SQLAlchemy tables generated by this code. That's good!

  • Property svn:executable set to *
Line 
1## mapping.vm
2
3
4#macro( beforeInsertListener $tableModel)
5#set ($tm = $tableModel.associatedClass.name.toLowerCase())
6def ${tableModel.associatedClass.name}_before_insert_listener(mapper, connection, target):
7${tab}if (target.${tm}_id is None):
8${tab}${tab}target.${tm}_id = next_id(connection, '${tm}_id_seq')
9#foreach( $parent in $tableModel.inherited)
10#set ($tp = $parent.associatedClass.name.toLowerCase())
11${tab}target.${tp}_id = next_id(connection, '${tp}_id_seq')
12${tab}target.${tm}_${tp}_id = target.${tp}_id
13#end
14#end
15
16#if(!$tableModel.associatedClass.name.equals('EARootClass'))
17mapper($tableModel.associatedClass.name, #tableName($tableModel)
18, properties  = {#relationColumns($tableModel)})
19#end
20
Note: See TracBrowser for help on using the repository browser.