| 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' } | 
| } |