Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15978


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
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectJobsView.cs

    r15969 r15978  
    144144
    145145    private StringMatrix CreateValueMatrix() {
     146      if (Content == null || Content.Id == Guid.Empty)
     147        return new StringMatrix();
     148
    146149      var jobs = HiveAdminClient.Instance.Jobs[Content.Id];
    147150      var resources = HiveAdminClient.Instance.Resources;
     
    172175      if (InvokeRequired) Invoke((Action)UpdateJobs);
    173176      else {
    174         StringMatrix matrix = null;
    175         if(Content != null) {
    176           matrix = CreateValueMatrix();
     177        if(Content != null && Content.Id != null && Content.Id != Guid.Empty) {
     178          var matrix = CreateValueMatrix();
     179          matrixView.Content = matrix;
     180          if(matrix != null) {
     181            foreach (DataGridViewRow row in matrixView.DataGridView.Rows) {
     182              string val = ((string)row.Cells[0].Value);
     183              if (val == JobState.Online.ToString()) {
     184                row.DefaultCellStyle.BackColor = onlineStatusColor;
     185              } else if (val == JobState.StatisticsPending.ToString()) {
     186                row.DefaultCellStyle.BackColor = statisticsPendingStatusColor;
     187              } else if (val == JobState.DeletionPending.ToString()) {
     188                row.DefaultCellStyle.BackColor = deletionPendingStatusColor;
     189              }
     190            }
     191
     192            matrixView.DataGridView.AutoResizeColumns();
     193            matrixView.DataGridView.Columns[0].MinimumWidth = 90;
     194            matrixView.DataGridView.Columns[1].MinimumWidth = 108;
     195          }
    177196        } else {
    178197          refreshButton.Enabled = false;
    179198          removeButton.Enabled = false;
    180         }
    181         matrixView.Content = matrix;
    182        
    183         foreach(DataGridViewRow row in matrixView.DataGridView.Rows) {
    184           string val = ((string)row.Cells[0].Value);
    185           if (val == JobState.Online.ToString()) {
    186             row.DefaultCellStyle.BackColor = onlineStatusColor;
    187           } else if(val == JobState.StatisticsPending.ToString()) {
    188             row.DefaultCellStyle.BackColor = statisticsPendingStatusColor;
    189           } else if(val == JobState.DeletionPending.ToString()) {
    190             row.DefaultCellStyle.BackColor = deletionPendingStatusColor;
    191           }
    192         }
    193 
    194         matrixView.DataGridView.AutoResizeColumns();
    195         matrixView.DataGridView.Columns[0].MinimumWidth = 90;
    196         matrixView.DataGridView.Columns[1].MinimumWidth = 108;
     199          matrixView.Content = null;
     200        }
    197201      }
    198202    }
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectPermissionsView.cs

    r15955 r15978  
    143143    #region Helpers
    144144    private void UpdatePermissionList() {
     145      AccessClient.Instance.Refresh();
     146
    145147      UpdateUserGroupGenealogy();
    146148      UpdateAssignedPermissions();
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs

    r15955 r15978  
    117117          SetAssignedProjectResources(Content.Id, newAssignedResources.Select(x => x.Id), false, true, false);
    118118        });
     119      HiveAdminClient.Instance.Refresh();
    119120      UpdateResourceTree();
    120121    }
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs

    r15953 r15978  
    198198      this.viewHost.Caption = "View";
    199199      this.viewHost.Content = null;
    200       this.viewHost.Enabled = false;
     200      this.viewHost.Enabled = true;
    201201      this.viewHost.Location = new System.Drawing.Point(6, 6);
    202202      this.viewHost.Name = "viewHost";
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r15953 r15978  
    123123      btnRemoveGroup.Enabled = !locked;
    124124      btnSave.Enabled = !locked;
    125       viewHost.Locked = locked;
     125      viewHost.Enabled = true;
     126      //viewHost.Locked = locked;
     127      viewHost.Locked = false;
     128      viewHost.ReadOnly = false;
    126129      scheduleView.Locked = locked;
    127       scheduleView.SetEnabledStateOfSchedule(!scheduleLocked);
     130      //scheduleView.SetEnabledStateOfSchedule(!scheduleLocked);
    128131    }
    129132    #endregion
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs

    r15956 r15978  
    234234    }
    235235
    236     public virtual void SetEnabledStateOfSchedule(bool state) {
    237       if (InvokeRequired) {
    238         Invoke(new Action(() => SetEnabledStateOfSchedule(state)));
    239       } else {
    240         if (Content == null || Locked || ReadOnly) state = false;
    241         //groupBox1.Enabled = state;
    242         btnClearCal.Enabled = state;
    243         btnSaveCal.Enabled = state;
    244       }
    245     }
     236    //public virtual void SetEnabledStateOfSchedule(bool state) {
     237    //  if (InvokeRequired) {
     238    //    Invoke(new Action(() => SetEnabledStateOfSchedule(state)));
     239    //  } else {
     240    //    if (Content == null || Locked || ReadOnly) state = false;
     241    //    //groupBox1.Enabled = state;
     242    //    btnClearCal.Enabled = state;
     243    //    btnSaveCal.Enabled = state;
     244    //  }
     245    //}
    246246
    247247    private void btnClearCal_Click(object sender, System.EventArgs e) {
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.cs

    r15422 r15978  
    6060    protected override void SetEnabledStateOfControls() {
    6161      base.SetEnabledStateOfControls();
    62       disposableCheckBox.Enabled = Content != null;
     62      bool enabled = Content != null && !Locked;
     63      disposableCheckBox.Enabled = enabled;
    6364    }
    6465    #endregion
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.Designer.cs

    r15956 r15978  
    147147      this.projectsTreeView.TabIndex = 3;
    148148      this.projectsTreeView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.projectsTreeView_MouseDoubleClick);
     149      this.projectsTreeView.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.projectsTreeView_BeforeSelect);
    149150      this.projectsTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.projectsTreeView_AfterSelect);
    150151      //
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r15966 r15978  
    227227    }
    228228
     229    private void projectsTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) {
     230      var node = (Project)e.Node.Tag;
     231      if (HiveClient.Instance.DisabledParentProjects.Contains(node)) {
     232        e.Cancel = true;
     233      }
     234    }
     235
    229236    private void projectsTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
    230237      var node = (Project)e.Node.Tag;
    231      
     238
    232239      if (node == null) {
    233240        projectsTreeView.SelectedNode = null;
     241      } else if (HiveClient.Instance.DisabledParentProjects.Contains(node)) {
     242        return;
    234243      } else {
    235244        ResetTreeNodes(projectsTreeView.Nodes);
    236245        e.Node.BackColor = selectedBackColor;
    237246        e.Node.ForeColor = selectedForeColor;
    238        
    239         if(node.Id == projectId) {
     247
     248        if (node.Id == projectId) {
    240249          e.Node.Text += CURRENT_SELECTION_TAG;
    241         } else if(projectId == null || projectId == Guid.Empty) {
     250        } else if (projectId == null || projectId == Guid.Empty) {
    242251          e.Node.Text += NEW_SELECTION_TAG;
    243252        } else {
     
    245254        }
    246255
    247        
     256
    248257      }
    249258      SelectedProject = node;
     
    313322      if (!projects.Any()) return;
    314323
     324      var disabledParentProjects = HiveClient.Instance.DisabledParentProjects;
    315325      // select all top level projects (withouth parent, or without any ancestor within current project collection)
    316326      var mainProjects = new HashSet<Project>(projects.Where(x => x.ParentProjectId == null));
    317       var parentedMainProjects = new HashSet<Project>(projects
    318         .Where(x => x.ParentProjectId.HasValue
    319         && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value)
    320         && !projects.SelectMany(y => HiveClient.Instance.ProjectAncestors[y.Id]).Contains(x.ParentProjectId.Value)));
    321       mainProjects.UnionWith(parentedMainProjects);
    322       var subProbjects = new HashSet<Project>(projects.Except(mainProjects));
    323       foreach(var p in subProbjects) {
    324         p.ParentProjectId = HiveClient.Instance.ProjectAncestors[p.Id].Where(x => projects.Select(y => y.Id).Contains(x)).FirstOrDefault();
    325       }
     327      //var parentedMainProjects = new HashSet<Project>(projects
     328      //  .Where(x => x.ParentProjectId.HasValue
     329      //  && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value)
     330      //  && !projects.SelectMany(y => HiveClient.Instance.ProjectAncestors[y.Id]).Contains(x.ParentProjectId.Value)));
     331      //mainProjects.UnionWith(parentedMainProjects);
     332      var mainDisabledParentProjects = new HashSet<Project>(disabledParentProjects.Where(x => x.ParentProjectId == null));
     333      mainProjects.UnionWith(mainDisabledParentProjects);
     334      var subProbjects = new HashSet<Project>(projects.Union(disabledParentProjects).Except(mainProjects));
     335      //foreach (var p in subProbjects) {
     336      //  p.ParentProjectId = HiveClient.Instance.ProjectAncestors[p.Id].Where(x => projects.Select(y => y.Id).Contains(x)).FirstOrDefault();
     337      //}
    326338
    327339      var stack = new Stack<Project>(mainProjects.OrderByDescending(x => x.Name));
     
    349361        newNode.SelectedImageIndex = newNode.ImageIndex;
    350362
    351         if (SelectedProject != null && SelectedProject.Id.Equals(newProject.Id)) {
     363        if(disabledParentProjects.Contains(newProject)) {
     364          newNode.Checked = false;
     365          newNode.ForeColor = grayTextColor;
     366        }
     367        else if (SelectedProject != null && SelectedProject.Id.Equals(newProject.Id)) {
    352368          newNode.BackColor = selectedBackColor;
    353369          newNode.ForeColor = selectedForeColor;
     
    673689      n.BackColor = Color.Transparent;
    674690      n.ForeColor = Color.Black;
     691
     692      if(n.Tag is Project) {
     693        var p = (Project)n.Tag;
     694        if(HiveClient.Instance.DisabledParentProjects.Select(x => x.Id).Contains(p.Id)) {
     695          n.ForeColor = grayTextColor;
     696        }
     697      }
    675698    }
    676699
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r15922 r15978  
    8787    }
    8888
     89    private Dictionary<Guid, string> projectNames;
     90    public Dictionary<Guid, string> ProjectNames {
     91      get { return projectNames; }
     92    }
     93
     94    private HashSet<Project> disabledParentProjects;
     95    public HashSet<Project> DisabledParentProjects {
     96      get { return disabledParentProjects; }
     97    }
    8998
    9099    private List<Plugin> onlinePlugins;
     
    127136        resources = new ItemList<Resource>();
    128137        jobs = new HiveItemCollection<RefreshableJob>();
     138        projectNames = new Dictionary<Guid, string>();
    129139
    130140        projectAncestors = new Dictionary<Guid, HashSet<Guid>>();
     
    138148          service.GetSlaves().ForEach(s => resources.Add(s));
    139149          service.GetJobs().ForEach(p => jobs.Add(new RefreshableJob(p)));
     150          projectNames = service.GetProjectNames();
    140151        });
    141152
    142153        UpdateResourceGenealogy();
    143154        UpdateProjectGenealogy();
     155        UpdateDisabledParentProjects();
    144156      }
    145157      catch {
     
    159171      try {
    160172        projects = new ItemList<Project>();
     173        projectNames = new Dictionary<Guid, string>();
    161174        resources = new ItemList<Resource>();
    162175
     
    170183          service.GetSlaveGroups().ForEach(g => resources.Add(g));
    171184          service.GetSlaves().ForEach(s => resources.Add(s));
     185          projectNames = service.GetProjectNames();
    172186        });
    173187
    174188        UpdateResourceGenealogy();
    175189        UpdateProjectGenealogy();
     190        UpdateDisabledParentProjects();
    176191      } catch {
    177192        projects = null;
     
    236251          projectDescendants[ancestor].Add(pa.Key);
    237252        }
     253      }
     254    }
     255
     256    private void UpdateDisabledParentProjects() {
     257      disabledParentProjects = new HashSet<Project>();
     258
     259      foreach (var pid in projects
     260        .Where(x => x.ParentProjectId.HasValue)
     261        .SelectMany(x => projectAncestors[x.Id]).Distinct()
     262        .Where(x => !projects.Select(y => y.Id).Contains(x))) {
     263        var p = new Project();
     264        p.Id = pid;
     265        p.ParentProjectId = projectAncestors[pid].FirstOrDefault();
     266        p.Name = projectNames[pid];
     267        disabledParentProjects.Add(p);
    238268      }
    239269    }
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs

    r15969 r15978  
    7575       
    7676        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
    77 
    7877    }
    7978   
     
    24612460        System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetProjectGenealogy();
    24622461       
     2462        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetProjectNames", ReplyAction="http://tempuri.org/IHiveService/GetProjectNamesResponse")]
     2463        System.Collections.Generic.Dictionary<System.Guid, string> GetProjectNames();
     2464       
    24632465        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/SaveProjectPermissions", ReplyAction="http://tempuri.org/IHiveService/SaveProjectPermissionsResponse")]
    24642466        void SaveProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds, bool reassign, bool cascading, bool reassignCascading);
     
    27892791        }
    27902792       
     2793        public System.Collections.Generic.Dictionary<System.Guid, string> GetProjectNames()
     2794        {
     2795            return base.Channel.GetProjectNames();
     2796        }
     2797       
    27912798        public void SaveProjectPermissions(System.Guid projectId, System.Collections.Generic.List<System.Guid> grantedUserIds, bool reassign, bool cascading, bool reassignCascading)
    27922799        {
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/SQL Scripts/Prepare Hive Database.sql

    r15737 r15978  
    104104REFERENCES [dbo].[Project] ([ProjectId])
    105105ON UPDATE CASCADE
    106 ON DELETE CASCADE
    107106GO
    108107
  • 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.