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
39
40
41
42
43
44
45
46
Quintiq file version 2.0
#parent: #root
Method SynchronizePaths (JSON jsondata)
{
  TextBody:
  [*
    old := selectset( this, Paths, path, true );
    new := construct( Lib3DS_Paths );
    
    pathiddata := guard( jsondata.Get( 'paths.path.id' ), null( JSON, owning ) );
    pathtypedata := guard( jsondata.Get( 'paths.path.type' ), null( JSON, owning ) );
    pathvaluedata := guard( jsondata.Get( 'paths.path.value' ), null( JSON, owning ) );
    pathroledata := guard( jsondata.Get( 'paths.path.attribute[RoleSemantics]' ), null( JSON, owning ) );
    
    if( not isnull( pathiddata ) ) // ensure that there is path
    {
      // array mode
      if( guard( pathiddata.IsArray(), false )
          and guard( pathtypedata.IsArray(), false )
          and guard( pathvaluedata.IsArray(), false )
          and guard( pathroledata.IsArray(), false ) )
      {
        for( i := 0; i < pathtypedata.Size(); i++ )
        {
          path := Lib3DS_Path::FindOrCreate( this, pathiddata.Get( i ).GetString() );
          path.Type( guard( pathtypedata.Get( i ).GetString(), '' ) );
          path.RoleSemantics( guard( pathroledata.Get( i ).GetString(), '' ) );
          path.SynchronizePathElements( pathvaluedata.Get( i ).GetString() );
          new.Add( path );
        }
      }
      else // non array mode
      {
        path := Lib3DS_Path::FindOrCreate( this, pathiddata.GetString() );
        path.Type( guard( pathtypedata.GetString(), '' ) );
        path.RoleSemantics( guard( pathroledata.GetString(), '' ) );
        path.SynchronizePathElements( pathvaluedata.GetString() );
        new.Add( path );
      }
    }
    
    deleted := old.Difference( new );
    Lib3DS_Path::Delete( deleted );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}