Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15768


Ignore:
Timestamp:
02/13/18 15:34:38 (7 years ago)
Author:
jzenisek
Message:

#2839: fixed cyclic-relation bug (part 2: HiveAdminClient)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs

    r15742 r15768  
    303303      return false;
    304304    }
     305
     306    public bool CheckParentChange(Project child, Project parent) {
     307      bool changeGranted = true;
     308
     309      // change is not granted, if the moved project is null
     310      // or the new parent is not stored yet
     311      // or there is not parental change
     312      if (child == null
     313        || (parent != null && parent.Id == Guid.Empty)
     314        || (parent != null && parent.Id == child.ParentProjectId)) {
     315        changeGranted = false;
     316      } else if(parent != null && projectDescendants.ContainsKey(child.Id)) {
     317        // change is not granted, if the new parent is among the moved project's descendants
     318        changeGranted = !projectDescendants[child.Id].Where(x => x.Id == parent.Id).Any();
     319      }
     320
     321      return changeGranted;
     322    }
     323
     324    public bool CheckParentChange(Resource child, Resource parent) {
     325      bool changeGranted = true;
     326
     327      // change is not granted, if the moved resource is null
     328      // or the new parent is not stored yet
     329      // or there is not parental change
     330      if (child == null
     331        || (parent != null && parent.Id == Guid.Empty)
     332        || (parent != null && parent.Id == child.ParentResourceId)) {
     333        changeGranted = false;
     334      } else if (parent != null && resourceDescendants.ContainsKey(child.Id)) {
     335        // change is not granted, if the new parent is among the moved resource's descendants
     336        changeGranted = !resourceDescendants[child.Id].Where(x => x.Id == parent.Id).Any();
     337      }
     338
     339      return changeGranted;
     340    }
    305341    #endregion
    306342  }
Note: See TracChangeset for help on using the changeset viewer.