1 64 65 package com.jcorporate.expresso.services.dbobj; 66 67 import com.jcorporate.expresso.core.controller.ControllerRequest; 68 import com.jcorporate.expresso.core.db.DBException; 69 import com.jcorporate.expresso.core.dbobj.DBObject; 70 import com.jcorporate.expresso.core.dbobj.Schema; 71 import com.jcorporate.expresso.core.dbobj.SchemaFactory; 72 import com.jcorporate.expresso.core.dbobj.SecuredDBObject; 73 import com.jcorporate.expresso.core.dbobj.ValidValue; 74 75 import java.util.Enumeration ; 76 import java.util.Iterator ; 77 import java.util.Vector ; 78 79 80 89 public class DBObjImpl 90 extends SecuredDBObject { 91 private Vector dbObjList = null; 92 93 96 public DBObjImpl() 97 throws DBException { 98 super(); 99 } 100 101 102 105 public DBObjImpl(int uid) 106 throws DBException { 107 super(uid); 108 } 109 110 116 public DBObjImpl(ControllerRequest request) 117 throws DBException { 118 super(request); 119 } 120 121 126 private void doSchema(String schemaName, String schemaDescrip, 127 Vector oList) 128 throws DBException { 129 Schema oneSchema = SchemaFactory.getInstance().getSchema(schemaName); 130 DBObject oneDBObj = null; 131 ValidValue oneVal = null; 132 133 if (oneSchema == null) { 134 throw new DBException("Error instantiating class '" + schemaName); 135 } 136 137 138 for (Enumeration e = oneSchema.getMembers(); e.hasMoreElements();) { 139 oneDBObj = (DBObject) e.nextElement(); 140 oneVal = new ValidValue(oneDBObj.getClass().getName(), 141 schemaDescrip + ": " + 142 oneDBObj.getJDBCMetaData().getDescription()); 143 oList.addElement(oneVal); 144 } 145 } 146 147 148 156 public synchronized Vector getValidValues(String fieldName) 157 throws DBException { 158 if (fieldName.equals("DBObjectName")) { 159 if (dbObjList == null) { 160 SchemaList myList = new SchemaList(SecuredDBObject.SYSTEM_ACCOUNT); 161 myList.setDataContext(getDataContext()); 162 163 SchemaList oneList = null; 164 165 166 167 168 DBOtherMap otherList = new DBOtherMap(); 169 otherList.setDataContext(getDataContext()); 170 171 DBOtherMap oneOther = null; 172 ValidValue oneVal; 173 174 for (Iterator e2 = otherList.searchAndRetrieveList().iterator(); 175 e2.hasNext();) { 176 oneOther = (DBOtherMap) e2.next(); 177 oneVal = new ValidValue(oneOther.getField("DBObjName"), 178 oneOther.getField("Descrip")); 179 dbObjList.addElement(oneVal); 180 } 181 182 doSchema("com.jcorporate.expresso.core.ExpressoSchema", 183 "Expresso", dbObjList); 184 185 186 for (Iterator sl = myList.searchAndRetrieveList().iterator(); 187 sl.hasNext();) { 188 oneList = (SchemaList) sl.next(); 189 doSchema(oneList.getField("SchemaClass"), 190 oneList.getField("Descrip"), dbObjList); 191 } 192 193 } 194 195 return dbObjList; 196 } 197 198 return super.getValidValues(fieldName); 199 } 200 201 202 205 public void setupFields() 206 throws DBException { 207 setTargetTable("DBOBJIMPL"); 208 setDescription("Database Object Implementation Mappings"); 209 setCharset("ISO-8859-1"); 210 addField("DBObjectName", "varchar", 80, false, "Database Object Name"); 211 addField("DBObjectImpl", "varchar", 132, false, 212 "Implementation Class Name"); 213 addField("ImplParams", "text", 0, true, "Implementation Parameters"); 214 setStringFilter("DBObjectName", "stripFilter"); 215 addKey("DBObjectName"); 216 setMultiValued("DBObjectName"); 217 } 218 219 220 } 221 222 | Popular Tags |