Changeset 13501 for trunk/sources
- Timestamp:
- 01/12/16 16:08:38 (9 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 11 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.OKB.DataAccess/3.3/CharacteristicType.cs
r13484 r13501 21 21 22 22 namespace HeuristicLab.Services.OKB.DataAccess { 23 public enum ValueNameType {23 public enum CharacteristicType { 24 24 Bool = 0, 25 25 Int = 1, … … 28 28 Double = 4, 29 29 String = 5, 30 Binary = 6, 31 Percent = 7, 32 TimeSpan = 8 30 Percent = 6, 31 TimeSpan = 7 33 32 } 34 33 } -
trunk/sources/HeuristicLab.Services.OKB.DataAccess/3.3/HeuristicLab.Services.OKB.DataAccess-3.3.csproj
r11623 r13501 128 128 </ItemGroup> 129 129 <ItemGroup> 130 <Compile Include="CharacteristicType.cs" /> 130 131 <Compile Include="ValueNameType.cs" /> 131 132 <Compile Include="ValueNameCategory.cs" /> -
trunk/sources/HeuristicLab.Services.OKB.DataAccess/3.3/OKB.dbml
r8049 r13501 141 141 <Column Name="Id" Type="System.Int64" DbType="BigInt NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> 142 142 <Column Name="Name" Type="System.String" DbType="NVarChar(200) NOT NULL" CanBeNull="false" /> 143 <Column Name="Type" Type=" System.Byte" DbType="TinyInt NOT NULL" CanBeNull="false" />143 <Column Name="Type" Type="CharacteristicType" DbType="TinyInt NOT NULL" CanBeNull="false" /> 144 144 <Association Name="Characteristic_CharacteristicValue" Member="CharacteristicValues" ThisKey="Id" OtherKey="CharacteristicId" Type="CharacteristicValue" /> 145 145 </Type> -
trunk/sources/HeuristicLab.Services.OKB.DataAccess/3.3/OKB.dbml.layout
r8049 r13501 139 139 </nestedChildShapes> 140 140 </classShape> 141 <associationConnector edgePoints="[(3.24167093356531 : 2.65549967447917); (3.24167093356531 : 8.23159912109375); (5.75 : 8.23159912109375)]" fixedFrom=" Algorithm" fixedTo="Algorithm">141 <associationConnector edgePoints="[(3.24167093356531 : 2.65549967447917); (3.24167093356531 : 8.23159912109375); (5.75 : 8.23159912109375)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 142 142 <AssociationMoniker Name="/OKBDataContext/Algorithm/Algorithm_Run" /> 143 143 <nodes> … … 146 146 </nodes> 147 147 </associationConnector> 148 <associationConnector edgePoints="[(12.7565713753709 : 2.65549967447917); (12.7565713753709 : 8.23159912109375); (8.13243692318721 : 8.23159912109375 : JumpStart); (7.96577025652055 : 8.23159912109375 : JumpEnd); (7.75 : 8.23159912109375)]" fixedFrom=" Algorithm" fixedTo="Algorithm">148 <associationConnector edgePoints="[(12.7565713753709 : 2.65549967447917); (12.7565713753709 : 8.23159912109375); (8.13243692318721 : 8.23159912109375 : JumpStart); (7.96577025652055 : 8.23159912109375 : JumpEnd); (7.75 : 8.23159912109375)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 149 149 <AssociationMoniker Name="/OKBDataContext/Problem/Problem_Run" /> 150 150 <nodes> -
trunk/sources/HeuristicLab.Services.OKB.DataAccess/3.3/OKB.designer.cs
r11623 r13501 3 3 // <auto-generated> 4 4 // This code was generated by a tool. 5 // Runtime Version:4.0.30319.34 0145 // Runtime Version:4.0.30319.34209 6 6 // 7 7 // Changes to this file may cause incorrect behavior and will be lost if … … 3140 3140 private string _Name; 3141 3141 3142 private byte _Type;3142 private CharacteristicType _Type; 3143 3143 3144 3144 private EntitySet<CharacteristicValue> _CharacteristicValues; … … 3152 3152 partial void OnNameChanging(string value); 3153 3153 partial void OnNameChanged(); 3154 partial void OnTypeChanging( byte value);3154 partial void OnTypeChanging(CharacteristicType value); 3155 3155 partial void OnTypeChanged(); 3156 3156 #endregion … … 3202 3202 } 3203 3203 3204 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Type", DbType="TinyInt NOT NULL" )]3205 public byte Type3204 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Type", DbType="TinyInt NOT NULL", CanBeNull=false)] 3205 public CharacteristicType Type 3206 3206 { 3207 3207 get -
trunk/sources/HeuristicLab.Services.OKB/3.3/HeuristicLab.Services.OKB-3.3.csproj
r12479 r13501 295 295 <Compile Include="RunCreation\DataTransfer\StringValue.cs" /> 296 296 <Compile Include="RunCreation\DataTransfer\Value.cs" /> 297 <Compile Include="RunCreation\MissingProblem.cs" /> 297 298 <Compile Include="RunCreation\RunCreationService.cs" /> 298 299 <Compile Include="RunCreation\IRunCreationService.cs" /> 300 <Compile Include="RunCreation\UnknownCharacteristicType.cs" /> 299 301 </ItemGroup> 300 302 <ItemGroup> -
trunk/sources/HeuristicLab.Services.OKB/3.3/Query/Convert.cs
r13473 r13501 88 88 return new DT.ValueName() { Id = source.Id, Category = source.Category, Name = source.Name }; 89 89 } 90 91 public static DT.Value ToDto(DA.CharacteristicValue source) { 92 if (source == null) return null; 93 if (source.Characteristic.Type == DA.CharacteristicType.Bool) { 94 return new DT.BoolValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.BoolValue.GetValueOrDefault() }; 95 } else if (source.Characteristic.Type == DA.CharacteristicType.Int) { 96 return new DT.IntValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.IntValue.GetValueOrDefault() }; 97 } else if (source.Characteristic.Type == DA.CharacteristicType.TimeSpan) { 98 return new DT.TimeSpanValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.LongValue.GetValueOrDefault() }; 99 } else if (source.Characteristic.Type == DA.CharacteristicType.Long) { 100 return new DT.LongValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.LongValue.GetValueOrDefault() }; 101 } else if (source.Characteristic.Type == DA.CharacteristicType.Float) { 102 return new DT.FloatValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.FloatValue.GetValueOrDefault() }; 103 } else if (source.Characteristic.Type == DA.CharacteristicType.Double) { 104 return new DT.DoubleValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.DoubleValue.GetValueOrDefault() }; 105 } else if (source.Characteristic.Type == DA.CharacteristicType.Percent) { 106 return new DT.PercentValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.DoubleValue.GetValueOrDefault() }; 107 } else if (source.Characteristic.Type == DA.CharacteristicType.String) { 108 return new DT.StringValue { Name = source.Characteristic.Name, DataType = Convert.ToDto(source.DataType), Value = source.StringValue }; 109 } else { 110 throw new ArgumentException("Unknown characteristic type.", "source"); 111 } 112 } 90 113 } 91 114 } -
trunk/sources/HeuristicLab.Services.OKB/3.3/Query/IQueryService.cs
r12012 r13501 48 48 [OperationContract] 49 49 IEnumerable<ValueName> GetValueNames(); 50 51 [OperationContract] 52 IEnumerable<Value> GetCharacteristics(long problemId); 50 53 } 51 54 } -
trunk/sources/HeuristicLab.Services.OKB/3.3/Query/QueryService.cs
r12012 r13501 278 278 } 279 279 280 281 public IEnumerable<DataTransfer.Value> GetCharacteristics(long problemId) { 282 using (OKBDataContext okb = new OKBDataContext()) { 283 var prob = okb.Problems.SingleOrDefault(x => x.Id == problemId); 284 if (prob == null) return Enumerable.Empty<DataTransfer.Value>(); 285 return prob.CharacteristicValues.Select(Convert.ToDto).ToArray(); 286 } 287 } 288 280 289 private List<DataAccess.Run> FilterRuns(IQueryable<DataAccess.Run> runs, Filter filter, OKBDataContext okb) { 281 290 IFilter f = (IFilter)Activator.CreateInstance(Type.GetType(filter.FilterTypeName), filter); -
trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation/Convert.cs
r12012 r13501 68 68 entity.Values.Add(Convert.ToEntity(value, entity, DA.ValueNameCategory.Result, okb, binCache)); 69 69 return entity; 70 } 71 72 public static DA.CharacteristicValue ToEntity(DT.Value source, DA.OKBDataContext okb, DA.Problem problem, string characteristicName, DA.CharacteristicType type) { 73 if (okb == null || problem == null || string.IsNullOrEmpty(characteristicName) || source == null) throw new ArgumentNullException(); 74 var entity = new DA.CharacteristicValue(); 75 entity.Problem = problem; 76 entity.DataType = Convert.ToEntity(source.DataType, okb); 77 entity.Characteristic = Convert.ToEntity(characteristicName, type, okb); 78 if (source is DT.BoolValue) { 79 entity.BoolValue = ((DT.BoolValue)source).Value; 80 } else if (source is DT.IntValue) { 81 entity.IntValue = ((DT.IntValue)source).Value; 82 } else if (source is DT.TimeSpanValue) { 83 entity.LongValue = ((DT.TimeSpanValue)source).Value; 84 } else if (source is DT.LongValue) { 85 entity.LongValue = ((DT.LongValue)source).Value; 86 } else if (source is DT.FloatValue) { 87 entity.FloatValue = ((DT.FloatValue)source).Value; 88 } else if (source is DT.DoubleValue) { 89 entity.DoubleValue = ((DT.DoubleValue)source).Value; 90 } else if (source is DT.PercentValue) { 91 entity.DoubleValue = ((DT.PercentValue)source).Value; 92 } else if (source is DT.StringValue) { 93 entity.StringValue = ((DT.StringValue)source).Value; 94 } else { 95 throw new ArgumentException("Unknown characteristic type.", "source"); 96 } 97 return entity; 98 } 99 100 private static DA.Characteristic ToEntity(string name, DA.CharacteristicType type, DA.OKBDataContext okb) { 101 if (string.IsNullOrEmpty(name)) return null; 102 var entity = okb.Characteristics.FirstOrDefault(x => (x.Name == name) && (x.Type == type)); 103 return entity ?? new DA.Characteristic() { Id = 0, Name = name, Type = type }; 70 104 } 71 105 -
trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation/IRunCreationService.cs
r12012 r13501 45 45 [OperationContract] 46 46 void AddRun(Run run); 47 48 [OperationContract] 49 [FaultContract(typeof(MissingProblem))] 50 [FaultContract(typeof(UnknownCharacteristicType))] 51 void SetCharacteristicValue(long problemId, string characteristicName, Value value); 47 52 } 48 53 } -
trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation/RunCreationService.cs
r12012 r13501 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Data.Linq; … … 135 136 } 136 137 } 138 139 140 public void SetCharacteristicValue(long problemId, string characteristicName, DataTransfer.Value value) { 141 roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser); 142 143 using (OKBDataContext okb = new OKBDataContext()) { 144 var problem = okb.Problems.SingleOrDefault(x => x.Id == problemId); 145 if (problem == null) throw new FaultException<MissingProblem>(new MissingProblem("Problem with id {0} cannot be found", problemId)); 146 CharacteristicType characteristicType; 147 try { 148 characteristicType = GetCharacteristicType(value); 149 } catch (ArgumentException ex) { 150 throw new FaultException<UnknownCharacteristicType>(new UnknownCharacteristicType(ex.Message)); 151 } 152 153 var entity = okb.CharacteristicValues.SingleOrDefault(x => x.Characteristic.Name == characteristicName && x.Characteristic.Type == characteristicType); 154 if (entity != null) { 155 // Update 156 switch (characteristicType) { 157 case CharacteristicType.Bool: entity.BoolValue = ((DataTransfer.BoolValue)value).Value; break; 158 case CharacteristicType.Int: entity.IntValue = ((DataTransfer.IntValue)value).Value; break; 159 case CharacteristicType.Long: entity.LongValue = ((DataTransfer.LongValue)value).Value; break; 160 case CharacteristicType.Float: entity.FloatValue = ((DataTransfer.FloatValue)value).Value; break; 161 case CharacteristicType.Double: entity.DoubleValue = ((DataTransfer.DoubleValue)value).Value; break; 162 case CharacteristicType.Percent: entity.DoubleValue = ((DataTransfer.PercentValue)value).Value; break; 163 case CharacteristicType.String: entity.StringValue = ((DataTransfer.StringValue)value).Value; break; 164 case CharacteristicType.TimeSpan: entity.LongValue = ((DataTransfer.TimeSpanValue)value).Value; break; 165 } 166 } else { 167 // Insert 168 entity = Convert.ToEntity(value, okb, problem, characteristicName, characteristicType); 169 okb.CharacteristicValues.InsertOnSubmit(entity); 170 } 171 okb.SubmitChanges(); 172 } 173 } 174 175 private CharacteristicType GetCharacteristicType(DataTransfer.Value source) { 176 if (source is DataTransfer.BoolValue) { 177 return CharacteristicType.Bool; 178 } else if (source is DataTransfer.IntValue) { 179 return CharacteristicType.Int; 180 } else if (source is DataTransfer.TimeSpanValue) { 181 return CharacteristicType.TimeSpan; 182 } else if (source is DataTransfer.LongValue) { 183 return CharacteristicType.Long; 184 } else if (source is DataTransfer.FloatValue) { 185 return CharacteristicType.Float; 186 } else if (source is DataTransfer.DoubleValue) { 187 return CharacteristicType.Double; 188 } else if (source is DataTransfer.PercentValue) { 189 return CharacteristicType.Percent; 190 } else if (source is DataTransfer.StringValue) { 191 return CharacteristicType.String; 192 } else { 193 throw new ArgumentException("Unknown characteristic type.", "source"); 194 } 195 } 137 196 } 138 197 }
Note: See TracChangeset
for help on using the changeset viewer.