lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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;
  *]
}