1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
function mapToDatabase( doc )
{
mapper = doc.getDatabaseMapper();
mapper.newTable( 'FormDoc' );
// On récupère la page
page1 = doc.getElementById('page1');
// On crée la table FormPage qui stockera les pages
mapper.newTable( 'FormPage' );
// On crée une relation entre une page et son document parent (clé étrangère si je me trompe pas)
mapper.setRelation( 'FormPage', 'FormPage.docId', 'FormDoc.id' );
with( page1 )
{
// On récupère la section
sectionBody = page1.getElementById( 'body' );
mapper.newTable( 'FormSection' );
mapper.setRelation( 'FormSection', 'FormSection.pageId', 'FormPage.id' );
with( sectionBody )
{
lineedit1 = getElementById( 'lineedit1' );
// Creation de la table Widget
mapper.newTable( 'Widget' );
mapper.setRelation( 'Widget', 'Widget.sectionId', 'FormSection.id' );
// On mappe le widget et toutes ses propriétés (non qt, géré avec une map perso)
mapper.mapWidget( 'Widget', lineedit1 );
}
// Mapping de propriétés diverses
mapper.map( 'FormSection', 'FormSection.width', sectionBody.width );
mapper.map( 'FormSection', 'FormSection.height', sectionBody.height );
}
// Mapping de propriétés diverses
mapper.map( 'FormPage', 'FormPage.numPage', page1.numPage );
mapper.map( 'FormPage', 'FormPage.pageFormat', page1.pageFormat );
} |
Partager