Ignore:
Timestamp:
12/18/17 17:38:05 (5 years ago)
Author:
jzenisek
Message:

#2839 added checks for the administration of project-resource assignments

File:
1 edited

Legend:

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

    r15530 r15540  
    6161      return DataContext.ExecuteQuery<Guid>(GetAllGrantedResourceIdsByProjectIdQueryString, projectId);
    6262    }
     63
     64    public IEnumerable<Guid> GetAllGrantedResourceIdsOfOwnedParentProjects(Guid projectId, Guid userId) {
     65      return DataContext.ExecuteQuery<Guid>(GetAllGrantedResourceIdsOfOwnedParentProjectsQueryString, projectId, userId);
     66    }
     67
    6368
    6469    #region Compiled queries
     
    140145    WHERE apr.ProjectId = {0}
    141146    ";
     147    private const string GetAllGrantedResourceIdsOfOwnedParentProjectsQueryString = @"
     148      WITH pbranch AS
     149      (
     150        SELECT ProjectId, ParentProjectId
     151        FROM [Project]
     152        UNION ALL
     153        SELECT pb.ProjectId, p.ParentProjectId
     154        FROM [Project] p
     155        JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pb.ParentProjectId <> pb.ProjectId
     156      ),
     157      rtree AS
     158      (
     159        SELECT ResourceId, ParentResourceId
     160        FROM [Resource]
     161        UNION ALL
     162        SELECT rt.ResourceId, r.ParentResourceId
     163        FROM [Resource] r
     164        JOIN rtree rt ON rt.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rt.ParentResourceId <> rt.ResourceId
     165      )
     166      SELECT DISTINCT rtree.ResourceId
     167      FROM pbranch, rtree, [Project] pro, [AssignedProjectResource] apr
     168      WHERE pbranch.ProjectId = {0}
     169      AND pbranch.ParentProjectId = pro.ProjectId
     170      AND pro.OwnerUserId = {1}
     171      AND pbranch.ParentProjectId = apr.ProjectId
     172      AND apr.ResourceId = rtree.ParentResourceId
     173    ";
    142174    #endregion
    143175  }
Note: See TracChangeset for help on using the changeset viewer.