| Quintiq file version 2.0 | 
| #parent: #root | 
| StaticMethod CreateAllDatabaseTablesForDBBook ( | 
|   String brokername, | 
|   output String feedback_o | 
| ) as Boolean | 
| { | 
|   Description: | 
|   [* | 
|     Create all the tables for database export for exchanging data. | 
|     This method only receives the broker name, thus this has to be called multiple times if there are few brokers for exporting to database. | 
|     Before using this method, the table has to be retrieved manually in the EDI broker. | 
|   *] | 
|   TextBody: | 
|   [* | 
|     // srt Jul-8-2014 (created) | 
|     //Squall | 
|     created := false; | 
|     domain := DomainModel::Domain(); | 
|      | 
|     edibroker := select( domain, EDIDefinitionManager.BrokerDefinitions, bd, bd.Name().ToUpper() = brokername.ToUpper().TrimBoth() ); | 
|      | 
|     if( not isnull( edibroker ) ) | 
|     { | 
|       link := guard( edibroker.Destination().astype( EDIODBCLinkDefinition ), null( EDIODBCLinkDefinition ) ); | 
|       if( not isnull( link ) ) | 
|       { | 
|         traverse( edibroker, Destination.astype( EDIODBCLinkDefinition).DescriptionPlug.Tables, t ) //Table that is already created | 
|         { | 
|           table := t.PlugTable(); | 
|           intftable := guard( table.USAGE_QEDIODBCLinkTable_QEDITableInfo_InterfaceTable(), null( EDIODBCLinkTable ) ); | 
|           //Check validation for each table | 
|           feedback_o := feedback_o | 
|                         + t.Name() + " : "; | 
|           if( not link.Description().Described() | 
|                or ( not isnull( table ) and isnull( intftable ) ) ) | 
|           { | 
|             feedback_o := feedback_o | 
|                           + Translations::MP_MacroPlan_CreateAllDatabaseTablesForDBBook_ObtainTable() | 
|                           + String::NewLine(); | 
|           } | 
|           else if( not isnull( t.SocketTable() ) ) | 
|           { | 
|             feedback_o := feedback_o | 
|                           + Translations::MP_MacroPlan_CreateAllDatabaseTablesForDBBook_TableExists() | 
|                           + String::NewLine(); | 
|           } | 
|           else if( not isnull( table ) and table.PrimaryKeyColumns( relsize ) = 0 ) | 
|           { | 
|             feedback_o := feedback_o | 
|                           + Translations::MP_MacroPlan_CreateAllDatabaseTablesForDBBook_NoPrimaryKey() | 
|                           + String::NewLine(); | 
|           } | 
|           else if( isnull( table ) ) | 
|           { | 
|             feedback_o := feedback_o | 
|                           + Translations::MP_MacroPlan_CreateAllDatabaseTablesForDBBook_NotInterface() | 
|                           + String::NewLine();// WBS: Should not be possible | 
|           } | 
|           else if( not isnull( intftable ) and not intftable.MayCreateTable() ) | 
|           { | 
|             feedback_o := feedback_o | 
|                           + Translations::MP_MacroPlan_CreateAllDatabaseTablesForDBBook_NoLocalPermission() | 
|                           + String::NewLine(); | 
|           } | 
|           else | 
|           { | 
|               //Create Table | 
|               created := true; | 
|               ct := table.USAGE_QEDIODBCLinkTable_QEDITableInfo_InterfaceTable(); | 
|               ct.CreateDBTable(); | 
|               feedback_o := feedback_o | 
|                             + Translations::MP_MacroPlan_CreateAllDatabaseTablesForDBBook_Created() | 
|                             + String::NewLine(); | 
|           } | 
|         } | 
|       } | 
|       else | 
|       { | 
|         created := false; | 
|         feedback_o := Translations::MP_MacroPlan_CreateAllDatabaseTablesForDBBook_Invalid(); | 
|       } | 
|     } | 
|     else | 
|     { | 
|       created := false; | 
|       feedback_o := Translations::MP_MacroPlan_CreateAllDatabaseTablesForDBBook_NotFound(); | 
|     } | 
|      | 
|     return created; | 
|   *] | 
| } |