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
Quintiq file version 2.0
#parent: #root
Method SynchronizeSolverSettingGroups
{
  Description: 'Updates the SolverSettingsGroup and SolverSettings instances with info from the SolverSettings KT.'
  TextBody:
  [*
    // Martijn van Elzakker Jul-21-2015 (created)
    // This method first flags all current solversettinggroups as not being part of the KT
    // Then it traverses the KT and checks if there exists a solversettinggroup with the same name as the KT name
    // if there does not, it creates a new SolverSettingGroup
    // if there does, it updates the SolverSettingGroup
    // In any case, it flags the current SolverSettingGroup as being part of the KT
    // At the end, the method deletes all SolverSettingGroup that are still flagged as not part of the KT and it synchronizes the SolverSetting
    
    traverse( this, SolverSettingGroup, solversettinggroup )
    {
      solversettinggroup.IsInKnowledgeTable( false );
    }
    
    solversettingstable := SolverSettingsTable::Table();
    
    traverse( solversettingstable, Rows, row )
    {
      group := select( this,
                       SolverSettingGroup,
                       solversettinggroup,
                       solversettinggroup.Name() = row.Name() );
    
      if( isnull( group ) )
      {
        group := SolverSettingGroup::Create( this, row.Name() );
      }
      else
      {
        group.Update( row.Name() );
      }
      group.IsInKnowledgeTable( true );
    }
    
    traverse( this, SolverSettingGroup, solversettinggroup, not solversettinggroup.IsInKnowledgeTable() )
    {
      solversettinggroup.Delete()
    }
    
     this.SynchronizeSolverSettings();
  *]
}