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
Quintiq file version 2.0
#parent: #root
Method RecoverFromRollback
{
  TextBody:
  [*
    algorithm := AlgorithmStore::TryRetrieve( LibOpt_Task::AlgorithmStore_Identifier( this ) );
    
    
    if( not isnull( algorithm )
      and algorithm.IsStringStored( LibOpt_Suboptimizer::RollbackStorage_HasRollback() )
      and algorithm.IsStringStored( LibOpt_Suboptimizer::RollbackStorage_Snapshot() ) )
    {
      json_string := algorithm.RetrieveString( LibOpt_Suboptimizer::RollbackStorage_Snapshot() );
      
      this.UpdateSnapshotComponent( JSON::Parse( json_string ) );
    }
    else if( this.Run().HasSnapshots() )
    {
      // Use the closest task with a snapshot component.
      task := this;
      while( not isnull( task.Parent() ) and isnull( task.SnapshotComponent() ) )
      {
        task := task.Parent();
      }
      LibOpt_SnapshotWarning::Throw( task, Translations::LibOpt_Task_RecoverFromRollbackFailure(), LibOpt_Issue::Severity_3_Medium() );
    }
    
    // Any LibOpt_DatasetCopyConditional objects that were deleted right before a rollback will be restored during the rollback.
    // We don't want these objects anymore, so we delete them again.
    LibOpt_DatasetCopyConditional::DeleteDatasetCopyConditionalWhenFlagged( this.Run().Optimization(), false );
  *]
}