Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/20/18 11:52:33 (6 years ago)
Author:
jzenisek
Message:

#2839: updated genealogy computation for hive job administrator

Location:
branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r15908 r15913  
    795795      }
    796796    }
     797
     798    public IDictionary<Guid, HashSet<Guid>> GetProjectGenealogy() {
     799      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     800      var pm = PersistenceManager;
     801      using(new PerformanceLogger("GetProjectGenealogy")) {
     802        var projectDao = pm.ProjectDao;
     803        var projectAncestors = new Dictionary<Guid, HashSet<Guid>>();
     804        return pm.UseTransaction(() => {
     805          var projects = projectDao.GetAll().ToList();
     806          projects.ForEach(p => projectAncestors.Add(p.ProjectId, new HashSet<Guid>()));
     807          foreach (var p in projects) {
     808            var parentProject = p.ParentProject;
     809            while(parentProject != null) {
     810              projectAncestors[p.ProjectId].Add(parentProject.ProjectId);
     811              parentProject = parentProject.ParentProject;
     812            }
     813          }
     814          return projectAncestors;
     815        });
     816      }
     817    }
    797818    #endregion
    798819
     
    12451266    }
    12461267
     1268    public IDictionary<Guid, HashSet<Guid>> GetResourceGenealogy() {
     1269      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     1270      var pm = PersistenceManager;
     1271      using (new PerformanceLogger("GetResourceGenealogy")) {
     1272        var resourceDao = pm.ResourceDao;
     1273        var resourceAncestors = new Dictionary<Guid, HashSet<Guid>>();
     1274        return pm.UseTransaction(() => {
     1275          var resources = resourceDao.GetAll().ToList();
     1276          resources.ForEach(r => resourceAncestors.Add(r.ResourceId, new HashSet<Guid>()));
     1277         
     1278          foreach(var r in resources) {
     1279            var parentResource = r.ParentResource;
     1280            while(parentResource != null) {
     1281              resourceAncestors[r.ResourceId].Add(parentResource.ResourceId);
     1282              parentResource = parentResource.ParentResource;
     1283            }
     1284          }
     1285          return resourceAncestors;
     1286        });
     1287      }
     1288    }
     1289
    12471290    public void UpdateSlave(DT.Slave slaveDto) {
    12481291      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r15819 r15913  
    154154    [OperationContract]
    155155    IEnumerable<Project> GetProjectsForAdministration();
     156
     157    [OperationContract]
     158    IDictionary<Guid, HashSet<Guid>> GetProjectGenealogy();
    156159    #endregion
    157160
     
    211214    [OperationContract]
    212215    IEnumerable<SlaveGroup> GetSlaveGroupsForAdministration();
     216
     217    [OperationContract]
     218    IDictionary<Guid, HashSet<Guid>> GetResourceGenealogy();
    213219
    214220    [OperationContract]
Note: See TracChangeset for help on using the changeset viewer.