Coverage Summary for Class: SQLStrings (com.acciente.oacc.sql.internal.persister)

Class Class, % Method, % Line, %
SQLStrings 100% (1/ 1) 60% (3/ 5) 98.7% (156/ 158)


1 /* 2  * Copyright 2009-2018, Acciente LLC 3  * 4  * Acciente LLC licenses this file to you under the 5  * Apache License, Version 2.0 (the "License"); you 6  * may not use this file except in compliance with the 7  * License. You may obtain a copy of the License at 8  * 9  * http://www.apache.org/licenses/LICENSE-2.0 10  * 11  * Unless required by applicable law or agreed to in 12  * writing, software distributed under the License is 13  * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES 14  * OR CONDITIONS OF ANY KIND, either express or implied. 15  * See the License for the specific language governing 16  * permissions and limitations under the License. 17  */ 18 package com.acciente.oacc.sql.internal.persister; 19  20 import com.acciente.oacc.ResourcePermission; 21 import com.acciente.oacc.ResourcePermissions; 22 import com.acciente.oacc.sql.SQLDialect; 23 import com.acciente.oacc.sql.SQLProfile; 24  25 import java.io.Serializable; 26  27 public class SQLStrings implements Serializable { 28  private static final long serialVersionUID = 1L; 29  30  // SQL string constants 31  32  // ResourceClass - common 33  public final String SQL_findInResourceClass_ResourceClassID_BY_ResourceClassName; 34  public final String SQL_findInResourceClass_ResourceClassID_ResourceClassName_IsAuthenticatable_IsUnauthenticatedCreateAllowed_BY_ResourceClassName; 35  public final String SQL_findInResourceClass_ResourceClassID_ResourceClassName_IsAuthenticatable_IsUnauthenticatedCreateAllowed_BY_ResourceID; 36  public final String SQL_findInResourceClass_ResourceClassName_BY_ALL; 37  public final String SQL_createInResourceClass_WITH_ResourceClassName_IsAuthenticatable_IsUnauthenticatedCreateAllowed; 38  39  // ResourceClassPermission - common 40  public final String SQL_findInResourceClassPermission_PermissionID_BY_ResourceClassID_PermissionName; 41  public final String SQL_findInResourceClassPermission_PermissionName_BY_ResourceClassName; 42  public final String SQL_createInResourceClassPermission_WITH_ResourceClassID_PermissionName; 43  44  // Domain - common 45  public final String SQL_findInDomain_DomainID_BY_ResourceDomainName; 46  public final String SQL_findInDomain_ResourceDomainName_BY_ResourceID; 47  public final String SQL_createInDomain_WITH_ResourceDomainName; 48  public final String SQL_createInDomain_WITH_ResourceDomainName_ParentDomainID; 49  public final String SQL_removeInDomain_BY_DomainID; 50  // Domain - recursive 51  public final String SQL_findInDomain_DescendantResourceDomainName_BY_ResourceDomainName; 52  public final String SQL_findInDomain_DescendantResourceDomainID_BY_DomainID_ORDERBY_DomainLevel; 53  public final String SQL_removeInDomain_withDescendants_BY_DomainID; 54  // Domain - non-recursive 55  public final String SQL_findInDomain_DirectDescendantResourceDomainName_BY_ResourceDomainName; 56  public final String SQL_findInDomain_DirectDescendantResourceDomainName_BY_DomainID; 57  public final String SQL_findInDomain_ParentResourceDomainName_BY_DomainID; 58  59  // GrantDomainCreatePermissionSys - common 60  public final String SQL_findInGrantDomainCreatePermissionSys_withoutInheritance_SysPermissionID_BY_AccessorID; 61  public final String SQL_createInGrantDomainCreatePermissionSys_WITH_AccessorID_GrantorID_IsWithGrant_SysPermissionID; 62  public final String SQL_updateInGrantDomainCreatePermissionSys_SET_GrantorID_IsWithGrant_BY_AccessorID_SysPermissionID; 63  public final String SQL_removeInGrantDomainCreatePermissionSys_BY_AccessorID; 64  public final String SQL_removeInGrantDomainCreatePermissionSys_BY_AccessorID_SysPermissionID; 65  // GrantDomainCreatePermissionSys - recursive 66  public final String SQL_findInGrantDomainCreatePermissionSys_SysPermissionID_IsWithGrant_BY_AccessorID; 67  68  // GrantDomainCreatePermissionPostCreateSys - common 69  public final String SQL_findInGrantDomainCreatePermissionPostCreateSys_withoutInheritance_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID; 70  public final String SQL_removeInGrantDomainCreatePermissionPostCreateSys_BY_AccessorID; 71  public final String SQL_removeInGrantDomainCreatePermissionPostCreateSys_BY_AccessorID_PostCreateSysPermissionID; 72  public final String SQL_createInGrantDomainCreatePermissionPostCreateSys_WITH_AccessorID_GrantorID_IsWithGrant_PostCreateIsWithGrant_PostCreateSysPermissionID; 73  public final String SQL_updateInGrantDomainCreatePermissionPostCreateSys_SET_GrantorID_IsWithGrant_PostCreateIsWithGrant_BY_AccessorID_PostCreateSysPermissionID; 74  // GrantDomainCreatePermissionPostCreateSys - recursive 75  public final String SQL_findInGrantDomainCreatePermissionPostCreateSys_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID; 76  77  // GrantDomainPermissionSys - common 78  public final String SQL_findInGrantDomainPermissionSys_withoutInheritance_SysPermissionID_IsWithGrant_BY_AccessorID_DomainID; 79  public final String SQL_findInGrantDomainPermissionSys_withoutInheritance_ResourceDomainName_SysPermissionID_IsWithGrant_BY_AccessorID; 80  public final String SQL_createInGrantDomainPermissionSys_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_SysPermissionID; 81  public final String SQL_updateInGrantDomainPermissionSys_SET_GrantorID_IsWithGrant_BY_AccessorID_AccessedDomainID_SysPermissionID; 82  public final String SQL_removeInGrantDomainPermissionSys_BY_AccessorID; 83  public final String SQL_removeInGrantDomainPermissionSys_BY_AccessedDomainID; 84  public final String SQL_removeInGrantDomainPermissionSys_BY_AccessorID_AccessedDomainID; 85  public final String SQL_removeInGrantDomainPermissionSys_BY_AccessorID_AccessedDomainID_SysPermissionID; 86  // GrantDomainPermissionSys - recursive 87  public final String SQL_findInGrantDomainPermissionSys_ResourceID_ExternalId_BY_AccessorID_SysPermissionID_IsWithGrant_ResourceClassID; 88  public final String SQL_findInGrantDomainPermissionSys_ResourceID_ExternalID_BY_AccessorID_DomainID_SysPermissionID_IsWithGrant_ResourceClassID; 89  public final String SQL_findInGrantDomainPermissionSys_SysPermissionID_IsWithGrant_BY_AccessorID_DomainID; 90  public final String SQL_findInGrantDomainPermissionSys_ResourceDomainName_SysPermissionID_IsWithGrant_BY_AccessorID; 91  public final String SQL_removeInGrantDomainPermissionSys_withDescendants_BY_AccessedDomainID; 92  // GrantDomainPermissionSys - non-recursive 93  public final String SQL_findInGrantDomainPermissionSys_withoutInheritance_ResourceDomainId_BY_AccessorID_SysPermissionID_IsWithGrant; 94  95  // Resource - common 96  public final String SQL_findInResource_COUNTResourceID_BY_ResourceClassID_DomainID; 97  public final String SQL_createInResource_WITH_ResourceID_ResourceClassID_DomainID; 98  public final String SQL_createInResource_WITH_ResourceClassID_DomainID; 99  public final String SQL_removeInResource_BY_ResourceID; 100  public final String SQL_findInResource_ResourceId_BY_ResourceID; 101  public final String SQL_findInResource_ResourceId_ExternalId_BY_ResourceID; 102  public final String SQL_findInResource_DomainID_BY_ResourceID; 103  public final String SQL_findInResource_withoutInheritance_ResourceId_ExternalId_BY_ResourceClassID_DomainID; 104  public final String SQL_createInResourceExternalId_WITH_ResourceID_ExternalID; 105  public final String SQL_removeInResourceExternalId_BY_ResourceID; 106  public final String SQL_findInResourceExternalId_ResourceId_ExternalId_BY_ExternalID; 107  // Resource - recursive 108  public final String SQL_findInResource_COUNTResourceID_BY_DomainID; 109  // Resource - non-recursive 110  public final String SQL_findInResource_withoutInheritance_COUNTResourceID_BY_DomainID; 111  112  // GrantResourceCreatePermissionSys - common 113  public final String SQL_findInGrantResourceCreatePermissionSys_withoutInheritance_SysPermissionId_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID; 114  public final String SQL_findInGrantResourceCreatePermissionSys_withoutInheritance_ResourceDomainName_ResourceClassName_SysPermissionId_IsWithGrant_BY_AccessorID; 115  public final String SQL_createInGrantResourceCreatePermissionSys_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_ResourceClassID_SysPermissionId; 116  public final String SQL_updateInGrantResourceCreatePermissionSys_SET_GrantorID_IsWithGrant_BY__AccessorID_AccessedDomainID_ResourceClassID_SysPermissionId; 117  public final String SQL_removeInGrantResourceCreatePermissionSys_BY_AccessorID; 118  public final String SQL_removeInGrantResourceCreatePermissionSys_BY_AccessedDomainId; 119  public final String SQL_removeInGrantResourceCreatePermissionSys_BY_AccessorID_AccessedDomainID_ResourceClassID; 120  public final String SQL_removeInGrantResourceCreatePermissionSys_BY_AccessorID_AccessedDomainID_ResourceClassID_SysPermissionID; 121  // GrantResourceCreatePermissionSys - recursive 122  public final String SQL_findInGrantResourceCreatePermissionSys_SysPermissionId_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID; 123  public final String SQL_findInGrantResourceCreatePermissionSys_ResourceDomainName_ResourceClassName_SysPermissionId_IsWithGrant_BY_AccessorID; 124  public final String SQL_removeInGrantResourceCreatePermissionSys_withDescendants_BY_AccessedDomainId; 125  126  // GrantResourceCreatePermissionPostCreateSys - common 127  public final String SQL_findInGrantResourceCreatePermissionPostCreateSys_withoutInheritance_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID; 128  public final String SQL_findInGrantResourceCreatePermissionPostCreateSys_withoutInheritance_ResourceDomainName_ResourceClassName_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID; 129  public final String SQL_createInGrantResourceCreatePermissionPostCreateSys_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_PostCreateIsWithGrant_ResourceClassID_PostCreateSysPermissionID; 130  public final String SQL_updateInGrantResourceCreatePermissionPostCreateSys_SET_GrantorID_IsWithGrant_PostCreateIsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID_PostCreateSysPermissionID; 131  public final String SQL_removeInGrantResourceCreatePermissionPostCreateSys_BY_AccessorID; 132  public final String SQL_removeInGrantResourceCreatePermissionPostCreateSys_BY_AccessedDomainID; 133  public final String SQL_removeInGrantResourceCreatePermissionPostCreateSys_BY_AccessorID_AccessedDomainID_ResourceClassID; 134  public final String SQL_removeInGrantResourceCreatePermissionPostCreateSys_BY_AccessorID_AccessedDomainID_ResourceClassID_PostCreateSysPermissionID; 135  // GrantResourceCreatePermissionPostCreateSys - recursive 136  public final String SQL_findInGrantResourceCreatePermissionPostCreateSys_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID; 137  public final String SQL_findInGrantResourceCreatePermissionPostCreateSys_ResourceDomainName_ResourceClassName_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID; 138  public final String SQL_removeInGrantResourceCreatePermissionPostCreateSys_withDescendants_BY_AccessedDomainID; 139  140  // GrantResourceCreatePermissionPostCreate - common 141  public final String SQL_findInGrantResourceCreatePermissionPostCreate_withoutInheritance_PostCreatePermissionName_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID; 142  public final String SQL_findInGrantResourceCreatePermissionPostCreate_withoutInheritance_ResourceDomainName_ResourceClassName_PostCreatePermissionName_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID; 143  public final String SQL_createInGrantResourceCreatePermissionPostCreate_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_PostCreateIsWithGrant_ResourceClassID_PostCreatePermissionName; 144  public final String SQL_updateInGrantResourceCreatePermissionPostCreate_SET_GrantorID_IsWithGrant_PostCreateIsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID_PostCreatePermissionName; 145  public final String SQL_removeInGrantResourceCreatePermissionPostCreate_BY_AccessorID; 146  public final String SQL_removeInGrantResourceCreatePermissionPostCreate_BY_AccessedDomainId; 147  public final String SQL_removeInGrantResourceCreatePermissionPostCreate_BY_AccessorID_AccessedDomainID_ResourceClassID; 148  public final String SQL_removeInGrantResourceCreatePermissionPostCreate_BY_AccessorID_AccessedDomainID_ResourceClassID_PostCreatePermissionName; 149  // GrantResourceCreatePermissionPostCreate - recursive 150  public final String SQL_findInGrantResourceCreatePermissionPostCreate_ResourceClassName_PostCreatePermissionName_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID; 151  public final String SQL_findInGrantResourceCreatePermissionPostCreate_ResourceDomainName_ResourceClassName_PostCreatePermissionName_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID; 152  public final String SQL_removeInGrantResourceCreatePermissionPostCreate_withDescendants_BY_AccessedDomainId; 153  154  // GrantResourcePermissionSys - common 155  public final String SQL_findInGrantResourcePermissionSys_ResourceID_ExternalID_BY_AccessedID_ResourceClassID_SysPermissionID_IsWithGrant; 156  public final String SQL_findInGrantResourcePermissionSys_withoutInheritance_ResourceClassName_SysPermissionID_IsWithGrant_BY_AccessorID_AccessedID; 157  public final String SQL_createInGrantResourcePermissionSys_WITH_AccessorID_GrantorID_AccessedID_IsWithGrant_ResourceClassID_SysPermissionID; 158  public final String SQL_updateInGrantResourcePermissionSys_SET_GrantorID_IsWithGrant_BY_AccessorID_AccessedID_ResourceClassID_SysPermissionID; 159  public final String SQL_removeInGrantResourcePermissionSys_BY_AccessorID_OR_AccessedID; 160  public final String SQL_removeInGrantResourcePermissionSys_BY_AccessorID_AccessedID; 161  public final String SQL_removeInGrantResourcePermissionSys_BY_AccessorID_AccessedID_ResourceClassID_SysPermissionID; 162  // GrantResourcePermissionSys - recursive 163  public final String SQL_findInGrantResourcePermissionSys_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_SysPermissionID_IsWithGrant; 164  public final String SQL_findInGrantResourcePermissionSys_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_SysPermissionID_IsWithGrant; 165  public final String SQL_findInGrantResourcePermissionSys_ResourceClassName_SysPermissionID_IsWithGrant_BY_AccessorID_AccessedID; 166  // GrantResourcePermissionSys - non-recursive 167  public final String SQL_findInGrantResourcePermissionSys_directInheritance_ResourceID_BY_AccessorID; 168  public final String SQL_findInGrantResourcePermissionSys_withoutInheritance_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_SysPermissionID_IsWithGrant; 169  public final String SQL_findInGrantResourcePermissionSys_withoutInheritance_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_SysPermissionID_IsWithGrant; 170  171  // GrantResourcePermission - common 172  public final String SQL_findInGrantResourcePermission_ResourceID_ExternalID_BY_AccessedID_ResourceClassID_PermissionID_IsWithGrant; 173  public final String SQL_findInGrantResourcePermission_withoutInheritance_ResourceClassName_PermissionName_IsWithGrant_BY_AccessorID_AccessedID; 174  public final String SQL_createInGrantResourcePermission_WITH_AccessorID_GrantorID_AccessedID_IsWithGrant_ResourceClassID_PermissionName; 175  public final String SQL_updateInGrantResourcePermission_SET_GrantorID_IsWithGrant_BY_AccessorID_AccessedID_ResourceClassID_PermissionName; 176  public final String SQL_removeInGrantResourcePermission_BY_AccessorID_OR_AccessedID; 177  public final String SQL_removeInGrantResourcePermission_BY_AccessorID_AccessedID; 178  public final String SQL_removeInGrantResourcePermission_BY_AccessorID_AccessedID_ResourceClassID_PermissionName; 179  // GrantResourcePermission - recursive 180  public final String SQL_findInGrantResourcePermission_ResourceClassName_PermissionName_IsWithGrant_BY_AccessorID_AccessedID; 181  public final String SQL_findInGrantResourcePermission_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_PermissionID_IsWithGrant; 182  public final String SQL_findInGrantResourcePermission_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_PermissionID_IsWithGrant; 183  // GrantResourcePermission - non-recursive 184  public final String SQL_findInGrantResourcePermission_withoutInheritance_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_PermissionID_IsWithGrant; 185  public final String SQL_findInGrantResourcePermission_withoutInheritance_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_PermissionID_IsWithGrant; 186  187  // GrantGlobalResourcePermissionSys - common 188  public final String SQL_findInGrantGlobalResourcePermissionSys_withoutInheritance_SysPermissionID_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID; 189  public final String SQL_findInGrantGlobalResourcePermissionSys_withoutInheritance_ResourceDomainName_ResourceClassName_SysPermissionID_IsWithGrant_BY_AccessorID; 190  public final String SQL_createInGrantGlobalResourcePermissionSys_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_ResourceClassID_SysPermissionID; 191  public final String SQL_updateInGrantGlobalResourcePermissionSys_SET_GrantorID_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID_SysPermissionID; 192  public final String SQL_removeInGrantGlobalResourcePermissionSys_BY_AccessorID; 193  public final String SQL_removeInGrantGlobalResourcePermissionSys_BY_AccessedDomainId; 194  public final String SQL_removeInGrantGlobalResourcePermissionSys_BY_AccessorID_AccessedDomainID_ResourceClassID; 195  public final String SQL_removeInGrantGlobalResourcePermissionSys_BY_AccessorID_AccessedDomainID_ResourceClassID_SysPermissionID; 196  // GrantGlobalResourcePermissionSys - recursive 197  public final String SQL_findInGrantGlobalResourcePermissionSys_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_SysPermissionID_IsWithGrant_ResourceClassID; 198  public final String SQL_findInGrantGlobalResourcePermissionSys_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_SysPermissionID_IsWithGrant_ResourceClassID; 199  public final String SQL_findInGrantGlobalResourcePermissionSys_SysPermissionID_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID; 200  public final String SQL_findInGrantGlobalResourcePermissionSys_ResourceDomainName_ResourceClassName_SysPermissionID_IsWithGrant_BY_AccessorID; 201  public final String SQL_removeInGrantGlobalResourcePermissionSys_withDescendants_BY_AccessedDomainId; 202  // GrantGlobalResourcePermissionSys - non-recursive 203  public final String SQL_findInGrantGlobalResourcePermissionSys_withoutInheritance_ResourceDomainID_BY_AccessorID_ResourceClassID_SysPermissionID_IsWithGrant; 204  205  // GrantGlobalResourcePermission - common 206  public final String SQL_findInGrantGlobalResourcePermission_withoutInheritance_PermissionName_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID; 207  public final String SQL_findInGrantGlobalResourcePermission_withoutInheritance_ResourceDomainName_ResourceClassName_PermissionName_IsWithGrant_BY_AccessorID; 208  public final String SQL_createInGrantGlobalResourcePermission_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_ResourceClassID_PermissionName; 209  public final String SQL_updateInGrantGlobalResourcePermission_SET_GrantorID_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID_PermissionName; 210  public final String SQL_removeInGrantGlobalResourcePermission_BY_AccessorID; 211  public final String SQL_removeInGrantGlobalResourcePermission_BY_AccessedDomainId; 212  public final String SQL_removeInGrantGlobalResourcePermission_BY_AccessorID_AccessedDomainID_ResourceClassID; 213  public final String SQL_removeInGrantGlobalResourcePermission_BY_AccessorID_AccessedDomainID_ResourceClassID_PermissionName; 214  // GrantGlobalResourcePermission - recursive 215  public final String SQL_findInGrantGlobalResourcePermission_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_PermissionID_IsWithGrant_ResourceClassID; 216  public final String SQL_findInGrantGlobalResourcePermission_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_PermissionID_IsWithGrant_ResourceClassID; 217  public final String SQL_findInGrantGlobalResourcePermission_PermissionName_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID; 218  public final String SQL_findInGrantGlobalResourcePermission_ResourceDomainName_ResourceClassName_PermissionName_IsWithGrant_BY_AccessorID; 219  public final String SQL_removeInGrantGlobalResourcePermission_withDescendants_BY_AccessedDomainId; 220  // GrantGlobalResourcePermission - non-recursive 221  public final String SQL_findInGrantGlobalResourcePermission_withoutInheritance_ResourceDomainID_BY_AccessorID_ResourceClassID_PermissionID_IsWithGrant; 222  223  // Key generators 224  public final String SQL_nextResourceID; 225  226  private final SQLProfile sqlProfile; 227  228  // resource permissions constants 229  private static final ResourcePermission ResourcePermission_INHERIT = ResourcePermissions.getInstance(ResourcePermissions.INHERIT); 230  231  public static SQLStrings getSQLStrings(String schemaName, 232  SQLProfile sqlProfile) { 233  return new SQLStrings(schemaName, sqlProfile, DialectSpecificSQLGenerator.getInstance(sqlProfile 234  .getSqlDialect())); 235  } 236  237  private SQLStrings(String schemaName, 238  SQLProfile sqlProfile, 239  DialectSpecificSQLGenerator dialectSpecificSQLGenerator) { 240  this.sqlProfile = sqlProfile; 241  final String withClause = dialectSpecificSQLGenerator.getWithClause(); 242  final String unionClause = dialectSpecificSQLGenerator.getUnionClause(); 243  final String schemaNameAndTablePrefix = schemaName != null ? schemaName + ".OAC_" : "OAC_"; 244  // recursive query to compute all the resource ids that a given accessor is equivalent to as a 245  // result of having the INHERIT permission 246  final String SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 247  = withClause + " N( AccessorResourceId ) AS " 248  + "( SELECT ResourceId FROM " 249  + schemaNameAndTablePrefix 250  + "Resource WHERE ResourceId = ? " + unionClause + " SELECT Nplus1.AccessedResourceId FROM " 251  + schemaNameAndTablePrefix 252  + "Grant_ResPerm_Sys Nplus1, N " 253  + "WHERE Nplus1.AccessorResourceId = N.AccessorResourceId AND Nplus1.SysPermissionId = " 254  + ResourcePermission_INHERIT.getSystemPermissionId() 255  + " ) "; 256  257  // recursive query to compute all ancestors of a given an domain 258  final String SQL_findAncestorsRecursiveInDomain_DomainID_BY_DomainID 259  = ", R( DomainId, ParentDomainId ) AS " 260  + "( SELECT DomainId, ParentDomainId FROM " 261  + schemaNameAndTablePrefix 262  + "Domain WHERE DomainId = ? " + unionClause + " SELECT Rplus1.DomainId, Rplus1.ParentDomainId FROM " 263  + schemaNameAndTablePrefix 264  + "Domain Rplus1, R " 265  + "WHERE R.ParentDomainId IS NOT NULL AND Rplus1.DomainId = R.ParentDomainId ) "; 266  267  // recursive query to compute all descendants of a given an domain 268  final String SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 269  = "S( DomainId ) AS " 270  + "( SELECT DomainId FROM " 271  + schemaNameAndTablePrefix 272  + "Domain WHERE DomainId = ? " + unionClause + " SELECT Splus1.DomainId FROM " 273  + schemaNameAndTablePrefix 274  + "Domain Splus1, S " 275  + "WHERE Splus1.ParentDomainId IS NOT NULL AND Splus1.ParentDomainId = S.DomainId ) "; 276  277  // ResourceClass 278  SQL_findInResourceClass_ResourceClassID_BY_ResourceClassName 279  = "SELECT ResourceClassId FROM " 280  + schemaNameAndTablePrefix 281  + "ResourceClass WHERE ResourceClassName = ?"; 282  283  SQL_findInResourceClass_ResourceClassID_ResourceClassName_IsAuthenticatable_IsUnauthenticatedCreateAllowed_BY_ResourceClassName 284  = "SELECT ResourceClassId, ResourceClassName, IsAuthenticatable, IsUnauthenticatedCreateAllowed FROM " 285  + schemaNameAndTablePrefix 286  + "ResourceClass WHERE ResourceClassName = ?"; 287  288  SQL_findInResourceClass_ResourceClassID_ResourceClassName_IsAuthenticatable_IsUnauthenticatedCreateAllowed_BY_ResourceID 289  = "SELECT ResourceClassId, ResourceClassName, IsAuthenticatable, IsUnauthenticatedCreateAllowed FROM " 290  + schemaNameAndTablePrefix 291  + "ResourceClass WHERE ResourceClassId = ( SELECT ResourceClassId FROM " 292  + schemaNameAndTablePrefix 293  + "Resource WHERE ResourceId = ? )"; 294  295  SQL_findInResourceClass_ResourceClassName_BY_ALL 296  = "SELECT ResourceClassName FROM " 297  + schemaNameAndTablePrefix 298  + "ResourceClass WHERE ResourceClassId <> 0"; // <> 0 filters out the SYSOBJECT class 299  300  SQL_createInResourceClass_WITH_ResourceClassName_IsAuthenticatable_IsUnauthenticatedCreateAllowed 301  = sqlProfile.isSequenceEnabled() 302  ? "INSERT INTO " 303  + schemaNameAndTablePrefix 304  + "ResourceClass ( ResourceClassId, ResourceClassName, IsAuthenticatable, IsUnauthenticatedCreateAllowed ) " 305  + "VALUES ( " 306  + dialectSpecificSQLGenerator.nextSequenceValueFragment(schemaNameAndTablePrefix + "ResourceClassId") 307  + ", ?, ?, ? )" 308  : "INSERT INTO " 309  + schemaNameAndTablePrefix 310  + "ResourceClass ( ResourceClassName, IsAuthenticatable, IsUnauthenticatedCreateAllowed ) " 311  + "VALUES ( ?, ?, ? )"; 312  313  // ResourceClassPermission 314  SQL_findInResourceClassPermission_PermissionID_BY_ResourceClassID_PermissionName 315  = "SELECT PermissionId FROM " 316  + schemaNameAndTablePrefix 317  + "ResourceClassPermission WHERE ResourceClassId = ? AND PermissionName = ?"; 318  319  SQL_findInResourceClassPermission_PermissionName_BY_ResourceClassName 320  = "SELECT PermissionName FROM " 321  + schemaNameAndTablePrefix 322  + "ResourceClassPermission WHERE ResourceClassId = ( SELECT ResourceClassId FROM " 323  + schemaNameAndTablePrefix 324  + "ResourceClass WHERE ResourceClassName = ? )"; 325  326  SQL_createInResourceClassPermission_WITH_ResourceClassID_PermissionName 327  = sqlProfile.isSequenceEnabled() 328  ? "INSERT INTO " 329  + schemaNameAndTablePrefix 330  + "ResourceClassPermission ( ResourceClassId, PermissionId, PermissionName ) VALUES ( ?, " 331  + dialectSpecificSQLGenerator.nextSequenceValueFragment(schemaNameAndTablePrefix + "PermissionId") 332  + ", ? )" 333  : "INSERT INTO " 334  + schemaNameAndTablePrefix 335  + "ResourceClassPermission ( ResourceClassId, PermissionName ) VALUES ( ?, ? )"; 336  337  // Domain - common 338  SQL_findInDomain_DomainID_BY_ResourceDomainName 339  = "SELECT DomainId FROM " 340  + schemaNameAndTablePrefix 341  + "Domain WHERE DomainName = ?"; 342  343  SQL_findInDomain_ResourceDomainName_BY_ResourceID 344  = "SELECT DomainName FROM " 345  + schemaNameAndTablePrefix 346  + "Domain WHERE DomainId = ( SELECT DomainId FROM " 347  + schemaNameAndTablePrefix 348  + "Resource WHERE ResourceId = ? )"; 349  350  SQL_createInDomain_WITH_ResourceDomainName 351  = sqlProfile.isSequenceEnabled() 352  ? "INSERT INTO " 353  + schemaNameAndTablePrefix 354  + "Domain ( DomainId, DomainName ) VALUES ( " 355  + dialectSpecificSQLGenerator.nextSequenceValueFragment(schemaNameAndTablePrefix + "DomainId") 356  + ", ? )" 357  : "INSERT INTO " 358  + schemaNameAndTablePrefix 359  + "Domain ( DomainName ) VALUES ( ? )"; 360  361  SQL_createInDomain_WITH_ResourceDomainName_ParentDomainID 362  = sqlProfile.isSequenceEnabled() 363  ? "INSERT INTO " 364  + schemaNameAndTablePrefix 365  + "Domain ( DomainId, DomainName, ParentDomainId ) VALUES ( " 366  + dialectSpecificSQLGenerator.nextSequenceValueFragment(schemaNameAndTablePrefix + "DomainId") 367  + ", ?, ? )" 368  : "INSERT INTO " 369  + schemaNameAndTablePrefix 370  + "Domain ( DomainName, ParentDomainId ) VALUES ( ?, ? )"; 371  372  SQL_removeInDomain_BY_DomainID 373  = "DELETE FROM " 374  + schemaNameAndTablePrefix 375  + "Domain WHERE DomainId = ?"; 376  377  // Domain - recursive 378  // recursive query to return all descendants domain names of the specified domain names 379  SQL_findInDomain_DescendantResourceDomainName_BY_ResourceDomainName 380  = withClause + " S( DomainId, DomainName ) AS " 381  + "( SELECT DomainId, DomainName FROM " 382  + schemaNameAndTablePrefix 383  + "Domain WHERE DomainName = ? " 384  + unionClause + " " 385  + "SELECT Splus1.DomainId, Splus1.DomainName FROM " 386  + schemaNameAndTablePrefix 387  + "Domain Splus1, S " 388  + "WHERE Splus1.ParentDomainId IS NOT NULL AND Splus1.ParentDomainId = S.DomainId ) " 389  + "SELECT DomainId, DomainName FROM S"; 390  391  SQL_findInDomain_DescendantResourceDomainID_BY_DomainID_ORDERBY_DomainLevel 392  = withClause + " S( DomainId, DomainName, DomainLevel ) AS " 393  + "( SELECT DomainId, DomainName, 0 FROM " 394  + schemaNameAndTablePrefix 395  + "Domain WHERE DomainId = ? " 396  + unionClause + " " 397  + "SELECT Splus1.DomainId, Splus1.DomainName, S.DomainLevel + 1 FROM " 398  + schemaNameAndTablePrefix 399  + "Domain Splus1, S " 400  + "WHERE Splus1.ParentDomainId IS NOT NULL AND Splus1.ParentDomainId = S.DomainId ) " 401  + "SELECT DomainId, DomainName FROM S ORDER BY DomainLevel"; 402  403  SQL_removeInDomain_withDescendants_BY_DomainID 404  = sqlProfile.isRecursiveDeleteEnabled() 405  ? (SQLDialect.Oracle_11_2.equals(sqlProfile.getSqlDialect())) 406  ? "DELETE FROM " 407  + schemaNameAndTablePrefix 408  + "Domain WHERE DomainId IN ( " 409  + withClause + " " 410  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 411  + "SELECT DomainId FROM S )" 412  : withClause + " " 413  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 414  + "DELETE FROM " 415  + schemaNameAndTablePrefix 416  + "Domain WHERE DomainId IN ( SELECT DomainId FROM S )" 417  : null; 418  419  // Domain - non-recursive 420  // non-recursive query to return only direct (first-level) descendants domain names of the specified domain 421  SQL_findInDomain_DirectDescendantResourceDomainName_BY_ResourceDomainName 422  = "SELECT d1.DomainId, d1.DomainName FROM " 423  + schemaNameAndTablePrefix 424  + "Domain d0 JOIN " 425  + schemaNameAndTablePrefix 426  + "Domain d1 on d1.ParentDomainId=d0.DomainId WHERE d0.DomainName = ?"; 427  428  SQL_findInDomain_DirectDescendantResourceDomainName_BY_DomainID 429  = "SELECT DomainId, DomainName FROM " 430  + schemaNameAndTablePrefix 431  + "Domain WHERE ParentDomainId = ?"; 432  433  SQL_findInDomain_ParentResourceDomainName_BY_DomainID 434  = "SELECT d1.DomainId, d1.DomainName FROM " 435  + schemaNameAndTablePrefix 436  + "Domain d0 JOIN " 437  + schemaNameAndTablePrefix 438  + "Domain d1 ON d1.DomainId = d0.ParentDomainId WHERE d0.DomainId = ?"; 439  440  // GrantDomainCreatePermissionSys - common 441  SQL_findInGrantDomainCreatePermissionSys_withoutInheritance_SysPermissionID_BY_AccessorID 442  = "SELECT A.SysPermissionId, A.IsWithGrant FROM " 443  + schemaNameAndTablePrefix 444  + "Grant_DomCrPerm_Sys A " 445  + "WHERE A.AccessorResourceId = ?"; 446  447  SQL_createInGrantDomainCreatePermissionSys_WITH_AccessorID_GrantorID_IsWithGrant_SysPermissionID 448  = "INSERT INTO " 449  + schemaNameAndTablePrefix 450  + "Grant_DomCrPerm_Sys ( AccessorResourceId, GrantorResourceId, IsWithGrant, SysPermissionId ) " 451  + "VALUES( ?, ?, ?, ? )"; 452  453  SQL_updateInGrantDomainCreatePermissionSys_SET_GrantorID_IsWithGrant_BY_AccessorID_SysPermissionID 454  = "UPDATE " 455  + schemaNameAndTablePrefix 456  + "Grant_DomCrPerm_Sys SET GrantorResourceId = ?, IsWithGrant = ? " 457  + "WHERE AccessorResourceId = ? AND SysPermissionId = ?"; 458  459  SQL_removeInGrantDomainCreatePermissionSys_BY_AccessorID 460  = "DELETE FROM " 461  + schemaNameAndTablePrefix 462  + "Grant_DomCrPerm_Sys WHERE AccessorResourceId = ?"; 463  464  SQL_removeInGrantDomainCreatePermissionSys_BY_AccessorID_SysPermissionID 465  = "DELETE FROM " 466  + schemaNameAndTablePrefix 467  + "Grant_DomCrPerm_Sys WHERE AccessorResourceId = ? AND SysPermissionId = ?"; 468  469  // GrantDomainCreatePermissionSys - recursive 470  SQL_findInGrantDomainCreatePermissionSys_SysPermissionID_IsWithGrant_BY_AccessorID 471  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 472  + "SELECT A.SysPermissionId, A.IsWithGrant FROM " 473  + schemaNameAndTablePrefix 474  + "Grant_DomCrPerm_Sys A " 475  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId "; 476  477  // GrantDomainCreatePermissionPostCreateSys - common 478  SQL_findInGrantDomainCreatePermissionPostCreateSys_withoutInheritance_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID 479  = "SELECT A.PostCreateSysPermissionId, A.PostCreateIsWithGrant, A.IsWithGrant FROM " 480  + schemaNameAndTablePrefix 481  + "Grant_DomCrPerm_PostCr_Sys A " 482  + "WHERE A.AccessorResourceId = ?"; 483  484  SQL_createInGrantDomainCreatePermissionPostCreateSys_WITH_AccessorID_GrantorID_IsWithGrant_PostCreateIsWithGrant_PostCreateSysPermissionID 485  = "INSERT INTO " 486  + schemaNameAndTablePrefix 487  + "Grant_DomCrPerm_PostCr_Sys ( AccessorResourceId, GrantorResourceId, IsWithGrant, PostCreateIsWithGrant, PostCreateSysPermissionId ) " 488  + "VALUES( ?, ?, ?, ?, ? )"; 489  490  SQL_updateInGrantDomainCreatePermissionPostCreateSys_SET_GrantorID_IsWithGrant_PostCreateIsWithGrant_BY_AccessorID_PostCreateSysPermissionID 491  = "UPDATE " 492  + schemaNameAndTablePrefix 493  + "Grant_DomCrPerm_PostCr_Sys SET GrantorResourceId = ?, IsWithGrant = ?, PostCreateIsWithGrant = ? " 494  + "WHERE AccessorResourceId = ? AND PostCreateSysPermissionId = ?"; 495  496  SQL_removeInGrantDomainCreatePermissionPostCreateSys_BY_AccessorID 497  = "DELETE FROM " 498  + schemaNameAndTablePrefix 499  + "Grant_DomCrPerm_PostCr_Sys WHERE AccessorResourceId = ?"; 500  501  SQL_removeInGrantDomainCreatePermissionPostCreateSys_BY_AccessorID_PostCreateSysPermissionID 502  = "DELETE FROM " 503  + schemaNameAndTablePrefix 504  + "Grant_DomCrPerm_PostCr_Sys WHERE AccessorResourceId = ? AND PostCreateSysPermissionId = ?"; 505  506  // GrantDomainCreatePermissionPostCreateSys - recursive 507  SQL_findInGrantDomainCreatePermissionPostCreateSys_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID 508  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 509  + "SELECT A.PostCreateSysPermissionId, A.PostCreateIsWithGrant, A.IsWithGrant FROM " 510  + schemaNameAndTablePrefix 511  + "Grant_DomCrPerm_PostCr_Sys A " 512  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId "; 513  514  // GrantDomainPermissionSys - common 515  SQL_findInGrantDomainPermissionSys_withoutInheritance_SysPermissionID_IsWithGrant_BY_AccessorID_DomainID 516  = "SELECT A.SysPermissionId, A.IsWithGrant FROM " 517  + schemaNameAndTablePrefix 518  + "Grant_DomPerm_Sys A " 519  + "WHERE A.AccessorResourceId = ? AND A.AccessedDomainId = ?"; 520  521  SQL_findInGrantDomainPermissionSys_withoutInheritance_ResourceDomainName_SysPermissionID_IsWithGrant_BY_AccessorID 522  = "SELECT B.DomainName, A.SysPermissionId, A.IsWithGrant FROM " 523  + schemaNameAndTablePrefix 524  + "Grant_DomPerm_Sys A JOIN " 525  + schemaNameAndTablePrefix 526  + "Domain B ON B.DomainId = A.AccessedDomainId " 527  + "WHERE A.AccessorResourceId = ?"; 528  529  SQL_createInGrantDomainPermissionSys_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_SysPermissionID 530  = "INSERT INTO " 531  + schemaNameAndTablePrefix 532  + "Grant_DomPerm_Sys ( AccessorResourceId, GrantorResourceId, AccessedDomainId, IsWithGrant, SysPermissionId ) VALUES ( ?, ?, ?, ?, ? )"; 533  534  SQL_updateInGrantDomainPermissionSys_SET_GrantorID_IsWithGrant_BY_AccessorID_AccessedDomainID_SysPermissionID 535  = "UPDATE " 536  + schemaNameAndTablePrefix 537  + "Grant_DomPerm_Sys SET GrantorResourceId = ?, IsWithGrant = ? " 538  + "WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND SysPermissionId = ?"; 539  540  SQL_removeInGrantDomainPermissionSys_BY_AccessorID 541  = "DELETE FROM " 542  + schemaNameAndTablePrefix 543  + "Grant_DomPerm_Sys WHERE AccessorResourceId = ?"; 544  545  SQL_removeInGrantDomainPermissionSys_BY_AccessedDomainID 546  = "DELETE FROM " 547  + schemaNameAndTablePrefix 548  + "Grant_DomPerm_Sys WHERE AccessedDomainId = ?"; 549  550  SQL_removeInGrantDomainPermissionSys_BY_AccessorID_AccessedDomainID 551  = "DELETE FROM " 552  + schemaNameAndTablePrefix 553  + "Grant_DomPerm_Sys WHERE AccessorResourceId = ? AND AccessedDomainId = ?"; 554  555  SQL_removeInGrantDomainPermissionSys_BY_AccessorID_AccessedDomainID_SysPermissionID 556  = "DELETE FROM " 557  + schemaNameAndTablePrefix 558  + "Grant_DomPerm_Sys WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND SysPermissionId = ?"; 559  560  // GrantDomainPermissionSys - recursive 561  562  // query returns the resources that the accessor has access to via super user permission 563  SQL_findInGrantDomainPermissionSys_ResourceID_ExternalId_BY_AccessorID_SysPermissionID_IsWithGrant_ResourceClassID 564  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 565  + ", R( DomainId ) AS " 566  // this sub query is the starting set for the domain recursion, it returns all the direct 567  // resources domains that the accessor has the specified system permission on (currently super-user) 568  + "( SELECT AccessedDomainId FROM " 569  + schemaNameAndTablePrefix 570  + "Grant_DomPerm_Sys G " 571  + "JOIN N ON N.AccessorResourceId = G.AccessorResourceId " 572  + "WHERE G.SysPermissionId = ? AND ( ? IN ( 0, G.IsWithGrant ) ) " 573  // now we find the nested domains that the accessor can reach from the direct set above 574  + unionClause + " SELECT Rplus1.DomainId FROM " 575  + schemaNameAndTablePrefix 576  + "Domain Rplus1, R " 577  + "WHERE Rplus1.ParentDomainId IS NOT NULL AND Rplus1.ParentDomainId = R.DomainId ) " 578  // finally we get the resources of the specified type in the domains we computed above 579  + "SELECT A.ResourceId, E.ExternalId FROM " 580  + schemaNameAndTablePrefix 581  + "Resource A " 582  + "JOIN R ON R.DomainId = A.DomainId LEFT JOIN " 583  + schemaNameAndTablePrefix 584  + "ResourceExternalID E ON E.ResourceId = A.ResourceId " 585  + "WHERE A.ResourceClassId = ?"; 586  587  SQL_findInGrantDomainPermissionSys_ResourceID_ExternalID_BY_AccessorID_DomainID_SysPermissionID_IsWithGrant_ResourceClassID 588  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 589  + ", " + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 590  + ", R( DomainId ) AS " 591  // this sub query is the starting set for the domain recursion, it returns all the direct 592  // resources domains that the accessor has the specified system permission on (currently super-user) 593  + "( SELECT AccessedDomainId FROM " 594  + schemaNameAndTablePrefix 595  + "Grant_DomPerm_Sys G " 596  + "JOIN N ON N.AccessorResourceId = G.AccessorResourceId " 597  + "WHERE G.SysPermissionId = ? AND ( ? IN ( 0, G.IsWithGrant ) ) " 598  // now we find the nested domains that the accessor can reach from the direct set above 599  + unionClause + " SELECT Rplus1.DomainId FROM " 600  + schemaNameAndTablePrefix 601  + "Domain Rplus1, R " 602  + "WHERE Rplus1.ParentDomainId IS NOT NULL AND Rplus1.ParentDomainId = R.DomainId ) " 603  // finally we get the resources of the specified type in the domains we computed above 604  + "SELECT A.ResourceId, E.ExternalId FROM " 605  + schemaNameAndTablePrefix 606  + "Resource A " 607  + "JOIN R ON R.DomainId = A.DomainId " 608  + "JOIN S ON S.DomainId = A.DomainId LEFT JOIN " 609  + schemaNameAndTablePrefix 610  + "ResourceExternalID E ON E.ResourceId = A.ResourceId " 611  + "WHERE A.ResourceClassId = ?"; 612  613  SQL_findInGrantDomainPermissionSys_SysPermissionID_IsWithGrant_BY_AccessorID_DomainID 614  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 615  + SQL_findAncestorsRecursiveInDomain_DomainID_BY_DomainID 616  + "SELECT A.SysPermissionId, A.IsWithGrant FROM " 617  + schemaNameAndTablePrefix 618  + "Grant_DomPerm_Sys A " 619  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 620  + "JOIN R ON R.DomainId = A.AccessedDomainId "; 621  622  SQL_findInGrantDomainPermissionSys_ResourceDomainName_SysPermissionID_IsWithGrant_BY_AccessorID 623  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 624  + ", P( AccessedDomainId, SysPermissionId, IsWithGrant ) AS " 625  + "( SELECT A.AccessedDomainId, A.SysPermissionId, A.IsWithGrant FROM " 626  + schemaNameAndTablePrefix 627  + "Grant_DomPerm_Sys A " 628  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 629  + unionClause + " " 630  + "SELECT Pplus1.DomainId, P.SysPermissionId, P.IsWithGrant FROM " 631  + schemaNameAndTablePrefix 632  + "Domain Pplus1, P " 633  + "WHERE Pplus1.ParentDomainId IS NOT NULL AND Pplus1.ParentDomainId = P.AccessedDomainId ) " 634  + "SELECT B.DomainName, P.SysPermissionId, P.IsWithGrant FROM P JOIN " 635  + schemaNameAndTablePrefix 636  + "Domain B ON B.DomainId = P.AccessedDomainId"; 637  638  SQL_removeInGrantDomainPermissionSys_withDescendants_BY_AccessedDomainID 639  = sqlProfile.isRecursiveDeleteEnabled() 640  ? (SQLDialect.Oracle_11_2.equals(sqlProfile.getSqlDialect())) 641  ? "DELETE FROM " 642  + schemaNameAndTablePrefix 643  + "Grant_DomPerm_Sys WHERE AccessedDomainId IN ( " 644  + withClause + " " 645  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 646  + "SELECT DomainId FROM S )" 647  : withClause + " " 648  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 649  + "DELETE FROM " 650  + schemaNameAndTablePrefix 651  + "Grant_DomPerm_Sys WHERE AccessedDomainId IN ( SELECT DomainId FROM S )" 652  : null; 653  654  // GrantDomainPermissionSys - non-recursive 655  SQL_findInGrantDomainPermissionSys_withoutInheritance_ResourceDomainId_BY_AccessorID_SysPermissionID_IsWithGrant 656  = "SELECT AccessedDomainID FROM " 657  + schemaNameAndTablePrefix 658  + "Grant_DomPerm_Sys " 659  + "WHERE AccessorResourceId = ? AND SysPermissionId = ? AND ( ? IN ( 0, IsWithGrant ) )"; 660  661  // Resource: finder methods used getAccessorResourcesByResourcePermission() 662  SQL_findInGrantResourcePermissionSys_ResourceID_ExternalID_BY_AccessedID_ResourceClassID_SysPermissionID_IsWithGrant 663  = "SELECT A.AccessorResourceId ResourceId, E.ExternalId FROM " 664  + schemaNameAndTablePrefix 665  + "Grant_ResPerm_Sys A LEFT JOIN " 666  + schemaNameAndTablePrefix 667  + "ResourceExternalID E ON E.ResourceId = A.AccessorResourceId " 668  + "WHERE A.AccessedResourceId = ? AND A.ResourceClassId = ? AND A.SysPermissionId = ? AND ( ? IN ( 0, A.IsWithGrant ) )"; 669  670  // Resource - common 671  SQL_findInResource_COUNTResourceID_BY_ResourceClassID_DomainID 672  = "SELECT COUNT( ResourceId ) COUNTResourceID FROM " 673  + schemaNameAndTablePrefix 674  + "Resource WHERE ResourceClassId = ? AND DomainId = ?"; 675  676  SQL_createInResource_WITH_ResourceID_ResourceClassID_DomainID 677  = "INSERT INTO " 678  + schemaNameAndTablePrefix 679  + "Resource ( ResourceId, ResourceClassId, DomainId ) VALUES ( ?, ?, ? )"; 680  681  SQL_createInResource_WITH_ResourceClassID_DomainID 682  = "INSERT INTO " 683  + schemaNameAndTablePrefix 684  + "Resource ( ResourceClassId, DomainId ) VALUES ( ?, ? )"; 685  686  SQL_removeInResource_BY_ResourceID 687  = "DELETE FROM " + schemaNameAndTablePrefix + "Resource WHERE ResourceId = ?"; 688  689  SQL_findInResource_ResourceId_BY_ResourceID 690  = "SELECT ResourceId FROM " + schemaNameAndTablePrefix + "Resource WHERE ResourceId = ?"; 691  692  SQL_findInResource_ResourceId_ExternalId_BY_ResourceID 693  = "SELECT A.ResourceId, B.ExternalId FROM " 694  + schemaNameAndTablePrefix + "Resource A LEFT JOIN " 695  + schemaNameAndTablePrefix + "ResourceExternalID B ON B.ResourceID = A.ResourceID WHERE A.ResourceId = ?"; 696  697  SQL_findInResource_DomainID_BY_ResourceID 698  = "SELECT DomainId FROM " + schemaNameAndTablePrefix + "Resource WHERE ResourceId = ? "; 699  700  SQL_findInResource_withoutInheritance_ResourceId_ExternalId_BY_ResourceClassID_DomainID 701  = "SELECT A.ResourceId, E.ExternalId FROM " 702  + schemaNameAndTablePrefix + "Resource A LEFT JOIN " 703  + schemaNameAndTablePrefix + "ResourceExternalID E ON E.ResourceId = A.ResourceId " 704  + "WHERE A.ResourceClassId = ? AND A.DomainId = ?"; 705  706  SQL_createInResourceExternalId_WITH_ResourceID_ExternalID 707  = "INSERT INTO " 708  + schemaNameAndTablePrefix 709  + "ResourceExternalID ( ResourceId, ExternalId ) VALUES ( ?, ? )"; 710  711  SQL_removeInResourceExternalId_BY_ResourceID 712  = "DELETE FROM " + schemaNameAndTablePrefix + "ResourceExternalID WHERE ResourceId = ?"; 713  714  SQL_findInResourceExternalId_ResourceId_ExternalId_BY_ExternalID 715  = "SELECT ResourceId, ExternalId FROM " 716  + schemaNameAndTablePrefix + "ResourceExternalID WHERE ExternalId = ?"; 717  718  // Resource - recursive 719  SQL_findInResource_COUNTResourceID_BY_DomainID 720  = withClause + " " 721  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 722  + "SELECT COUNT( ResourceId ) COUNTResourceID FROM " 723  + schemaNameAndTablePrefix 724  + "Resource C JOIN S ON S.DomainId = C.DomainId"; 725  726  // Resource - non-recursive 727  SQL_findInResource_withoutInheritance_COUNTResourceID_BY_DomainID 728  = "SELECT COUNT( ResourceId ) COUNTResourceID FROM " 729  + schemaNameAndTablePrefix 730  + "Resource WHERE DomainId = ?"; 731  732  // GrantResourceCreatePermissionSys - common 733  SQL_findInGrantResourceCreatePermissionSys_withoutInheritance_SysPermissionId_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID 734  = "SELECT A.SysPermissionId, A.IsWithGrant FROM " 735  + schemaNameAndTablePrefix 736  + "Grant_ResCrPerm_Sys A " 737  + "WHERE A.AccessorResourceId = ? AND A.AccessedDomainId = ? AND A.ResourceClassId = ?"; 738  739  SQL_findInGrantResourceCreatePermissionSys_withoutInheritance_ResourceDomainName_ResourceClassName_SysPermissionId_IsWithGrant_BY_AccessorID 740  = "SELECT C.DomainName, B.ResourceClassName, A.SysPermissionId, A.IsWithGrant FROM " 741  + schemaNameAndTablePrefix 742  + "Grant_ResCrPerm_Sys A JOIN " 743  + schemaNameAndTablePrefix 744  + "ResourceClass B ON B.ResourceClassId = A.ResourceClassId JOIN " 745  + schemaNameAndTablePrefix 746  + "Domain C ON C.DomainId = A.AccessedDomainId " 747  + "WHERE A.AccessorResourceId = ?"; 748  749  SQL_createInGrantResourceCreatePermissionSys_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_ResourceClassID_SysPermissionId 750  = "INSERT INTO " 751  + schemaNameAndTablePrefix 752  + "Grant_ResCrPerm_Sys ( AccessorResourceId, GrantorResourceId, AccessedDomainId, IsWithGrant, ResourceClassId, SysPermissionId ) " 753  + "VALUES( ?, ?, ?, ?, ?, ? )"; 754  755  SQL_updateInGrantResourceCreatePermissionSys_SET_GrantorID_IsWithGrant_BY__AccessorID_AccessedDomainID_ResourceClassID_SysPermissionId 756  = "UPDATE " 757  + schemaNameAndTablePrefix 758  + "Grant_ResCrPerm_Sys SET GrantorResourceId = ?, IsWithGrant = ? " 759  + "WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ? AND SysPermissionId = ?"; 760  761  SQL_removeInGrantResourceCreatePermissionSys_BY_AccessorID 762  = "DELETE FROM " 763  + schemaNameAndTablePrefix 764  + "Grant_ResCrPerm_Sys WHERE AccessorResourceId = ?"; 765  766  SQL_removeInGrantResourceCreatePermissionSys_BY_AccessedDomainId 767  = "DELETE FROM " 768  + schemaNameAndTablePrefix 769  + "Grant_ResCrPerm_Sys WHERE AccessedDomainId = ?"; 770  771  SQL_removeInGrantResourceCreatePermissionSys_BY_AccessorID_AccessedDomainID_ResourceClassID 772  = "DELETE FROM " 773  + schemaNameAndTablePrefix 774  + "Grant_ResCrPerm_Sys WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ?"; 775  776  SQL_removeInGrantResourceCreatePermissionSys_BY_AccessorID_AccessedDomainID_ResourceClassID_SysPermissionID 777  = "DELETE FROM " 778  + schemaNameAndTablePrefix 779  + "Grant_ResCrPerm_Sys WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ? AND SysPermissionId = ?"; 780  781  // GrantResourceCreatePermissionSys - recursive 782  SQL_findInGrantResourceCreatePermissionSys_SysPermissionId_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID 783  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 784  + SQL_findAncestorsRecursiveInDomain_DomainID_BY_DomainID 785  + "SELECT A.SysPermissionId, A.IsWithGrant FROM " 786  + schemaNameAndTablePrefix 787  + "Grant_ResCrPerm_Sys A " 788  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 789  + "JOIN R ON R.DomainId = A.AccessedDomainId " 790  + "WHERE A.ResourceClassId = ?"; 791  792  SQL_findInGrantResourceCreatePermissionSys_ResourceDomainName_ResourceClassName_SysPermissionId_IsWithGrant_BY_AccessorID 793  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 794  + ", P( AccessedDomainId, ResourceClassId, SysPermissionId, IsWithGrant ) AS " 795  + "( SELECT A.AccessedDomainId, A.ResourceClassId, A.SysPermissionId, A.IsWithGrant FROM " 796  + schemaNameAndTablePrefix 797  + "Grant_ResCrPerm_Sys A " 798  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 799  + unionClause + " " 800  + "SELECT Pplus1.DomainId, P.ResourceClassId, P.SysPermissionId, P.IsWithGrant FROM " 801  + schemaNameAndTablePrefix 802  + "Domain Pplus1, P " 803  + "WHERE Pplus1.ParentDomainId IS NOT NULL AND Pplus1.ParentDomainId = P.AccessedDomainId ) " 804  + "SELECT C.DomainName, B.ResourceClassName, P.SysPermissionId, P.IsWithGrant FROM P JOIN " 805  + schemaNameAndTablePrefix 806  + "ResourceClass B ON B.ResourceClassId = P.ResourceClassId JOIN " 807  + schemaNameAndTablePrefix 808  + "Domain C ON C.DomainId = P.AccessedDomainId"; 809  810  SQL_removeInGrantResourceCreatePermissionSys_withDescendants_BY_AccessedDomainId 811  = sqlProfile.isRecursiveDeleteEnabled() 812  ? (SQLDialect.Oracle_11_2.equals(sqlProfile.getSqlDialect())) 813  ? "DELETE FROM " 814  + schemaNameAndTablePrefix 815  + "Grant_ResCrPerm_Sys WHERE AccessedDomainId IN ( " 816  + withClause + " " 817  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 818  + "SELECT DomainId FROM S )" 819  : withClause + " " 820  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 821  + "DELETE FROM " 822  + schemaNameAndTablePrefix 823  + "Grant_ResCrPerm_Sys WHERE AccessedDomainId IN ( SELECT DomainId FROM S )" 824  : null; 825  826  // GrantResourceCreatePermissionPostCreateSys - common 827  SQL_findInGrantResourceCreatePermissionPostCreateSys_withoutInheritance_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID 828  = "SELECT A.PostCreateSysPermissionId, A.PostCreateIsWithGrant, A.IsWithGrant FROM " 829  + schemaNameAndTablePrefix 830  + "Grant_ResCrPerm_PostCr_Sys A " 831  + "WHERE A.AccessorResourceId = ? AND A.AccessedDomainId = ? AND A.ResourceClassId = ?"; 832  833  SQL_findInGrantResourceCreatePermissionPostCreateSys_withoutInheritance_ResourceDomainName_ResourceClassName_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID 834  = "SELECT C.DomainName, B.ResourceClassName, A.PostCreateSysPermissionId, A.PostCreateIsWithGrant, A.IsWithGrant FROM " 835  + schemaNameAndTablePrefix 836  + "Grant_ResCrPerm_PostCr_Sys A JOIN " 837  + schemaNameAndTablePrefix 838  + "ResourceClass B ON B.ResourceClassId = A.ResourceClassId JOIN " 839  + schemaNameAndTablePrefix 840  + "Domain C ON C.DomainId = A.AccessedDomainId " 841  + "WHERE A.AccessorResourceId = ?"; 842  843  SQL_createInGrantResourceCreatePermissionPostCreateSys_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_PostCreateIsWithGrant_ResourceClassID_PostCreateSysPermissionID 844  = "INSERT INTO " 845  + schemaNameAndTablePrefix 846  + "Grant_ResCrPerm_PostCr_Sys ( AccessorResourceId, GrantorResourceId, AccessedDomainId, IsWithGrant, PostCreateIsWithGrant, ResourceClassId, PostCreateSysPermissionId ) " 847  + "VALUES( ?, ?, ?, ?, ?, ?, ? )"; 848  849  SQL_updateInGrantResourceCreatePermissionPostCreateSys_SET_GrantorID_IsWithGrant_PostCreateIsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID_PostCreateSysPermissionID 850  = "UPDATE " 851  + schemaNameAndTablePrefix 852  + "Grant_ResCrPerm_PostCr_Sys SET GrantorResourceId = ?, IsWithGrant = ?, PostCreateIsWithGrant = ? " 853  + "WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ? AND PostCreateSysPermissionId = ?"; 854  855  SQL_removeInGrantResourceCreatePermissionPostCreateSys_BY_AccessorID 856  = "DELETE FROM " 857  + schemaNameAndTablePrefix 858  + "Grant_ResCrPerm_PostCr_Sys WHERE AccessorResourceId = ?"; 859  860  SQL_removeInGrantResourceCreatePermissionPostCreateSys_BY_AccessedDomainID 861  = "DELETE FROM " 862  + schemaNameAndTablePrefix 863  + "Grant_ResCrPerm_PostCr_Sys WHERE AccessedDomainId = ?"; 864  865  SQL_removeInGrantResourceCreatePermissionPostCreateSys_BY_AccessorID_AccessedDomainID_ResourceClassID 866  = "DELETE FROM " 867  + schemaNameAndTablePrefix 868  + "Grant_ResCrPerm_PostCr_Sys WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ?"; 869  870  SQL_removeInGrantResourceCreatePermissionPostCreateSys_BY_AccessorID_AccessedDomainID_ResourceClassID_PostCreateSysPermissionID 871  = "DELETE FROM " 872  + schemaNameAndTablePrefix 873  + "Grant_ResCrPerm_PostCr_Sys WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ? AND PostCreateSysPermissionId = ?"; 874  875  // GrantResourceCreatePermissionPostCreateSys - recursive 876  SQL_findInGrantResourceCreatePermissionPostCreateSys_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID 877  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 878  + SQL_findAncestorsRecursiveInDomain_DomainID_BY_DomainID 879  + "SELECT A.PostCreateSysPermissionId, A.PostCreateIsWithGrant, A.IsWithGrant FROM " 880  + schemaNameAndTablePrefix 881  + "Grant_ResCrPerm_PostCr_Sys A " 882  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 883  + "JOIN R ON R.DomainId = A.AccessedDomainId " 884  + "WHERE A.ResourceClassId = ?"; 885  886  SQL_findInGrantResourceCreatePermissionPostCreateSys_ResourceDomainName_ResourceClassName_PostCreateSysPermissionID_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID 887  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 888  + ", P( AccessedDomainId, ResourceClassId, PostCreateSysPermissionId, PostCreateIsWithGrant, IsWithGrant ) AS " 889  + "( SELECT A.AccessedDomainId, A.ResourceClassId, A.PostCreateSysPermissionId, A.PostCreateIsWithGrant, A.IsWithGrant FROM " 890  + schemaNameAndTablePrefix 891  + "Grant_ResCrPerm_PostCr_Sys A " 892  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 893  + unionClause + " " 894  + "SELECT Pplus1.DomainId, P.ResourceClassId, P.PostCreateSysPermissionId, P.PostCreateIsWithGrant, P.IsWithGrant FROM " 895  + schemaNameAndTablePrefix 896  + "Domain Pplus1, P " 897  + "WHERE Pplus1.ParentDomainId IS NOT NULL AND Pplus1.ParentDomainId = P.AccessedDomainId ) " 898  + "SELECT C.DomainName, B.ResourceClassName, P.PostCreateSysPermissionId, P.PostCreateIsWithGrant, P.IsWithGrant FROM P JOIN " 899  + schemaNameAndTablePrefix 900  + "ResourceClass B ON B.ResourceClassId = P.ResourceClassId JOIN " 901  + schemaNameAndTablePrefix 902  + "Domain C ON C.DomainId = P.AccessedDomainId"; 903  904  SQL_removeInGrantResourceCreatePermissionPostCreateSys_withDescendants_BY_AccessedDomainID 905  = sqlProfile.isRecursiveDeleteEnabled() 906  ? (SQLDialect.Oracle_11_2.equals(sqlProfile.getSqlDialect())) 907  ? "DELETE FROM " 908  + schemaNameAndTablePrefix 909  + "Grant_ResCrPerm_PostCr_Sys WHERE AccessedDomainId IN ( " 910  + withClause + " " 911  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 912  + "SELECT DomainId FROM S )" 913  : withClause + " " 914  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 915  + "DELETE FROM " 916  + schemaNameAndTablePrefix 917  + "Grant_ResCrPerm_PostCr_Sys WHERE AccessedDomainId IN ( SELECT DomainId FROM S )" 918  : null; 919  920  // GrantResourceCreatePermissionPostCreate - common 921  SQL_findInGrantResourceCreatePermissionPostCreate_withoutInheritance_PostCreatePermissionName_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID 922  = "SELECT B.PermissionName PostCreatePermissionName, A.PostCreateIsWithGrant, A.IsWithGrant FROM " 923  + schemaNameAndTablePrefix 924  + "Grant_ResCrPerm_PostCr A JOIN " 925  + schemaNameAndTablePrefix 926  + "ResourceClassPermission B ON B.ResourceClassId = A.ResourceClassId AND B.PermissionId = A.PostCreatePermissionId " 927  + "WHERE A.AccessorResourceId = ? AND A.AccessedDomainId = ? AND A.ResourceClassId = ?"; 928  929  SQL_findInGrantResourceCreatePermissionPostCreate_withoutInheritance_ResourceDomainName_ResourceClassName_PostCreatePermissionName_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID 930  = "SELECT D.DomainName, C.ResourceClassName, B.PermissionName PostCreatePermissionName, A.PostCreateIsWithGrant, A.IsWithGrant FROM " 931  + schemaNameAndTablePrefix 932  + "Grant_ResCrPerm_PostCr A JOIN " 933  + schemaNameAndTablePrefix 934  + "ResourceClassPermission B ON B.ResourceClassId = A.ResourceClassId AND B.PermissionId = A.PostCreatePermissionId JOIN " 935  + schemaNameAndTablePrefix 936  + "ResourceClass C ON C.ResourceClassId = A.ResourceClassId JOIN " 937  + schemaNameAndTablePrefix 938  + "Domain D ON D.DomainId = A.AccessedDomainId " 939  + "WHERE A.AccessorResourceId = ?"; 940  941  SQL_createInGrantResourceCreatePermissionPostCreate_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_PostCreateIsWithGrant_ResourceClassID_PostCreatePermissionName 942  = "INSERT INTO " 943  + schemaNameAndTablePrefix 944  + "Grant_ResCrPerm_PostCr ( AccessorResourceId, GrantorResourceId, AccessedDomainId, IsWithGrant, PostCreateIsWithGrant, ResourceClassId, PostCreatePermissionId ) " 945  + "SELECT ?, ?, ?, ?, ?, A.ResourceClassId, A.PermissionId FROM " 946  + schemaNameAndTablePrefix 947  + "ResourceClassPermission A WHERE A.ResourceClassId = ? AND A.PermissionName = ?"; 948  949  SQL_updateInGrantResourceCreatePermissionPostCreate_SET_GrantorID_IsWithGrant_PostCreateIsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID_PostCreatePermissionName 950  = "UPDATE " 951  + schemaNameAndTablePrefix 952  + "Grant_ResCrPerm_PostCr SET GrantorResourceId = ?, IsWithGrant = ?, PostCreateIsWithGrant = ? " 953  + "WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ? AND PostCreatePermissionId = ( " 954  + "SELECT A.PermissionId FROM " 955  + schemaNameAndTablePrefix 956  + "ResourceClassPermission A WHERE A.ResourceClassId = " 957  + schemaNameAndTablePrefix 958  + "Grant_ResCrPerm_PostCr.ResourceClassId AND A.PermissionName = ? )"; 959  960  SQL_removeInGrantResourceCreatePermissionPostCreate_BY_AccessorID 961  = "DELETE FROM " 962  + schemaNameAndTablePrefix 963  + "Grant_ResCrPerm_PostCr WHERE AccessorResourceId = ?"; 964  965  SQL_removeInGrantResourceCreatePermissionPostCreate_BY_AccessedDomainId 966  = "DELETE FROM " 967  + schemaNameAndTablePrefix 968  + "Grant_ResCrPerm_PostCr WHERE AccessedDomainId = ?"; 969  970  SQL_removeInGrantResourceCreatePermissionPostCreate_BY_AccessorID_AccessedDomainID_ResourceClassID 971  = "DELETE FROM " 972  + schemaNameAndTablePrefix 973  + "Grant_ResCrPerm_PostCr WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ?"; 974  975  SQL_removeInGrantResourceCreatePermissionPostCreate_BY_AccessorID_AccessedDomainID_ResourceClassID_PostCreatePermissionName 976  = "DELETE FROM " 977  + schemaNameAndTablePrefix 978  + "Grant_ResCrPerm_PostCr WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ? AND PostCreatePermissionId = ( " 979  + "SELECT A.PermissionId FROM " 980  + schemaNameAndTablePrefix 981  + "ResourceClassPermission A WHERE A.ResourceClassId = " 982  + schemaNameAndTablePrefix 983  + "Grant_ResCrPerm_PostCr.ResourceClassId AND A.PermissionName = ? )"; 984  985  // GrantResourceCreatePermissionPostCreate - recursive 986  SQL_findInGrantResourceCreatePermissionPostCreate_ResourceClassName_PostCreatePermissionName_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID 987  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 988  + SQL_findAncestorsRecursiveInDomain_DomainID_BY_DomainID 989  + "SELECT C.ResourceClassName, B.PermissionName PostCreatePermissionName, A.PostCreateIsWithGrant, A.IsWithGrant FROM " 990  + schemaNameAndTablePrefix 991  + "Grant_ResCrPerm_PostCr A JOIN " 992  + schemaNameAndTablePrefix 993  + "ResourceClassPermission B ON B.ResourceClassId = A.ResourceClassId AND B.PermissionId = A.PostCreatePermissionId JOIN " 994  + schemaNameAndTablePrefix 995  + "ResourceClass C ON C.ResourceClassId = A.ResourceClassId " 996  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 997  + "JOIN R ON R.DomainId = A.AccessedDomainId " 998  + "WHERE A.ResourceClassId = ?"; 999  1000  SQL_findInGrantResourceCreatePermissionPostCreate_ResourceDomainName_ResourceClassName_PostCreatePermissionName_PostCreateIsWithGrant_IsWithGrant_BY_AccessorID 1001  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1002  + ", P( AccessedDomainId, ResourceClassId, PostCreatePermissionId, PostCreateIsWithGrant, IsWithGrant ) AS " 1003  + "( SELECT A.AccessedDomainId, A.ResourceClassId, A.PostCreatePermissionId, A.PostCreateIsWithGrant, A.IsWithGrant FROM " 1004  + schemaNameAndTablePrefix 1005  + "Grant_ResCrPerm_PostCr A " 1006  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 1007  + unionClause + " " 1008  + "SELECT Pplus1.DomainId, P.ResourceClassId, P.PostCreatePermissionId, P.PostCreateIsWithGrant, P.IsWithGrant FROM " 1009  + schemaNameAndTablePrefix 1010  + "Domain Pplus1, P " 1011  + "WHERE Pplus1.ParentDomainId IS NOT NULL AND Pplus1.ParentDomainId = P.AccessedDomainId ) " 1012  + "SELECT D.DomainName, C.ResourceClassName, B.PermissionName PostCreatePermissionName, P.PostCreateIsWithGrant, P.IsWithGrant FROM P JOIN " 1013  + schemaNameAndTablePrefix 1014  + "ResourceClassPermission B ON B.ResourceClassId = P.ResourceClassId AND B.PermissionId = P.PostCreatePermissionId JOIN " 1015  + schemaNameAndTablePrefix 1016  + "ResourceClass C ON C.ResourceClassId = P.ResourceClassId JOIN " 1017  + schemaNameAndTablePrefix 1018  + "Domain D ON D.DomainId = P.AccessedDomainId"; 1019  1020  SQL_removeInGrantResourceCreatePermissionPostCreate_withDescendants_BY_AccessedDomainId 1021  = sqlProfile.isRecursiveDeleteEnabled() 1022  ? (SQLDialect.Oracle_11_2.equals(sqlProfile.getSqlDialect())) 1023  ? "DELETE FROM " 1024  + schemaNameAndTablePrefix 1025  + "Grant_ResCrPerm_PostCr WHERE AccessedDomainId IN ( " 1026  + withClause + " " 1027  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 1028  + "SELECT DomainId FROM S )" 1029  : withClause + " " 1030  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 1031  + "DELETE FROM " 1032  + schemaNameAndTablePrefix 1033  + "Grant_ResCrPerm_PostCr WHERE AccessedDomainId IN ( SELECT DomainId FROM S )" 1034  : null; 1035  1036  // GrantResourcePermissionSys - common 1037  SQL_findInGrantResourcePermissionSys_withoutInheritance_ResourceClassName_SysPermissionID_IsWithGrant_BY_AccessorID_AccessedID 1038  = "SELECT B.ResourceClassName, A.SysPermissionId, A.IsWithGrant FROM " 1039  + schemaNameAndTablePrefix 1040  + "Grant_ResPerm_Sys A JOIN " 1041  + schemaNameAndTablePrefix 1042  + "ResourceClass B ON B.ResourceClassId = A.ResourceClassId " 1043  + "WHERE A.AccessorResourceId = ? AND A.AccessedResourceId = ?"; 1044  1045  SQL_createInGrantResourcePermissionSys_WITH_AccessorID_GrantorID_AccessedID_IsWithGrant_ResourceClassID_SysPermissionID 1046  = "INSERT INTO " 1047  + schemaNameAndTablePrefix 1048  + "Grant_ResPerm_Sys ( AccessorResourceId, GrantorResourceId, AccessedResourceId, IsWithGrant, ResourceClassId, SysPermissionId ) " 1049  + "VALUES ( ?, ?, ?, ?, ?, ? )"; 1050  1051  SQL_updateInGrantResourcePermissionSys_SET_GrantorID_IsWithGrant_BY_AccessorID_AccessedID_ResourceClassID_SysPermissionID 1052  = "UPDATE " 1053  + schemaNameAndTablePrefix 1054  + "Grant_ResPerm_Sys SET GrantorResourceId = ?, IsWithGrant = ? " 1055  + "WHERE AccessorResourceId = ? AND AccessedResourceId = ? AND ResourceClassId = ? AND SysPermissionId = ?"; 1056  1057  SQL_removeInGrantResourcePermissionSys_BY_AccessorID_OR_AccessedID 1058  = "DELETE FROM " 1059  + schemaNameAndTablePrefix 1060  + "Grant_ResPerm_Sys WHERE AccessorResourceId = ? OR AccessedResourceId = ?"; 1061  1062  SQL_removeInGrantResourcePermissionSys_BY_AccessorID_AccessedID 1063  = "DELETE FROM " 1064  + schemaNameAndTablePrefix 1065  + "Grant_ResPerm_Sys WHERE AccessorResourceId = ? AND AccessedResourceId = ?"; 1066  1067  SQL_removeInGrantResourcePermissionSys_BY_AccessorID_AccessedID_ResourceClassID_SysPermissionID 1068  = "DELETE FROM " 1069  + schemaNameAndTablePrefix 1070  + "Grant_ResPerm_Sys WHERE AccessorResourceId = ? AND AccessedResourceId = ? AND ResourceClassId = ? AND SysPermissionId = ?"; 1071  1072  // GrantResourcePermissionSys - recursive 1073  SQL_findInGrantResourcePermissionSys_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_SysPermissionID_IsWithGrant 1074  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1075  + "SELECT B.AccessedResourceId ResourceId, E.ExternalId FROM " 1076  + schemaNameAndTablePrefix 1077  + "Grant_ResPerm_Sys B " 1078  + "JOIN N ON N.AccessorResourceId = B.AccessorResourceId LEFT JOIN " 1079  + schemaNameAndTablePrefix 1080  + "ResourceExternalID E ON E.ResourceId = B.AccessedResourceId " 1081  + "WHERE B.ResourceClassId = ? AND B.SysPermissionId = ? AND ( ? IN ( 0, B.IsWithGrant ) )"; 1082  1083  SQL_findInGrantResourcePermissionSys_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_SysPermissionID_IsWithGrant 1084  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1085  + ", " + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 1086  + "SELECT B.AccessedResourceId ResourceId, E.ExternalId FROM " 1087  + schemaNameAndTablePrefix 1088  + "Grant_ResPerm_Sys B JOIN " 1089  + schemaNameAndTablePrefix 1090  + "Resource C ON C.ResourceId = B.AccessedResourceId " 1091  + "JOIN N ON N.AccessorResourceId = B.AccessorResourceId " 1092  + "JOIN S ON S.DomainId = C.DomainId LEFT JOIN " 1093  + schemaNameAndTablePrefix 1094  + "ResourceExternalID E ON E.ResourceId = B.AccessedResourceId " 1095  + "WHERE B.ResourceClassId = ? AND B.SysPermissionId = ? AND ( ? IN ( 0, B.IsWithGrant ) )"; 1096  1097  SQL_findInGrantResourcePermissionSys_ResourceClassName_SysPermissionID_IsWithGrant_BY_AccessorID_AccessedID 1098  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1099  + "SELECT B.ResourceClassName, A.SysPermissionId, A.IsWithGrant FROM " 1100  + schemaNameAndTablePrefix 1101  + "Grant_ResPerm_Sys A JOIN " 1102  + schemaNameAndTablePrefix 1103  + "ResourceClass B ON B.ResourceClassId = A.ResourceClassId " 1104  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 1105  + "WHERE A.AccessedResourceId = ?"; 1106  1107  // GrantResourcePermissionSys - non-recursive 1108  SQL_findInGrantResourcePermissionSys_directInheritance_ResourceID_BY_AccessorID 1109  = "SELECT AccessedResourceId ResourceId FROM " 1110  + schemaNameAndTablePrefix 1111  + "Grant_ResPerm_Sys " 1112  + "WHERE AccessorResourceId = ? AND SysPermissionId = " 1113  + ResourcePermission_INHERIT.getSystemPermissionId(); 1114  1115  SQL_findInGrantResourcePermissionSys_withoutInheritance_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_SysPermissionID_IsWithGrant 1116  = "SELECT B.AccessedResourceId ResourceId, E.ExternalId FROM " 1117  + schemaNameAndTablePrefix 1118  + "Grant_ResPerm_Sys B LEFT JOIN " 1119  + schemaNameAndTablePrefix 1120  + "ResourceExternalID E ON E.ResourceId = B.AccessedResourceId " 1121  + "WHERE B.AccessorResourceId = ? AND B.ResourceClassId = ? AND B.SysPermissionId = ? AND ( ? IN ( 0, B.IsWithGrant ) )"; 1122  1123  SQL_findInGrantResourcePermissionSys_withoutInheritance_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_SysPermissionID_IsWithGrant 1124  = "SELECT B.AccessedResourceId ResourceId, E.ExternalId FROM " 1125  + schemaNameAndTablePrefix 1126  + "Grant_ResPerm_Sys B JOIN " 1127  + schemaNameAndTablePrefix 1128  + "Resource C ON C.ResourceId = B.AccessedResourceId LEFT JOIN " 1129  + schemaNameAndTablePrefix 1130  + "ResourceExternalID E ON E.ResourceId = B.AccessedResourceId " 1131  + "WHERE B.AccessorResourceId = ? AND C.DomainId = ? AND B.ResourceClassId = ? AND B.SysPermissionId = ? AND ( ? IN ( 0, B.IsWithGrant ) )"; 1132  1133  // GrantResourcePermission - common 1134  SQL_findInGrantResourcePermission_ResourceID_ExternalID_BY_AccessedID_ResourceClassID_PermissionID_IsWithGrant 1135  = "SELECT A.AccessorResourceId ResourceId, E.ExternalId FROM " 1136  + schemaNameAndTablePrefix 1137  + "Grant_ResPerm A LEFT JOIN " 1138  + schemaNameAndTablePrefix 1139  + "ResourceExternalID E ON E.ResourceId = A.AccessorResourceId " 1140  + "WHERE A.AccessedResourceId = ? AND A.ResourceClassId = ? AND A.PermissionId = ? AND ( ? IN ( 0, A.IsWithGrant ) )"; 1141  1142  SQL_findInGrantResourcePermission_withoutInheritance_ResourceClassName_PermissionName_IsWithGrant_BY_AccessorID_AccessedID 1143  = "SELECT C.ResourceClassName, B.PermissionName, A.IsWithGrant FROM " 1144  + schemaNameAndTablePrefix 1145  + "Grant_ResPerm A JOIN " 1146  + schemaNameAndTablePrefix 1147  + "ResourceClassPermission B ON B.ResourceClassId = A.ResourceClassId AND B.PermissionId = A.PermissionId JOIN " 1148  + schemaNameAndTablePrefix 1149  + "ResourceClass C ON C.ResourceClassId = A.ResourceClassId " 1150  + "WHERE A.AccessorResourceId = ? AND A.AccessedResourceId = ?"; 1151  1152  SQL_createInGrantResourcePermission_WITH_AccessorID_GrantorID_AccessedID_IsWithGrant_ResourceClassID_PermissionName 1153  = "INSERT INTO " 1154  + schemaNameAndTablePrefix 1155  + "Grant_ResPerm ( AccessorResourceId, GrantorResourceId, AccessedResourceId, IsWithGrant, ResourceClassId, PermissionId ) " 1156  + "SELECT ?, ?, ?, ?, A.ResourceClassId, A.PermissionId FROM " 1157  + schemaNameAndTablePrefix 1158  + "ResourceClassPermission A WHERE A.ResourceClassId = ? AND A.PermissionName = ?"; 1159  1160  SQL_updateInGrantResourcePermission_SET_GrantorID_IsWithGrant_BY_AccessorID_AccessedID_ResourceClassID_PermissionName 1161  = "UPDATE " 1162  + schemaNameAndTablePrefix 1163  + "Grant_ResPerm SET GrantorResourceId = ?, IsWithGrant = ? " 1164  + "WHERE AccessorResourceId = ? AND AccessedResourceId = ? AND ResourceClassId = ? AND PermissionId = ( " 1165  + "SELECT A.PermissionId FROM " 1166  + schemaNameAndTablePrefix 1167  + "ResourceClassPermission A WHERE A.ResourceClassId = " 1168  + schemaNameAndTablePrefix 1169  + "Grant_ResPerm.ResourceClassId AND A.PermissionName = ? )"; 1170  1171  SQL_removeInGrantResourcePermission_BY_AccessorID_OR_AccessedID 1172  = "DELETE FROM " 1173  + schemaNameAndTablePrefix 1174  + "Grant_ResPerm WHERE AccessorResourceId = ? OR AccessedResourceId = ?"; 1175  1176  SQL_removeInGrantResourcePermission_BY_AccessorID_AccessedID 1177  = "DELETE FROM " 1178  + schemaNameAndTablePrefix 1179  + "Grant_ResPerm WHERE AccessorResourceId = ? AND AccessedResourceId = ?"; 1180  1181  SQL_removeInGrantResourcePermission_BY_AccessorID_AccessedID_ResourceClassID_PermissionName 1182  = "DELETE FROM " 1183  + schemaNameAndTablePrefix 1184  + "Grant_ResPerm WHERE AccessorResourceId = ? AND AccessedResourceId = ? AND ResourceClassId = ? AND PermissionId = ( " 1185  + "SELECT A.PermissionId FROM " 1186  + schemaNameAndTablePrefix 1187  + "ResourceClassPermission A WHERE A.ResourceClassId = " 1188  + schemaNameAndTablePrefix 1189  + "Grant_ResPerm.ResourceClassId AND A.PermissionName = ? )"; 1190  1191  // GrantResourcePermission - recursive 1192  SQL_findInGrantResourcePermission_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_PermissionID_IsWithGrant 1193  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1194  + "SELECT B.AccessedResourceId ResourceId, E.ExternalId FROM " 1195  + schemaNameAndTablePrefix 1196  + "Grant_ResPerm B " 1197  + "JOIN N ON N.AccessorResourceId = B.AccessorResourceId LEFT JOIN " 1198  + schemaNameAndTablePrefix 1199  + "ResourceExternalID E ON E.ResourceId = B.AccessedResourceId " 1200  + "WHERE B.ResourceClassId = ? AND B.PermissionId = ? AND ( ? IN ( 0, B.IsWithGrant ) )"; 1201  1202  SQL_findInGrantResourcePermission_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_PermissionID_IsWithGrant 1203  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1204  + ", " + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 1205  + "SELECT B.AccessedResourceId ResourceId, E.ExternalId FROM " 1206  + schemaNameAndTablePrefix 1207  + "Grant_ResPerm B JOIN " 1208  + schemaNameAndTablePrefix 1209  + "Resource C ON C.ResourceId = B.AccessedResourceId " 1210  + "JOIN N ON N.AccessorResourceId = B.AccessorResourceId " 1211  + "JOIN S ON S.DomainId = C.DomainId LEFT JOIN " 1212  + schemaNameAndTablePrefix 1213  + "ResourceExternalID E ON E.ResourceId = B.AccessedResourceId " 1214  + "WHERE B.ResourceClassId = ? AND B.PermissionId = ? AND ( ? IN ( 0, B.IsWithGrant ) )"; 1215  1216  SQL_findInGrantResourcePermission_ResourceClassName_PermissionName_IsWithGrant_BY_AccessorID_AccessedID 1217  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1218  + "SELECT C.ResourceClassName, B.PermissionName, A.IsWithGrant FROM " 1219  + schemaNameAndTablePrefix 1220  + "Grant_ResPerm A JOIN " 1221  + schemaNameAndTablePrefix 1222  + "ResourceClassPermission B ON B.ResourceClassId = A.ResourceClassId AND B.PermissionId = A.PermissionId JOIN " 1223  + schemaNameAndTablePrefix 1224  + "ResourceClass C ON C.ResourceClassId = A.ResourceClassId " 1225  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 1226  + "WHERE A.AccessedResourceId = ?"; 1227  1228  // GrantResourcePermission - non-recursive 1229  SQL_findInGrantResourcePermission_withoutInheritance_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_PermissionID_IsWithGrant 1230  = "SELECT A.AccessedResourceId ResourceId, E.ExternalId FROM " 1231  + schemaNameAndTablePrefix 1232  + "Grant_ResPerm A LEFT JOIN " 1233  + schemaNameAndTablePrefix 1234  + "ResourceExternalID E ON E.ResourceId = A.AccessedResourceId " 1235  + "WHERE A.AccessorResourceId = ? AND A.ResourceClassId = ? AND A.PermissionId = ? AND ( ? IN ( 0, A.IsWithGrant ) )"; 1236  1237  SQL_findInGrantResourcePermission_withoutInheritance_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_PermissionID_IsWithGrant 1238  = "SELECT A.AccessedResourceId ResourceId, E.ExternalId FROM " 1239  + schemaNameAndTablePrefix 1240  + "Grant_ResPerm A JOIN " 1241  + schemaNameAndTablePrefix 1242  + "Resource B ON A.AccessedResourceId=B.ResourceId LEFT JOIN " 1243  + schemaNameAndTablePrefix 1244  + "ResourceExternalID E ON E.ResourceId = A.AccessedResourceId " 1245  + "WHERE A.AccessorResourceId = ? AND B.DomainId = ? AND A.ResourceClassId = ? AND A.PermissionId = ? AND ( ? IN ( 0, A.IsWithGrant ) )"; 1246  1247  // GrantGlobalResourcePermissionSys - common 1248  SQL_findInGrantGlobalResourcePermissionSys_withoutInheritance_SysPermissionID_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID 1249  = "SELECT A.SysPermissionId, A.IsWithGrant FROM " 1250  + schemaNameAndTablePrefix 1251  + "Grant_Global_ResPerm_Sys A " 1252  + "WHERE A.AccessorResourceId = ? AND A.AccessedDomainId = ? AND A.ResourceClassId = ?"; 1253  1254  SQL_findInGrantGlobalResourcePermissionSys_withoutInheritance_ResourceDomainName_ResourceClassName_SysPermissionID_IsWithGrant_BY_AccessorID 1255  = "SELECT C.DomainName, B.ResourceClassName, A.SysPermissionId, A.IsWithGrant FROM " 1256  + schemaNameAndTablePrefix 1257  + "Grant_Global_ResPerm_Sys A JOIN " 1258  + schemaNameAndTablePrefix 1259  + "ResourceClass B ON B.ResourceClassId = A.ResourceClassId JOIN " 1260  + schemaNameAndTablePrefix 1261  + "Domain C ON C.DomainId = A.AccessedDomainId " 1262  + "WHERE A.AccessorResourceId = ?"; 1263  1264  SQL_createInGrantGlobalResourcePermissionSys_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_ResourceClassID_SysPermissionID 1265  = "INSERT INTO " 1266  + schemaNameAndTablePrefix 1267  + "Grant_Global_ResPerm_Sys ( AccessorResourceId, GrantorResourceId, AccessedDomainId, IsWithGrant, ResourceClassId, SysPermissionId ) " 1268  + "VALUES ( ?, ?, ?, ?, ?, ? )"; 1269  1270  SQL_updateInGrantGlobalResourcePermissionSys_SET_GrantorID_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID_SysPermissionID 1271  = "UPDATE " 1272  + schemaNameAndTablePrefix 1273  + "Grant_Global_ResPerm_Sys SET GrantorResourceId = ?, IsWithGrant = ? " 1274  + "WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ? AND SysPermissionId = ?"; 1275  1276  SQL_removeInGrantGlobalResourcePermissionSys_BY_AccessorID 1277  = "DELETE FROM " 1278  + schemaNameAndTablePrefix 1279  + "Grant_Global_ResPerm_Sys WHERE AccessorResourceId = ?"; 1280  1281  SQL_removeInGrantGlobalResourcePermissionSys_BY_AccessedDomainId 1282  = "DELETE FROM " 1283  + schemaNameAndTablePrefix 1284  + "Grant_Global_ResPerm_Sys WHERE AccessedDomainId = ?"; 1285  1286  SQL_removeInGrantGlobalResourcePermissionSys_BY_AccessorID_AccessedDomainID_ResourceClassID 1287  = "DELETE FROM " 1288  + schemaNameAndTablePrefix 1289  + "Grant_Global_ResPerm_Sys WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ?"; 1290  1291  SQL_removeInGrantGlobalResourcePermissionSys_BY_AccessorID_AccessedDomainID_ResourceClassID_SysPermissionID 1292  = "DELETE FROM " 1293  + schemaNameAndTablePrefix 1294  + "Grant_Global_ResPerm_Sys WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ? AND SysPermissionId = ?"; 1295  1296  // GrantGlobalResourcePermissionSys - recursive 1297  SQL_findInGrantGlobalResourcePermissionSys_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_SysPermissionID_IsWithGrant_ResourceClassID 1298  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1299  + ", R( DomainId ) AS " 1300  // this sub query is the starting set for the domain recursion, it returns all the direct 1301  // resources domains that the accessor has the specified system permission on 1302  + "( SELECT B.AccessedDomainId FROM " 1303  + schemaNameAndTablePrefix 1304  + "Grant_Global_ResPerm_Sys B " 1305  + "JOIN N ON N.AccessorResourceId = B.AccessorResourceId " 1306  + "WHERE B.ResourceClassId = ? AND B.SysPermissionId = ? AND ( ? IN ( 0, B.IsWithGrant ) ) " 1307  // now we find the nested domains that the accessor can reach from the direct set above 1308  + unionClause + " SELECT Rplus1.DomainId FROM " 1309  + schemaNameAndTablePrefix 1310  + "Domain Rplus1, R " 1311  + "WHERE Rplus1.ParentDomainId IS NOT NULL AND Rplus1.ParentDomainId = R.DomainId ) " 1312  // finally we get the resources of the specified type in the domains we computed above 1313  + "SELECT A.ResourceId, E.ExternalId FROM " 1314  + schemaNameAndTablePrefix 1315  + "Resource A " 1316  + "JOIN R ON R.DomainId = A.DomainId LEFT JOIN " 1317  + schemaNameAndTablePrefix 1318  + "ResourceExternalID E ON E.ResourceId = A.ResourceId " 1319  + "WHERE A.ResourceClassId = ?"; 1320  1321  SQL_findInGrantGlobalResourcePermissionSys_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_SysPermissionID_IsWithGrant_ResourceClassID 1322  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1323  + ", " + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 1324  + ", R( DomainId ) AS " 1325  // this sub query is the starting set for the domain recursion, it returns all the direct 1326  // resources domains that the accessor has the specified system permission on 1327  + "( SELECT B.AccessedDomainId FROM " 1328  + schemaNameAndTablePrefix 1329  + "Grant_Global_ResPerm_Sys B " 1330  + "JOIN N ON N.AccessorResourceId = B.AccessorResourceId " 1331  + "WHERE B.ResourceClassId = ? AND B.SysPermissionId = ? AND ( ? IN ( 0, B.IsWithGrant ) ) " 1332  // now we find the nested domains that the accessor can reach from the direct set above 1333  + unionClause + " SELECT Rplus1.DomainId FROM " 1334  + schemaNameAndTablePrefix 1335  + "Domain Rplus1, R " 1336  + "WHERE Rplus1.ParentDomainId IS NOT NULL AND Rplus1.ParentDomainId = R.DomainId ) " 1337  // finally we get the resources of the specified type in the domains we computed above 1338  + "SELECT A.ResourceId, E.ExternalId FROM " 1339  + schemaNameAndTablePrefix 1340  + "Resource A " 1341  + "JOIN R ON R.DomainId = A.DomainId " 1342  + "JOIN S ON S.DomainId = A.DomainId LEFT JOIN " 1343  + schemaNameAndTablePrefix 1344  + "ResourceExternalID E ON E.ResourceId = A.ResourceId " 1345  + "WHERE A.ResourceClassId = ?"; 1346  1347  SQL_findInGrantGlobalResourcePermissionSys_SysPermissionID_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID 1348  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1349  + SQL_findAncestorsRecursiveInDomain_DomainID_BY_DomainID 1350  + "SELECT A.SysPermissionId, A.IsWithGrant FROM " 1351  + schemaNameAndTablePrefix 1352  + "Grant_Global_ResPerm_Sys A " 1353  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 1354  + "JOIN R ON R.DomainId = A.AccessedDomainId " 1355  + "WHERE A.ResourceClassId = ?"; 1356  1357  SQL_findInGrantGlobalResourcePermissionSys_ResourceDomainName_ResourceClassName_SysPermissionID_IsWithGrant_BY_AccessorID 1358  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1359  + ", P( AccessedDomainId, ResourceClassId, SysPermissionId, IsWithGrant ) AS " 1360  + "( SELECT A.AccessedDomainId, A.ResourceClassId, A.SysPermissionId, A.IsWithGrant FROM " 1361  + schemaNameAndTablePrefix 1362  + "Grant_Global_ResPerm_Sys A " 1363  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 1364  + unionClause + " " 1365  + "SELECT Pplus1.DomainId, P.ResourceClassId, P.SysPermissionId, P.IsWithGrant FROM " 1366  + schemaNameAndTablePrefix 1367  + "Domain Pplus1, P " 1368  + "WHERE Pplus1.ParentDomainId IS NOT NULL AND Pplus1.ParentDomainId = P.AccessedDomainId ) " 1369  + "SELECT C.DomainName, B.ResourceClassName, P.SysPermissionId, P.IsWithGrant FROM P JOIN " 1370  + schemaNameAndTablePrefix 1371  + "ResourceClass B ON B.ResourceClassId = P.ResourceClassId JOIN " 1372  + schemaNameAndTablePrefix 1373  + "Domain C ON C.DomainId = P.AccessedDomainId"; 1374  1375  SQL_removeInGrantGlobalResourcePermissionSys_withDescendants_BY_AccessedDomainId 1376  = sqlProfile.isRecursiveDeleteEnabled() 1377  ? (SQLDialect.Oracle_11_2.equals(sqlProfile.getSqlDialect())) 1378  ? "DELETE FROM " 1379  + schemaNameAndTablePrefix 1380  + "Grant_Global_ResPerm_Sys WHERE AccessedDomainId IN ( " 1381  + withClause + " " 1382  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 1383  + "SELECT DomainId FROM S )" 1384  : withClause + " " 1385  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 1386  + "DELETE FROM " 1387  + schemaNameAndTablePrefix 1388  + "Grant_Global_ResPerm_Sys WHERE AccessedDomainId IN ( SELECT DomainId FROM S )" 1389  : null; 1390  1391  // GrantGlobalResourcePermissionSys - non-recursive 1392  SQL_findInGrantGlobalResourcePermissionSys_withoutInheritance_ResourceDomainID_BY_AccessorID_ResourceClassID_SysPermissionID_IsWithGrant 1393  = "SELECT AccessedDomainId DomainId FROM " 1394  + schemaNameAndTablePrefix 1395  + "Grant_Global_ResPerm_Sys " 1396  + "WHERE AccessorResourceId = ? AND ResourceClassId = ? AND SysPermissionId = ? AND ( ? IN ( 0, IsWithGrant ) )"; 1397  1398  // GrantGlobalResourcePermission - common 1399  SQL_findInGrantGlobalResourcePermission_withoutInheritance_PermissionName_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID 1400  = "SELECT B.PermissionName, A.IsWithGrant FROM " 1401  + schemaNameAndTablePrefix 1402  + "Grant_Global_ResPerm A JOIN " 1403  + schemaNameAndTablePrefix 1404  + "ResourceClassPermission B ON B.ResourceClassId = A.ResourceClassId AND B.PermissionId = A.PermissionId " 1405  + "WHERE A.AccessorResourceId = ? AND A.AccessedDomainId = ? AND A.ResourceClassId = ?"; 1406  1407  SQL_findInGrantGlobalResourcePermission_withoutInheritance_ResourceDomainName_ResourceClassName_PermissionName_IsWithGrant_BY_AccessorID 1408  = "SELECT D.DomainName, C.ResourceClassName, B.PermissionName, A.IsWithGrant FROM " 1409  + schemaNameAndTablePrefix 1410  + "Grant_Global_ResPerm A JOIN " 1411  + schemaNameAndTablePrefix 1412  + "ResourceClassPermission B ON B.ResourceClassId = A.ResourceClassId AND B.PermissionId = A.PermissionId JOIN " 1413  + schemaNameAndTablePrefix 1414  + "ResourceClass C ON C.ResourceClassId = A.ResourceClassId JOIN " 1415  + schemaNameAndTablePrefix 1416  + "Domain D ON D.DomainId = A.AccessedDomainId " 1417  + "WHERE A.AccessorResourceId = ?"; 1418  1419  SQL_createInGrantGlobalResourcePermission_WITH_AccessorID_GrantorID_AccessedDomainID_IsWithGrant_ResourceClassID_PermissionName 1420  = "INSERT INTO " 1421  + schemaNameAndTablePrefix 1422  + "Grant_Global_ResPerm ( AccessorResourceId, GrantorResourceId, AccessedDomainId, IsWithGrant, ResourceClassId, PermissionId ) " 1423  + "SELECT ?, ?, ?, ?, A.ResourceClassId, A.PermissionId FROM " 1424  + schemaNameAndTablePrefix 1425  + "ResourceClassPermission A WHERE A.ResourceClassId = ? AND A.PermissionName = ?"; 1426  1427  SQL_updateInGrantGlobalResourcePermission_SET_GrantorID_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID_PermissionName 1428  = "UPDATE " 1429  + schemaNameAndTablePrefix 1430  + "Grant_Global_ResPerm SET GrantorResourceId = ?, IsWithGrant = ? " 1431  + "WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ? AND PermissionId = ( " 1432  + "SELECT A.PermissionId FROM " 1433  + schemaNameAndTablePrefix 1434  + "ResourceClassPermission A WHERE A.ResourceClassId = " 1435  + schemaNameAndTablePrefix 1436  + "Grant_Global_ResPerm.ResourceClassId AND A.PermissionName = ? )"; 1437  1438  SQL_removeInGrantGlobalResourcePermission_BY_AccessorID 1439  = "DELETE FROM " 1440  + schemaNameAndTablePrefix 1441  + "Grant_Global_ResPerm WHERE AccessorResourceId = ?"; 1442  1443  SQL_removeInGrantGlobalResourcePermission_BY_AccessedDomainId 1444  = "DELETE FROM " 1445  + schemaNameAndTablePrefix 1446  + "Grant_Global_ResPerm WHERE AccessedDomainId = ?"; 1447  1448  SQL_removeInGrantGlobalResourcePermission_BY_AccessorID_AccessedDomainID_ResourceClassID 1449  = "DELETE FROM " 1450  + schemaNameAndTablePrefix 1451  + "Grant_Global_ResPerm WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ?"; 1452  1453  SQL_removeInGrantGlobalResourcePermission_BY_AccessorID_AccessedDomainID_ResourceClassID_PermissionName 1454  = "DELETE FROM " 1455  + schemaNameAndTablePrefix 1456  + "Grant_Global_ResPerm WHERE AccessorResourceId = ? AND AccessedDomainId = ? AND ResourceClassId = ? AND PermissionId = ( " 1457  + "SELECT A.PermissionId FROM " 1458  + schemaNameAndTablePrefix 1459  + "ResourceClassPermission A WHERE A.ResourceClassId = " 1460  + schemaNameAndTablePrefix 1461  + "Grant_Global_ResPerm.ResourceClassId AND A.PermissionName = ? )"; 1462  1463  // GrantGlobalResourcePermission - recursive 1464  SQL_findInGrantGlobalResourcePermission_ResourceID_ExternalID_BY_AccessorID_ResourceClassID_PermissionID_IsWithGrant_ResourceClassID 1465  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1466  + ", R( DomainId ) AS " 1467  // this sub query is the starting set for the domain recursion, it returns all the direct 1468  // resources domains that the accessor has the specified system permission on 1469  + "( SELECT B.AccessedDomainId FROM " 1470  + schemaNameAndTablePrefix 1471  + "Grant_Global_ResPerm B " 1472  + "JOIN N ON N.AccessorResourceId = B.AccessorResourceId " 1473  + "WHERE B.ResourceClassId = ? AND B.PermissionId = ? AND ( ? IN ( 0, B.IsWithGrant ) ) " 1474  // now we find the nested domains that the accessor can reach from the direct set above 1475  + unionClause + " SELECT Rplus1.DomainId FROM " 1476  + schemaNameAndTablePrefix 1477  + "Domain Rplus1, R " 1478  + "WHERE Rplus1.ParentDomainId IS NOT NULL AND Rplus1.ParentDomainId = R.DomainId ) " 1479  // finally we get the resources of the specified type in the domains we computed above 1480  + "SELECT A.ResourceId, E.ExternalId FROM " 1481  + schemaNameAndTablePrefix 1482  + "Resource A " 1483  + "JOIN R ON R.DomainId = A.DomainId LEFT JOIN " 1484  + schemaNameAndTablePrefix 1485  + "ResourceExternalID E ON E.ResourceId = A.ResourceId " 1486  + "WHERE A.ResourceClassId = ?"; 1487  1488  SQL_findInGrantGlobalResourcePermission_ResourceID_ExternalID_BY_AccessorID_DomainID_ResourceClassID_PermissionID_IsWithGrant_ResourceClassID 1489  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1490  + ", " + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 1491  + ", R( DomainId ) AS " 1492  // this sub query is the starting set for the domain recursion, it returns all the direct 1493  // resources domains that the accessor has the specified system permission on 1494  + "( SELECT B.AccessedDomainId FROM " 1495  + schemaNameAndTablePrefix 1496  + "Grant_Global_ResPerm B " 1497  + "JOIN N ON N.AccessorResourceId = B.AccessorResourceId " 1498  + "WHERE B.ResourceClassId = ? AND B.PermissionId = ? AND ( ? IN ( 0, B.IsWithGrant ) ) " 1499  // now we find the nested domains that the accessor can reach from the direct set above 1500  + unionClause + " SELECT Rplus1.DomainId FROM " 1501  + schemaNameAndTablePrefix 1502  + "Domain Rplus1, R " 1503  + "WHERE Rplus1.ParentDomainId IS NOT NULL AND Rplus1.ParentDomainId = R.DomainId ) " 1504  // finally we get the resources of the specified type in the domains we computed above 1505  + "SELECT A.ResourceId, E.ExternalId FROM " 1506  + schemaNameAndTablePrefix 1507  + "Resource A " 1508  + "JOIN R ON R.DomainId = A.DomainId " 1509  + "JOIN S ON S.DomainId = A.DomainId LEFT JOIN " 1510  + schemaNameAndTablePrefix 1511  + "ResourceExternalID E ON E.ResourceId = A.ResourceId " 1512  + "WHERE A.ResourceClassId = ?"; 1513  1514  SQL_findInGrantGlobalResourcePermission_PermissionName_IsWithGrant_BY_AccessorID_AccessedDomainID_ResourceClassID 1515  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1516  + SQL_findAncestorsRecursiveInDomain_DomainID_BY_DomainID 1517  + "SELECT B.PermissionName, A.IsWithGrant FROM " 1518  + schemaNameAndTablePrefix 1519  + "Grant_Global_ResPerm A JOIN " 1520  + schemaNameAndTablePrefix 1521  + "ResourceClassPermission B ON B.ResourceClassId = A.ResourceClassId AND B.PermissionId = A.PermissionId " 1522  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 1523  + "JOIN R ON R.DomainId = A.AccessedDomainId " 1524  + "WHERE A.ResourceClassId = ?"; 1525  1526  SQL_findInGrantGlobalResourcePermission_ResourceDomainName_ResourceClassName_PermissionName_IsWithGrant_BY_AccessorID 1527  = SQL_findRecursiveInGrantResourcePermissionSys_AccessorID_BY_AccessorID 1528  + ", P( AccessedDomainId, ResourceClassId, PermissionId, IsWithGrant ) AS " 1529  + "( SELECT A.AccessedDomainId, A.ResourceClassId, A.PermissionId, A.IsWithGrant FROM " 1530  + schemaNameAndTablePrefix 1531  + "Grant_Global_ResPerm A " 1532  + "JOIN N ON N.AccessorResourceId = A.AccessorResourceId " 1533  + unionClause + " " 1534  + "SELECT Pplus1.DomainId, P.ResourceClassId, P.PermissionId, P.IsWithGrant FROM " 1535  + schemaNameAndTablePrefix 1536  + "Domain Pplus1, P " 1537  + "WHERE Pplus1.ParentDomainId IS NOT NULL AND Pplus1.ParentDomainId = P.AccessedDomainId ) " 1538  + "SELECT D.DomainName, C.ResourceClassName, B.PermissionName, P.IsWithGrant FROM P JOIN " 1539  + schemaNameAndTablePrefix 1540  + "ResourceClassPermission B ON B.ResourceClassId = P.ResourceClassId AND B.PermissionId = P.PermissionId JOIN " 1541  + schemaNameAndTablePrefix 1542  + "ResourceClass C ON C.ResourceClassId = P.ResourceClassId JOIN " 1543  + schemaNameAndTablePrefix 1544  + "Domain D ON D.DomainId = P.AccessedDomainId"; 1545  1546  SQL_removeInGrantGlobalResourcePermission_withDescendants_BY_AccessedDomainId 1547  = sqlProfile.isRecursiveDeleteEnabled() 1548  ? (SQLDialect.Oracle_11_2.equals(sqlProfile.getSqlDialect())) 1549  ? "DELETE FROM " 1550  + schemaNameAndTablePrefix 1551  + "Grant_Global_ResPerm WHERE AccessedDomainId IN ( " 1552  + withClause + " " 1553  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 1554  + "SELECT DomainId FROM S )" 1555  : withClause + " " 1556  + SQL_findDescendantsRecursiveInDomain_DomainID_BY_DomainID 1557  + "DELETE FROM " 1558  + schemaNameAndTablePrefix 1559  + "Grant_Global_ResPerm WHERE AccessedDomainId IN ( SELECT DomainId FROM S )" 1560  : null; 1561  1562  // GrantGlobalResourcePermission - non-recursive 1563  SQL_findInGrantGlobalResourcePermission_withoutInheritance_ResourceDomainID_BY_AccessorID_ResourceClassID_PermissionID_IsWithGrant 1564  = "SELECT AccessedDomainId DomainId FROM " 1565  + schemaNameAndTablePrefix 1566  + "Grant_Global_ResPerm " 1567  + "WHERE AccessorResourceId = ? AND ResourceClassId = ? AND PermissionId = ? AND ( ? IN ( 0, IsWithGrant ) )"; 1568  1569  // Key generators 1570  SQL_nextResourceID 1571  = dialectSpecificSQLGenerator.nextSequenceValueStatement(schemaNameAndTablePrefix + "ResourceId"); 1572  } 1573  1574  public SQLProfile getSqlProfile() { 1575  return sqlProfile; 1576  } 1577  1578  public SQLDialect getSqlDialect() { 1579  return sqlProfile.getSqlDialect(); 1580  } 1581 }