Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Communication.Data/OdbcDatabaseDriverConfiguration.cs @ 618

Last change on this file since 618 was 591, checked in by abeham, 16 years ago

Put the GPL license in the files from the communication framework and simulation optimization project

File size: 7.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Text;
25using System.Data;
26using System.Xml;
27using HeuristicLab.Core;
28using HeuristicLab.Data;
29
30namespace HeuristicLab.Communication.Data {
31  public class OdbcDatabaseDriverConfiguration : ItemBase, IDriverConfiguration {
32    private StringData odbcDriver;
33    public StringData OdbcDriver {
34      get { return odbcDriver; }
35      set {
36        odbcDriver = value;
37        OnChanged();
38      }
39    }
40    private StringData ipAddress;
41    public StringData IPAddress {
42      get { return ipAddress; }
43      set {
44        ipAddress = value;
45        OnChanged();
46      }
47    }
48    private IntData port;
49    public IntData Port {
50      get { return port; }
51      set {
52        port = value;
53        OnChanged();
54      }
55    }
56    private StringData dbName;
57    public StringData DBName {
58      get { return dbName; }
59      set {
60        dbName = value;
61        OnChanged();
62      }
63    }
64    private StringData dbUser;
65    public StringData DBUser {
66      get { return dbUser; }
67      set {
68        dbUser = value;
69        OnChanged();
70      }
71    }
72    private StringData dbPassword;
73    public StringData DBPassword {
74      get { return dbPassword; }
75      set {
76        dbPassword = value;
77        OnChanged();
78      }
79    }
80    private StringData dbTable;
81    public StringData DBTable {
82      get { return dbTable; }
83      set {
84        dbTable = value;
85        OnChanged();
86      }
87    }
88    private StringData dbIDcolumnName;
89    public StringData DBIDColumnName {
90      get { return dbIDcolumnName; }
91      set {
92        dbIDcolumnName = value;
93        OnChanged();
94      }
95    }
96    private StringData dbCommunicationColumnName;
97    public StringData DBCommunciationColumnName {
98      get { return dbCommunicationColumnName; }
99      set {
100        dbCommunicationColumnName = value;
101        OnChanged();
102      }
103    }
104    private StringData dbSynchronizationColumnName;
105    public StringData DBSynchronizationColumnName {
106      get { return dbSynchronizationColumnName; }
107      set {
108        dbSynchronizationColumnName = value;
109        OnChanged();
110      }
111    }
112   
113    public OdbcDatabaseDriverConfiguration() {
114      odbcDriver = new StringData("");
115      ipAddress = new StringData("127.0.0.1");
116      port = new IntData(0);
117      dbName = new StringData("");
118      dbUser = new StringData("");
119      dbPassword = new StringData("");
120      dbTable = new StringData("");
121      dbIDcolumnName = new StringData("");
122      dbCommunicationColumnName = new StringData("");
123      dbSynchronizationColumnName = new StringData("");
124    }
125
126    public override IView CreateView() {
127      return new OdbcDatabaseDriverConfigurationView(this);
128    }
129
130    #region persistence & clone
131    public override XmlNode GetXmlNode(string name, XmlDocument document, IDictionary<Guid, IStorable> persistedObjects) {
132      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
133      XmlNode driverNode = PersistenceManager.Persist("Driver", OdbcDriver, document, persistedObjects);
134      node.AppendChild(driverNode);
135      XmlNode ipNode = PersistenceManager.Persist("IP", IPAddress, document, persistedObjects);
136      node.AppendChild(ipNode);
137      XmlNode portNode = PersistenceManager.Persist("Port", Port, document, persistedObjects);
138      node.AppendChild(portNode);
139      XmlNode nameNode = PersistenceManager.Persist("DBName", DBName, document, persistedObjects);
140      node.AppendChild(nameNode);
141      XmlNode userNode = PersistenceManager.Persist("DBUser", DBUser, document, persistedObjects);
142      node.AppendChild(userNode);
143      XmlNode pwdNode = PersistenceManager.Persist("DBPassword", DBPassword, document, persistedObjects);
144      node.AppendChild(pwdNode);
145      XmlNode tableNode = PersistenceManager.Persist("DBTable", DBTable, document, persistedObjects);
146      node.AppendChild(tableNode);
147      XmlNode idNode = PersistenceManager.Persist("DBIDColumnName", DBIDColumnName, document, persistedObjects);
148      node.AppendChild(idNode);
149      XmlNode commNode = PersistenceManager.Persist("DBCommunicationColumnName", DBCommunciationColumnName, document, persistedObjects);
150      node.AppendChild(commNode);
151      XmlNode syncNode = PersistenceManager.Persist("DBSynchronizationColumnName", DBSynchronizationColumnName, document, persistedObjects);
152      node.AppendChild(syncNode);
153      return node;
154    }
155
156    public override void Populate(XmlNode node, IDictionary<Guid, IStorable> restoredObjects) {
157      base.Populate(node, restoredObjects);
158      odbcDriver = (StringData)PersistenceManager.Restore(node.SelectSingleNode("Driver"), restoredObjects);
159      ipAddress = (StringData)PersistenceManager.Restore(node.SelectSingleNode("IP"), restoredObjects);
160      port = (IntData)PersistenceManager.Restore(node.SelectSingleNode("Port"), restoredObjects);
161      dbName = (StringData)PersistenceManager.Restore(node.SelectSingleNode("DBName"), restoredObjects);
162      dbUser = (StringData)PersistenceManager.Restore(node.SelectSingleNode("DBUser"), restoredObjects);
163      dbPassword = (StringData)PersistenceManager.Restore(node.SelectSingleNode("DBPassword"), restoredObjects);
164      dbTable = (StringData)PersistenceManager.Restore(node.SelectSingleNode("DBTable"), restoredObjects);
165      dbIDcolumnName = (StringData)PersistenceManager.Restore(node.SelectSingleNode("DBIDColumnName"), restoredObjects);
166      dbCommunicationColumnName = (StringData)PersistenceManager.Restore(node.SelectSingleNode("DBCommunicationColumnName"), restoredObjects);
167      dbSynchronizationColumnName = (StringData)PersistenceManager.Restore(node.SelectSingleNode("DBSynchronizationColumnName"), restoredObjects);
168    }
169
170    public override object Clone(IDictionary<Guid, object> clonedObjects) {
171      OdbcDatabaseDriverConfiguration clone = new OdbcDatabaseDriverConfiguration();
172      clonedObjects.Add(Guid, clone);
173      clone.odbcDriver = (StringData)Auxiliary.Clone(odbcDriver, clonedObjects);
174      clone.ipAddress = (StringData)Auxiliary.Clone(ipAddress, clonedObjects);
175      clone.port = (IntData)Auxiliary.Clone(port, clonedObjects);
176      clone.dbName = (StringData)Auxiliary.Clone(dbName, clonedObjects);
177      clone.dbUser = (StringData)Auxiliary.Clone(dbUser, clonedObjects);
178      clone.dbPassword = (StringData)Auxiliary.Clone(dbPassword, clonedObjects);
179      clone.dbTable = (StringData)Auxiliary.Clone(dbTable, clonedObjects);
180      clone.dbIDcolumnName = (StringData)Auxiliary.Clone(dbIDcolumnName, clonedObjects);
181      clone.dbCommunicationColumnName = (StringData)Auxiliary.Clone(dbCommunicationColumnName, clonedObjects);
182      clone.dbSynchronizationColumnName = (StringData)Auxiliary.Clone(dbSynchronizationColumnName, clonedObjects);
183      return clone;
184    }
185    #endregion
186  }
187}
Note: See TracBrowser for help on using the repository browser.