Index: branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourceDao.cs
===================================================================
--- branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourceDao.cs	(revision 15500)
+++ branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourceDao.cs	(revision 15503)
@@ -41,10 +41,18 @@
     }
 
+    public IEnumerable<Resource> GetResourcesByParentId(Guid id) {
+      return DataContext.ExecuteQuery<Resource>(GetResourcesByParentIdQuery, id);
+    }
+
     public IEnumerable<Guid> GetResourceIdsByParentId(Guid id) {
       return DataContext.ExecuteQuery<Guid>(GetResourceIdsByParentIdQuery, id);
     }
 
-    public IEnumerable<Resource> GetResourcesByParentId(Guid id) {
-      return DataContext.ExecuteQuery<Resource>(GetResourcesByParentIdQuery, id);
+    public IEnumerable<Resource> GetResourcesByChildId(Guid id) {
+      return DataContext.ExecuteQuery<Resource>(GetResourcesByChildIdQuery, id);
+    }
+
+    public IEnumerable<Guid> GetResourceIdsByChildId(Guid id) {
+      return DataContext.ExecuteQuery<Guid>(GetResourceIdsByChildIdQuery, id);
     }
 
@@ -65,18 +73,4 @@
     #region String queries
     private const string GetResourcesByParentIdQuery = @"
-      WITH rtree AS
-      (
-	      SELECT ResourceId, ParentResourceId
-	      FROM [Resource]
-	      UNION ALL
-	      SELECT rt.ResourceId, r.ParentResourceId
-	      FROM [Resource] r
-	      JOIN rtree rt ON rt.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rt.ParentResourceId <> rt.ResourceId
-      )
-      SELECT DISTINCT rtree.ResourceId
-      FROM rtree
-      WHERE rtree.ParentResourceId = ({0})
-    ";
-    private const string GetResourceIdsByParentIdQuery = @"
     	WITH rtree AS
       (
@@ -93,4 +87,47 @@
 	    AND rtree.ResourceId = res.ResourceId
     ";
+    private const string GetResourceIdsByParentIdQuery = @"
+      WITH rtree AS
+      (
+	      SELECT ResourceId, ParentResourceId
+	      FROM [Resource]
+	      UNION ALL
+	      SELECT rt.ResourceId, r.ParentResourceId
+	      FROM [Resource] r
+	      JOIN rtree rt ON rt.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rt.ParentResourceId <> rt.ResourceId
+      )
+      SELECT DISTINCT rtree.ResourceId
+      FROM rtree
+      WHERE rtree.ParentResourceId = ({0})
+    ";
+    private const string GetResourcesByChildIdQuery = @"
+      WITH rtree AS
+      (
+	      SELECT ResourceId, ParentResourceId
+	      FROM [Resource]
+	      UNION ALL
+	      SELECT rt.ResourceId, r.ParentResourceId
+	      FROM [Resource] r
+	      JOIN rtree rt ON rt.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rt.ParentResourceId <> rt.ResourceId
+      )
+      SELECT DISTINCT res.*
+      FROM rtree, [Resource] res
+      WHERE rtree.ResourceId = ({0})
+      AND rtree.ParentResourceId = res.ResourceId
+    ";
+    private const string GetResourceIdsByChildIdQuery = @"
+      WITH rtree AS
+      (
+	      SELECT ResourceId, ParentResourceId
+	      FROM [Resource]
+	      UNION ALL
+	      SELECT rt.ResourceId, r.ParentResourceId
+	      FROM [Resource] r
+	      JOIN rtree rt ON rt.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rt.ParentResourceId <> rt.ResourceId
+      )
+      SELECT DISTINCT rtree.ParentResourceId
+      FROM rtree
+      WHERE rtree.ResourceId = ({0})
+    ";
     #endregion
   }
Index: branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourcePermissionDao.cs
===================================================================
--- branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourcePermissionDao.cs	(revision 15500)
+++ branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourcePermissionDao.cs	(revision 15503)
@@ -43,4 +43,12 @@
     }
 
+    public void DeleteByResourceIdAndGrantedUserId(Guid resourceId, IEnumerable<Guid> grantedUserId) {
+      string paramIds = string.Join(",", grantedUserId.Select(x => string.Format("'{0}'", x)));
+      if (!string.IsNullOrWhiteSpace(paramIds)) {
+        string query = string.Format(DeleteByGrantedUserQuery, resourceId, paramIds);
+        DataContext.ExecuteCommand(query);
+      }
+    }
+
     #region Compiled queries
     private static readonly Func<DataContext, Guid, IEnumerable<ResourcePermission>> GetByResourceIdQuery =
@@ -71,4 +79,9 @@
       ;";
 
+    private const string DeleteByGrantedUserQuery = @"
+      DELETE FROM [ResourcePermission]
+        WHERE ResourceId = '{0}'
+        AND GrantedUserId IN ({1})
+    ;";
     #endregion
   }
