1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2013 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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
26 | using HEAL.Attic;
|
---|
27 |
|
---|
28 | namespace HeuristicLab.DataImporter.DbExplorer.Interfaces {
|
---|
29 | [StorableType("A0613D0D-C6C6-4958-9F26-8810E84EAD27")]
|
---|
30 | public class DbTable {
|
---|
31 | [StorableConstructor]
|
---|
32 | protected DbTable(bool deserializing)
|
---|
33 | : base() {
|
---|
34 | this.informationLoaded = new DateTime(1990, 1, 1);
|
---|
35 | }
|
---|
36 |
|
---|
37 | public DbTable(string ownerName, string tableName)
|
---|
38 | : base() {
|
---|
39 | this.informationLoaded = new DateTime(1990, 1, 1);
|
---|
40 | this.columns = new List<DbColumn>();
|
---|
41 | this.ownerName = ownerName;
|
---|
42 | this.tableName = tableName;
|
---|
43 | }
|
---|
44 |
|
---|
45 | [Storable]
|
---|
46 | private string ownerName;
|
---|
47 | public string OwnerName {
|
---|
48 | get { return this.ownerName; }
|
---|
49 | set { this.ownerName = value; }
|
---|
50 | }
|
---|
51 |
|
---|
52 | [Storable]
|
---|
53 | private string tableName;
|
---|
54 | public string TableName {
|
---|
55 | get { return this.tableName; }
|
---|
56 | set { this.tableName = value; }
|
---|
57 | }
|
---|
58 |
|
---|
59 | [Storable]
|
---|
60 | private List<DbColumn> columns;
|
---|
61 | public IEnumerable<DbColumn> Columns {
|
---|
62 | get { return this.columns; }
|
---|
63 | }
|
---|
64 |
|
---|
65 | public bool IsSelected {
|
---|
66 | get { return columns.Any(col => col.Selected); }
|
---|
67 | }
|
---|
68 |
|
---|
69 | private int affectedRows;
|
---|
70 | public int AffectedRows {
|
---|
71 | get { return this.affectedRows; }
|
---|
72 | set { this.affectedRows = value; }
|
---|
73 | }
|
---|
74 |
|
---|
75 | private int totalRows;
|
---|
76 | public int TotalRows {
|
---|
77 | get { return this.totalRows; }
|
---|
78 | set { this.totalRows = value; }
|
---|
79 | }
|
---|
80 |
|
---|
81 | private DateTime informationLoaded;
|
---|
82 | public DateTime InformationLoaded {
|
---|
83 | get { return this.informationLoaded; }
|
---|
84 | }
|
---|
85 |
|
---|
86 | public void AddColumn(DbColumn column) {
|
---|
87 | this.columns.Add(column);
|
---|
88 | }
|
---|
89 |
|
---|
90 | public void ClearSelection() {
|
---|
91 | foreach (DbColumn col in columns) {
|
---|
92 | col.Selected = false;
|
---|
93 | col.FilterColumn = false;
|
---|
94 | col.LikeValue = "";
|
---|
95 | }
|
---|
96 | }
|
---|
97 |
|
---|
98 | public void SelectAllColumns() {
|
---|
99 | foreach (DbColumn col in this.columns)
|
---|
100 | col.Selected = true;
|
---|
101 | }
|
---|
102 |
|
---|
103 | public int SelectedColumnsCount {
|
---|
104 | get { return this.columns.Count(col => col.Selected); }
|
---|
105 | }
|
---|
106 |
|
---|
107 | public IEnumerable<DbColumn> SelectedColumns {
|
---|
108 | get { return this.columns.Where(col => col.Selected); }
|
---|
109 | }
|
---|
110 |
|
---|
111 | public IEnumerable<DbColumn> FilterColumns {
|
---|
112 | get { return this.columns.Where(col => col.FilterColumn); }
|
---|
113 | }
|
---|
114 |
|
---|
115 | public void UpdateInformationLoaded() {
|
---|
116 | this.informationLoaded = DateTime.Now;
|
---|
117 | }
|
---|
118 |
|
---|
119 | public bool ReloadOfInformationNeeded {
|
---|
120 | get { return DateTime.Now.Subtract(this.InformationLoaded).Minutes > 5; }
|
---|
121 | }
|
---|
122 |
|
---|
123 | public override string ToString() {
|
---|
124 | string s = this.tableName + " " + SelectedColumnsCount + "/" + this.columns.Count;
|
---|
125 | return s;
|
---|
126 | }
|
---|
127 | }
|
---|
128 | }
|
---|