Free cookie consent management tool by TermsFeed Policy Generator

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

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

Location:
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3
Files:
4 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  }
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ProjectDao.cs

    r15527 r15540  
    153153      FROM pbranch
    154154    ";
     155    private const string GetNearestOwnedParentProjectByIdQuery = @"
     156      WITH pbranch AS
     157      (
     158        SELECT ProjectId, ParentProjectId, CAST(ProjectId AS NVARCHAR(MAX)) Path, 1 Distance
     159        FROM [Project]
     160        WHERE ProjectId = {0}
     161        UNION ALL
     162        SELECT pb.ProjectId, p.ParentProjectId, pb.Path + N', ' + CAST(pb.ProjectId AS NVARCHAR(MAX)), pb.Distance + 1
     163        FROM [Project] p
     164        JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pb.ParentProjectId <> pb.ProjectId
     165      )
     166      SELECT TOP(1) pro.*
     167      FROM pbranch, [Project] pro
     168      WHERE pbranch.ParentProjectId = pro.ProjectId
     169      AND pro.OwnerUserId = {1}
     170      ORDER BY pbranch.Distance
     171    ";
     172    private const string GetFarestOwnedParentProjectIdByIdQuery = @"
     173      WITH pbranch AS
     174      (
     175        SELECT ProjectId, ParentProjectId, CAST(ProjectId AS NVARCHAR(MAX)) Path, 1 Distance
     176        FROM [Project]
     177        WHERE ProjectId = {0}
     178        UNION ALL
     179        SELECT pb.ProjectId, p.ParentProjectId, pb.Path + N', ' + CAST(pb.ProjectId AS NVARCHAR(MAX)), pb.Distance + 1
     180        FROM [Project] p
     181        JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pb.ParentProjectId <> pb.ProjectId
     182      )
     183      SELECT TOP(1) pro.*
     184      FROM pbranch, [Project] pro
     185      WHERE pbranch.ParentProjectId = pro.ProjectId
     186      AND pro.OwnerUserId = {1}
     187      ORDER BY pbranch.Distance DESC
     188    ";
    155189    #endregion
    156190  }
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourceDao.cs

    r15527 r15540  
    3535    public Resource GetByName(string name) {
    3636      return GetByNameQuery(DataContext, name);
     37    }
     38
     39    public bool CheckExistence(IEnumerable<Guid> ids) {
     40      string paramResourceIds = string.Join(",", ids.Select(x => string.Format("'{0}'", x)));
     41      if (!string.IsNullOrWhiteSpace(paramResourceIds)) {
     42        string queryString = string.Format(CountExistenceQuery, paramResourceIds);
     43        return DataContext.ExecuteQuery<int>(queryString).Count() == ids.Count();
     44      }
     45      return false;
    3746    }
    3847
     
    8089
    8190    #region String queries
     91    private const string CountExistenceQuery = @"
     92      SELECT COUNT(DISTINCT r.ResourceId)
     93      FROM [Resource] r
     94      WHERE r.ResourceId IN ({0})
     95    ";
    8296    private const string GetChildResourcesByIdQuery = @"
    8397      WITH rtree AS
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/HeuristicLab.Services.Hive.DataAccess-3.3.csproj

    r15508 r15540  
    104104  <ItemGroup>
    105105    <None Include="Plugin.cs.frame" />
     106    <Compile Include="Daos\AssignedJobResourceDao.cs" />
    106107    <Compile Include="Daos\AssignedProjectResourceDao.cs" />
    107108    <Compile Include="Daos\AssignedTaskResourceDao.cs" />
     
    123124    <Compile Include="Daos\RequiredPluginDao.cs" />
    124125    <Compile Include="Daos\ResourceDao.cs" />
    125     <Compile Include="Daos\ResourcePermissionDao.cs" />
    126126    <Compile Include="Daos\SlaveDao.cs" />
    127127    <Compile Include="Daos\SlaveGroupDao.cs" />
Note: See TracChangeset for help on using the changeset viewer.