Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/11/17 16:56:19 (5 years ago)
Author:
jzenisek
Message:

#2839 finalized permission checks in AddTask and revised implementation of ResourcePermission methods

File:
1 edited

Legend:

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

    r15379 r15508  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Data.Linq;
    2425using System.Linq;
     
    3233    }
    3334
     35    public IEnumerable<Project> GetProjectsByChildId(Guid id) {
     36      return DataContext.ExecuteQuery<Project>(GetProjectsByChildIdQuery, id);
     37    }
     38
     39    public IEnumerable<Guid> GetProjectIdsByChildId(Guid id) {
     40      return DataContext.ExecuteQuery<Guid>(GetProjectIdsByChildIdQuery, id);
     41    }
     42
    3443    #region Compiled queries
    3544    private static readonly Func<DataContext, Guid, Project> GetByIdQuery =
     
    3948         select project).SingleOrDefault());
    4049    #endregion
     50
     51    #region String queries
     52    private const string GetProjectsByChildIdQuery = @"
     53      WITH ptree AS
     54      (
     55        SELECT ProjectId, ParentProjectId
     56        FROM [Project]
     57        UNION ALL
     58        SELECT pt.ProjectId, p.ParentProjectId
     59        FROM [Project] p
     60        JOIN ptree pt ON pt.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pt.ParentProjectId <> pt.ProjectId
     61      )
     62      SELECT DISTINCT pro.*
     63      FROM ptree, [Project] pro
     64      WHERE ptree.ProjectId = {0}
     65      AND ptree.ParentProjectId = pro.ProjectId
     66    ";
     67    private const string GetProjectIdsByChildIdQuery = @"
     68      WITH ptree AS
     69      (
     70        SELECT ProjectId, ParentProjectId
     71        FROM [Project]
     72        UNION ALL
     73        SELECT pt.ProjectId, p.ParentProjectId
     74        FROM [Project] p
     75        JOIN ptree pt ON pt.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pt.ParentProjectId <> pt.ProjectId
     76      )
     77      SELECT DISTINCT ptree.ParentProjectId
     78      FROM ptree
     79      WHERE ptree.ProjectId = {0}
     80    ";
     81    #endregion
    4182  }
    4283}
Note: See TracChangeset for help on using the changeset viewer.