Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.3-Hive/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.LINQDataAccess/3.3/PluginInfoDao.cs @ 4423

Last change on this file since 4423 was 4423, checked in by cneumuel, 14 years ago
  • Refactored HL.Hive.Experiment. JobItems are not called HiveJobs and OptimizerJobs do not contain a hierarchy anymore.
  • Dynamic generation of jobs on a slave are not reflected on the client user interface.
  • Optimizer-Trees are now strictly synchronized with the HiveJob-Trees (also the ComputeInParallel property is taken into account when the Child HiveJobs are created)
  • Improved the way a class can report progress and lock the UI (IProgressReporter, IProgress, Progress, ProgressView)
  • Changes were made to the config-files, so that server and clients work with blade12.hpc.fh-hagenberg.at
  • Lots of small changes and bugfixes
File size: 3.3 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Hive.Contracts.BusinessObjects;
6using HeuristicLab.Hive.Server.DataAccess;
7
8namespace HeuristicLab.Hive.Server.LINQDataAccess {
9  public class PluginInfoDao: BaseDao<HivePluginInfoDto, PluginInfo>, IPluginInfoDao {
10    #region IGenericDao<HivePluginInfoDto,PluginInfo> Members
11
12    public HivePluginInfoDto FindById(Guid id) {
13      return (from pi in Context.PluginInfos
14              where pi.PluginId.Equals(id)
15              select EntityToDto(pi, null)
16             ).SingleOrDefault(); 
17    }
18
19    public IEnumerable<HivePluginInfoDto> FindAll() {
20      return (from pi in Context.PluginInfos             
21              select EntityToDto(pi, null)
22       ).ToList(); 
23    }
24
25    public HivePluginInfoDto Insert(HivePluginInfoDto bObj) {
26      PluginInfo pi = DtoToEntity(bObj, null);
27      Context.PluginInfos.InsertOnSubmit(pi);
28      CommitChanges();
29      bObj.Id = pi.PluginId;
30      return bObj;
31    }
32
33    public void Delete(Guid id) {
34      PluginInfo pi = Context.PluginInfos.SingleOrDefault(p => p.PluginId.Equals(id));
35      Context.PluginInfos.DeleteOnSubmit(pi);     
36    }
37
38    public void Update(HivePluginInfoDto bObj) {
39      PluginInfo pi = Context.PluginInfos.SingleOrDefault(p => p.PluginId.Equals(bObj.Id));
40      DtoToEntity(bObj, pi);
41      CommitChanges();
42    }
43
44    public void InsertPluginDependenciesForJob(JobDto jobDto) {
45      foreach (HivePluginInfoDto info in jobDto.PluginsNeeded) {               
46        PluginInfo dbpi =
47          Context.PluginInfos.Where(pi => pi.Name.Equals(info.Name) && pi.Version == info.Version.ToString()).SingleOrDefault();
48        if (dbpi == null) {
49          dbpi = new PluginInfo {
50                                  Name = info.Name,
51                                  Version = info.Version.ToString()
52                                };
53          Context.PluginInfos.InsertOnSubmit(dbpi);
54          CommitChanges();
55        }
56
57        RequiredPlugin rq = new RequiredPlugin();
58        rq.JobId = jobDto.Id;
59        rq.PluginInfo = dbpi;
60        Context.RequiredPlugins.InsertOnSubmit(rq);
61        CommitChanges();
62      }
63    }
64
65    public List<HivePluginInfoDto> GetPluginDependenciesForJob(JobDto jobDto) {
66      return (from rp in Context.RequiredPlugins
67              where rp.JobId.Equals(jobDto.Id)
68              select EntityToDto(rp.PluginInfo, null)).ToList();
69     
70    }
71
72    #endregion
73
74    // Build Date not mapped - won't matter anyway, it's a obsolete field.
75    public override PluginInfo DtoToEntity(HivePluginInfoDto source, PluginInfo target) {
76      if (source == null)
77        return null;
78      if (target == null)
79        target = new PluginInfo();
80
81      target.Name = source.Name;
82      target.PluginId = source.Id;
83      target.Version = source.Version.ToString();     
84
85      return target;
86
87    }
88
89    public override HivePluginInfoDto EntityToDto(PluginInfo source, HivePluginInfoDto target) {
90      if (source == null)
91        return null;
92      if (target == null)
93        target = new HivePluginInfoDto();
94
95      target.Name = source.Name;
96      target.Id = source.PluginId;
97      target.Version = new Version(source.Version);
98
99      return target;
100    }
101  }
102}
Note: See TracBrowser for help on using the repository browser.