1 package com.daffodilwoods.daffodildb.server.sql99.ddl.schemadefinition; 2 3 import com.daffodilwoods.daffodildb.server.serversystem.*; 4 import com.daffodilwoods.daffodildb.server.sql99.*; 5 import com.daffodilwoods.daffodildb.server.sql99.common.*; 6 import com.daffodilwoods.daffodildb.server.sql99.ddl.descriptors.*; 7 import com.daffodilwoods.daffodildb.server.sql99.ddl.utility.*; 8 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.*; 9 import com.daffodilwoods.daffodildb.server.sql99.token.*; 10 import com.daffodilwoods.daffodildb.utils.parser.*; 11 import com.daffodilwoods.database.resource.*; 12 13 public class domaindefinition implements SQLschemadefinitionstatement, schemaelement { 14 public dummyrule _Optdummyrule0; 15 public domainconstraint[] _OptRepdomainconstraint1; 16 public defaultclause _Optdefaultclause2; 17 public datatype _datatype3; 18 public SRESERVEDWORD1206543922 _OptSRESERVEDWORD12065439224; 19 public domainname _domainname5; 20 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439226; 21 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439227; 22 23 private SchemaDescriptor schemaDescriptor; 24 25 public domaindefinition() { 26 } 27 28 44 45 49 50 65 public Object run(Object obj) throws DException { 66 _ServerSession currentSession = (_ServerSession) obj; 67 if(!(_datatype3 instanceof predefinedtype)){ 68 throw new DException("DSE8178",new Object []{_datatype3.toString()}); 69 } 70 boolean isIndependentStt = schemaDescriptor == null; 71 DomainDescriptor domainDescriptor = new DomainDescriptor(); 72 setDomainName(currentSession, domainDescriptor); 73 if (isIndependentStt) { 74 checkAccessRules(currentSession); 75 } 76 setDomainProperties(currentSession, domainDescriptor); 77 domainDescriptor.save(currentSession); 78 if (_OptRepdomainconstraint1 != null) { 79 setDomainConstraints(currentSession, domainDescriptor); 80 } 81 createPrivileges(currentSession, domainDescriptor); 82 return null; 83 } 84 85 private void setDomainProperties(_ServerSession currentSession, 86 DomainDescriptor domainDescriptor) throws 87 DException { 88 91 domainDescriptor.dtd_Idenifier = domainDescriptor.catalog_name + "." 92 + domainDescriptor.schema_name + "." + domainDescriptor.domain_name; 93 setDataTypeDescriptor(currentSession, domainDescriptor); 94 if (_Optdefaultclause2 != null) { 95 _Optdefaultclause2.setDataTypeDescriptor(domainDescriptor. 96 dataTypeDescriptor); 97 domainDescriptor.default_clause = (String ) _Optdefaultclause2.run( 98 currentSession); 99 } 100 } 101 102 104 private void setDomainName(_ServerSession currentSession, 105 DomainDescriptor domainDescriptor) throws DException { 106 domainDescriptor.catalog_name = _domainname5.getCatalogName(); 107 domainDescriptor.schema_name = _domainname5.getSchemaName(); 108 domainDescriptor.domain_name = _domainname5.getDomainName(); 109 if (schemaDescriptor != null) { 110 if (domainDescriptor.schema_name != null && 111 !domainDescriptor.schema_name.equalsIgnoreCase(schemaDescriptor. 112 schema_name)) { 113 throw new DException("DSE906", 114 new Object [] {domainDescriptor.domain_name}); 115 } 116 if (domainDescriptor.catalog_name != null && 117 !domainDescriptor.catalog_name.equalsIgnoreCase(schemaDescriptor. 118 catalog_name)) { 119 throw new DException("DSE226", 120 new Object [] {domainDescriptor.domain_name}); 121 } 122 domainDescriptor.schema_name = schemaDescriptor.schema_name; 123 domainDescriptor.catalog_name = schemaDescriptor.catalog_name; 124 } else { 125 if (domainDescriptor.catalog_name == null) { 126 domainDescriptor.catalog_name = currentSession.getCurrentCatalog(); 127 } 128 if (domainDescriptor.schema_name == null) { 129 domainDescriptor.schema_name = currentSession.getCurrentSchema(); 130 } 131 schemaDescriptor = new SchemaDescriptor(); 132 schemaDescriptor.catalog_name = domainDescriptor.catalog_name; 133 schemaDescriptor.schema_name = domainDescriptor.schema_name; 134 schemaDescriptor.load(currentSession); 135 } 136 } 137 138 private void setDataTypeDescriptor(_ServerSession currentSession, 139 DomainDescriptor domainDescriptor) throws 140 DException { 141 DataTypeDescriptor dataTypeDescriptor = new DataTypeDescriptor(); 142 dataTypeDescriptor.object_catalog = domainDescriptor.catalog_name; 143 dataTypeDescriptor.object_schema = domainDescriptor.schema_name; 144 dataTypeDescriptor.object_name = domainDescriptor.domain_name; 145 dataTypeDescriptor.object_type = SqlKeywords.DOMAIN; 146 _datatype3.setDescriptor(dataTypeDescriptor); 147 _datatype3.run(null); 148 domainDescriptor.dataTypeDescriptor = dataTypeDescriptor; 149 dataTypeDescriptor.dtd_identifier = domainDescriptor.dtd_Idenifier; 150 } 151 152 public void setSchemaDescriptor(_Descriptor schemaDes0) throws 153 DException { 154 schemaDescriptor = (SchemaDescriptor) schemaDes0; 155 } 156 157 private void setDomainConstraints(_ServerSession currentSession, DomainDescriptor domainDes) throws 158 DException { 159 for (int i = 0, size = _OptRepdomainconstraint1.length; i < size; i++) { 160 _OptRepdomainconstraint1[i].setDomainDescriptor(domainDes); 161 _OptRepdomainconstraint1[i].run(currentSession); 162 } 163 } 164 165 166 private void createPrivileges(_ServerSession currentSession, DomainDescriptor domainDescriptor) throws DException { 167 String user = schemaDescriptor.schema_owner; 168 boolean isGrantable = domainDescriptor.hasGrantableRefRightsForColumnsIncluded(currentSession, user); 169 String query = QueryMaker.getDomainDefinitionGrantQuery(domainDescriptor. 170 getQualifiedIdentifier(), user, isGrantable); 171 grantprivilegestatement _grantprivilegestatement = (grantprivilegestatement) 172 Parser.parseQuery(query.toString()); 173 _grantprivilegestatement.setObjectDescriptor(domainDescriptor); 174 _grantprivilegestatement.run(currentSession.getSystemServerSession()); 175 } 176 177 178 private void checkAccessRules(_ServerSession currentSession) throws DException { 179 String authorizationIdentifier = schemaDescriptor.schema_owner; 180 if (!currentSession.isEnabledAuthorizationIdentifier(authorizationIdentifier, true)) { 181 ; throw new DException("DSE12", null); 183 } 184 } 185 186 public Object clone() throws CloneNotSupportedException { 187 return this; 188 } 189 190 public String toString() { 191 StringBuffer sb = new StringBuffer (); 192 sb.append(" "); 193 sb.append(_SRESERVEDWORD12065439227); 194 sb.append(" "); 195 sb.append(_SRESERVEDWORD12065439226); 196 sb.append(" "); 197 sb.append(_domainname5); 198 sb.append(" "); 199 if (_OptSRESERVEDWORD12065439224 != null) { 200 sb.append(_OptSRESERVEDWORD12065439224); 201 } 202 sb.append(" "); 203 sb.append(_datatype3); 204 sb.append(" "); 205 if (_Optdefaultclause2 != null) { 206 sb.append(_Optdefaultclause2); 207 } 208 sb.append(" "); 209 if (_OptRepdomainconstraint1 != null) { 210 for (int i = 0; i < _OptRepdomainconstraint1.length; i++) { 211 sb.append("").append(_OptRepdomainconstraint1[i]); 212 } 213 } 214 sb.append(" "); 215 if (_Optdummyrule0 != null) { 216 sb.append(_Optdummyrule0); 217 } 218 return sb.toString(); 219 } 220 } 221 | Popular Tags |