1 64 65 package com.jcorporate.expresso.ext.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 import com.jcorporate.expresso.kernel.util.FastStringBuffer; 75 import com.jcorporate.expresso.services.dbobj.DBOtherMap; 76 import com.jcorporate.expresso.services.dbobj.SchemaList; 77 78 import java.util.Enumeration ; 79 import java.util.Iterator ; 80 import java.util.Vector ; 81 82 83 92 public class AppIntegration 93 extends SecuredDBObject { 94 95 98 public AppIntegration() 99 throws DBException { 100 super(); 101 } 102 103 104 111 public AppIntegration(int uid) 112 throws DBException { 113 super(uid); 114 } 115 116 122 public AppIntegration(ControllerRequest request) 123 throws DBException { 124 super(request); 125 } 126 127 132 public void setupFields() 133 throws DBException { 134 setTargetTable("APPINTEGRATE"); 135 setDescription("DBappIntegrate"); 136 setCharset("ISO-8859-1"); 137 addField("IntegrationId", "auto-inc", 0, false, "integrationKey"); 138 addField("FromSchema", "varchar", 128, false, "fromSchema"); 139 addField("ToSchema", "varchar", 128, false, "toSchema"); 140 addField("FromObj", "varchar", 128, false, "fromObject"); 141 addField("ToObj", "varchar", 128, false, "toObject"); 142 addField("FromKey", "text", 0, false, "fromKey"); 143 addField("ToKey", "text", 0, false, "toKey"); 144 addKey("IntegrationId"); 145 setReadOnly("IntegrationId"); 146 setMultiValued("FromSchema"); 147 setMultiValued("ToSchema"); 148 setMultiValued("FromObj"); 149 setMultiValued("ToObj"); 150 } 151 152 153 public Vector getValidValues(String fieldName) 154 throws DBException { 155 if (fieldName.equals("FromSchema") || fieldName.equals("ToSchema")) { 156 Vector v2 = new Vector (2); 157 v2.addElement(new ValidValue("com.jcorporate.expresso.core.ExpressoSchema", 158 "General")); 159 160 SchemaList sl = new SchemaList(SecuredDBObject.SYSTEM_ACCOUNT); 161 sl.setDataContext(getDataContext()); 162 163 SchemaList oneSchema = null; 164 165 for (Iterator e = sl.searchAndRetrieveList("Descrip").iterator(); 166 e.hasNext();) { 167 oneSchema = (SchemaList) e.next(); 168 v2.addElement(new ValidValue(oneSchema.getField("SchemaClass"), 169 oneSchema.getField("Descrip"))); 170 } 171 172 return v2; 173 } else if (fieldName.equals("FromObj") || fieldName.equals("ToObj")) { 174 SchemaList myList = new SchemaList(SecuredDBObject.SYSTEM_ACCOUNT); 175 myList.setDataContext(getDataContext()); 176 177 SchemaList oneList = null; 178 Vector dbObjList = new Vector (10); 179 dbObjList.addElement(new ValidValue("com.jcorporate.expresso.core.dbobj.AutoDBObject", 180 "Expresso: Automatic DB Objects")); 181 doSchema("com.jcorporate.expresso.core.ExpressoSchema", "Expresso", 182 dbObjList); 183 184 185 186 187 DBOtherMap otherList = new DBOtherMap(); 188 otherList.setDataContext(getDataContext()); 189 190 DBOtherMap oneOther = null; 191 192 for (Iterator e2 = otherList.searchAndRetrieveList().iterator(); 193 e2.hasNext();) { 194 oneOther = (DBOtherMap) e2.next(); 195 dbObjList.addElement(new ValidValue(oneOther.getField("DBObjName"), 196 oneOther.getField("Descrip"))); 197 } 198 199 for (Iterator sl = myList.searchAndRetrieveList().iterator(); 200 sl.hasNext();) { 201 oneList = (SchemaList) sl.next(); 202 doSchema(oneList.getField("SchemaClass"), 203 oneList.getField("Descrip"), dbObjList); 204 } 205 206 207 return dbObjList; 208 } 209 210 return super.getValidValues(fieldName); 211 } 212 213 214 220 private void doSchema(String schemaName, String schemaDescrip, 221 Vector oList) 222 throws DBException { 223 Schema oneSchema = null; 224 DBObject oneDBObj = null; 225 ValidValue oneVal = null; 226 227 oneSchema = SchemaFactory.getInstance().getSchema(schemaName); 228 if (oneSchema == null) { 229 throw new DBException("Error instantiating class '" + schemaName); 230 } 231 232 FastStringBuffer fsb = new FastStringBuffer(128); 233 234 for (Enumeration e = oneSchema.getMembers(); e.hasMoreElements();) { 235 oneDBObj = (DBObject) e.nextElement(); 236 fsb.clear(); 237 fsb.append(schemaDescrip); 238 fsb.append(": "); 239 fsb.append(oneDBObj.getMetaData().getDescription()); 240 oneVal = new ValidValue(oneDBObj.getClass().getName(), 241 fsb.toString()); 242 oList.addElement(oneVal); 243 } 244 } 245 246 247 } 248 249 | Popular Tags |