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
Quintiq file version 2.0
#parent: #root
Method SetDatasetMacroPlan
{
  Description: 'This method will search for the demo dataset and create a copy from there, this will be faster compare to create and synchronize new dataset'
  TextBody:
  [*
    if( this.GetDemoScenario() <> "" )
    {
      opt := DatasetFindOptions::Construct( GlobalParameters_MP::GetDatasetScenarioManager() );
      sm := MDSScenarioManager::Find( opt );
      scenariomp := null( ScenarioMP);
      sm -> ( scenariomanager )
      {
         scenariomp := select( scenariomanager, 
                               ScenarioMP, 
                               scenario, 
                               true, scenario.OptimizerStatus() <> "" and  scenario.Name() = this.GetDemoScenario() and scenario.Parent().Name() = this.GetDemoFolder() );
         
         if( isnull( scenariomp ) or scenariomp.OptimizerStatus() = Translations::MP_GlobalParameters_GetOptimizerRunningStatus() )
         {
           // Wait x seconds before triggering itself again( a newly created dataset might take some time to synchronize and execute optimizer)
           wait := stream[Void]::Wait( Duration::Seconds( 15 ) );
           this->After( wait )->SetDatasetMacroPlan();
         }
         else
         {
           keys := DatasetController::Find( DatasetFindOptions::Construct( this.GetUTFDatasetname() ) );
           if( keys.Size() = 0 )
           {
               // Copy new UTF dataset from existing demo dataset                                    
               MDSMacroPlan::Create( DatasetCreateOptions::Construct( this.GetUTFDatasetname() ).AsCopy( scenariomp.DatasetMDSID() )
                                                                                                .State( DatasetState::MemoryOnly() )
                                                                                                .Path( GlobalParameters_MP::GetDatasetFolder() ) )
               // For subclass to override. Execute logic post creation of UTF dataset in preparation to run test methods.
               ->| this->OnCreatedUTFDataset();
           }
         }
      }
    }
    else
    {
      // Create dataset for UTF that does not use demo dataset or import from test data path
      if( this.GetTestDataPath() = "" )
      {
        mp := MDSMacroPlan::Create( DatasetCreateOptions::Construct( this.GetUTFDatasetname() ).State( DatasetState::MemoryOnly() ) );
        mp-> ( macroplan )
        {
          this.SynchronizeAccount( macroplan );   
        }
      }
    }
  *]
  InterfaceProperties { Accessibility: 'Module' }
}