1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2010 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.Collections.Generic;
|
---|
23 | using System.Runtime.Serialization;
|
---|
24 | using HeuristicLab.Services.OKB.AttributeSelection;
|
---|
25 | using HeuristicLab.Services.OKB.DataAccess;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.Services.OKB {
|
---|
28 |
|
---|
29 | /// <summary>
|
---|
30 | /// Data capsule for describing data base fields and
|
---|
31 | /// restrictions. This is the basis for building complex queries.
|
---|
32 | /// </summary>
|
---|
33 | [DataContract]
|
---|
34 | public class AttributeSelector : IAttributeSelector {
|
---|
35 |
|
---|
36 | /// <summary>
|
---|
37 | /// Gets or sets the name of the table.
|
---|
38 | /// </summary>
|
---|
39 | /// <value>The name of the table.</value>
|
---|
40 | [DataMember]
|
---|
41 | public string TableName { get; set; }
|
---|
42 |
|
---|
43 | /// <summary>
|
---|
44 | /// Gets or sets the name of the field.
|
---|
45 | /// </summary>
|
---|
46 | /// <value>The name of the field.</value>
|
---|
47 | [DataMember]
|
---|
48 | public string FieldName { get; set; }
|
---|
49 |
|
---|
50 | /// <summary>
|
---|
51 | /// Gets or sets a value indicating whether this instance is hidden.
|
---|
52 | /// </summary>
|
---|
53 | /// <value><c>true</c> if this instance is hidden; otherwise, <c>false</c>.</value>
|
---|
54 | [DataMember]
|
---|
55 | public bool IsHidden { get; set; }
|
---|
56 |
|
---|
57 | /// <summary>
|
---|
58 | /// Gets or sets the min value.
|
---|
59 | /// </summary>
|
---|
60 | /// <value>The min value.</value>
|
---|
61 | [DataMember]
|
---|
62 | public object MinValue { get; set; }
|
---|
63 |
|
---|
64 | /// <summary>
|
---|
65 | /// Gets or sets the max value.
|
---|
66 | /// </summary>
|
---|
67 | /// <value>The max value.</value>
|
---|
68 | [DataMember]
|
---|
69 | public object MaxValue { get; set; }
|
---|
70 |
|
---|
71 | /// <summary>
|
---|
72 | /// Gets or sets the allowed values.
|
---|
73 | /// </summary>
|
---|
74 | /// <value>The allowed values.</value>
|
---|
75 | [DataMember]
|
---|
76 | public ICollection<object> AllowedValues { get; set; }
|
---|
77 |
|
---|
78 | /// <summary>
|
---|
79 | /// Gets or sets the name of the data type.
|
---|
80 | /// </summary>
|
---|
81 | /// <value>The name of the data type.</value>
|
---|
82 | [DataMember]
|
---|
83 | public string DataTypeName { get; set; }
|
---|
84 |
|
---|
85 | /// <summary>
|
---|
86 | /// Gets an actual implementations linked to the database.
|
---|
87 | /// </summary>
|
---|
88 | /// <param name="okb">The okb data context.</param>
|
---|
89 | /// <returns>A <see cref="RunAttributeSelector"/></returns>
|
---|
90 | public RunAttributeSelector GetImpl(OKBDataContext okb) {
|
---|
91 | return new RunAttributeSelector(okb, TableName, FieldName) {
|
---|
92 | IsHidden = IsHidden,
|
---|
93 | MinValue = MinValue,
|
---|
94 | MaxValue = MaxValue,
|
---|
95 | AllowedValues = AllowedValues,
|
---|
96 | };
|
---|
97 | }
|
---|
98 |
|
---|
99 | /// <summary>
|
---|
100 | /// Initializes a new instance of the <see cref="AttributeSelector"/> class.
|
---|
101 | /// </summary>
|
---|
102 | public AttributeSelector() { }
|
---|
103 |
|
---|
104 | /// <summary>
|
---|
105 | /// Initializes a new instance of the <see cref="AttributeSelector"/> class.
|
---|
106 | /// </summary>
|
---|
107 | /// <param name="selector">The selector.</param>
|
---|
108 | public AttributeSelector(RunAttributeSelector selector) {
|
---|
109 | TableName = selector.TableName;
|
---|
110 | FieldName = selector.FieldName;
|
---|
111 | IsHidden = selector.IsHidden;
|
---|
112 | MinValue = selector.MinValue;
|
---|
113 | MaxValue = selector.MaxValue;
|
---|
114 | AllowedValues = selector.AllowedValues;
|
---|
115 | DataTypeName = selector.DataType.FullName;
|
---|
116 | }
|
---|
117 | }
|
---|
118 | }
|
---|