Quintiq file version 2.0
#parent: #root
Method EnsureImportExportDataset (
  Boolean loadIfOffline_i,
  Boolean createIfNotExists_i
) as Boolean id:Method_LibCal_GlobalState_EnsureImportExportDataset
{
  #keys: '[131094.1.1070484139]'
  Body:
  [*
    // Make sure that an ImportExport-dataset exists for the currently selected planning-dataset.
    // (EnsureDataset modifies the name, if applicable)
    success := false;
    
    importExport := dhImportExport.Data();
    if( not isnull( importExport ) )
    {
      datasetName := importExport.GetDatasetName();
      datasetName := LibCal_ImportExportDataset::EnsureDataset( datasetName, loadIfOffline_i, createIfNotExists_i );
    
      // Select the ImportExport-datatset.
      this.SelectImportExportDatasetIfExists();
    
      if( isnull( LibCal_ImportExportDataset ) )
      {
        // Try again, that usually works...
        this.SelectImportExportDatasetIfExists();
    
        if( isnull( LibCal_ImportExportDataset ) and createIfNotExists_i )
        {
          LibCal_Util::Info( "LibCal_pnlImportButton.EnsureImportExportDataset() : dataset '" + datasetName + "' of datasetkind '" + LibCal_ImportExportDataset::DATASETKIND() + "' could not be selected." );
        }
      }
    
      success := not isnull( LibCal_ImportExportDataset );
    }
    
    return success;
  *]
}
