1 package com.daffodilwoods.daffodildb.server.sql99.ddl.schemamanipulation; 2 3 import com.daffodilwoods.database.resource.*; 4 import com.daffodilwoods.daffodildb.server.sql99.token.*; 5 import com.daffodilwoods.daffodildb.server.sql99.ddl.descriptors.*; 6 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._Iterator; 7 import java.util.ArrayList ; 8 import com.daffodilwoods.daffodildb.server.serversystem.*; 9 import com.daffodilwoods.database.general.*; 10 import com.daffodilwoods.database.sqlinitiator.*; 11 import com.daffodilwoods.daffodildb.server.sql99.utils._Reference; 12 import com.daffodilwoods.daffodildb.server.sql99.dql.listenerevents.*; 13 import com.daffodilwoods.daffodildb.server.sql99.dql.iterator._SelectQueryIterator; 14 import com.daffodilwoods.daffodildb.server.sql99.ddl.utility.QueryMaker; 15 16 public class dropdomaindefaultclause 17 implements alterdomainaction { 18 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439220; 19 public SRESERVEDWORD1206543922 _SRESERVEDWORD12065439221; 20 21 22 23 24 private DomainDescriptor domainDescriptor; 25 private ArrayList tableList; 26 public void setDomainDescriptor(_Descriptor domainDes) throws 27 DException { 28 domainDescriptor = (DomainDescriptor) domainDes; 29 } 30 31 32 public Object run(Object object) throws DException { 33 _ServerSession currentSession = (_ServerSession) object; 34 _ServerSession systemSession = currentSession.getSystemServerSession(); 35 if(domainDescriptor.default_clause != null){ 36 updateDomainDefault(currentSession); 37 updateColumnsDefault(currentSession) ; 38 } 39 refreshServerSystem(systemSession, domainDescriptor); 40 return null; 41 } 42 43 44 private void refreshServerSystem(_ServerSession systemSession, 45 DomainDescriptor domainDescriptor) throws 46 DException { 47 if(tableList!=null) 48 { 49 for (int i=0, size=tableList.size();i<size;i++) 50 { 51 QualifiedIdentifier tableName=(QualifiedIdentifier)tableList.get(i); 52 systemSession.deleteTable(tableName, false); 53 } 54 } 55 } 56 57 58 private void updateDomainDefault(_ServerSession currentSession) throws DException{ 59 domainDescriptor.update(currentSession, 60 new int[] { 61 SystemTablesFields.domain_default_clause} ,new Object [] {null}); 62 } 63 64 private void updateColumnsDefault(_ServerSession currentSession) throws DException{ 65 ArrayList columnDescriptors = domainDescriptor. 66 getColumnDescriptorsForDomain(currentSession); 67 if (columnDescriptors != null) { 68 int size = columnDescriptors.size(); 69 tableList = new ArrayList (size); 70 for (int i = 0; i < size; i++) { 71 ColumnDescriptor columnDescriptor = (ColumnDescriptor) columnDescriptors.get(i); 72 QualifiedIdentifier tableName = columnDescriptor.getQualifiedTableName(); 73 if(!tableList.contains(tableName)) 74 tableList.add(tableName); 75 columnDescriptor.update(currentSession, 76 new int[] { 77 SystemTablesFields.columns_column_default} ,new Object [] {null}); 78 } 79 } 80 } 81 82 private void check_syntax() throws DException { 83 if (domainDescriptor.default_clause == null) 84 throw new DException("DSE323", null); 85 } 86 87 public Object clone() throws CloneNotSupportedException { 88 return this; 89 } 90 public String toString() 91 { 92 StringBuffer sb = new StringBuffer (); 93 sb.append(" "); 94 sb.append(_SRESERVEDWORD12065439221); 95 sb.append(" "); 96 sb.append(_SRESERVEDWORD12065439220); 97 return sb.toString(); 98 } 99 } 100 | Popular Tags |