1 package com.daffodilwoods.daffodildb.server.sql99.ddl.schemadefinition; 2 3 import java.util.*; 4 5 import com.daffodilwoods.daffodildb.server.serversystem.*; 6 import com.daffodilwoods.daffodildb.server.serversystem.dmlvalidation.constraintsystem.*; 7 import com.daffodilwoods.daffodildb.server.sql99.common.*; 8 import com.daffodilwoods.daffodildb.server.sql99.ddl.descriptors.*; 9 import com.daffodilwoods.database.resource.*; 10 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._SelectQueryIterator; 11 import com.daffodilwoods.daffodildb.server.sql99._Executer; 12 import com.daffodilwoods.daffodildb.server.datadictionarysystem.DataDictionary; 13 import com.daffodilwoods.daffodildb.server.sql99.expression.booleanvalueexpression.domainname; 14 15 public class SQLparameterdeclarationlist { 16 public SQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration _OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0; 17 18 private ParametersDescriptor parameterDescriptor; 19 20 public int getNumberOfParameters() throws DException { 21 if (_OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0 == null) { 22 return 0; 23 } 24 return _OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0. 25 getNumberOfParameters(); 26 } 27 28 public String [] getNameOfParameters() throws DException { 29 if (_OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0 == null) { 30 return null; 31 } 32 return 33 _OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0. 34 getNameOfParameters(); 35 } 36 37 public String [] getModeOfParameters() throws DException { 38 if (_OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0 == null) { 39 return null; 40 } 41 return 42 _OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0.getModeOfParameters(); 43 } 44 45 public Object [] getTypeOfParameters() throws DException { 46 if (_OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0 == null) { 47 return null; 48 } 49 return 50 _OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0. 51 getTypeOfParameters(); 52 } 53 54 public Object [] getDataTypeOfParameters() throws DException { 55 if (_OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0 == null) { 56 return null; 57 } 58 return 59 _OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0. 60 getDataTypeOfParameters(); 61 } 62 63 public DataTypeDescriptor[] storeParameteresForProcedure(Object [] specifics, 64 _ServerSession serverSession) throws DException { 65 if (_OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0 == null) { 66 return null; 67 } 68 parameterDescriptor = new ParametersDescriptor(); 69 ArrayList declarations = 70 _OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0. 71 getdeclarations(); 72 ArrayList paramterNames = new ArrayList(); 73 DataTypeDescriptor[] dtds = new DataTypeDescriptor[declarations.size()]; 74 for (int i = 0; i < declarations.size(); i++) { 75 SQLparameterdeclaration sqlDeclaration = (SQLparameterdeclaration) declarations.get(i); 76 String parameter_name = sqlDeclaration.getParameterName(); 77 78 if (!paramterNames.contains(parameter_name)) { 79 paramterNames.add(parameter_name); 80 } else { 81 throw new DException("DSE731", new Object [] {parameter_name}); 82 } 83 84 DataTypeDescriptor dtd = new DataTypeDescriptor(); 85 86 Object parameterType = sqlDeclaration.getParameterType(); 87 if (parameterType instanceof domainname) { 88 dtd = setDomainDescriptor(serverSession, parameterType); 89 ( (SQLparameterdeclaration) sqlDeclaration).setDescriptor(dtd); 90 ( (SQLparameterdeclaration) sqlDeclaration).run(null); 91 dtd.object_catalog = (String ) specifics[0]; 92 dtd.object_schema = (String ) specifics[1]; 93 dtd.object_name = (String ) specifics[2]; 94 dtd.object_type = SqlKeywords.ROUTINE; 95 dtd.dtd_identifier = sqlDeclaration.getParameterName(); 96 } else { 97 dtd.object_catalog = (String ) specifics[0]; 98 dtd.object_schema = (String ) specifics[1]; 99 dtd.object_name = (String ) specifics[2]; 100 dtd.object_type = SqlKeywords.ROUTINE; 101 dtd.dtd_identifier = sqlDeclaration.getParameterName(); 102 ( (SQLparameterdeclaration) sqlDeclaration).setDescriptor(dtd); 103 ( (SQLparameterdeclaration) sqlDeclaration).run(null); 104 } 105 parameterDescriptor.SPECIFIC_CATALOG = (String ) specifics[0]; 106 parameterDescriptor.SPECIFIC_SCHEMA = (String ) specifics[1]; 107 parameterDescriptor.SPECIFIC_NAME = (String ) specifics[2]; 108 110 parameterDescriptor.ORDINAL_POSITION = i + 1; 111 parameterDescriptor.DTD_IDENTIFIER = parameter_name; 112 parameterDescriptor.PARAMETER_MODE = sqlDeclaration._Optparametermode3 == null ? 113 SqlKeywords.IN : (String ) sqlDeclaration._Optparametermode3.run(null); 114 116 parameterDescriptor.IS_RESULT = SqlKeywords.NO; 117 parameterDescriptor.AS_LOCATOR = SqlKeywords.NO; 118 parameterDescriptor.PARAMETER_NAME = parameter_name; 119 try { 120 dtd.save(serverSession); 121 } catch (PrimaryConstraintException de) { 122 DException tde = new DException("DSE1135", new Object [] {specifics[2].toString()}); 123 throw tde; 124 } catch (DException de) { 125 if (de.getDseCode().equals("DSE1255")) { 126 DException tde = new DException("DSE1135", new Object [] {specifics[2].toString()}); 127 throw tde; 128 } 129 throw de; 130 } 131 parameterDescriptor.save(serverSession); 132 dtds[i] = dtd; 133 } 134 return dtds; 135 } 136 137 public Object clone() throws CloneNotSupportedException { 138 return this; 139 } 140 141 public String toString() { 142 StringBuffer sb = new StringBuffer (); 143 sb.append(" "); 144 sb.append("("); 145 sb.append(" "); 146 if (_OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0 != null) { 147 sb.append(_OptSQLparameterdeclarationOptRepScomma94843605SQLparameterdeclaration0); 148 } 149 sb.append(" "); 150 sb.append(")"); 151 return sb.toString(); 152 } 153 154 205 206 208 private DataTypeDescriptor setDomainDescriptor(_ServerSession currentSession, Object parameterType) throws DException { 209 String domain_Catalog, domain_Schema, domain_Name; 210 domainname domainName = (domainname) parameterType; 211 domain_Catalog = domainName.getCatalogName(); 212 domain_Schema = domainName.getSchemaName(); 213 if (domain_Catalog == null) { 214 domain_Catalog = currentSession.getCurrentCatalog(); 215 } 216 if (domain_Schema == null) { 217 domain_Schema = currentSession.getCurrentSchema(); 218 } 219 domain_Name = domainName.getDomainName(); 220 DomainDescriptor domainDescriptor = checkDomainPrivilege(currentSession, domain_Catalog, domain_Schema, domain_Name); 221 return domainDescriptor.dataTypeDescriptor; 222 } 223 224 private DomainDescriptor checkDomainPrivilege(_ServerSession currentSession, String domainCatalog, String domainSchema, String domainName) throws 225 DException { 226 DomainDescriptor domainDescriptor = getDomainDescriptor(currentSession, domainCatalog, domainSchema, domainName); 227 if (! (currentSession.getCurrentUser().equalsIgnoreCase(ServerSystem.browserUser))) { 228 _Executer domainExecuter = ( (DataDictionary) currentSession.getDataDictionary()).getPreparedStatementGetter().getExecuterForDomainValidity(); 229 _SelectQueryIterator iter = (_SelectQueryIterator) domainExecuter.executeForFresh(new Object [] {domainDescriptor.catalog_name, domainDescriptor.schema_name, domainDescriptor.domain_name, SqlKeywords.DOMAIN, currentSession.getCurrentUser()}); 230 if (!iter.first()) { 231 throw new DException("DSE8188", new Object [] {domainDescriptor.getQualifiedIdentifier()}); 232 } 233 } 234 return domainDescriptor; 235 } 236 237 private DomainDescriptor getDomainDescriptor( 238 _ServerSession serverSession, String domainCatalog, String domainSchema, String domainName) throws DException { 239 DomainDescriptor domainDescriptor = new DomainDescriptor(); 240 domainDescriptor.catalog_name = domainCatalog; 241 domainDescriptor.schema_name = domainSchema; 242 domainDescriptor.domain_name = domainName; 243 domainDescriptor.loadWithoutConstraints(serverSession); 244 return domainDescriptor; 245 } 246 } 247 | Popular Tags |