Index: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs
===================================================================
--- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs	(revision 6725)
+++ branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive/3.3/HiveDao.cs	(revision 6743)
@@ -36,6 +36,6 @@
     public HiveDao() { }
 
-    #region Job Methods
-    public DT.Task GetJob(Guid id) {
+    #region Task Methods
+    public DT.Task GetTask(Guid id) {
       using (var db = CreateContext()) {
         return DT.Convert.ToDto(db.Tasks.SingleOrDefault(x => x.TaskId == id));
@@ -43,5 +43,5 @@
     }
 
-    public IEnumerable<DT.Task> GetJobs(Expression<Func<Task, bool>> predicate) {
+    public IEnumerable<DT.Task> GetTasks(Expression<Func<Task, bool>> predicate) {
       using (var db = CreateContext()) {
         return db.Tasks.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
@@ -49,5 +49,5 @@
     }
 
-    public Guid AddJob(DT.Task dto) {
+    public Guid AddTask(DT.Task dto) {
       using (var db = CreateContext()) {
         var entity = DT.Convert.ToEntity(dto);
@@ -62,5 +62,5 @@
     }
 
-    public void UpdateJob(DT.Task dto) {
+    public void UpdateTask(DT.Task dto) {
       using (var db = CreateContext()) {
         var entity = db.Tasks.FirstOrDefault(x => x.TaskId == dto.Id);
@@ -76,20 +76,20 @@
     }
 
-    public void DeleteJob(Guid id) {
+    public void DeleteTask(Guid id) {
       using (var db = CreateContext()) {
         var entity = db.Tasks.FirstOrDefault(x => x.TaskId == id);
         if (entity != null) db.Tasks.DeleteOnSubmit(entity);
-        db.SubmitChanges(); // JobData and child jobs are deleted by db-trigger
+        db.SubmitChanges(); // taskData and child tasks are deleted by db-trigger
       }
     }
 
     /// <summary>
-    /// returns all parent jobs which are waiting for their child jobs to finish
+    /// returns all parent tasks which are waiting for their child tasks to finish
     /// </summary>
-    /// <param name="resourceIds">list of resourceids which for which the jobs should be valid</param>
-    /// <param name="count">maximum number of jobs to return</param>
-    /// <param name="finished">if true, all parent jobs which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param>
+    /// <param name="resourceIds">list of resourceids which for which the task should be valid</param>
+    /// <param name="count">maximum number of task to return</param>
+    /// <param name="finished">if true, all parent task which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param>
     /// <returns></returns>
-    public IEnumerable<DT.Task> GetParentJobs(IEnumerable<Guid> resourceIds, int count, bool finished) {
+    public IEnumerable<DT.Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished) {
       using (var db = CreateContext()) {
         var query = from ar in db.AssignedResources
@@ -103,5 +103,5 @@
                                || child.State == TaskState.Aborted
                                || child.State == TaskState.Failed).All(x => x)
-                       && (from child in db.Tasks // avoid returning WaitForChildJobs jobs where no child-jobs exist (yet)
+                       && (from child in db.Tasks // avoid returning WaitForChildTasks task where no child-task exist (yet)
                            where child.ParentTaskId == ar.Task.TaskId
                            select child).Count() > 0
@@ -112,8 +112,8 @@
     }
 
-    public IEnumerable<DT.Task> GetWaitingJobs(DT.Slave slave, int count) {
+    public IEnumerable<DT.Task> GetWaitingTasks(DT.Slave slave, int count) {
       using (var db = CreateContext()) {
         var resourceIds = GetParentResources(slave.Id).Select(r => r.Id);
-        var waitingParentJobs = GetParentJobs(resourceIds, count, false);
+        var waitingParentJobs = GetParentTasks(resourceIds, count, false);
         if (count > 0 && waitingParentJobs.Count() >= count) return waitingParentJobs.Take(count).ToArray();
 
@@ -124,18 +124,18 @@
                        && ar.Task.CoresNeeded <= slave.FreeCores
                        && ar.Task.MemoryNeeded <= slave.FreeMemory
-                    orderby ar.Task.Priority descending, db.Random() // take random job to avoid the race condition that occurs when this method is called concurrently (the same job would be returned)
+                    orderby ar.Task.Priority descending, db.Random() // take random task to avoid the race condition that occurs when this method is called concurrently (the same task would be returned)
                     select DT.Convert.ToDto(ar.Task);
-        var waitingJobs = (count == 0 ? query : query.Take(count)).ToArray();
-        return waitingJobs.Union(waitingParentJobs).OrderByDescending(x => x.Priority);
-      }
-    }
-
-    public DT.Task UpdateJobState(Guid jobId, TaskState jobState, Guid? slaveId, Guid? userId, string exception) {
-      using (var db = CreateContext()) {
-        var job = db.Tasks.SingleOrDefault(x => x.TaskId == jobId);
-        job.State = jobState;
+        var waitingTasks = (count == 0 ? query : query.Take(count)).ToArray();
+        return waitingTasks.Union(waitingParentJobs).OrderByDescending(x => x.Priority);
+      }
+    }
+
+    public DT.Task UpdateTaskState(Guid taskId, TaskState taskState, Guid? slaveId, Guid? userId, string exception) {
+      using (var db = CreateContext()) {
+        var job = db.Tasks.SingleOrDefault(x => x.TaskId == taskId);
+        job.State = taskState;
         db.StateLogs.InsertOnSubmit(new StateLog {
-          TaskId = jobId,
-          State = jobState,
+          TaskId = taskId,
+          State = taskState,
           SlaveId = slaveId,
           UserId = userId,
@@ -144,5 +144,5 @@
         });
         db.SubmitChanges();
-        job = db.Tasks.SingleOrDefault(x => x.TaskId == jobId);
+        job = db.Tasks.SingleOrDefault(x => x.TaskId == taskId);
         return DT.Convert.ToDto(job);
       }
@@ -151,5 +151,5 @@
 
     #region TaskData Methods
-    public DT.TaskData GetJobData(Guid id) {
+    public DT.TaskData GetTaskData(Guid id) {
       using (var db = CreateContext(true)) {
         return DT.Convert.ToDto(db.TaskDatas.SingleOrDefault(x => x.TaskId == id));
@@ -157,5 +157,5 @@
     }
 
-    public IEnumerable<DT.TaskData> GetJobDatas(Expression<Func<TaskData, bool>> predicate) {
+    public IEnumerable<DT.TaskData> GetTaskDatas(Expression<Func<TaskData, bool>> predicate) {
       using (var db = CreateContext(true)) {
         return db.TaskDatas.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
@@ -163,5 +163,5 @@
     }
 
-    public Guid AddJobData(DT.TaskData dto) {
+    public Guid AddTaskData(DT.TaskData dto) {
       using (var db = CreateContext(true)) {
         var entity = DT.Convert.ToEntity(dto);
@@ -172,5 +172,5 @@
     }
 
-    public void UpdateJobData(DT.TaskData dto) {
+    public void UpdateTaskData(DT.TaskData dto) {
       using (var db = CreateContext(true)) {
         var entity = db.TaskDatas.FirstOrDefault(x => x.TaskId == dto.TaskId);
@@ -181,5 +181,5 @@
     }
 
-    public void DeleteJobData(Guid id) {
+    public void DeleteTaskData(Guid id) {
       using (var db = CreateContext()) {
         var entity = db.TaskDatas.FirstOrDefault(x => x.TaskId == id); // check if all the byte[] is loaded into memory here. otherwise work around to delete without loading it
@@ -231,5 +231,5 @@
 
     #region Job Methods
-    public DT.Job GetHiveExperiment(Guid id) {
+    public DT.Job GetJob(Guid id) {
       using (var db = CreateContext()) {
         return AddStatsToExperiment(db, DT.Convert.ToDto(db.Jobs.SingleOrDefault(x => x.JobId == id)));
@@ -248,5 +248,5 @@
     }
 
-    public IEnumerable<DT.Job> GetHiveExperiments(Expression<Func<Job, bool>> predicate) {
+    public IEnumerable<DT.Job> GetJobs(Expression<Func<Job, bool>> predicate) {
       using (var db = CreateContext()) {
         return db.Jobs.Where(predicate).Select(x => AddStatsToExperiment(db, DT.Convert.ToDto(x))).ToArray();
@@ -254,5 +254,5 @@
     }
 
-    public Guid AddHiveExperiment(DT.Job dto) {
+    public Guid AddJob(DT.Job dto) {
       using (var db = CreateContext()) {
         var entity = DT.Convert.ToEntity(dto);
@@ -263,5 +263,5 @@
     }
 
-    public void UpdateHiveExperiment(DT.Job dto) {
+    public void UpdateJob(DT.Job dto) {
       using (var db = CreateContext()) {
         var entity = db.Jobs.FirstOrDefault(x => x.JobId == dto.Id);
@@ -272,5 +272,5 @@
     }
 
-    public void DeleteHiveExperiment(Guid id) {
+    public void DeleteJob(Guid id) {
       using (var db = CreateContext()) {
         var entity = db.Jobs.FirstOrDefault(x => x.JobId == id);
@@ -282,11 +282,11 @@
 
     #region JobPermission Methods
-    public DT.JobPermission GetHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId) {
-      using (var db = CreateContext()) {
-        return DT.Convert.ToDto(db.JobPermissions.SingleOrDefault(x => x.JobId == hiveExperimentId && x.GrantedUserId == grantedUserId));
-      }
-    }
-
-    public IEnumerable<DT.JobPermission> GetHiveExperimentPermissions(Expression<Func<JobPermission, bool>> predicate) {
+    public DT.JobPermission GetJobPermission(Guid jobId, Guid grantedUserId) {
+      using (var db = CreateContext()) {
+        return DT.Convert.ToDto(db.JobPermissions.SingleOrDefault(x => x.JobId == jobId && x.GrantedUserId == grantedUserId));
+      }
+    }
+
+    public IEnumerable<DT.JobPermission> GetJobPermissions(Expression<Func<JobPermission, bool>> predicate) {
       using (var db = CreateContext()) {
         return db.JobPermissions.Where(predicate).Select(x => DT.Convert.ToDto(x)).ToArray();
@@ -294,5 +294,5 @@
     }
 
-    public void AddHiveExperimentPermission(DT.JobPermission dto) {
+    public void AddJobPermission(DT.JobPermission dto) {
       using (var db = CreateContext()) {
         var entity = DT.Convert.ToEntity(dto);
@@ -302,5 +302,5 @@
     }
 
-    public void UpdateHiveExperimentPermission(DT.JobPermission dto) {
+    public void UpdateJobPermission(DT.JobPermission dto) {
       using (var db = CreateContext()) {
         var entity = db.JobPermissions.FirstOrDefault(x => x.JobId == dto.JobId && x.GrantedUserId == dto.GrantedUserId);
@@ -311,7 +311,7 @@
     }
 
-    public void DeleteHiveExperimentPermission(Guid hiveExperimentId, Guid grantedUserId) {
-      using (var db = CreateContext()) {
-        var entity = db.JobPermissions.FirstOrDefault(x => x.JobId == hiveExperimentId && x.GrantedUserId == grantedUserId);
+    public void DeleteJobPermission(Guid jobId, Guid grantedUserId) {
+      using (var db = CreateContext()) {
+        var entity = db.JobPermissions.FirstOrDefault(x => x.JobId == jobId && x.GrantedUserId == grantedUserId);
         if (entity != null) db.JobPermissions.DeleteOnSubmit(entity);
         db.SubmitChanges();
@@ -322,21 +322,21 @@
     /// Sets the permissions for a experiment. makes sure that only one permission per user exists.
     /// </summary>
-    public void SetHiveExperimentPermission(Guid hiveExperimentId, Guid grantedByUserId, Guid grantedUserId, Permission permission) {
-      using (var db = CreateContext()) {
-        JobPermission hiveExperimentPermission = db.JobPermissions.SingleOrDefault(x => x.JobId == hiveExperimentId && x.GrantedUserId == grantedUserId);
-        if (hiveExperimentPermission != null) {
+    public void SetJobPermission(Guid jobId, Guid grantedByUserId, Guid grantedUserId, Permission permission) {
+      using (var db = CreateContext()) {
+        JobPermission jobPermission = db.JobPermissions.SingleOrDefault(x => x.JobId == jobId && x.GrantedUserId == grantedUserId);
+        if (jobPermission != null) {
           if (permission == Permission.NotAllowed) {
             // not allowed, delete
-            db.JobPermissions.DeleteOnSubmit(hiveExperimentPermission);
+            db.JobPermissions.DeleteOnSubmit(jobPermission);
           } else {
             // update
-            hiveExperimentPermission.Permission = permission;
-            hiveExperimentPermission.GrantedByUserId = grantedByUserId; // update grantedByUserId, always the last "granter" is stored
+            jobPermission.Permission = permission;
+            jobPermission.GrantedByUserId = grantedByUserId; // update grantedByUserId, always the last "granter" is stored
           }
         } else {
           // insert
           if (permission != Permission.NotAllowed) {
-            hiveExperimentPermission = new JobPermission() { JobId = hiveExperimentId, GrantedByUserId = grantedByUserId, GrantedUserId = grantedUserId, Permission = permission };
-            db.JobPermissions.InsertOnSubmit(hiveExperimentPermission);
+            jobPermission = new JobPermission() { JobId = jobId, GrantedByUserId = grantedByUserId, GrantedUserId = grantedUserId, Permission = permission };
+            db.JobPermissions.InsertOnSubmit(jobPermission);
           }
         }
@@ -613,23 +613,23 @@
 
     #region Authorization Methods
+    public Permission GetPermissionForTask(Guid taskId, Guid userId) {
+      using (var db = CreateContext()) {
+        return GetPermissionForJob(GetJobForTask(taskId), userId);
+      }
+    }
+
     public Permission GetPermissionForJob(Guid jobId, Guid userId) {
       using (var db = CreateContext()) {
-        return GetPermissionForExperiment(GetExperimentForJob(jobId), userId);
-      }
-    }
-
-    public Permission GetPermissionForExperiment(Guid experimentId, Guid userId) {
-      using (var db = CreateContext()) {
-        Job hiveExperiment = db.Jobs.SingleOrDefault(x => x.JobId == experimentId);
-        if (hiveExperiment == null) return Permission.NotAllowed;
-        if (hiveExperiment.OwnerUserId == userId) return Permission.Full;
-        JobPermission permission = db.JobPermissions.SingleOrDefault(p => p.JobId == experimentId && p.GrantedUserId == userId);
+        Job job = db.Jobs.SingleOrDefault(x => x.JobId == jobId);
+        if (job == null) return Permission.NotAllowed;
+        if (job.OwnerUserId == userId) return Permission.Full;
+        JobPermission permission = db.JobPermissions.SingleOrDefault(p => p.JobId == jobId && p.GrantedUserId == userId);
         return permission != null ? permission.Permission : Permission.NotAllowed;
       }
     }
 
-    public Guid GetExperimentForJob(Guid jobId) {
-      using (var db = CreateContext()) {
-        return db.Tasks.Single(j => j.TaskId == jobId).JobId;
+    public Guid GetJobForTask(Guid taskId) {
+      using (var db = CreateContext()) {
+        return db.Tasks.Single(j => j.TaskId == taskId).JobId;
       }
     }
@@ -765,5 +765,5 @@
         }
 
-        // execution times only of finished jobs - necessary to compute efficieny
+        // execution times only of finished task - necessary to compute efficieny
         var executionTimesFinishedJobs = from job in db.Tasks
                                          where job.State == TaskState.Finished
@@ -778,5 +778,5 @@
         }
 
-        // start to end times only of finished jobs - necessary to compute efficiency
+        // start to end times only of finished task - necessary to compute efficiency
         var startToEndTimesFinishedJobs = from job in db.Tasks
                                           where job.State == TaskState.Finished
@@ -817,10 +817,10 @@
 
     #region Helpers
-    private void CollectChildJobs(HiveDataContext db, Guid parentJobId, List<Task> collection) {
-      var jobs = db.Tasks.Where(j => j.ParentTaskId == parentJobId);
-      foreach (var job in jobs) {
-        collection.Add(job);
-        if (job.IsParentTask)
-          CollectChildJobs(db, job.TaskId, collection);
+    private void CollectChildTasks(HiveDataContext db, Guid parentTaskId, List<Task> collection) {
+      var tasks = db.Tasks.Where(j => j.ParentTaskId == parentTaskId);
+      foreach (var task in tasks) {
+        collection.Add(task);
+        if (task.IsParentTask)
+          CollectChildTasks(db, task.TaskId, collection);
       }
     }
