Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.Modeling.SQLServerCompactBackend/3.2/DataObjects/Model.cs @ 2190

Last change on this file since 2190 was 2190, checked in by gkronber, 15 years ago

Refactored CEDMA plugins to work with new modeling backend. #712

File size: 4.5 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Data.Linq;
5using System.Data.Linq.Mapping;
6using System.Text;
7
8namespace HeuristicLab.Modeling.SQLServerCompactBackend {
9  [Table(Name = "Model")]
10  public class Model : IModel{
11    public Model() {
12      targetVariable = default(EntityRef<Variable>);
13      algorithm = default(EntityRef<Algorithm>);
14    }
15
16    public Model(Variable targetVariable, Algorithm algorithm, byte[] model)
17      : this() {
18      this.TargetVariable = targetVariable;
19      this.Algorithm = algorithm;
20      this.modelData = model;
21    }
22
23    private int id;
24    [Column(Storage = "id", IsPrimaryKey = true, IsDbGenerated = true)]
25    public int Id {
26      get { return this.id; }
27      private set { this.id = value; }
28    }
29
30    private byte[] modelData;
31    [Column(Storage = "model", DbType = "image", CanBeNull = false)]
32    public byte[] ModelData {
33      get { return this.modelData; }
34      set { this.modelData = value; }
35    }
36
37    private int algorithmId;
38    [Column(Storage = "algorithmId", CanBeNull = false)]
39    public int AlgorithmId {
40      get { return this.algorithmId; }
41      private set {
42        if (algorithmId != value) {
43          if (algorithm.HasLoadedOrAssignedValue)
44            throw new ForeignKeyReferenceAlreadyHasValueException();
45          algorithmId = value;
46        }
47      }
48    }
49
50    private EntityRef<Algorithm> algorithm;
51    [Association(Storage = "algorithm", ThisKey = "AlgorithmId", OtherKey = "Id", IsForeignKey = true)]
52    public Algorithm Algorithm {
53      get { return this.algorithm.Entity; }
54      set {
55        Algorithm previousValue = algorithm.Entity;
56        if (previousValue != value || (!algorithm.HasLoadedOrAssignedValue)) {
57          if (previousValue != null) {
58            algorithm.Entity = null;
59          }
60          algorithm.Entity = value;
61          if (value != null) {
62            algorithmId = value.Id;
63          }
64        }
65      }
66    }
67
68    private int targetVariableId;
69    [Column(Storage = "targetVariableId", CanBeNull = false)]
70    public int TargetVariableId {
71      get { return this.targetVariableId; }
72      private set {
73        if (targetVariableId != value) {
74          if (targetVariable.HasLoadedOrAssignedValue)
75            throw new ForeignKeyReferenceAlreadyHasValueException();
76          targetVariableId = value;
77        }
78      }
79    }
80
81    private EntityRef<Variable> targetVariable;
82    [Association(Storage = "targetVariable", ThisKey = "TargetVariableId", OtherKey = "Id", IsForeignKey = true)]
83    public Variable TargetVariable {
84      get { return this.targetVariable.Entity; }
85      set {
86        Variable previousValue = targetVariable.Entity;
87        if (previousValue != value || (!targetVariable.HasLoadedOrAssignedValue)) {
88          if (previousValue != null) {
89            targetVariable.Entity = null;
90          }
91          targetVariable.Entity = value;
92          if (value != null) {
93            targetVariableId = value.Id;
94          }
95        }
96      }
97    }
98
99    private int trainingSamplesStart;
100    [Column(Storage = "trainingSamplesStart", CanBeNull = false)]
101    public int TrainingSamplesStart {
102      get { return this.trainingSamplesStart; }
103      set { this.trainingSamplesStart = value; }
104    }
105
106    private int trainingSamplesEnd;
107    [Column(Storage = "trainingSamplesEnd", CanBeNull = false)]
108    public int TrainingSamplesEnd {
109      get { return this.trainingSamplesEnd; }
110      set { this.trainingSamplesEnd = value; }
111    }
112
113    private int validationSamplesStart;
114    [Column(Storage = "validationSamplesStart", CanBeNull = false)]
115    public int ValidationSamplesStart {
116      get { return this.validationSamplesStart; }
117      set { this.validationSamplesStart = value; }
118    }
119
120    private int validationSamplesEnd;
121    [Column(Storage = "validationSamplesEnd", CanBeNull = false)]
122    public int ValidationSamplesEnd {
123      get { return this.validationSamplesEnd; }
124      set { this.validationSamplesEnd = value; }
125    }
126
127    private int testSamplesStart;
128    [Column(Storage = "testSamplesStart", CanBeNull = false)]
129    public int TestSamplesStart {
130      get { return this.testSamplesStart; }
131      set { this.testSamplesStart = value; }
132    }
133
134    private int testSamplesEnd;
135    [Column(Storage = "testSamplesEnd", CanBeNull = false)]
136    public int TestSamplesEnd {
137      get { return this.testSamplesEnd; }
138      set { this.testSamplesEnd = value; }
139    }
140  }
141}
Note: See TracBrowser for help on using the repository browser.