Changeset 15527 for branches/HiveProjectManagement
- Timestamp:
- 12/14/17 15:08:38 (7 years ago)
- Location:
- branches/HiveProjectManagement
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ProjectDao.cs
r15508 r15527 33 33 } 34 34 35 public IEnumerable<Project> Get ProjectsByChildId(Guid id) {36 return DataContext.ExecuteQuery<Project>(Get ProjectsByChildIdQuery, id);35 public IEnumerable<Project> GetChildProjectsById(Guid id) { 36 return DataContext.ExecuteQuery<Project>(GetChildProjectsByIdQuery, id); 37 37 } 38 38 39 public IEnumerable<Guid> GetProjectIdsByChildId(Guid id) { 40 return DataContext.ExecuteQuery<Guid>(GetProjectIdsByChildIdQuery, id); 39 public IEnumerable<Guid> GetChildProjectIdsById(Guid id) { 40 return DataContext.ExecuteQuery<Guid>(GetChildProjectIdsByIdQuery, id); 41 } 42 43 public IEnumerable<Project> GetParentProjectsById(Guid id) { 44 return DataContext.ExecuteQuery<Project>(GetParentProjectsByIdQuery, id); 45 } 46 47 public IEnumerable<Guid> GetParentProjectIdsById(Guid id) { 48 return DataContext.ExecuteQuery<Guid>(GetParentProjectIdsByIdQuery, id); 49 } 50 51 public IEnumerable<Project> GetCurrentAndParentProjectsById(Guid id) { 52 return DataContext.ExecuteQuery<Project>(GetCurrentAndParentProjectsByIdQuery, id); 53 } 54 55 public IEnumerable<Guid> GetCurrentAndParentProjectIdsById(Guid id) { 56 return DataContext.ExecuteQuery<Guid>(GetCurrentAndParentProjectIdsByIdQuery, id); 41 57 } 42 58 … … 50 66 51 67 #region String queries 52 private const string Get ProjectsByChildIdQuery = @"53 68 private const string GetChildProjectsByIdQuery = @" 69 WITH ptree AS 54 70 ( 55 71 SELECT ProjectId, ParentProjectId 56 72 FROM [Project] 57 73 UNION ALL 58 74 SELECT pt.ProjectId, p.ParentProjectId … … 62 78 SELECT DISTINCT pro.* 63 79 FROM ptree, [Project] pro 64 WHERE ptree.P rojectId = {0}65 AND ptree.ParentProjectId = pro.ProjectId80 WHERE ptree.ParentProjectId = {0} 81 AND ptree.ProjectId = pro.ProjectId 66 82 "; 67 private const string Get ProjectIdsByChildIdQuery = @"83 private const string GetChildProjectIdsByIdQuery = @" 68 84 WITH ptree AS 85 ( 86 SELECT ProjectId, ParentProjectId 87 FROM [Project] 88 UNION ALL 89 SELECT pt.ProjectId, r.ParentProjectId 90 FROM [Project] r 91 JOIN ptree pt ON pt.ParentProjectId = r.ProjectId AND r.ParentProjectId <> r.ProjectId AND pt.ParentProjectId <> pt.ProjectId 92 ) 93 SELECT DISTINCT ptree.ProjectId 94 FROM ptree 95 WHERE ptree.ParentProjectId = {0} 96 "; 97 private const string GetParentProjectsByIdQuery = @" 98 WITH pbranch AS 69 99 ( 70 100 SELECT ProjectId, ParentProjectId 71 101 FROM [Project] 72 102 UNION ALL 73 SELECT p t.ProjectId, p.ParentProjectId103 SELECT pb.ProjectId, p.ParentProjectId 74 104 FROM [Project] p 75 JOIN p tree pt ON pt.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pt.ParentProjectId <> pt.ProjectId105 JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pb.ParentProjectId <> pb.ProjectId 76 106 ) 77 SELECT DISTINCT ptree.ParentProjectId 78 FROM ptree 79 WHERE ptree.ProjectId = {0} 107 SELECT DISTINCT pro.* 108 FROM pbranch, [Project] pro 109 WHERE pbranch.ProjectId = {0} 110 AND pbranch.ParentProjectId = pro.ProjectId 111 "; 112 private const string GetParentProjectIdsByIdQuery = @" 113 WITH pbranch AS 114 ( 115 SELECT ProjectId, ParentProjectId 116 FROM [Project] 117 UNION ALL 118 SELECT pb.ProjectId, p.ParentProjectId 119 FROM [Project] p 120 JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId AND p.ParentProjectId <> p.ProjectId AND pb.ParentProjectId <> pb.ProjectId 121 ) 122 SELECT DISTINCT pbranch.ParentProjectId 123 FROM pbranch 124 WHERE pbranch.ProjectId = {0} 125 "; 126 private const string GetCurrentAndParentProjectsByIdQuery = @" 127 WITH pbranch AS 128 ( 129 SELECT ProjectId, ParentProjectId 130 FROM Project 131 WHERE ProjectId = {0} 132 UNION ALL 133 SELECT p.ProjectId, p.ParentProjectId 134 FROM Project p 135 JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId 136 ) 137 SELECT DISTINCT pro.* 138 FROM pbranch, Project pro 139 WHERE pbranch.ProjectId = pro.ProjectId 140 "; 141 private const string GetCurrentAndParentProjectIdsByIdQuery = @" 142 WITH pbranch AS 143 ( 144 SELECT ProjectId, ParentProjectId 145 FROM Project 146 WHERE ProjectId = {0} 147 UNION ALL 148 SELECT p.ProjectId, p.ParentProjectId 149 FROM Project p 150 JOIN pbranch pb ON pb.ParentProjectId = p.ProjectId 151 ) 152 SELECT DISTINCT pbranch.ProjectId 153 FROM pbranch 80 154 "; 81 155 #endregion -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourceDao.cs
r15503 r15527 41 41 } 42 42 43 public IEnumerable<Resource> Get ResourcesByParentId(Guid id) {44 return DataContext.ExecuteQuery<Resource>(Get ResourcesByParentIdQuery, id);43 public IEnumerable<Resource> GetChildResourcesById(Guid id) { 44 return DataContext.ExecuteQuery<Resource>(GetChildResourcesByIdQuery, id); 45 45 } 46 46 47 public IEnumerable<Guid> Get ResourceIdsByParentId(Guid id) {48 return DataContext.ExecuteQuery<Guid>(Get ResourceIdsByParentIdQuery, id);47 public IEnumerable<Guid> GetChildResourceIdsById(Guid id) { 48 return DataContext.ExecuteQuery<Guid>(GetChildResourceIdsByIdQuery, id); 49 49 } 50 50 51 public IEnumerable<Resource> Get ResourcesByChildId(Guid id) {52 return DataContext.ExecuteQuery<Resource>(Get ResourcesByChildIdQuery, id);51 public IEnumerable<Resource> GetParentResourcesById(Guid id) { 52 return DataContext.ExecuteQuery<Resource>(GetParentResourcesByIdQuery, id); 53 53 } 54 54 55 public IEnumerable<Guid> GetResourceIdsByChildId(Guid id) { 56 return DataContext.ExecuteQuery<Guid>(GetResourceIdsByChildIdQuery, id); 55 public IEnumerable<Guid> GetParentResourceIdsById(Guid id) { 56 return DataContext.ExecuteQuery<Guid>(GetParentResourceIdsByIdQuery, id); 57 } 58 59 public IEnumerable<Resource> GetCurrentAndParentResourcesById(Guid id) { 60 return DataContext.ExecuteQuery<Resource>(GetCurrentAndParentResourcesByIdQuery, id); 61 } 62 63 public IEnumerable<Guid> GetCurrentAndParentResourceIdsById(Guid id) { 64 return DataContext.ExecuteQuery<Guid>(GetCurrentAndParentResourceIdsByIdQuery, id); 57 65 } 58 66 … … 72 80 73 81 #region String queries 74 private const string Get ResourcesByParentIdQuery = @"82 private const string GetChildResourcesByIdQuery = @" 75 83 WITH rtree AS 76 84 ( … … 84 92 SELECT DISTINCT res.* 85 93 FROM rtree, [Resource] res 86 WHERE rtree.ParentResourceId = ({0})94 WHERE rtree.ParentResourceId = {0} 87 95 AND rtree.ResourceId = res.ResourceId 88 96 "; 89 private const string Get ResourceIdsByParentIdQuery = @"97 private const string GetChildResourceIdsByIdQuery = @" 90 98 WITH rtree AS 91 99 ( … … 99 107 SELECT DISTINCT rtree.ResourceId 100 108 FROM rtree 101 WHERE rtree.ParentResourceId = ({0})109 WHERE rtree.ParentResourceId = {0} 102 110 "; 103 private const string Get ResourcesByChildIdQuery = @"104 WITH r treeAS111 private const string GetParentResourcesByIdQuery = @" 112 WITH rbranch AS 105 113 ( 106 114 SELECT ResourceId, ParentResourceId 107 115 FROM [Resource] 108 116 UNION ALL 109 SELECT r t.ResourceId, r.ParentResourceId117 SELECT rb.ResourceId, r.ParentResourceId 110 118 FROM [Resource] r 111 JOIN r tree rt ON rt.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rt.ParentResourceId <> rt.ResourceId119 JOIN rbranch rb ON rb.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rb.ParentResourceId <> rb.ResourceId 112 120 ) 113 121 SELECT DISTINCT res.* 114 FROM r tree, [Resource] res115 WHERE r tree.ResourceId = ({0})116 AND r tree.ParentResourceId = res.ResourceId122 FROM rbranch, [Resource] res 123 WHERE rbranch.ResourceId = {0} 124 AND rbranch.ParentResourceId = res.ResourceId 117 125 "; 118 private const string Get ResourceIdsByChildIdQuery = @"119 WITH r treeAS126 private const string GetParentResourceIdsByIdQuery = @" 127 WITH rbranch AS 120 128 ( 121 129 SELECT ResourceId, ParentResourceId 122 130 FROM [Resource] 123 131 UNION ALL 124 SELECT r t.ResourceId, r.ParentResourceId132 SELECT rb.ResourceId, r.ParentResourceId 125 133 FROM [Resource] r 126 JOIN r tree rt ON rt.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rt.ParentResourceId <> rt.ResourceId134 JOIN rbranch rb ON rb.ParentResourceId = r.ResourceId AND r.ParentResourceId <> r.ResourceId AND rb.ParentResourceId <> rb.ResourceId 127 135 ) 128 SELECT DISTINCT rtree.ParentResourceId 129 FROM rtree 130 WHERE rtree.ResourceId = ({0}) 136 SELECT DISTINCT rbranch.ParentResourceId 137 FROM rbranch 138 WHERE rbranch.ResourceId = {0} 139 "; 140 private const string GetCurrentAndParentResourcesByIdQuery = @" 141 WITH rbranch AS 142 ( 143 SELECT ResourceId, ParentResourceId 144 FROM [Resource] 145 WHERE ResourceId = {0} 146 UNION ALL 147 SELECT r.ResourceId, r.ParentResourceId 148 FROM [Resource] r 149 JOIN rbranch rb ON rb.ParentResourceId = r.ResourceId 150 ) 151 SELECT DISTINCT res.* 152 FROM rbranch, [Resource] res 153 WHERE rbranch.ResourceId = res.ResourceId 154 "; 155 private const string GetCurrentAndParentResourceIdsByIdQuery = @" 156 WITH rbranch AS 157 ( 158 SELECT ResourceId, ParentResourceId 159 FROM [Resource] 160 WHERE ResourceId = {0} 161 UNION ALL 162 SELECT r.ResourceId, r.ParentResourceId 163 FROM [Resource] r 164 JOIN rbranch rb ON rb.ParentResourceId = r.ResourceId 165 ) 166 SELECT DISTINCT rbranch.ResourceId 167 FROM rbranch 131 168 "; 132 169 #endregion -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml
r15526 r15527 4 4 <Column Name="ResourceId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" /> 5 5 <Column Name="ProjectId" Storage="_JobId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" /> 6 <Association Name="Resource_Assigned Resource" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" DeleteRule="CASCADE" />7 <Association Name="Project_Assigned Resource" Member="Project" ThisKey="ProjectId" OtherKey="ProjectId" Type="Project" IsForeignKey="true" DeleteRule="CASCADE" />6 <Association Name="Resource_AssignedProjectResource" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" DeleteRule="CASCADE" /> 7 <Association Name="Project_AssignedProjectResource" Member="Project" ThisKey="ProjectId" OtherKey="ProjectId" Type="Project" IsForeignKey="true" DeleteRule="CASCADE" /> 8 8 </Type> 9 9 </Table> … … 37 37 <Column Name="HbInterval" Type="System.Int32" DbType="Int" CanBeNull="false" /> 38 38 <Column Name="OwnerUserId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="true" /> 39 <Association Name="Resource_Assigned Resource" Member="AssignedProjectResources" Storage="_AssignedResources" ThisKey="ResourceId" OtherKey="ResourceId" Type="AssignedProjectResource" />39 <Association Name="Resource_AssignedProjectResource" Member="AssignedProjectResources" Storage="_AssignedResources" ThisKey="ResourceId" OtherKey="ResourceId" Type="AssignedProjectResource" /> 40 40 <Association Name="Resource_Resource" Member="ChildResources" ThisKey="ResourceId" OtherKey="ParentResourceId" Type="Resource" /> 41 41 <Association Name="Resource_Downtime" Member="Downtimes" Storage="_UptimeCalendars" ThisKey="ResourceId" OtherKey="ResourceId" Type="Downtime" /> 42 42 <Association Name="Resource_StateLog" Member="StateLogs" ThisKey="ResourceId" OtherKey="SlaveId" Type="StateLog" /> 43 <Association Name="Resource_ResourcePermission" Member="ResourcePermissions" ThisKey="ResourceId" OtherKey="ResourceId" Type="ResourcePermission" />44 43 <Association Name="Resource_AssignedTaskResource" Member="AssignedTaskResources" ThisKey="ResourceId" OtherKey="ResourceId" Type="AssignedTaskResource" /> 45 44 <Association Name="Resource_Resource" Member="ParentResource" ThisKey="ParentResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" /> … … 103 102 <Column Name="Name" Type="System.String" DbType="VarChar(MAX)" CanBeNull="false" /> 104 103 <Column Name="Description" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" /> 105 <Column Name="ResourceIds" Type="System.String" DbType="VarChar(MAX)" CanBeNull="true" />106 104 <Column Name="OwnerUserId" Storage="_UserId" Type="System.Guid" DbType="UniqueIdentifier" CanBeNull="false" /> 107 105 <Column Name="DateCreated" Type="System.DateTime" DbType="DateTime" CanBeNull="false" /> … … 155 153 <Column Name="LifecycleId" Type="System.Int32" DbType="Int" IsPrimaryKey="true" CanBeNull="false" /> 156 154 <Column Name="LastCleanup" Type="System.DateTime" DbType="DateTime" CanBeNull="false" /> 157 </Type>158 </Table>159 <Table Name="dbo.ResourcePermission" Member="ResourcePermissions">160 <Type Name="ResourcePermission">161 <Column Name="ResourceId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />162 <Column Name="GrantedUserId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />163 <Column Name="GrantedByUserId" Type="System.Guid" DbType="UniqueIdentifier NOT NULL" CanBeNull="false" />164 <Association Name="Resource_ResourcePermission" Member="Resource" ThisKey="ResourceId" OtherKey="ResourceId" Type="Resource" IsForeignKey="true" />165 155 </Type> 166 156 </Table> … … 268 258 <Column Name="StartDate" Type="System.DateTime" DbType="DateTime NOT NULL" CanBeNull="false" /> 269 259 <Column Name="EndDate" Type="System.DateTime" DbType="DateTime" CanBeNull="true" /> 270 <Association Name="Project_Assigned Resource" Member="AssignedProjectResources" Storage="_AssignedResources" ThisKey="ProjectId" OtherKey="ProjectId" Type="AssignedProjectResource" />260 <Association Name="Project_AssignedProjectResource" Member="AssignedProjectResources" Storage="_AssignedResources" ThisKey="ProjectId" OtherKey="ProjectId" Type="AssignedProjectResource" /> 271 261 <Association Name="Project_Job" Member="Jobs" ThisKey="ProjectId" OtherKey="ProjectId" Type="Job" /> 272 262 <Association Name="Project_Project" Member="ChildProjects" Storage="_Projects" ThisKey="ProjectId" OtherKey="ParentProjectId" Type="Project" /> -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.dbml.layout
r15526 r15527 39 39 </nestedChildShapes> 40 40 </classShape> 41 <classShape Id="e6f840cc-2968-4be1-b234-eef624ccacbb" absoluteBounds="4.125, 2.625, 2, 2.1554996744791666">41 <classShape Id="e6f840cc-2968-4be1-b234-eef624ccacbb" absoluteBounds="4.125, 2.625, 2, 1.9631982421874996"> 42 42 <DataClassMoniker Name="/HiveDataContext/Job" /> 43 43 <nestedChildShapes> 44 <elementListCompartment Id="0c65d4e1-256a-4a91-9a57-392f25e4de7f" absoluteBounds="4.1400000000000006, 3.0850000000000009, 1.9700000000000002, 1. 5954996744791665" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />44 <elementListCompartment Id="0c65d4e1-256a-4a91-9a57-392f25e4de7f" absoluteBounds="4.1400000000000006, 3.0850000000000009, 1.9700000000000002, 1.4031982421875" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" /> 45 45 </nestedChildShapes> 46 46 </classShape> … … 69 69 </nodes> 70 70 </inheritanceConnector> 71 <associationConnector edgePoints="[(13.25 : 2.15469482421875); (15.71875 : 2.15469482421875); (15.71875 : 8.25)]" manuallyRouted="true" fixedFrom="NotFixed" fixedTo="NotFixed">72 <AssociationMoniker Name="/HiveDataContext/Resource/Resource_AssignedResource" />73 <nodes>74 <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />75 <classShapeMoniker Id="a929c9dc-69f4-4488-ba1c-a2342bf81d89" />76 </nodes>77 </associationConnector>78 71 <classShape Id="6bc13f26-f9a8-4597-b054-35be34190d12" absoluteBounds="4.125, 1, 2, 1.3862939453125"> 79 72 <DataClassMoniker Name="/HiveDataContext/TaskData" /> … … 95 88 </nodes> 96 89 </associationConnector> 97 <associationConnector edgePoints="[(8.875 : 6.56814697265625); (8.5 : 6.56814697265625)]" fixedFrom=" Algorithm" fixedTo="Algorithm">90 <associationConnector edgePoints="[(8.875 : 6.56814697265625); (8.5 : 6.56814697265625)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 98 91 <AssociationMoniker Name="/HiveDataContext/Plugin/Plugin_RequiredPlugin" /> 99 92 <nodes> … … 162 155 </nodes> 163 156 </associationConnector> 164 <associationConnector edgePoints="[(6.5 : 2.50564697265625); (3.75 : 2.50564697265625)]" fixedFrom=" NotFixed" fixedTo="NotFixed">157 <associationConnector edgePoints="[(6.5 : 2.50564697265625); (3.75 : 2.50564697265625)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 165 158 <AssociationMoniker Name="/HiveDataContext/Task/Task_StateLog" /> 166 159 <nodes> … … 169 162 </nodes> 170 163 </associationConnector> 171 <associationConnector edgePoints="[(6.125 : 3.37100341796875); (6.5 : 3.37100341796875)]" fixedFrom=" NotFixed" fixedTo="NotFixed">164 <associationConnector edgePoints="[(6.125 : 3.37100341796875); (6.5 : 3.37100341796875)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 172 165 <AssociationMoniker Name="/HiveDataContext/Job/Job_Task" /> 173 166 <nodes> … … 176 169 </nodes> 177 170 </associationConnector> 178 <associationConnector edgePoints="[(4.125 : 4. 20274983723958); (3.75 : 4.20274983723958)]" fixedFrom="NotFixed" fixedTo="NotFixed">171 <associationConnector edgePoints="[(4.125 : 4.10659912109375); (3.75 : 4.10659912109375)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 179 172 <AssociationMoniker Name="/HiveDataContext/Job/Job_JobPermission" /> 180 173 <nodes> … … 183 176 </nodes> 184 177 </associationConnector> 185 <classShape Id="a3f352be-9f15-4e73-8d44-3e8ac02fb4cf" absoluteBounds="11.25, 3.875, 2, 1.3862939453124996">186 <DataClassMoniker Name="/HiveDataContext/ResourcePermission" />187 <nestedChildShapes>188 <elementListCompartment Id="45e2f1a8-8a1e-4647-b649-10ec55976ab4" absoluteBounds="11.265, 4.335, 1.9700000000000002, 0.8262939453125" name="DataPropertiesCompartment" titleTextColor="Black" itemTextColor="Black" />189 </nestedChildShapes>190 </classShape>191 <associationConnector edgePoints="[(12.5942481820367 : 2.9631982421875); (12.5942481820367 : 3.875)]" fixedFrom="NotFixed" fixedTo="NotFixed">192 <AssociationMoniker Name="/HiveDataContext/Resource/Resource_ResourcePermission" />193 <nodes>194 <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" />195 <classShapeMoniker Id="a3f352be-9f15-4e73-8d44-3e8ac02fb4cf" />196 </nodes>197 </associationConnector>198 178 <classShape Id="f9e8867f-fd15-4a72-8ca4-4f02cd3f141f" absoluteBounds="4.125, 5.5, 2, 1.1939925130208327"> 199 179 <DataClassMoniker Name="/HiveDataContext/UserPriority" /> … … 299 279 </nodes> 300 280 </associationConnector> 301 <associationConnector edgePoints="[(13.25 : 8.84699625651042); (13.875 : 8.84699625651042)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 302 <AssociationMoniker Name="/HiveDataContext/Project/Project_AssignedResource" /> 303 <nodes> 304 <classShapeMoniker Id="30778876-b5f6-4a97-9ec7-792011973d75" /> 305 <classShapeMoniker Id="a929c9dc-69f4-4488-ba1c-a2342bf81d89" /> 306 </nodes> 307 </associationConnector> 308 <associationConnector edgePoints="[(11.25 : 9.42390055338542); (10.375 : 9.42390055338542); (10.375 : 8); (4 : 8); (4 : 5.15549967447917); (5.125 : 5.15549967447917); (5.125 : 4.78049967447917)]" fixedFrom="NotFixed" fixedTo="NotFixed"> 281 <associationConnector edgePoints="[(11.25 : 9.42390055338542); (10.375 : 9.42390055338542); (10.375 : 8); (4 : 8); (4 : 4.9631982421875); (5.125 : 4.9631982421875); (5.125 : 4.5881982421875)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 309 282 <AssociationMoniker Name="/HiveDataContext/Project/Project_Job" /> 310 283 <nodes> … … 326 299 </nodes> 327 300 </associationConnector> 328 <associationConnector edgePoints="[(12.25 : 2.9631982421875); (12.25 : 3.8125); (11.1875 : 3.8125); (11.1875 :4.97199625651042); (10.875 : 4.97199625651042)]" fixedFrom="Algorithm" fixedTo="Algorithm">301 <associationConnector edgePoints="[(12.25 : 2.9631982421875); (12.25 : 4.97199625651042); (10.875 : 4.97199625651042)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 329 302 <AssociationMoniker Name="/HiveDataContext/Resource/Resource_AssignedTaskResource" /> 330 303 <nodes> 331 304 <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" /> 332 305 <classShapeMoniker Id="72ac5c1b-0fdf-43a1-bbe7-3774893b40af" /> 306 </nodes> 307 </associationConnector> 308 <associationConnector edgePoints="[(13.25 : 2.15469482421875); (15.71875 : 2.15469482421875); (15.71875 : 8.25)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 309 <AssociationMoniker Name="/HiveDataContext/Resource/Resource_AssignedProjectResource" /> 310 <nodes> 311 <classShapeMoniker Id="706a4581-6daf-4e71-ae2a-87d50b27a051" /> 312 <classShapeMoniker Id="a929c9dc-69f4-4488-ba1c-a2342bf81d89" /> 313 </nodes> 314 </associationConnector> 315 <associationConnector edgePoints="[(13.25 : 8.84699625651042); (13.875 : 8.84699625651042)]" fixedFrom="Algorithm" fixedTo="Algorithm"> 316 <AssociationMoniker Name="/HiveDataContext/Project/Project_AssignedProjectResource" /> 317 <nodes> 318 <classShapeMoniker Id="30778876-b5f6-4a97-9ec7-792011973d75" /> 319 <classShapeMoniker Id="a929c9dc-69f4-4488-ba1c-a2342bf81d89" /> 333 320 </nodes> 334 321 </associationConnector> -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/HiveDataContext.designer.cs
r15526 r15527 67 67 partial void UpdateLifecycle(Lifecycle instance); 68 68 partial void DeleteLifecycle(Lifecycle instance); 69 partial void InsertResourcePermission(ResourcePermission instance);70 partial void UpdateResourcePermission(ResourcePermission instance);71 partial void DeleteResourcePermission(ResourcePermission instance);72 69 partial void InsertUserPriority(UserPriority instance); 73 70 partial void UpdateUserPriority(UserPriority instance); … … 222 219 } 223 220 224 public System.Data.Linq.Table<ResourcePermission> ResourcePermissions225 {226 get227 {228 return this.GetTable<ResourcePermission>();229 }230 }231 232 221 public System.Data.Linq.Table<UserPriority> UserPriorities 233 222 { … … 938 927 private EntitySet<StateLog> _StateLogs; 939 928 940 private EntitySet<ResourcePermission> _ResourcePermissions;941 942 929 private EntitySet<AssignedTaskResource> _AssignedTaskResources; 943 930 … … 968 955 this._UptimeCalendars = new EntitySet<Downtime>(new Action<Downtime>(this.attach_UptimeCalendars), new Action<Downtime>(this.detach_UptimeCalendars)); 969 956 this._StateLogs = new EntitySet<StateLog>(new Action<StateLog>(this.attach_StateLogs), new Action<StateLog>(this.detach_StateLogs)); 970 this._ResourcePermissions = new EntitySet<ResourcePermission>(new Action<ResourcePermission>(this.attach_ResourcePermissions), new Action<ResourcePermission>(this.detach_ResourcePermissions));971 957 this._AssignedTaskResources = new EntitySet<AssignedTaskResource>(new Action<AssignedTaskResource>(this.attach_AssignedTaskResources), new Action<AssignedTaskResource>(this.detach_AssignedTaskResources)); 972 958 this._ParentResource = default(EntityRef<Resource>); … … 1150 1136 } 1151 1137 1152 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_ResourcePermission", Storage="_ResourcePermissions", ThisKey="ResourceId", OtherKey="ResourceId")]1153 public EntitySet<ResourcePermission> ResourcePermissions1154 {1155 get1156 {1157 return this._ResourcePermissions;1158 }1159 set1160 {1161 this._ResourcePermissions.Assign(value);1162 }1163 }1164 1165 1138 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_AssignedTaskResource", Storage="_AssignedTaskResources", ThisKey="ResourceId", OtherKey="ResourceId")] 1166 1139 public EntitySet<AssignedTaskResource> AssignedTaskResources … … 1273 1246 1274 1247 private void detach_StateLogs(StateLog entity) 1275 {1276 this.SendPropertyChanging();1277 entity.Resource = null;1278 }1279 1280 private void attach_ResourcePermissions(ResourcePermission entity)1281 {1282 this.SendPropertyChanging();1283 entity.Resource = this;1284 }1285 1286 private void detach_ResourcePermissions(ResourcePermission entity)1287 1248 { 1288 1249 this.SendPropertyChanging(); … … 2480 2441 private string _Description; 2481 2442 2482 private string _ResourceIds;2483 2484 2443 private System.Guid _UserId; 2485 2444 … … 2504 2463 partial void OnDescriptionChanging(string value); 2505 2464 partial void OnDescriptionChanged(); 2506 partial void OnResourceIdsChanging(string value);2507 partial void OnResourceIdsChanged();2508 2465 partial void OnOwnerUserIdChanging(System.Guid value); 2509 2466 partial void OnOwnerUserIdChanged(); … … 2578 2535 this.SendPropertyChanged("Description"); 2579 2536 this.OnDescriptionChanged(); 2580 }2581 }2582 }2583 2584 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ResourceIds", DbType="VarChar(MAX)")]2585 public string ResourceIds2586 {2587 get2588 {2589 return this._ResourceIds;2590 }2591 set2592 {2593 if ((this._ResourceIds != value))2594 {2595 this.OnResourceIdsChanging(value);2596 this.SendPropertyChanging();2597 this._ResourceIds = value;2598 this.SendPropertyChanged("ResourceIds");2599 this.OnResourceIdsChanged();2600 2537 } 2601 2538 } … … 3621 3558 this.SendPropertyChanged("LastCleanup"); 3622 3559 this.OnLastCleanupChanged(); 3623 }3624 }3625 }3626 3627 public event PropertyChangingEventHandler PropertyChanging;3628 3629 public event PropertyChangedEventHandler PropertyChanged;3630 3631 protected virtual void SendPropertyChanging()3632 {3633 if ((this.PropertyChanging != null))3634 {3635 this.PropertyChanging(this, emptyChangingEventArgs);3636 }3637 }3638 3639 protected virtual void SendPropertyChanged(String propertyName)3640 {3641 if ((this.PropertyChanged != null))3642 {3643 this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));3644 }3645 }3646 }3647 3648 [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.ResourcePermission")]3649 public partial class ResourcePermission : INotifyPropertyChanging, INotifyPropertyChanged3650 {3651 3652 private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty);3653 3654 private System.Guid _ResourceId;3655 3656 private System.Guid _GrantedUserId;3657 3658 private System.Guid _GrantedByUserId;3659 3660 private EntityRef<Resource> _Resource;3661 3662 #region Extensibility Method Definitions3663 partial void OnLoaded();3664 partial void OnValidate(System.Data.Linq.ChangeAction action);3665 partial void OnCreated();3666 partial void OnResourceIdChanging(System.Guid value);3667 partial void OnResourceIdChanged();3668 partial void OnGrantedUserIdChanging(System.Guid value);3669 partial void OnGrantedUserIdChanged();3670 partial void OnGrantedByUserIdChanging(System.Guid value);3671 partial void OnGrantedByUserIdChanged();3672 #endregion3673 3674 public ResourcePermission()3675 {3676 this._Resource = default(EntityRef<Resource>);3677 OnCreated();3678 }3679 3680 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ResourceId", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)]3681 public System.Guid ResourceId3682 {3683 get3684 {3685 return this._ResourceId;3686 }3687 set3688 {3689 if ((this._ResourceId != value))3690 {3691 if (this._Resource.HasLoadedOrAssignedValue)3692 {3693 throw new System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException();3694 }3695 this.OnResourceIdChanging(value);3696 this.SendPropertyChanging();3697 this._ResourceId = value;3698 this.SendPropertyChanged("ResourceId");3699 this.OnResourceIdChanged();3700 }3701 }3702 }3703 3704 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_GrantedUserId", DbType="UniqueIdentifier NOT NULL", IsPrimaryKey=true)]3705 public System.Guid GrantedUserId3706 {3707 get3708 {3709 return this._GrantedUserId;3710 }3711 set3712 {3713 if ((this._GrantedUserId != value))3714 {3715 this.OnGrantedUserIdChanging(value);3716 this.SendPropertyChanging();3717 this._GrantedUserId = value;3718 this.SendPropertyChanged("GrantedUserId");3719 this.OnGrantedUserIdChanged();3720 }3721 }3722 }3723 3724 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_GrantedByUserId", DbType="UniqueIdentifier NOT NULL")]3725 public System.Guid GrantedByUserId3726 {3727 get3728 {3729 return this._GrantedByUserId;3730 }3731 set3732 {3733 if ((this._GrantedByUserId != value))3734 {3735 this.OnGrantedByUserIdChanging(value);3736 this.SendPropertyChanging();3737 this._GrantedByUserId = value;3738 this.SendPropertyChanged("GrantedByUserId");3739 this.OnGrantedByUserIdChanged();3740 }3741 }3742 }3743 3744 [global::System.Data.Linq.Mapping.AssociationAttribute(Name="Resource_ResourcePermission", Storage="_Resource", ThisKey="ResourceId", OtherKey="ResourceId", IsForeignKey=true)]3745 public Resource Resource3746 {3747 get3748 {3749 return this._Resource.Entity;3750 }3751 set3752 {3753 Resource previousValue = this._Resource.Entity;3754 if (((previousValue != value)3755 || (this._Resource.HasLoadedOrAssignedValue == false)))3756 {3757 this.SendPropertyChanging();3758 if ((previousValue != null))3759 {3760 this._Resource.Entity = null;3761 previousValue.ResourcePermissions.Remove(this);3762 }3763 this._Resource.Entity = value;3764 if ((value != null))3765 {3766 value.ResourcePermissions.Add(this);3767 this._ResourceId = value.ResourceId;3768 }3769 else3770 {3771 this._ResourceId = default(System.Guid);3772 }3773 this.SendPropertyChanged("Resource");3774 3560 } 3775 3561 } -
branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs
r15508 r15527 1016 1016 #endregion 1017 1017 1018 #region ResourcePermission Methods1019 // only for authorized Administrator/ResourceOwner1020 public void GrantResourcePermissions(Guid resourceId, Guid[] grantedUserIds) {1021 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);1022 AuthorizationManager.AuthorizeForResourceAdministration(resourceId);1023 var pm = PersistenceManager;1024 using(new PerformanceLogger("GrantResourcePermissions")) {1025 pm.UseTransaction(() => {1026 var resourceDao = pm.ResourceDao;1027 var resource = resourceDao.GetById(resourceId);1028 var resourcePermissions = resource.ResourcePermissions.ToList();1029 foreach(var id in grantedUserIds) {1030 if(resourcePermissions.All(x => x.GrantedUserId != id)) {1031 resource.ResourcePermissions.Add(new DA.ResourcePermission {1032 GrantedUserId = id,1033 GrantedByUserId = UserManager.CurrentUserId1034 });1035 }1036 }1037 pm.SubmitChanges();1038 });1039 }1040 }1041 1042 1043 // only for authorized Administrator/ResourceOwner1044 public void RevokeResourcePermissions(Guid resourceId, Guid[] grantedUserIds) {1045 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);1046 AuthorizationManager.AuthorizeForResourceAdministration(resourceId);1047 var pm = PersistenceManager;1048 using(new PerformanceLogger("RevokeResourcePermission")) {1049 pm.UseTransaction(() => {1050 var resourcePermissionDao = pm.ResourcePermissionDao;1051 resourcePermissionDao.DeleteByResourceIdAndGrantedUserId(resourceId, grantedUserIds);1052 pm.SubmitChanges();1053 });1054 }1055 }1056 1057 1058 // OBSOLETE (change to public if...)1059 // only for authorized Administrator/ResourceOwner/(Sub)ProjectOwner to which the Resource (i.e. resourceId) is assigned1060 private void GrantResourcePermissions(Guid resourceId, Guid projectId, Guid[] grantedUserIds) {1061 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);1062 //AuthorizationManager.AuthorizeForResourceAdministration(resourceId);1063 var pm = PersistenceManager;1064 using (new PerformanceLogger("GrantResourcePermissions")) {1065 pm.UseTransaction(() => {1066 // TODO-JAN1067 pm.SubmitChanges();1068 });1069 }1070 }1071 1072 // OBSOLETE (change to public if...)1073 // only for authorized Administrator/ResourceOwner/(Sub)ProjectOwner to which the Resource (i.e. resourceId) is assigned1074 private void RevokeResourcePermissions(Guid resourceId, Guid projectId, Guid[] grantedUserIds) {1075 // TODO-JAN1076 }1077 1078 #endregion1079 1080 1018 #region Downtime Methods 1081 1019 public Guid AddDowntime(DT.Downtime downtimeDto) { … … 1204 1142 //} 1205 1143 1206 private void CheckTaskPermissions(IPersistenceManager pm, DT.Task task, IEnumerable<Guid> resourceIds) {1144 private void CheckTaskPermissions(IPersistenceManager pm, DT.Task task, IEnumerable<Guid> resourceIds) { 1207 1145 var jobDao = pm.JobDao; 1208 1146 var projectDao = pm.ProjectDao; 1209 1147 var resourceDao = pm.ResourceDao; 1210 var resourcePermissionDao = pm.ResourcePermissionDao;1211 1148 var projectPermissionDao = pm.ProjectPermissionDao; 1212 1149 var currentUserId = UserManager.CurrentUserId; 1213 1214 //// PART 1: user-resource permission check (V1)1215 //// get granted (parent) resources1216 //var allGrantedResourceIds = pm.UseTransaction(() => {1217 // return resourcePermissionDao.GetAll().ToList()1218 // .Where(x => x.GrantedUserId == currentUserId1219 // || UserManager.VerifyUser(currentUserId, new List<Guid> { x.GrantedUserId }))1220 // .Select(y => y.ResourceId)1221 // .ToList();1222 //});1223 1224 //// get children of granted parent resources1225 //var userGrantedChildResourceIds = pm.UseTransaction(() => {1226 // return allGrantedResourceIds1227 // .SelectMany(x => resourceDao.GetResourcesByParentId(x))1228 // .Select(y => y.ResourceId);1229 //});1230 1231 //// join list of parent and child resources1232 //allGrantedResourceIds.AddRange(userGrantedChildResourceIds);1233 1234 // PART 1: user-resource permission check (V2)1235 // collect the current currentUserId and all Ids of affiliated groups1236 var userAndGroupIds = new List<Guid> { currentUserId };1237 userAndGroupIds.AddRange(UserManager.GetUserGroupIdsOfUser(currentUserId));1238 1239 // get all granted resourceIds1240 var allGrantedResourceIds = resourcePermissionDao.GetByUserAndGroupIds(userAndGroupIds).ToList();1241 1242 // get all owned resourceIds (including child resourceIds)1243 var ownedResourceIds = resourceDao.GetAll()1244 .Where(x => x.OwnerUserId == currentUserId)1245 .Select(x => x.ResourceId).ToList();1246 var ownedChildResourceIds = ownedResourceIds.SelectMany(x => resourceDao.GetResourceIdsByParentId(x));1247 ownedResourceIds.AddRange(ownedChildResourceIds);1248 1249 // join list of owned into the list with granted resourceIds1250 allGrantedResourceIds.AddRange(ownedResourceIds);1251 1252 // check the argument resourceIds against the list of granted (and owned) ones1253 if (resourceIds.Except(allGrantedResourceIds).Any()) {1254 throw new SecurityException(NOT_AUTHORIZED_RESOURCE);1255 }1256 1150 1257 1151 // PART 2: user-project permission check … … 1262 1156 // PART 3: project-resource permission check 1263 1157 var assignedResourceIds = project.AssignedProjectResources.Select(x => x.ResourceId).ToList(); 1264 var assignedChildResourceIds = assignedResourceIds.SelectMany(x => resourceDao.Get ResourceIdsByParentId(x));1158 var assignedChildResourceIds = assignedResourceIds.SelectMany(x => resourceDao.GetChildResourceIdsById(x)); 1265 1159 assignedResourceIds.AddRange(assignedChildResourceIds); 1266 1160 if (resourceIds.Except(assignedResourceIds).Any()) { … … 1279 1173 var projectDao = pm.ProjectDao; 1280 1174 var projectBranch = new List<DA.Project>() { project }; 1281 projectBranch.AddRange(projectDao.GetP rojectsByChildId(project.ProjectId));1175 projectBranch.AddRange(projectDao.GetParentProjectsById(project.ProjectId)); 1282 1176 if (projectBranch 1283 1177 .Select(x => x.OwnerUserId) 1284 1178 .Contains(UserManager.CurrentUserId)) { 1285 return; 1179 return; 1286 1180 } 1287 1181 1288 1182 // case 3 1289 if (project.ProjectPermissions1183 if (project.ProjectPermissions 1290 1184 .Select(x => x.GrantedUserId) 1291 1185 .Contains(UserManager.CurrentUserId)) { 1292 1186 return; 1293 1187 } 1294 if (projectBranch1188 if (projectBranch 1295 1189 .SelectMany(x => x.ProjectPermissions) 1296 1190 .Select(x => x.GrantedUserId) … … 1308 1202 1309 1203 var projectBranch = new List<DA.Project> { project }; 1310 projectBranch.AddRange(projectDao.GetP rojectsByChildId(project.ProjectId));1204 projectBranch.AddRange(projectDao.GetParentProjectsById(project.ProjectId)); 1311 1205 var ownedProjects = projectBranch.Where(x => x.OwnerUserId == UserManager.CurrentUserId).ToList(); 1312 1206 1313 1207 // get all assigned resourceIds (including children) of owned projects in this branch 1314 1208 var assignedResourceIds = ownedProjects.SelectMany(x => x.AssignedProjectResources).Select(x => x.ResourceId).ToList(); 1315 var assignedChildResourceIds = assignedResourceIds.SelectMany(x => resourceDao.Get ResourceIdsByChildId(x));1209 var assignedChildResourceIds = assignedResourceIds.SelectMany(x => resourceDao.GetParentResourceIdsById(x)); 1316 1210 assignedResourceIds.AddRange(assignedChildResourceIds); 1317 1211 1318 1212 // look up if all resourceIds are among the assigned ones 1319 if (resourceIds.Except(assignedResourceIds).Any()) {1213 if (resourceIds.Except(assignedResourceIds).Any()) { 1320 1214 throw new SecurityException(NOT_AUTHORIZED_RESOURCE); 1321 1215 } … … 1336 1230 // check if user is administrator, owner of the project or any parent project 1337 1231 var projectTree = new List<DA.Project> { project }; 1338 projectTree.AddRange(projectDao.GetP rojectsByChildId(projectId));1339 if (!projectTree.Select(x => x.OwnerUserId).Contains(UserManager.CurrentUserId)1232 projectTree.AddRange(projectDao.GetParentProjectsById(projectId)); 1233 if (!projectTree.Select(x => x.OwnerUserId).Contains(UserManager.CurrentUserId) 1340 1234 && !RoleVerifier.IsInRole(HiveRoles.Administrator)) { 1341 1235 throw new SecurityException(NOT_AUTHORIZED_PROJECT); … … 1351 1245 // note: this should be faster than checking all children of the assigned 1352 1246 // resource(-groups) for the certain resourceId 1353 var parentResourceIds = resourceDao.Get ResourceIdsByChildId(resourceId);1354 if (assignedResources.Select(x => x.ResourceId)1247 var parentResourceIds = resourceDao.GetParentResourceIdsById(resourceId); 1248 if (assignedResources.Select(x => x.ResourceId) 1355 1249 .Intersect(parentResourceIds).Count() > 0) { 1356 1250 return resource;
Note: See TracChangeset
for help on using the changeset viewer.