Index: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
===================================================================
--- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs	(revision 6723)
+++ branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs	(revision 6725)
@@ -45,10 +45,10 @@
 
     #region Properties
-    private ItemCollection<RefreshableHiveExperiment> hiveExperiments;
-    public ItemCollection<RefreshableHiveExperiment> HiveExperiments {
-      get { return hiveExperiments; }
+    private ItemCollection<RefreshableJob> jobs;
+    public ItemCollection<RefreshableJob> Jobs {
+      get { return jobs; }
       set {
-        if (value != hiveExperiments) {
-          hiveExperiments = value;
+        if (value != jobs) {
+          jobs = value;
           OnHiveExperimentsChanged();
         }
@@ -84,6 +84,6 @@
         this.IsAllowedPrivileged = ServiceLocator.Instance.CallHiveService((s) => s.IsAllowedPrivileged());
 
-        var oldExperiments = hiveExperiments ?? new ItemCollection<RefreshableHiveExperiment>();
-        hiveExperiments = new HiveItemCollection<RefreshableHiveExperiment>();
+        var oldExperiments = jobs ?? new ItemCollection<RefreshableJob>();
+        jobs = new HiveItemCollection<RefreshableJob>();
         var experimentsLoaded = ServiceLocator.Instance.CallHiveService<IEnumerable<Job>>(s => s.GetHiveExperiments());
 
@@ -92,10 +92,10 @@
           if (hiveExperiment == null) {
             // new
-            hiveExperiments.Add(new RefreshableHiveExperiment(he) { IsAllowedPrivileged = this.isAllowedPrivileged });
+            jobs.Add(new RefreshableJob(he) { IsAllowedPrivileged = this.isAllowedPrivileged });
           } else {
             // update
-            hiveExperiment.HiveExperiment = he;
+            hiveExperiment.Job = he;
             hiveExperiment.IsAllowedPrivileged = this.isAllowedPrivileged;
-            hiveExperiments.Add(hiveExperiment);
+            jobs.Add(hiveExperiment);
           }
         }
@@ -104,5 +104,5 @@
           if (experiment.Id == Guid.Empty) {
             // experiment not uploaded... keep
-            hiveExperiments.Add(experiment);
+            jobs.Add(experiment);
           } else {
             experiment.RefreshAutomatically = false; // stop results polling
@@ -111,5 +111,5 @@
       }
       catch {
-        hiveExperiments = null;
+        jobs = null;
         throw;
       }
@@ -138,6 +138,6 @@
     public static void Store(IHiveItem item, CancellationToken cancellationToken) {
       if (item.Id == Guid.Empty) {
-        if (item is RefreshableHiveExperiment) {
-          HiveClient.Instance.UploadExperiment((RefreshableHiveExperiment)item, cancellationToken);
+        if (item is RefreshableJob) {
+          HiveClient.Instance.UploadExperiment((RefreshableJob)item, cancellationToken);
         }
         if (item is JobPermission) {
@@ -178,5 +178,5 @@
       if (item is Job)
         ServiceLocator.Instance.CallHiveService(s => s.DeleteHiveExperiment(item.Id));
-      if (item is RefreshableHiveExperiment)
+      if (item is RefreshableJob)
         ServiceLocator.Instance.CallHiveService(s => s.DeleteHiveExperiment(item.Id));
       if (item is JobPermission) {
@@ -206,18 +206,18 @@
     #endregion
 
-    public static void StartExperiment(Action<Exception> exceptionCallback, RefreshableHiveExperiment refreshableHiveExperiment, CancellationToken cancellationToken) {
+    public static void StartExperiment(Action<Exception> exceptionCallback, RefreshableJob refreshableJob, CancellationToken cancellationToken) {
       HiveClient.StoreAsync(
         new Action<Exception>((Exception ex) => {
-          refreshableHiveExperiment.ExecutionState = ExecutionState.Prepared;
+          refreshableJob.ExecutionState = ExecutionState.Prepared;
           exceptionCallback(ex);
-        }), refreshableHiveExperiment, cancellationToken);
-      refreshableHiveExperiment.ExecutionState = ExecutionState.Started;
-    }
-
-    public static void PauseExperiment(RefreshableHiveExperiment refreshableHiveExperiment) {
+        }), refreshableJob, cancellationToken);
+      refreshableJob.ExecutionState = ExecutionState.Started;
+    }
+
+    public static void PauseExperiment(RefreshableJob refreshableHiveExperiment) {
       ServiceLocator.Instance.CallHiveService(service => {
-        foreach (HiveJob job in refreshableHiveExperiment.GetAllHiveJobs()) {
-          if (job.Job.State != TaskState.Finished && job.Job.State != TaskState.Aborted && job.Job.State != TaskState.Failed)
-            service.PauseJob(job.Job.Id);
+        foreach (HiveTask job in refreshableHiveExperiment.GetAllHiveJobs()) {
+          if (job.Task.State != TaskState.Finished && job.Task.State != TaskState.Aborted && job.Task.State != TaskState.Failed)
+            service.PauseJob(job.Task.Id);
         }
       });
@@ -225,9 +225,9 @@
     }
 
-    public static void StopExperiment(RefreshableHiveExperiment refreshableHiveExperiment) {
+    public static void StopExperiment(RefreshableJob refreshableJob) {
       ServiceLocator.Instance.CallHiveService(service => {
-        foreach (HiveJob job in refreshableHiveExperiment.GetAllHiveJobs()) {
-          if (job.Job.State != TaskState.Finished && job.Job.State != TaskState.Aborted && job.Job.State != TaskState.Failed)
-            service.StopJob(job.Job.Id);
+        foreach (HiveTask job in refreshableJob.GetAllHiveJobs()) {
+          if (job.Task.State != TaskState.Finished && job.Task.State != TaskState.Aborted && job.Task.State != TaskState.Failed)
+            service.StopJob(job.Task.Id);
         }
       });
@@ -239,10 +239,10 @@
     private static object jobCountLocker = new object();
     private static object pluginLocker = new object();
-    private void UploadExperiment(RefreshableHiveExperiment refreshableHiveExperiment, CancellationToken cancellationToken) {
+    private void UploadExperiment(RefreshableJob refreshableJob, CancellationToken cancellationToken) {
       try {
-        refreshableHiveExperiment.Progress = new Progress("Connecting to server...");
-        refreshableHiveExperiment.IsProgressing = true;
-
-        IEnumerable<string> resourceNames = ToResourceNameList(refreshableHiveExperiment.HiveExperiment.ResourceNames);
+        refreshableJob.Progress = new Progress("Connecting to server...");
+        refreshableJob.IsProgressing = true;
+
+        IEnumerable<string> resourceNames = ToResourceNameList(refreshableJob.Job.ResourceNames);
         var resourceIds = new List<Guid>();
         foreach (var resourceName in resourceNames) {
@@ -254,22 +254,22 @@
         }
 
-        foreach (OptimizerHiveJob hiveJob in refreshableHiveExperiment.HiveJobs.OfType<OptimizerHiveJob>()) {
+        foreach (OptimizerHiveTask hiveJob in refreshableJob.HiveJobs.OfType<OptimizerHiveTask>()) {
           hiveJob.SetIndexInParentOptimizerList(null);
         }
 
-        // upload Job
-        refreshableHiveExperiment.Progress.Status = "Uploading Job...";
-        refreshableHiveExperiment.HiveExperiment.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddHiveExperiment(refreshableHiveExperiment.HiveExperiment));
-        bool isPrivileged = refreshableHiveExperiment.HiveExperiment.IsPrivileged;
-        refreshableHiveExperiment.HiveExperiment = ServiceLocator.Instance.CallHiveService((s) => s.GetHiveExperiment(refreshableHiveExperiment.HiveExperiment.Id)); // update owner and permissions
-        refreshableHiveExperiment.HiveExperiment.IsPrivileged = isPrivileged;
-        cancellationToken.ThrowIfCancellationRequested();
-
-        int totalJobCount = refreshableHiveExperiment.GetAllHiveJobs().Count();
+        // upload Task
+        refreshableJob.Progress.Status = "Uploading Task...";
+        refreshableJob.Job.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddHiveExperiment(refreshableJob.Job));
+        bool isPrivileged = refreshableJob.Job.IsPrivileged;
+        refreshableJob.Job = ServiceLocator.Instance.CallHiveService((s) => s.GetHiveExperiment(refreshableJob.Job.Id)); // update owner and permissions
+        refreshableJob.Job.IsPrivileged = isPrivileged;
+        cancellationToken.ThrowIfCancellationRequested();
+
+        int totalJobCount = refreshableJob.GetAllHiveJobs().Count();
         int[] jobCount = new int[1]; // use a reference type (int-array) instead of value type (int) in order to pass the value via a delegate to task-parallel-library
         cancellationToken.ThrowIfCancellationRequested();
 
         // upload plugins
-        refreshableHiveExperiment.Progress.Status = "Uploading plugins...";
+        refreshableJob.Progress.Status = "Uploading plugins...";
         this.OnlinePlugins = ServiceLocator.Instance.CallHiveService((s) => s.GetPlugins());
         this.AlreadyUploadedPlugins = new List<Plugin>();
@@ -278,15 +278,15 @@
         cancellationToken.ThrowIfCancellationRequested();
 
-        if (refreshableHiveExperiment.RefreshAutomatically) refreshableHiveExperiment.StartResultPolling();
+        if (refreshableJob.RefreshAutomatically) refreshableJob.StartResultPolling();
 
         // upload jobs
-        refreshableHiveExperiment.Progress.Status = "Uploading jobs...";
+        refreshableJob.Progress.Status = "Uploading jobs...";
 
         var tasks = new List<TS.Task>();
-        foreach (HiveJob hiveJob in refreshableHiveExperiment.HiveJobs) {
+        foreach (HiveTask hiveJob in refreshableJob.HiveJobs) {
           tasks.Add(TS.Task.Factory.StartNew((hj) => {
-            UploadJobWithChildren(refreshableHiveExperiment.Progress, (HiveJob)hj, null, resourceIds, jobCount, totalJobCount, configFilePlugin.Id, refreshableHiveExperiment.HiveExperiment.Id, refreshableHiveExperiment.Log, refreshableHiveExperiment.HiveExperiment.IsPrivileged, cancellationToken);
+            UploadJobWithChildren(refreshableJob.Progress, (HiveTask)hj, null, resourceIds, jobCount, totalJobCount, configFilePlugin.Id, refreshableJob.Job.Id, refreshableJob.Log, refreshableJob.Job.IsPrivileged, cancellationToken);
           }, hiveJob)
-          .ContinueWith((x) => refreshableHiveExperiment.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));
+          .ContinueWith((x) => refreshableJob.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));
         }
         try {
@@ -296,8 +296,8 @@
           if (!ae.InnerExceptions.All(e => e is TaskCanceledException)) throw ae; // for some reason the WaitAll throws a AggregateException containg a TaskCanceledException. i don't know where it comes from, however the tasks all finish properly, so for now just ignore it
         }
-        refreshableHiveExperiment.HiveExperiment.Modified = false;
+        refreshableJob.Job.Modified = false;
       }
       finally {
-        refreshableHiveExperiment.IsProgressing = false;
+        refreshableJob.IsProgressing = false;
       }
     }
@@ -331,8 +331,8 @@
 
     /// <summary>
-    /// Uploads the given job and all its child-jobs while setting the proper parentJobId values for the childs
+    /// Uploads the given task and all its child-jobs while setting the proper parentJobId values for the childs
     /// </summary>
-    /// <param name="parentHiveJob">shall be null if its the root job</param>
-    private void UploadJobWithChildren(IProgress progress, HiveJob hiveJob, HiveJob parentHiveJob, IEnumerable<Guid> groups, int[] jobCount, int totalJobCount, Guid configPluginId, Guid hiveExperimentId, ILog log, bool isPrivileged, CancellationToken cancellationToken) {
+    /// <param name="parentHiveTask">shall be null if its the root task</param>
+    private void UploadJobWithChildren(IProgress progress, HiveTask hiveJob, HiveTask parentHiveJob, IEnumerable<Guid> groups, int[] jobCount, int totalJobCount, Guid configPluginId, Guid hiveExperimentId, ILog log, bool isPrivileged, CancellationToken cancellationToken) {
       jobUploadSemaphore.WaitOne();
       bool semaphoreReleased = false;
@@ -345,12 +345,12 @@
         List<IPluginDescription> plugins;
 
-        if (hiveJob.ItemJob.ComputeInParallel && (hiveJob.ItemJob.Item is Optimization.Experiment || hiveJob.ItemJob.Item is Optimization.BatchRun)) {
-          hiveJob.Job.IsParentJob = true;
-          hiveJob.Job.FinishWhenChildJobsFinished = true;
-          jobData = hiveJob.GetAsJobData(true, out plugins);
+        if (hiveJob.ItemTask.ComputeInParallel && (hiveJob.ItemTask.Item is Optimization.Experiment || hiveJob.ItemTask.Item is Optimization.BatchRun)) {
+          hiveJob.Task.IsParentTask = true;
+          hiveJob.Task.FinishWhenChildJobsFinished = true;
+          jobData = hiveJob.GetAsTaskData(true, out plugins);
         } else {
-          hiveJob.Job.IsParentJob = false;
-          hiveJob.Job.FinishWhenChildJobsFinished = false;
-          jobData = hiveJob.GetAsJobData(false, out plugins);
+          hiveJob.Task.IsParentTask = false;
+          hiveJob.Task.FinishWhenChildJobsFinished = false;
+          jobData = hiveJob.GetAsTaskData(false, out plugins);
         }
         cancellationToken.ThrowIfCancellationRequested();
@@ -359,36 +359,36 @@
           if (!cancellationToken.IsCancellationRequested) {
             lock (pluginLocker) {
-              ServiceLocator.Instance.CallHiveService((s) => hiveJob.Job.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));
+              ServiceLocator.Instance.CallHiveService((s) => hiveJob.Task.PluginsNeededIds = PluginUtil.GetPluginDependencies(s, this.onlinePlugins, this.alreadyUploadedPlugins, plugins));
             }
           }
         }, -1, "Failed to upload plugins");
         cancellationToken.ThrowIfCancellationRequested();
-        hiveJob.Job.PluginsNeededIds.Add(configPluginId);
-        hiveJob.Job.JobId = hiveExperimentId;
-        hiveJob.Job.IsPrivileged = isPrivileged;
-
-        log.LogMessage(string.Format("Uploading job ({0} kb, {1} objects)", jobData.Data.Count() / 1024, hiveJob.ItemJob.GetObjectGraphObjects().Count()));
+        hiveJob.Task.PluginsNeededIds.Add(configPluginId);
+        hiveJob.Task.JobId = hiveExperimentId;
+        hiveJob.Task.IsPrivileged = isPrivileged;
+
+        log.LogMessage(string.Format("Uploading task ({0} kb, {1} objects)", jobData.Data.Count() / 1024, hiveJob.ItemTask.GetObjectGraphObjects().Count()));
         TryAndRepeat(() => {
           if (!cancellationToken.IsCancellationRequested) {
             if (parentHiveJob != null) {
-              hiveJob.Job.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddChildJob(parentHiveJob.Job.Id, hiveJob.Job, jobData));
+              hiveJob.Task.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddChildJob(parentHiveJob.Task.Id, hiveJob.Task, jobData));
             } else {
-              hiveJob.Job.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddJob(hiveJob.Job, jobData, groups.ToList()));
+              hiveJob.Task.Id = ServiceLocator.Instance.CallHiveService((s) => s.AddJob(hiveJob.Task, jobData, groups.ToList()));
             }
           }
-        }, 50, "Failed to add job", log);
+        }, 50, "Failed to add task", log);
         cancellationToken.ThrowIfCancellationRequested();
 
         lock (jobCountLocker) {
           progress.ProgressValue = (double)jobCount[0] / totalJobCount;
-          progress.Status = string.Format("Uploaded job ({0} of {1})", jobCount[0], totalJobCount);
+          progress.Status = string.Format("Uploaded task ({0} of {1})", jobCount[0], totalJobCount);
         }
 
         var tasks = new List<TS.Task>();
-        foreach (HiveJob child in hiveJob.ChildHiveJobs) {
+        foreach (HiveTask child in hiveJob.ChildHiveTasks) {
           tasks.Add(TS.Task.Factory.StartNew((tuple) => {
-            var arguments = (Tuple<HiveJob, HiveJob>)tuple;
+            var arguments = (Tuple<HiveTask, HiveTask>)tuple;
             UploadJobWithChildren(progress, arguments.Item1, arguments.Item2, groups, jobCount, totalJobCount, configPluginId, hiveExperimentId, log, isPrivileged, cancellationToken);
-          }, new Tuple<HiveJob, HiveJob>(child, hiveJob))
+          }, new Tuple<HiveTask, HiveTask>(child, hiveJob))
           .ContinueWith((x) => log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted));
         }
@@ -408,25 +408,25 @@
 
     #region Download Experiment
-    public static void LoadExperiment(RefreshableHiveExperiment refreshableHiveExperiment) {
-      var hiveExperiment = refreshableHiveExperiment.HiveExperiment;
-      refreshableHiveExperiment.Progress = new Progress();
+    public static void LoadExperiment(RefreshableJob refreshableJob) {
+      var hiveExperiment = refreshableJob.Job;
+      refreshableJob.Progress = new Progress();
 
       try {
-        refreshableHiveExperiment.IsProgressing = true;
+        refreshableJob.IsProgressing = true;
         int totalJobCount = 0;
         IEnumerable<LightweightTask> allJobs;
 
-        refreshableHiveExperiment.Progress.Status = "Connecting to Server...";
-        // fetch all Task objects to create the full tree of tree of HiveJob objects
-        refreshableHiveExperiment.Progress.Status = "Downloading list of jobs...";
+        refreshableJob.Progress.Status = "Connecting to Server...";
+        // fetch all Task objects to create the full tree of tree of HiveTask objects
+        refreshableJob.Progress.Status = "Downloading list of jobs...";
         allJobs = ServiceLocator.Instance.CallHiveService(s => s.GetLightweightExperimentJobs(hiveExperiment.Id));
         totalJobCount = allJobs.Count();
 
-        HiveJobDownloader downloader = new HiveJobDownloader(allJobs.Select(x => x.Id));
+        TaskDownloader downloader = new TaskDownloader(allJobs.Select(x => x.Id));
         downloader.StartAsync();
 
         while (!downloader.IsFinished) {
-          refreshableHiveExperiment.Progress.ProgressValue = downloader.FinishedCount / (double)totalJobCount;
-          refreshableHiveExperiment.Progress.Status = string.Format("Downloading/deserializing jobs... ({0}/{1} finished)", downloader.FinishedCount, totalJobCount);
+          refreshableJob.Progress.ProgressValue = downloader.FinishedCount / (double)totalJobCount;
+          refreshableJob.Progress.Status = string.Format("Downloading/deserializing jobs... ({0}/{1} finished)", downloader.FinishedCount, totalJobCount);
           Thread.Sleep(500);
 
@@ -435,33 +435,33 @@
           }
         }
-        IDictionary<Guid, HiveJob> allHiveJobs = downloader.Results;
-
-        refreshableHiveExperiment.HiveJobs = new ItemCollection<HiveJob>(allHiveJobs.Values.Where(x => !x.Job.ParentTaskId.HasValue));
-
-        if (refreshableHiveExperiment.IsFinished()) {
-          refreshableHiveExperiment.ExecutionState = Core.ExecutionState.Stopped;
+        IDictionary<Guid, HiveTask> allHiveJobs = downloader.Results;
+
+        refreshableJob.HiveJobs = new ItemCollection<HiveTask>(allHiveJobs.Values.Where(x => !x.Task.ParentTaskId.HasValue));
+
+        if (refreshableJob.IsFinished()) {
+          refreshableJob.ExecutionState = Core.ExecutionState.Stopped;
         } else {
-          refreshableHiveExperiment.ExecutionState = Core.ExecutionState.Started;
-        }
-
-        // build child-job tree
-        foreach (HiveJob hiveJob in refreshableHiveExperiment.HiveJobs) {
+          refreshableJob.ExecutionState = Core.ExecutionState.Started;
+        }
+
+        // build child-task tree
+        foreach (HiveTask hiveJob in refreshableJob.HiveJobs) {
           BuildHiveJobTree(hiveJob, allJobs, allHiveJobs);
         }
 
-        refreshableHiveExperiment.OnLoaded();
+        refreshableJob.OnLoaded();
       }
       finally {
-        refreshableHiveExperiment.IsProgressing = false;
-      }
-    }
-
-    private static void BuildHiveJobTree(HiveJob parentHiveJob, IEnumerable<LightweightTask> allJobs, IDictionary<Guid, HiveJob> allHiveJobs) {
+        refreshableJob.IsProgressing = false;
+      }
+    }
+
+    private static void BuildHiveJobTree(HiveTask parentHiveJob, IEnumerable<LightweightTask> allJobs, IDictionary<Guid, HiveTask> allHiveJobs) {
       IEnumerable<LightweightTask> childJobs = from job in allJobs
-                                               where job.ParentTaskId.HasValue && job.ParentTaskId.Value == parentHiveJob.Job.Id
+                                               where job.ParentTaskId.HasValue && job.ParentTaskId.Value == parentHiveJob.Task.Id
                                                orderby job.DateCreated ascending
                                                select job;
       foreach (LightweightTask job in childJobs) {
-        HiveJob childHiveJob = allHiveJobs[job.Id];
+        HiveTask childHiveJob = allHiveJobs[job.Id];
         parentHiveJob.AddChildHiveJob(childHiveJob);
         BuildHiveJobTree(childHiveJob, allJobs, allHiveJobs);
@@ -481,8 +481,8 @@
     }
 
-    public static ItemJob LoadItemJob(Guid jobId) {
+    public static ItemTask LoadItemJob(Guid jobId) {
       TaskData jobData = ServiceLocator.Instance.CallHiveService(s => s.GetJobData(jobId));
       try {
-        return PersistenceUtil.Deserialize<ItemJob>(jobData.Data);
+        return PersistenceUtil.Deserialize<ItemTask>(jobData.Data);
       }
       catch {
