Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/16/10 06:42:00 (14 years ago)
Author:
swagner
Message:

Worked on OKB data model and services (#1174)

Location:
trunk/sources/HeuristicLab.Services.OKB/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Services.OKB/3.3/AdminService.cs

    r4390 r4407  
    3131  [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    3232  public class AdminService : IAdminService {
     33    public void AddAlgorithmClass(AlgorithmClass algorithmClass) {
     34      using (OKBDataContext okb = new OKBDataContext()) {
     35        okb.AlgorithmClasses.InsertOnSubmit(new AlgorithmClass() {
     36          Name = algorithmClass.Name,
     37          Description = algorithmClass.Description
     38        });
     39        okb.SubmitChanges();
     40      }
     41    }
     42    public AlgorithmClass[] GetAlgorithmClasses() {
     43      using (OKBDataContext okb = new OKBDataContext()) {
     44        return okb.AlgorithmClasses.ToArray();
     45      }
     46    }
     47    public void UpdateAlgorithmClass(AlgorithmClass algorithmClass) {
     48      using (OKBDataContext okb = new OKBDataContext()) {
     49        AlgorithmClass original = okb.AlgorithmClasses.First(a => a.Id == algorithmClass.Id);
     50        original.Name = algorithmClass.Name;
     51        original.Description = algorithmClass.Description;
     52        okb.SubmitChanges();
     53      }
     54    }
     55    public void DeleteAlgorithmClass(long algorithmClassId) {
     56      using (OKBDataContext okb = new OKBDataContext()) {
     57        okb.AlgorithmClasses.DeleteOnSubmit(okb.AlgorithmClasses.First(a => a.Id == algorithmClassId));
     58        okb.SubmitChanges();
     59      }
     60    }
     61
     62    public void AddAlgorithm(Algorithm algorithm) {
     63      using (OKBDataContext okb = new OKBDataContext()) {
     64        okb.Algorithms.InsertOnSubmit(new Algorithm() {
     65          AlgorithmClassId = algorithm.AlgorithmClassId,
     66          PlatformId = algorithm.PlatformId,
     67          Name = algorithm.Name,
     68          Description = algorithm.Description
     69        });
     70        okb.SubmitChanges();
     71      }
     72    }
     73    public Algorithm[] GetAlgorithms() {
     74      using (OKBDataContext okb = new OKBDataContext()) {
     75        return okb.Algorithms.ToArray();
     76      }
     77    }
     78    public void UpdateAlgorithm(Algorithm algorithm) {
     79      using (OKBDataContext okb = new OKBDataContext()) {
     80        Algorithm original = okb.Algorithms.First(a => a.Id == algorithm.Id);
     81        original.AlgorithmClassId = algorithm.AlgorithmClassId;
     82        original.PlatformId = algorithm.PlatformId;
     83        original.Name = algorithm.Name;
     84        original.Description = algorithm.Description;
     85        okb.SubmitChanges();
     86      }
     87    }
     88    public void DeleteAlgorithm(long algorithmId) {
     89      using (OKBDataContext okb = new OKBDataContext()) {
     90        okb.Algorithms.DeleteOnSubmit(okb.Algorithms.First(a => a.Id == algorithmId));
     91        okb.SubmitChanges();
     92      }
     93    }
     94
    3395    /// <summary>
    3496    /// Gets all available platforms.
     
    80142        var dlo = new DataLoadOptions();
    81143        dlo.LoadWith<Problem>(p => p.ProblemClass);
    82         dlo.LoadWith<Problem>(p => p.SolutionRepresentation);
    83144        dlo.LoadWith<Problem>(p => p.Platform);
    84145        dlo.LoadWith<Problem>(p => p.ProblemUsers);
    85146        dlo.LoadWith<ProblemUser>(u => u.User);
    86         dlo.LoadWith<Problem>(p => p.ProblemCharacteristicIntValues);
    87         dlo.LoadWith<Problem>(p => p.ProblemCharacteristicFloatValues);
    88         dlo.LoadWith<Problem>(p => p.ProblemCharacteristicStringValues);
    89         dlo.LoadWith<ProblemCharacteristicIntValue>(ipcv => ipcv.ProblemCharacteristic);
    90         dlo.LoadWith<ProblemCharacteristicFloatValue>(fpcv => fpcv.ProblemCharacteristic);
    91         dlo.LoadWith<ProblemCharacteristicStringValue>(cpcv => cpcv.ProblemCharacteristic);
    92         dlo.LoadWith<ProblemCharacteristic>(pc => pc.DataType);
    93147        okb.LoadOptions = dlo;
    94148        return okb.Problems.Single(p => p.Id == id);
     
    143197        Problem originalProblem = okb.Problems.Single(p => p.Id == problem.Id);
    144198        UpdateProblemData(problem, originalProblem, okb);
    145         UpdateProblemCharacteristics(problem, originalProblem, okb);
    146199        okb.SubmitChanges();
    147200      }
     
    178231      }
    179232    }
    180     private static void UpdateProblemCharacteristics(Problem problem, Problem original, OKBDataContext okb) {
    181       okb.ProblemCharacteristicIntValues.DeleteAllOnSubmit(original.ProblemCharacteristicIntValues);
    182       okb.ProblemCharacteristicFloatValues.DeleteAllOnSubmit(original.ProblemCharacteristicFloatValues);
    183       okb.ProblemCharacteristicStringValues.DeleteAllOnSubmit(original.ProblemCharacteristicStringValues);
    184       original.ProblemCharacteristicIntValues.Clear();
    185       original.ProblemCharacteristicFloatValues.Clear();
    186       original.ProblemCharacteristicStringValues.Clear();
    187       foreach (var ipc in problem.ProblemCharacteristicIntValues) {
    188         original.ProblemCharacteristicIntValues.Add(new ProblemCharacteristicIntValue() {
    189           ProblemId = original.Id,
    190           ProblemCharacteristicId = ipc.ProblemCharacteristicId,
    191           Value = ipc.Value,
    192         });
    193       }
    194       foreach (var fpc in problem.ProblemCharacteristicFloatValues) {
    195         original.ProblemCharacteristicFloatValues.Add(new ProblemCharacteristicFloatValue() {
    196           ProblemId = original.Id,
    197           ProblemCharacteristicId = fpc.ProblemCharacteristicId,
    198           Value = fpc.Value,
    199         });
    200       }
    201       foreach (var cpc in problem.ProblemCharacteristicStringValues) {
    202         original.ProblemCharacteristicStringValues.Add(new ProblemCharacteristicStringValue() {
    203           ProblemId = original.Id,
    204           ProblemCharacteristicId = cpc.ProblemCharacteristicId,
    205           Value = cpc.Value,
    206         });
    207       }
    208     }
    209 
    210 
    211     public void AddAlgorithmClass(AlgorithmClass algorithmClass) {
    212       using (OKBDataContext okb = new OKBDataContext()) {
    213         okb.AlgorithmClasses.InsertOnSubmit(new AlgorithmClass() { Name = algorithmClass.Name, Description = algorithmClass.Description });
    214         okb.SubmitChanges();
    215       }
    216     }
    217 
    218     public AlgorithmClass[] GetAlgorithmClasses() {
    219       using (OKBDataContext okb = new OKBDataContext()) {
    220         return okb.AlgorithmClasses.ToArray();
    221       }
    222     }
    223 
    224     public void UpdateAlgorithmClass(AlgorithmClass algorithmClass) {
    225       using (OKBDataContext okb = new OKBDataContext()) {
    226         AlgorithmClass original = okb.AlgorithmClasses.First(a => a.Id == algorithmClass.Id);
    227         original.Name = algorithmClass.Name;
    228         original.Description = algorithmClass.Description;
    229         okb.SubmitChanges();
    230       }
    231     }
    232 
    233     public void DeleteAlgorithmClass(long algorithmClassId) {
    234       using (OKBDataContext okb = new OKBDataContext()) {
    235         okb.AlgorithmClasses.DeleteOnSubmit(okb.AlgorithmClasses.First(a => a.Id == algorithmClassId));
    236         okb.SubmitChanges();
    237       }
    238     }
    239 
    240233  }
    241234}
  • trunk/sources/HeuristicLab.Services.OKB/3.3/HeuristicLab.Services.OKB-3.3.csproj

    r4388 r4407  
    121121  <ItemGroup>
    122122    <Compile Include="AdminService.cs" />
    123     <Compile Include="DataService.cs" />
    124     <Compile Include="ExperimentKit.cs" />
    125123    <Compile Include="Interfaces\IAdminService.cs" />
    126     <Compile Include="Interfaces\IDataService.cs" />
    127124    <Compile Include="Properties\AssemblyInfo.cs" />
    128     <Compile Include="StarterKit.cs" />
    129125  </ItemGroup>
    130126  <ItemGroup>
  • trunk/sources/HeuristicLab.Services.OKB/3.3/Interfaces/IAdminService.cs

    r4390 r4407  
    2626namespace HeuristicLab.Services.OKB {
    2727  /// <summary>
    28   /// Allows updating the implementation of algorithms and problems. All
    29   /// other entities can be modified using the <see cref="TableService"/>
     28  /// Service of administrating the OKB.
    3029  /// </summary> 
    3130  [ServiceContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)]
    3231  public interface IAdminService {
     32    [OperationContract]
     33    void AddAlgorithmClass(AlgorithmClass algorithmClass);
     34    [OperationContract]
     35    AlgorithmClass[] GetAlgorithmClasses();
     36    [OperationContract]
     37    void UpdateAlgorithmClass(AlgorithmClass algorithmClass);
     38    [OperationContract]
     39    void DeleteAlgorithmClass(long algorithmClassId);
     40
     41    [OperationContract]
     42    void AddAlgorithm(Algorithm algorithm);
     43    [OperationContract]
     44    Algorithm[] GetAlgorithms();
     45    [OperationContract]
     46    void UpdateAlgorithm(Algorithm algorithm);
     47    [OperationContract]
     48    void DeleteAlgorithm(long algorithmId);
     49
     50
     51
     52
    3353
    3454    /// <summary>
     
    108128    [OperationContract]
    109129    void UpdateCompleteProblem(Problem problem);
    110 
    111 
    112 
    113     [OperationContract]
    114     void AddAlgorithmClass(AlgorithmClass algorithmClass);
    115 
    116     [OperationContract]
    117     AlgorithmClass[] GetAlgorithmClasses();
    118 
    119     [OperationContract]
    120     void UpdateAlgorithmClass(AlgorithmClass algorithmClass);
    121 
    122     [OperationContract]
    123     void DeleteAlgorithmClass(long algorithmClassId);
    124 
    125130  }
    126131}
  • trunk/sources/HeuristicLab.Services.OKB/3.3/app.config

    r4313 r4407  
    6767      <service name="HeuristicLab.Services.OKB.AdminService" behaviorConfiguration="DefaultServiceBehavior">
    6868        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="DefaultMexHttpBinding" contract="IMetadataExchange" />
    69         <endpoint binding="netTcpBinding" bindingConfiguration="DefaultNetTcpBinding" contract="HeuristicLab.Services.OKB.IAdminService" />
     69        <endpoint binding="wsHttpBinding" bindingConfiguration="DefaultWsHttpBinding" contract="HeuristicLab.Services.OKB.IAdminService" />
    7070        <host>
    7171          <baseAddresses>
    7272            <add baseAddress="http://localhost:8732/Design_Time_Addresses/OKB-3.3/AdminService" />
    73             <add baseAddress="net.tcp://localhost:8733/OKB-3.3/AdminService" />
    7473          </baseAddresses>
    7574        </host>
Note: See TracChangeset for help on using the changeset viewer.