Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/22/13 14:23:56 (10 years ago)
Author:
ascheibe
Message:

#2117

  • improved creation of ItemTasks from Items and moved common functionality to ItemTask
  • added a MenuItem for directly uploading tasks (e.g. from experiments, batchruns,...)
  • added a MenuItem for creating RefreshableHiveJobs
Location:
trunk/sources/HeuristicLab.Clients.Hive/3.3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r10130 r10150  
    351351    /// </summary>
    352352    /// <param name="parentHiveTask">shall be null if its the root task</param>
    353     private void UploadTaskWithChildren(Progress progress, HiveTask hiveTask, HiveTask parentHiveTask, IEnumerable<Guid> groups, int[] taskCount, int totalJobCount, Guid configPluginId, Guid jobId, ILog log, bool isPrivileged, CancellationToken cancellationToken) {
     353    private void UploadTaskWithChildren(IProgress progress, HiveTask hiveTask, HiveTask parentHiveTask, IEnumerable<Guid> groups, int[] taskCount, int totalJobCount, Guid configPluginId, Guid jobId, ILog log, bool isPrivileged, CancellationToken cancellationToken) {
    354354      taskUploadSemaphore.WaitOne();
    355355      bool semaphoreReleased = false;
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/RefreshableJob.cs

    r9893 r10150  
    157157    }
    158158
    159     private Progress progress;
    160     public Progress Progress {
     159    private IProgress progress;
     160    public IProgress Progress {
    161161      get { return progress; }
    162162      set {
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/Tasks/EngineTask.cs

    r10130 r10150  
    6060    }
    6161
    62     public EngineTask(IEngine engine) {
    63       this.Item = engine;
    64     }
     62    public EngineTask(IEngine engine) : base(engine) { }
    6563
    6664    [StorableConstructor]
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/Tasks/ItemTask.cs

    r10130 r10150  
    2222using System;
    2323using System.Drawing;
     24using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Hive;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.PluginInfrastructure;
    2830
    2931namespace HeuristicLab.Clients.Hive {
     
    7678      this.Item = cloner.Clone(original.Item);
    7779    }
     80    public ItemTask(IItem item) {
     81      Item = item;
     82    }
    7883
    7984    [StorableHook(HookType.AfterDeserialization)]
     
    216221      return Name;
    217222    }
     223
     224    #region Helpers
     225    public static bool IsTypeSupported(Type itemType) {
     226      var supportedHiveTaskTypes = ApplicationManager.Manager.GetTypes(typeof(ItemTask))
     227          .Select(t => t.GetProperties().Single(x => x.Name == "Item" && x.PropertyType != typeof(IItem)).PropertyType);
     228      return supportedHiveTaskTypes.Any(x => x.IsAssignableFrom(itemType));
     229    }
     230
     231    public static Type GetHiveTaskType(Type itemType) {
     232      if (!IsTypeSupported(itemType)) throw new Exception("Item " + itemType + " is not supported for Hive.");
     233
     234      var typeHiveTaskMap = ApplicationManager.Manager.GetTypes(typeof(ItemTask))
     235          .Select(t => new Tuple<Type, Type>(t.GetProperties().Single(x => x.Name == "Item" && x.PropertyType != typeof(IItem)).PropertyType, t));
     236
     237      return typeHiveTaskMap.Single(x => x.Item1.IsAssignableFrom(itemType)).Item2;
     238    }
     239
     240    public static ItemTask GetItemTaskForItem(IItem item) {
     241      Type itemType = item.GetType();
     242      Type hiveTaskType = GetHiveTaskType(itemType);
     243      return Activator.CreateInstance(hiveTaskType, new object[] { item }) as ItemTask;
     244    }
     245    #endregion
    218246  }
    219247}
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/Tasks/OptimizerTask.cs

    r10130 r10150  
    5050    }
    5151
    52     public OptimizerTask(IOptimizer optimizer) {
    53       this.Item = optimizer;
     52    public OptimizerTask(IOptimizer optimizer)
     53      : base(optimizer) {
    5454
    5555      if (optimizer is Experiment) {
Note: See TracChangeset for help on using the changeset viewer.