Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/05/11 15:37:04 (14 years ago)
Author:
cneumuel
Message:

#1233

  • seperated ExperimentMangerClient (OKB-Style, contains business logic) and HiveExperiment (mainly only contains information)
  • fixed redundant cloning methods in dtos
  • added simple statistics in HiveExperiment which the user can see before downloading an experiment
  • added db-delete cascade for slaves and statelogs - now slaves can be safely deleted
Location:
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/HiveDao.cs

    r5786 r5955  
    232232    public DT.HiveExperiment GetHiveExperiment(Guid id) {
    233233      using (var db = CreateContext()) {
    234         return Convert.ToDto(db.HiveExperiments.SingleOrDefault(x => x.HiveExperimentId == id));
    235       }
     234        return AddStatsToExperiment(db, Convert.ToDto(db.HiveExperiments.SingleOrDefault(x => x.HiveExperimentId == id)));
     235      }
     236    }
     237
     238    private DT.HiveExperiment AddStatsToExperiment(HiveDataContext db, DT.HiveExperiment exp) {
     239      var jobs = new List<Job>();
     240      CollectChildJobs(db, exp.RootJobId, jobs);
     241      exp.JobCount = jobs.Count;
     242      exp.CalculatingCount = jobs.Count(j => j.State == JobState.Calculating);
     243      exp.FinishedCount = jobs.Count(j => j.State == JobState.Finished);
     244      return exp;
    236245    }
    237246
    238247    public IEnumerable<DT.HiveExperiment> GetHiveExperiments(Expression<Func<HiveExperiment, bool>> predicate) {
    239248      using (var db = CreateContext()) {
    240         return db.HiveExperiments.Where(predicate).Select(x => Convert.ToDto(x)).ToArray();
     249        return db.HiveExperiments.Where(predicate).Select(x => AddStatsToExperiment(db, Convert.ToDto(x))).ToArray();
    241250      }
    242251    }
     
    640649    }
    641650    #endregion
     651
     652    #region Helpers
     653    private void CollectChildJobs(HiveDataContext db, Guid parentJobId, List<Job> collection) {
     654      var jobs = db.Jobs.Where(j => j.ParentJobId == parentJobId);
     655      foreach (var job in jobs) {
     656        collection.Add(job);
     657        if (job.IsParentJob)
     658          CollectChildJobs(db, job.JobId, collection);
     659      }
     660    }
     661    #endregion
    642662  }
    643663}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.DataAccess/3.4/Tools/prepareHiveDatabase.sql

    r5511 r5955  
    4747ON UPDATE CASCADE
    4848ON DELETE CASCADE
     49GO
     50ALTER TABLE [dbo].[StateLog]  DROP  CONSTRAINT [Resource_StateLog]
     51ALTER TABLE [dbo].[StateLog]  WITH CHECK ADD CONSTRAINT [Resource_StateLog] FOREIGN KEY([SlaveId])
     52REFERENCES [dbo].[Resource] ([ResourceId])
     53ON UPDATE CASCADE
     54ON DELETE SET NULL
    4955GO
    5056
Note: See TracChangeset for help on using the changeset viewer.