hongji.li
2023-11-07 1a1ba3ad5ed9e4380185aa1ccad20204a0e5f115
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
Quintiq file version 2.0
#parent: #root
StaticMethod CreateDataSources (
  Object sourceObject_i,
  LibSOPImpExp_ImportExportBase owner_i,
  Boolean isIncludeGlobal_i
) #extension
{
  TextBody:
  [*
    mpsync := sourceObject_i.astype( MPSync );
    
    // Create all interface group
    group_all := LibSOPImpExp_DataSource::FindCreate( owner_i, Translations::LibSOPImpExp_DataSource_All_Interfaces(), Translations::LibSOPImpExp_DataSource_All_Interfaces() );
    
    // Create data source groups (based on import profile group)
    // Reason, we need hierarchical structure to display for web import/export dialog
    traverse( mpsync, DefaultImportProfile.ImportObjectGroupInDefaultProfile.ImportObjectGroup, iog, isIncludeGlobal_i or iog.IsGlobal() = isIncludeGlobal_i  )
    {
      // Ensure we call ImportObjectGroup methods to use translation text
      group := LibSOPImpExp_DataSource::FindCreate( owner_i, group_all, iog.GetDisplayCategory(), iog.GetDisplayCategory() );
      
      // Data source under the data group
      datasource := LibSOPImpExp_DataSource::FindCreate( owner_i, group, iog.GetDisplayName(), iog.GetDescription() );
      datasource.LibSOPImpExp_DataSourceFile( relflush );
      
      // Files associated with each ImportObjectGroup
      traverse( iog.GetMPFileNames(), Elements, filename )
      {
        brokerName := ImportObjectGroup::GetDirectImportBrokerByFile( mpsync, filename );
        mpsync_brokername := ImportObjectGroup::GetMPSyncImportBrokerByFile( mpsync, filename );
        LibSOPImpExp_DataSourceFile::Create( datasource, filename, brokerName, mpsync_brokername );
      }
    }
  *]
}