Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/27/11 15:20:23 (13 years ago)
Author:
cneumuel
Message:

#1233

  • finished experiment sharing
  • added role for executing privileged jobs
  • refreshing experiments in experimentManager does not delete already downloaded jobs
  • moved some properties from HiveExperiment into RefreshableHiveExperiment
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.4/ServiceClients/HiveExperiment.cs

    r6426 r6479  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.ComponentModel;
    25 using System.Linq;
    26 using HeuristicLab.Collections;
    2724using HeuristicLab.Common;
    28 using HeuristicLab.Core;
    2925
    3026namespace HeuristicLab.Clients.Hive {
    31   public partial class HiveExperiment : IDeepCloneable, IContent, IProgressReporter {
     27  public partial class HiveExperiment : IDeepCloneable, IContent {
    3228
    3329    private bool isPrivileged;
     
    3733    }
    3834
    39     private ExecutionState executionState;
    40     public ExecutionState ExecutionState {
    41       get { return executionState; }
    42       internal set {
    43         if (executionState != value) {
    44           executionState = value;
    45           OnExecutionStateChanged();
    46         }
    47       }
    48     }
    49 
    50     private TimeSpan executionTime;
    51     public TimeSpan ExecutionTime {
    52       get { return executionTime; }
    53       internal set {
    54         if (executionTime != value) {
    55           executionTime = value;
    56           OnExecutionTimeChanged();
    57         }
    58       }
    59     }
    60 
    61     private ItemCollection<HiveJob> hiveJobs;
    62     public ItemCollection<HiveJob> HiveJobs {
    63       get { return hiveJobs; }
    64       set {
    65         if (hiveJobs != value) {
    66           if (hiveJobs != null) DeregisterHiveJobsEvents();
    67           hiveJobs = value;
    68           if (hiveJobs != null) RegisterHiveJobsEvents();
    69           OnHiveJobsChanged();
    70         }
    71       }
    72     }
    73 
    74     private bool isProgressing;
    75     public bool IsProgressing {
    76       get { return isProgressing; }
    77       set {
    78         if (isProgressing != value) {
    79           isProgressing = value;
    80           OnIsProgressingChanged();
    81         }
    82       }
    83     }
    84 
    85     private IProgress progress;
    86     public IProgress Progress {
    87       get { return progress; }
    88       set { this.progress = value; }
    89     }
    90 
    91     public StateLogListList StateLogList {
    92       get { return new StateLogListList(this.GetAllHiveJobs().Select(x => x.StateLog)); }
    93     }
    94 
    9535    #region Constructors and Cloning
    9636    public HiveExperiment() {
    9737      this.ResourceNames = "HEAL";
    98       this.HiveJobs = new ItemCollection<HiveJob>();
    9938      this.DateCreated = DateTime.Now;
     39      this.Permission = Permission.Full;
    10040    }
    10141
     
    10949      this.Description = original.Description;
    11050      this.Id = original.Id;
    111       this.HiveJobs = cloner.Clone(original.HiveJobs);
    112       this.ExecutionTime = original.ExecutionTime;
    11351      this.IsPrivileged = original.IsPrivileged;
     52      this.Permission = original.Permission;
    11453    }
    11554    public override IDeepCloneable Clone(Cloner cloner) {
     
    11958
    12059    #region Events
    121     public event EventHandler ExecutionTimeChanged;
    122     protected virtual void OnExecutionTimeChanged() {
    123       var handler = ExecutionTimeChanged;
    124       if (handler != null) handler(this, EventArgs.Empty);
    125     }
    126 
    127     public event EventHandler ExecutionStateChanged;
    128     protected virtual void OnExecutionStateChanged() {
    129       var handler = ExecutionStateChanged;
    130       if (handler != null) handler(this, EventArgs.Empty);
    131     }
    132 
    133     public event EventHandler HiveJobsChanged;
    134     protected virtual void OnHiveJobsChanged() {
    135       var handler = HiveJobsChanged;
    136       if (handler != null) handler(this, EventArgs.Empty);
    137     }
    138 
    139     public event EventHandler IsProgressingChanged;
    140     protected virtual void OnIsProgressingChanged() {
    141       var handler = IsProgressingChanged;
    142       if (handler != null) handler(this, EventArgs.Empty);
    143     }
    144 
    145     public event EventHandler Loaded;
    146     public virtual void OnLoaded() {
    147       var handler = Loaded;
    148       if (handler != null) handler(this, EventArgs.Empty);
    149     }
    150 
    151     public event EventHandler<CollectionItemsChangedEventArgs<HiveJob>> HiveJobsAdded;
    152     private void OnHiveJobsAdded(CollectionItemsChangedEventArgs<HiveJob> e) {
    153       var handler = HiveJobsAdded;
    154       if (handler != null) handler(this, e);
    155     }
    156 
    157     public event EventHandler<CollectionItemsChangedEventArgs<HiveJob>> HiveJobsRemoved;
    158     private void OnHiveJobsRemoved(CollectionItemsChangedEventArgs<HiveJob> e) {
    159       var handler = HiveJobsRemoved;
    160       if (handler != null) handler(this, e);
    161     }
    162 
    163     public event EventHandler<CollectionItemsChangedEventArgs<HiveJob>> HiveJobsReset;
    164     private void OnHiveJobsReset(CollectionItemsChangedEventArgs<HiveJob> e) {
    165       var handler = HiveJobsReset;
    166       if (handler != null) handler(this, e);
    167     }
    168 
    16960    public event EventHandler StateLogListChanged;
    17061    private void OnStateLogListChanged() {
    17162      var handler = StateLogListChanged;
    17263      if (handler != null) handler(this, EventArgs.Empty);
    173     }
    174     #endregion
    175 
    176     #region HiveJobs Events
    177     private void RegisterHiveJobsEvents() {
    178       this.hiveJobs.ItemsAdded += new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsAdded);
    179       this.hiveJobs.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsRemoved);
    180       this.hiveJobs.CollectionReset += new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_CollectionReset);
    181     }
    182 
    183     private void DeregisterHiveJobsEvents() {
    184       this.hiveJobs.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsAdded);
    185       this.hiveJobs.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_ItemsRemoved);
    186       this.hiveJobs.CollectionReset -= new CollectionItemsChangedEventHandler<HiveJob>(hiveJobs_CollectionReset);
    187     }
    188 
    189     private void hiveJobs_CollectionReset(object sender, CollectionItemsChangedEventArgs<HiveJob> e) {
    190       foreach (var item in e.Items) {
    191         item.StateLogChanged -= new EventHandler(item_StateLogChanged);
    192       }
    193       OnHiveJobsReset(e);
    194     }
    195 
    196     private void hiveJobs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<HiveJob> e) {
    197       foreach (var item in e.Items) {
    198         item.StateLogChanged -= new EventHandler(item_StateLogChanged);
    199       }
    200       OnHiveJobsRemoved(e);
    201     }
    202 
    203     private void hiveJobs_ItemsAdded(object sender, CollectionItemsChangedEventArgs<HiveJob> e) {
    204       foreach (var item in e.Items) {
    205         item.StateLogChanged += new EventHandler(item_StateLogChanged);
    206       }
    207       OnHiveJobsAdded(e);
    208     }
    209 
    210     private void item_StateLogChanged(object sender, EventArgs e) {
    211       OnStateLogListChanged();
    21264    }
    21365    #endregion
     
    22981    }
    23082
    231     public bool IsFinished() {
    232       return HiveJobs != null
    233         && HiveJobs.All(x => x.Job.DateFinished.HasValue && x.Job.DateCreated.HasValue);
    234     }
    235 
    236     public IEnumerable<HiveJob> GetAllHiveJobs() {
    237       if (hiveJobs == null) return Enumerable.Empty<HiveJob>();
    238 
    239       var jobs = new List<HiveJob>();
    240       foreach (HiveJob job in HiveJobs) {
    241         jobs.AddRange(job.GetAllHiveJobs());
    242       }
    243       return jobs;
    244     }
    245 
    24683    public override string ToString() {
    24784      return Name;
Note: See TracChangeset for help on using the changeset viewer.