yanweiyuan3
2023-08-09 588bc7829387dfc761cc25f06f77d4c81818bd10
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
Quintiq file version 2.0
#parent: #root
Method DeserializeScopeElements (JSON array)
{
  TextBody:
  [*
    key_comment := LibOpt_Scope::JSON_Comment();
    key_id := attribute( LibOpt_ScopeElement, InternalIdentifier ).Name();
    optimization := this.Run().Optimization();
    scope_elements := selectsortedset( optimization, ScopeElement, se, true, se.InternalIdentifier() );
    se_index := 0;
    for( i := 0; i < array.Size(); i++ )
    {
      json_se := array.Get( i );
      comment := json_se.Get( key_comment ).GetString();
      id := [Key] json_se.Get( key_id ).GetString();
      
      // Find the scope element in the set of scope elements.
      for( {}; se_index < scope_elements.Size() and scope_elements.Element( se_index ).InternalIdentifier() < id; se_index++ )
      { }
      scope_element := guard( scope_elements.Element( se_index ), null( LibOpt_ScopeElement ) );
      if( isnull( scope_element ) or id <> scope_element.InternalIdentifier() )
      {
        identifier := json_se.Get( attribute( LibOpt_ScopeElement, Identifier ).Name() ).GetString();
        details := json_se.Get( attribute( LibOpt_ScopeElement, Details ).Name() ).GetString();
        scope_element := LibOpt_ScopeElementDeleted::Create( this.Run().Optimization(), id, details, identifier, true );
      }
      group := null( LibOpt_Group );
      if( json_se.Has( LibOpt_Scope::JSON_Group() ) )
      {
        group := LibOpt_Group::FindOrCreateByName( optimization, json_se.Get( LibOpt_Scope::JSON_Group() ).GetString() );
      }
      
      this.Add( scope_element, group, comment );
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}