admin
2025-01-22 7e31442f0e9b07764e9c6a9680d3d4aeba5fe1de
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
Quintiq file version 2.0
#parent: #root
Method SyncSetMeta (const LibDEF_Set set_i, Boolean isDatasetConstructed_i)
{
  Description: 'Performance improvement - only sync created/updated set'
  TextBody:
  [*
    channel := set_i.SetType().Channel();
    setType := set_i.SetType();
    
    // Synchronization  
    channelMeta := LibDEF_ChannelMeta::CreateFromRepository( this, channel );
    channelMeta.SyncFromRepository( channel );
    
    setTypeMeta := LibDEF_SetTypeMeta::CreateFromRepository( this, channelMeta, setType );
    
    isNew   := false;
    setMeta := LibDEF_SetMeta::CreateFromRepository( setTypeMeta, set_i, isNew );
    setMeta.IsSoftDeleted( false );
    
    hasUpdate := setMeta.SyncFromRepository( set_i );
    
    // broadcast to other systems if new
    if( isNew )
    {
      // Create Set interest for local datasets that already have interest in Set Type level
      setTypeMeta.CreateSetInterestOfDatasets( setMeta );
      
      // Create Set interest for external system that already have interest in Set Type level
      setTypeMeta.CreateSetInterestFromSystem( setMeta );
      
      this.SendMetadataRequestSetCreated( setMeta );
       
      setMeta.SendSetCreated();
      //setMeta.SendSetUpdated();
    }
    
    // Send SetUpdated if change in LastUpdated
    else if( hasUpdate )
    {
      setMeta.SendSetUpdated();
    }
    
    
    // if the DataRepository just constructed (during wake-up), sync with the Domain too
    dataBroker := this.DataBroker();
    if( isDatasetConstructed_i and not dataBroker.IsInSyncWithDataRepository() )
    {
      // only connect when allowed, upon dataset constructed
      if( LibDEF_Util::GetSettingValueConnectOnStartup() )
      {
        dataBroker.RequestJoinDomainOrBroadcast();
        // also sync interests
        LibDEF_SetInterestOfDataset::SyncDatasetStatusExternally( dataBroker );
      }
      dataBroker.IsInSyncWithDataRepository( true );
    }
    
    LibDEF_Util::Log( "Metadata in DataBroker has been synchronized with Data in DataRepository." );
  *]
  InterfaceProperties { Accessibility: 'Module' }
}