Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/02/18 15:51:17 (6 years ago)
Author:
jzenisek
Message:

#2839: applied several fixes:

  • show full project-path in project/resource selector
  • handle lost of project-ownership by not withdrawing permissions
  • update automatically after hand-down save
  • lock jobs for which statistics/deletion is pending
  • lock the disabled checkbox in ProjectResourcesView...
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

    r15969 r15978  
    4343    private const string NOT_AUTHORIZED_PROJECTRESOURCE = "Selected project is not authorized to access the requested resource";
    4444    private const string NOT_AUTHORIZED_USERPROJECT = "Current user is not authorized to access the requested project";
     45    private const string NO_JOB_UPDATE_POSSIBLE = "This job has already been flagged for deletion, thus, it can not be updated anymore.";
    4546
    4647    private static readonly DA.TaskState[] CompletedStates = { DA.TaskState.Finished, DA.TaskState.Aborted, DA.TaskState.Failed };
     
    465466            exists = false;
    466467            job = new DA.Job();
    467           }
     468          } else if(job.State != DA.JobState.Online) {
     469            throw new InvalidOperationException(NO_JOB_UPDATE_POSSIBLE);
     470          }
     471
     472
    468473          jobDto.CopyToEntity(job);
    469474
     
    539544
    540545      var pm = PersistenceManager;
    541       using (new PerformanceLogger("UpdateJobsState")) {
     546      using (new PerformanceLogger("UpdateJobStates")) {
    542547        var jobDao = pm.JobDao;
    543548        var projectDao = pm.ProjectDao;
     
    802807        pm.UseTransaction(() => {
    803808          var project = projectDao.GetById(projectDto.Id);
    804           if (project != null) { // update existent
     809          if (project != null) { // update existent project
    805810            var formerOwnerId = project.OwnerUserId;
    806811            projectDto.CopyToEntity(project);
     
    808813            // if owner has changed...
    809814            if(formerOwnerId != projectDto.OwnerUserId) {
    810               var formerPermissionItem = project.ProjectPermissions.Where(x => x.GrantedUserId == formerOwnerId).FirstOrDefault();
    811               if (formerPermissionItem != null) {
    812                 // remove permissions
    813                 project.ProjectPermissions.Remove(formerPermissionItem);
    814                 // remove jobs if former owner is no member of a still permitted group
    815                 var ugt = GetUserGroupTree();
    816                 var permittedGuids = new HashSet<Guid>(); // User- and Group-Guids
    817                 // get all member-Guids of all still permitted groups
    818                 foreach (var item in project.ProjectPermissions) {
    819                   permittedGuids.Add(item.GrantedUserId);
    820                   if(ugt.ContainsKey(item.GrantedUserId)) {
    821                     ugt[item.GrantedUserId].ToList().ForEach(x => permittedGuids.Add(x));
    822                   }
    823 
    824                   // check if former owner Guid is in Member-Guids
    825                   // if yes: do nothing, if not do:
    826                   if (!permittedGuids.Contains(formerOwnerId)) {
    827                     assignedJobResourceDao.DeleteByProjectIdAndUserIds(project.ProjectId, new List<Guid> { formerOwnerId });
    828                   }
    829                 }
     815              // OBSOLETE: former owner looses permission and project-related jobs
     816              //var formerPermissionItem = project.ProjectPermissions.Where(x => x.GrantedUserId == formerOwnerId).FirstOrDefault();
     817              //if (formerPermissionItem != null) {
     818              //  // remove permissions
     819              //  project.ProjectPermissions.Remove(formerPermissionItem);
     820              //  // remove jobs if former owner is no member of a still permitted group
     821              //  var ugt = GetUserGroupTree();
     822              //  var permittedGuids = new HashSet<Guid>(); // User- and Group-Guids
     823              //  // get all member-Guids of all still permitted groups
     824              //  foreach (var item in project.ProjectPermissions) {
     825              //    permittedGuids.Add(item.GrantedUserId);
     826              //    if(ugt.ContainsKey(item.GrantedUserId)) {
     827              //      ugt[item.GrantedUserId].ToList().ForEach(x => permittedGuids.Add(x));
     828              //    }
     829
     830              //    // check if former owner Guid is in Member-Guids
     831              //    // if yes: do nothing, if not do:
     832              //    if (!permittedGuids.Contains(formerOwnerId)) {
     833              //      assignedJobResourceDao.DeleteByProjectIdAndUserIds(project.ProjectId, new List<Guid> { formerOwnerId });
     834              //    }
     835              //  }
     836              //}
     837              // Add permission for new owner if not already done
     838              if(!project.ProjectPermissions
     839                .Select(pp => pp.GrantedUserId)
     840                .Contains(projectDto.OwnerUserId)) {
     841                project.ProjectPermissions.Add(new DA.ProjectPermission {
     842                  GrantedUserId = projectDto.OwnerUserId,
     843                  GrantedByUserId = UserManager.CurrentUserId
     844                });
    830845              }
    831               project.ProjectPermissions.Add(new DA.ProjectPermission {
    832                 GrantedUserId = projectDto.OwnerUserId,
    833                 GrantedByUserId = UserManager.CurrentUserId
    834               });
    835846            }
    836847
    837           } else { // save new
     848          } else { // save new project
    838849            var newProject = projectDao.Save(projectDto.ToEntity());
    839850            newProject.ProjectPermissions.Clear();
     
    953964          }
    954965          return projectAncestors;
     966        });
     967      }
     968    }
     969
     970    public IDictionary<Guid, string> GetProjectNames() {
     971      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     972      var pm = PersistenceManager;
     973      using (new PerformanceLogger("GetProjectNames")) {
     974        var projectDao = pm.ProjectDao;
     975        var projectNames = new Dictionary<Guid, string>();
     976        return pm.UseTransaction(() => {
     977          projectDao
     978            .GetAll().ToList()
     979            .ForEach(p=> projectNames.Add(p.ProjectId, p.Name));
     980          return projectNames;
    955981        });
    956982      }
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r15969 r15978  
    166166    [OperationContract]
    167167    IDictionary<Guid, HashSet<Guid>> GetProjectGenealogy();
     168
     169    [OperationContract]
     170    IDictionary<Guid, string> GetProjectNames();
    168171    #endregion
    169172
Note: See TracChangeset for help on using the changeset viewer.