Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/18 15:24:44 (7 years ago)
Author:
jzenisek
Message:

#2839

  • updated TaskDao towards independency of the formerly used Task-Resource assignment entity
  • updated several permission/assignment handling service methods for client
  • added AssignedJobResource DTO
Location:
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/AssignedProjectResourceDao.cs

    r15577 r15628  
    107107        WHERE ProjectId IN ({0})
    108108    ";
     109    // tested
    109110    private const string CheckProjectGrantedForResourcesQueryString = @"
    110111    WITH rtree AS
     
    125126      FROM rtree, [AssignedProjectResource] apr
    126127      WHERE rtree.ParentResourceId = apr.ResourceId
    127       AND apr.ProjectId = {0}
     128      AND apr.ProjectId = '{0}'
    128129      UNION
    129130      SELECT apr.ResourceId
    130131      FROM [AssignedProjectResource] apr
    131       WHERE apr.ProjectId = {0}
     132      WHERE apr.ProjectId = '{0}'
    132133    )
    133134    ";
     
    146147      WHERE rtree.ParentResourceId = apr.ResourceId
    147148      AND rtree.ResourceId = res.ResourceId
    148       AND apr.ProjectId = {0}
     149      AND apr.ProjectId = '{0}'
    149150      UNION
    150151      SELECT res.*
    151152      FROM [AssignedProjectResource] apr, [Resource] res
    152153      WHERE apr.ResourceId = res.ResourceId
    153       AND apr.ProjectId = {0}
     154      AND apr.ProjectId = '{0}'
    154155    ";
    155156    private const string GetAllGrantedResourceIdsByProjectIdQueryString = @"
     
    166167    FROM rtree, [AssignedProjectResource] apr
    167168    WHERE rtree.ParentResourceId = apr.ResourceId
    168     AND apr.ProjectId = {0}
     169    AND apr.ProjectId = '{0}'
    169170    UNION
    170171    SELECT apr.ResourceId
    171172    FROM [AssignedProjectResource] apr
    172     WHERE apr.ProjectId = {0}
     173    WHERE apr.ProjectId = '{0}'
    173174    ";
    174175    private const string GetAllGrantedResourceIdsOfOwnedParentProjectsQueryString = @"
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ProjectPermissionDao.cs

    r15577 r15628  
    7474    private const string DeleteByProjectIdAndGrantedUserIdsQueryString = @"
    7575      DELETE FROM [ProjectPermission]
    76       WHERE ProjectId = '{0}'
     76      WHERE ProjectId = {0}
    7777      AND GrantedUserId IN ({1});
    7878    ";
     
    8585      SELECT COUNT(pp.ProjectId)
    8686      FROM [ProjectPermission] pp
    87       WHERE pp.ProjectId = {0}
     87      WHERE pp.ProjectId = '{0}'
    8888      AND pp.GrantedUserId IN ({1})
    8989    ";
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/TaskDao.cs

    r15497 r15628  
    6464    /// <param name="finished">if true, all parent task which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param>
    6565    /// <returns></returns>
    66     public IEnumerable<Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished) {
     66    public IEnumerable<Task> GetParentTasks_Old(IEnumerable<Guid> resourceIds, int count, bool finished) {
    6767      var query = from ar in AssignedTaskResourceTable
    6868                  where resourceIds.Contains(ar.ResourceId)
     
    8383    }
    8484
     85    /// <summary>
     86    /// returns all parent tasks which are waiting for their child tasks to finish
     87    /// </summary>
     88    /// <param name="resourceIds">list of resourceids which for which the task should be valid</param>
     89    /// <param name="count">maximum number of task to return</param>
     90    /// <param name="finished">if true, all parent task which have FinishWhenChildJobsFinished=true are returned, otherwise only FinishWhenChildJobsFinished=false are returned</param>
     91    /// <returns></returns>
     92    public IEnumerable<Task> GetParentTasks(IEnumerable<Guid> resourceIds, int count, bool finished) {
     93      var query = from t in Table
     94                  where t.State == TaskState.Waiting
     95                    && t.IsParentTask
     96                    && !t.Job.AssignedJobResources.Select(x => x.ResourceId).Except(resourceIds).Any()
     97                    && t.FinishWhenChildJobsFinished == finished
     98                    && t.ChildJobs.Any()
     99                    && t.ChildJobs.All(x =>
     100                      x.State == TaskState.Finished
     101                      || x.State == TaskState.Aborted
     102                      || x.State == TaskState.Failed)
     103                  orderby t.Priority descending
     104                  select t;
     105      return count == 0 ? query.ToArray() : query.Take(count).ToArray();
     106    }
     107
    85108    public void UpdateExecutionTime(Guid taskId, double executionTime) {
    86109      DataContext.ExecuteCommand(UpdateExecutionTimeQuery, executionTime, DateTime.Now, taskId);
     
    96119
    97120    #region String queries
     121    private const string GetParentTasksQueryString = @"
     122      SELECT t.* FROM [Task] t, [Job] j, [AssignedJobResource] ajr
     123        WHERE t.IsParentTask = 1
     124        AND t.TaskState = 'Waiting'
     125        AND t.JobId = j.JobId
     126        AND j.JobId = ajr.JobId
     127        AND t.FinishWhenChildJobsFinished = 1
     128        ... TODO (not necessary)
     129    ";
    98130    private const string GetWaitingTasksQueryString = @"
    99131      WITH pr AS (
Note: See TracChangeset for help on using the changeset viewer.