Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/14/17 15:08:38 (5 years ago)
Author:
jzenisek
Message:

#2839

  • updated dbml (removed ResourcePermission and ResourceIds in Job-Table)
  • updated Resource and Project Daos
File:
1 edited

Legend:

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

    r15508 r15527  
    3333    }
    3434
    35     public IEnumerable<Project> GetProjectsByChildId(Guid id) {
    36       return DataContext.ExecuteQuery<Project>(GetProjectsByChildIdQuery, id);
     35    public IEnumerable<Project> GetChildProjectsById(Guid id) {
     36      return DataContext.ExecuteQuery<Project>(GetChildProjectsByIdQuery, id);
    3737    }
    3838
    39     public IEnumerable<Guid> GetProjectIdsByChildId(Guid id) {
    40       return DataContext.ExecuteQuery<Guid>(GetProjectIdsByChildIdQuery, id);
     39    public IEnumerable<Guid> GetChildProjectIdsById(Guid id) {
     40      return DataContext.ExecuteQuery<Guid>(GetChildProjectIdsByIdQuery, id);
     41    }
     42
     43    public IEnumerable<Project> GetParentProjectsById(Guid id) {
     44      return DataContext.ExecuteQuery<Project>(GetParentProjectsByIdQuery, id);
     45    }
     46
     47    public IEnumerable<Guid> GetParentProjectIdsById(Guid id) {
     48      return DataContext.ExecuteQuery<Guid>(GetParentProjectIdsByIdQuery, id);
     49    }
     50
     51    public IEnumerable<Project> GetCurrentAndParentProjectsById(Guid id) {
     52      return DataContext.ExecuteQuery<Project>(GetCurrentAndParentProjectsByIdQuery, id);
     53    }
     54
     55    public IEnumerable<Guid> GetCurrentAndParentProjectIdsById(Guid id) {
     56      return DataContext.ExecuteQuery<Guid>(GetCurrentAndParentProjectIdsByIdQuery, id);
    4157    }
    4258
     
    5066
    5167    #region String queries
    52     private const string GetProjectsByChildIdQuery = @"
    53       WITH ptree AS
     68    private const string GetChildProjectsByIdQuery = @"
     69      WITH ptree AS
    5470      (
    5571        SELECT ProjectId, ParentProjectId
    56         FROM [Project]
     72        FROM [Project]
    5773        UNION ALL
    5874        SELECT pt.ProjectId, p.ParentProjectId
     
    6278      SELECT DISTINCT pro.*
    6379      FROM ptree, [Project] pro
    64       WHERE ptree.ProjectId = {0}
    65       AND ptree.ParentProjectId = pro.ProjectId
     80      WHERE ptree.ParentProjectId = {0}
     81      AND ptree.ProjectId = pro.ProjectId
    6682    ";
    67     private const string GetProjectIdsByChildIdQuery = @"
     83    private const string GetChildProjectIdsByIdQuery = @"
    6884      WITH ptree AS
     85      (
     86        SELECT ProjectId, ParentProjectId
     87        FROM [Project]
     88        UNION ALL
     89        SELECT pt.ProjectId, r.ParentProjectId
     90        FROM [Project] r
     91        JOIN ptree pt ON pt.ParentProjectId = r.ProjectId AND r.ParentProjectId <> r.ProjectId AND pt.ParentProjectId <> pt.ProjectId
     92      )
     93      SELECT DISTINCT ptree.ProjectId
     94      FROM ptree
     95      WHERE ptree.ParentProjectId = {0}
     96    ";
     97    private const string GetParentProjectsByIdQuery = @"
     98      WITH pbranch AS
    6999      (
    70100        SELECT ProjectId, ParentProjectId
    71101        FROM [Project]
    72102        UNION ALL
    73         SELECT pt.ProjectId, p.ParentProjectId
     103        SELECT pb.ProjectId, p.ParentProjectId
    74104        FROM [Project] p
    75         JOIN ptree pt ON pt.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pt.ParentProjectId <> pt.ProjectId
     105        JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pb.ParentProjectId <> pb.ProjectId
    76106      )
    77       SELECT DISTINCT ptree.ParentProjectId
    78       FROM ptree
    79       WHERE ptree.ProjectId = {0}
     107      SELECT DISTINCT pro.*
     108      FROM pbranch, [Project] pro
     109      WHERE pbranch.ProjectId = {0}
     110      AND pbranch.ParentProjectId = pro.ProjectId
     111    ";
     112    private const string GetParentProjectIdsByIdQuery = @"
     113      WITH pbranch AS
     114      (
     115        SELECT ProjectId, ParentProjectId
     116        FROM [Project]
     117        UNION ALL
     118        SELECT pb.ProjectId, p.ParentProjectId
     119        FROM [Project] p
     120        JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pb.ParentProjectId <> pb.ProjectId
     121      )
     122      SELECT DISTINCT pbranch.ParentProjectId
     123      FROM pbranch
     124      WHERE pbranch.ProjectId = {0}
     125    ";
     126    private const string GetCurrentAndParentProjectsByIdQuery = @"
     127      WITH pbranch AS
     128      (
     129        SELECT ProjectId, ParentProjectId
     130        FROM Project
     131        WHERE ProjectId = {0}
     132        UNION ALL
     133        SELECT p.ProjectId, p.ParentProjectId
     134        FROM Project p
     135        JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId
     136      )
     137      SELECT DISTINCT pro.*
     138      FROM pbranch, Project pro
     139      WHERE pbranch.ProjectId = pro.ProjectId
     140    ";
     141    private const string GetCurrentAndParentProjectIdsByIdQuery = @"
     142      WITH pbranch AS
     143      (
     144        SELECT ProjectId, ParentProjectId
     145        FROM Project
     146        WHERE ProjectId = {0}
     147        UNION ALL
     148        SELECT p.ProjectId, p.ParentProjectId
     149        FROM Project p
     150        JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId
     151      )
     152      SELECT DISTINCT pbranch.ProjectId
     153      FROM pbranch
    80154    ";
    81155    #endregion
Note: See TracChangeset for help on using the changeset viewer.