Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Modeling.Database.SQLServerCompact/3.2/DataObjects/Model.cs @ 2229

Last change on this file since 2229 was 2229, checked in by mkommend, 15 years ago

added license information (ticket #712)

File size: 5.3 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.Linq;
25using System.Data.Linq;
26using System.Data.Linq.Mapping;
27using System.Text;
28
29namespace HeuristicLab.Modeling.Database.SQLServerCompact {
30  [Table(Name = "Model")]
31  public class Model : IModel {
32    public Model() {
33      targetVariable = default(EntityRef<Variable>);
34      algorithm = default(EntityRef<Algorithm>);
35    }
36
37    public Model(Variable targetVariable, Algorithm algorithm)
38      : this() {
39      this.targetVariableId = targetVariable.Id;
40      this.algorithmId = algorithm.Id;
41    }
42
43    private int id;
44    [Column(Storage = "id", IsPrimaryKey = true, IsDbGenerated = true)]
45    public int Id {
46      get { return this.id; }
47      private set { this.id = value; }
48    }
49
50    private int algorithmId;
51    [Column(Storage = "algorithmId", CanBeNull = false)]
52    public int AlgorithmId {
53      get { return this.algorithmId; }
54      private set {
55        if (algorithmId != value) {
56          if (algorithm.HasLoadedOrAssignedValue)
57            throw new ForeignKeyReferenceAlreadyHasValueException();
58          algorithmId = value;
59        }
60      }
61    }
62
63    private EntityRef<Algorithm> algorithm;
64    [Association(Storage = "algorithm", ThisKey = "AlgorithmId", OtherKey = "Id", IsForeignKey = true)]
65    public Algorithm Algorithm {
66      get { return this.algorithm.Entity; }
67      //private set {
68      //  Algorithm previousValue = algorithm.Entity;
69      //  if (previousValue != value || (!algorithm.HasLoadedOrAssignedValue)) {
70      //    if (previousValue != null) {
71      //      algorithm.Entity = null;
72      //    }
73      //    algorithm.Entity = value;
74      //    if (value != null) {
75      //      algorithmId = value.Id;
76      //    }
77      //  }
78      //}
79    }
80
81    IAlgorithm IModel.Algorithm {
82      get { return this.Algorithm; }
83    }
84
85    private int targetVariableId;
86    [Column(Storage = "targetVariableId", CanBeNull = false)]
87    public int TargetVariableId {
88      get { return this.targetVariableId; }
89      private set {
90        if (targetVariableId != value) {
91          if (targetVariable.HasLoadedOrAssignedValue)
92            throw new ForeignKeyReferenceAlreadyHasValueException();
93          targetVariableId = value;
94        }
95      }
96    }
97
98    private EntityRef<Variable> targetVariable;
99    [Association(Storage = "targetVariable", ThisKey = "TargetVariableId", OtherKey = "Id", IsForeignKey = true)]
100    public Variable TargetVariable {
101      get { return this.targetVariable.Entity; }
102      //private set {
103      //  Variable previousValue = targetVariable.Entity;
104      //  if (previousValue != value || (!targetVariable.HasLoadedOrAssignedValue)) {
105      //    if (previousValue != null) {
106      //      targetVariable.Entity = null;
107      //    }
108      //    targetVariable.Entity = value;
109      //    if (value != null) {
110      //      targetVariableId = value.Id;
111      //    }
112      //  }
113      //}
114    }
115
116    IVariable IModel.TargetVariable {
117      get { return this.TargetVariable; }
118    }
119
120    private int trainingSamplesStart;
121    [Column(Storage = "trainingSamplesStart", CanBeNull = false)]
122    public int TrainingSamplesStart {
123      get { return this.trainingSamplesStart; }
124      set { this.trainingSamplesStart = value; }
125    }
126
127    private int trainingSamplesEnd;
128    [Column(Storage = "trainingSamplesEnd", CanBeNull = false)]
129    public int TrainingSamplesEnd {
130      get { return this.trainingSamplesEnd; }
131      set { this.trainingSamplesEnd = value; }
132    }
133
134    private int validationSamplesStart;
135    [Column(Storage = "validationSamplesStart", CanBeNull = false)]
136    public int ValidationSamplesStart {
137      get { return this.validationSamplesStart; }
138      set { this.validationSamplesStart = value; }
139    }
140
141    private int validationSamplesEnd;
142    [Column(Storage = "validationSamplesEnd", CanBeNull = false)]
143    public int ValidationSamplesEnd {
144      get { return this.validationSamplesEnd; }
145      set { this.validationSamplesEnd = value; }
146    }
147
148    private int testSamplesStart;
149    [Column(Storage = "testSamplesStart", CanBeNull = false)]
150    public int TestSamplesStart {
151      get { return this.testSamplesStart; }
152      set { this.testSamplesStart = value; }
153    }
154
155    private int testSamplesEnd;
156    [Column(Storage = "testSamplesEnd", CanBeNull = false)]
157    public int TestSamplesEnd {
158      get { return this.testSamplesEnd; }
159      set { this.testSamplesEnd = value; }
160    }
161  }
162}
Note: See TracBrowser for help on using the repository browser.