Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method SynchronizeLibSCIScenarioWithScenarioMP ( 
 | 
  Strings existingscenariosmpdatasetname, 
 | 
  Strings existingscenariompnames, 
 | 
  Strings assumptions 
 | 
) 
 | 
{ 
 | 
  Description: 
 | 
  [* 
 | 
    Synchronize LibSCIScenarios with ScenarioMP given in parameters. 
 | 
    It will Create or Update or Delete LibSCIScenarios 
 | 
    The goal is to get LibSCIScenario mathcing non IsDeleted Scenario_MP 
 | 
  *] 
 | 
  TextBody: 
 | 
  [* 
 | 
    existinglibsciscenarios := this.GetAllLibSCIScenarios(); 
 | 
    updates := construct( LibSCIScenarios ); 
 | 
     
 | 
    // Introduce index because traversing scenariodatasetname and need to match element index to scenarioname list 
 | 
    index := 0; 
 | 
     
 | 
    traverse( existingscenariosmpdatasetname, Elements, scenariompdataset ) 
 | 
    { 
 | 
      // Get ScenarioName 
 | 
      scenarioname := existingscenariompnames.Element( index ); 
 | 
      assumption := assumptions.Element( index ); 
 | 
      assumption := assumption.TrimBoth(); 
 | 
      // Find existing LibSCIScenario 
 | 
      objectinstance := LibSCIScenario::FindLibSCIScenarioTypeIndex( scenariompdataset );  
 | 
       
 | 
      // If no existing LibSCIScenario is found, create one 
 | 
      if( isnull( objectinstance ) ) 
 | 
      { 
 | 
         this.CreateScenario( scenarioname, scenariompdataset, assumption ); 
 | 
      } 
 | 
      else 
 | 
      { 
 | 
        objectinstance.Update( scenarioname, assumption ); 
 | 
        updates.Add( objectinstance ); 
 | 
      } 
 | 
      index := index + 1; 
 | 
    } 
 | 
     
 | 
    // Get the set of old LibSCIScenarios to be deleted 
 | 
    tobedeleted := existinglibsciscenarios.Difference( updates ); 
 | 
     
 | 
    // Traverse the set of LibSCIScenarios to be deleted 
 | 
    traverse( tobedeleted, Elements, ele ) 
 | 
    { 
 | 
      ele.Delete(); 
 | 
    } 
 | 
  *] 
 | 
} 
 |