1 package com.daffodilwoods.daffodildb.server.sql99.ddl.schemadefinition; 2 3 import com.daffodilwoods.daffodildb.server.serversystem.*; 4 import com.daffodilwoods.daffodildb.server.sql99.ddl.descriptors.*; 5 import com.daffodilwoods.database.resource.*; 6 import com.daffodilwoods.daffodildb.server.serversystem.dmlvalidation.constraintsystem.PrimaryConstraintException; 7 import com.daffodilwoods.database.general.*; 8 9 public class domainconstraint { 10 public constraintcharacteristics _Optconstraintcharacteristics0; 11 public checkconstraintdefinition _checkconstraintdefinition1; 12 public constraintnamedefinition _Optconstraintnamedefinition2; 13 14 private DomainDescriptor domainDescriptor; 15 private DomainConstraintDescriptor domainConsDes; 16 17 public Object run(Object object) throws DException { 18 _ServerSession currentSession = (_ServerSession) object; 19 DomainConstraintDescriptor domainConsDes = new DomainConstraintDescriptor(); 20 setDomainName(domainConsDes); 21 if (_Optconstraintnamedefinition2 != null) { 22 _Optconstraintnamedefinition2.setDomianConstraintName(domainConsDes); 23 } else { 24 domainConsDes.setGeneratedConstraintName(currentSession); 25 } 26 if (_Optconstraintcharacteristics0 != null) { 27 _Optconstraintcharacteristics0.setConstraintCharacterstics(domainConsDes); 28 } 29 setCheckConstraint(currentSession, domainConsDes); 30 domainDescriptor.addDomainConstraintDescriptor(domainConsDes); 31 domainConsDes.save(currentSession); 32 return null; 33 } 34 35 private void setDomainName(DomainConstraintDescriptor domainConsDes) { 36 domainConsDes.domain_catalog = domainDescriptor.catalog_name; 37 domainConsDes.domain_schema = domainDescriptor.schema_name; 38 domainConsDes.domain_name = domainDescriptor.domain_name; 39 domainConsDes.domainDes = domainDescriptor; 40 } 41 42 private void setCheckConstraint(_ServerSession currentSession, 43 DomainConstraintDescriptor domainConsDes) throws DException { 44 _checkconstraintdefinition1.setDomainConstraintDescriptor(domainConsDes); 45 CheckConstraintDescriptor checkConsDes = (CheckConstraintDescriptor) _checkconstraintdefinition1.run(currentSession); 46 domainConsDes.checkConsDes = checkConsDes; 47 try { 48 checkConsDes.save(currentSession); 49 } catch (PrimaryConstraintException de) { 50 DException tde = new DException("DSE1135", new Object [] {checkConsDes.constraint_name}); 51 throw tde; 52 } catch (SizeMisMatchException de) { 53 if (de.getDseCode().equals("DSE773")) { 54 DException tde = new DException("DSE8171", new Object [] {checkConsDes.constraint_name}); 55 throw tde; 56 } 57 } catch (DException de) { 58 if (de.getDseCode().equals("DSE773")) { 59 DException tde = new DException("DSE8171", new Object [] {checkConsDes.constraint_name}); 60 throw tde; 61 } 62 throw de; 63 } 64 } 65 66 public void setDomainDescriptor(_Descriptor domainDes0) throws DException { 67 domainDescriptor = (DomainDescriptor) domainDes0; 68 } 69 70 public DomainConstraintDescriptor getDomainConstraintDescriptor() throws DException { 71 return domainConsDes; 72 } 73 74 public Object clone() throws CloneNotSupportedException { 75 return this; 76 } 77 78 public String toString() { 79 StringBuffer sb = new StringBuffer (); 80 sb.append(" "); 81 if (_Optconstraintnamedefinition2 != null) { 82 sb.append(_Optconstraintnamedefinition2); 83 } 84 sb.append(" "); 85 sb.append(_checkconstraintdefinition1); 86 sb.append(" "); 87 if (_Optconstraintcharacteristics0 != null) { 88 sb.append(_Optconstraintcharacteristics0); 89 } 90 return sb.toString(); 91 } 92 } 93 | Popular Tags |