#region License Information /* HeuristicLab * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using HeuristicLab.DataImporter.Data.CommandBase; using HeuristicLab.DataImporter.Data.Model; using HeuristicLab.DataImporter.DbExplorer.Interfaces; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.DataImporter.DataProcessor.Command { [StorableClass] public class LoadColumnGroupWithSqlStringFromDBCommand : DatabaseCommandBase { [Storable] private string sqlString; private ColumnGroup newColumnGroup; [StorableConstructor] protected LoadColumnGroupWithSqlStringFromDBCommand(bool deserializing) : base(deserializing) { } public LoadColumnGroupWithSqlStringFromDBCommand(DataSet dataSet, IDbExplorer dbExplorer, string sqlString) : base(dataSet, dbExplorer) { this.sqlString = sqlString; } public override string Description { get { return "Load ColumnGroups from database"; } } public override void Execute() { base.Execute(); if (DbExplorer == null || !DbExplorer.IsConnected) throw new CommandExecutionException("Could not load data because no connection to the database exists", this); newColumnGroup = DbExplorer.CreateColumnGroup(sqlString); newColumnGroup.Name = "New ColumnGroup from SQL string"; this.DataSet.AddColumnGroup(newColumnGroup); this.DataSet.FireChanged(); } public override void UndoExecute() { base.UndoExecute(); this.DataSet.RemoveColumnGroup(newColumnGroup); newColumnGroup = null; this.DataSet.FireChanged(); } } }