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.SecuredDBObject; 70 import com.jcorporate.expresso.core.dbobj.ValidValue; 71 72 import java.util.Vector ; 73 74 75 86 public class RegistrationObjectMap 87 extends SecuredDBObject { 88 public static final String REG_DOMAIN_ID = "RegDomId"; 89 public static final String REG_OBJ_CLASS = "RegObj"; 90 91 97 public RegistrationObjectMap() 98 throws DBException { 99 super(); 100 } 101 102 103 110 public RegistrationObjectMap(int uid) 111 throws DBException { 112 super(uid); 113 } 114 115 121 public RegistrationObjectMap(ControllerRequest request) 122 throws DBException { 123 super(request); 124 } 125 126 133 public void add() 134 throws com.jcorporate.expresso.core.db.DBException { 135 if (getField("RecMin").equals("")) { 136 setField("RecMin", "1"); 137 } 138 if (getField("RecMax").equals("")) { 139 setField("RecMax", "1"); 140 } 141 if (getField("RegOrder").equals("")) { 142 setField("RegOrder", "999"); 143 } 144 if (getField("AllowEdit").equals("")) { 145 setField("AllowEdit", "Y"); 146 } 147 if (getField("AllowDel").equals("")) { 148 setField("AllowDel", "Y"); 149 } 150 151 super.add(); 152 } 153 154 155 161 protected void checkAllRefs() 162 throws DBException { 163 checkRef("RegDomId", 164 new RegistrationDomain(SecuredDBObject.SYSTEM_ACCOUNT), 165 "Invalid " + getString(getMetaData().getDescription("RegDomId"))); 166 } 167 168 169 177 public Vector getValidValues(String fieldName) 178 throws DBException { 179 if (fieldName.equals("AllowEdit") || fieldName.equals("AllowDel")) { 180 Vector myValues = new Vector (2); 181 myValues.addElement(new ValidValue("Y", "Yes")); 182 myValues.addElement(new ValidValue("N", "No")); 183 184 return myValues; 185 } 186 187 return super.getValidValues(fieldName); 188 } 189 190 191 201 protected void setupFields() 202 throws DBException { 203 setTargetTable("REGOBJMAP"); 204 setDescription("DBregObjMap"); 205 setCharset("ISO-8859-1"); 206 addField(REG_DOMAIN_ID, "int", 0, false, "regDomId"); 207 addField(REG_OBJ_CLASS, "varchar", 128, false, "regObjClass"); 208 addField("UidField", "char", 10, false, "uidFieldName"); 209 addField("RecMin", "int", 0, true, "minRecords"); 210 addField("RecMax", "int", 0, true, "maxRecords"); 211 addField("RegFields", "text", 0, true, "fieldsInAuto"); 212 addField("RegOrder", "int", 0, true, "displayOrder"); 213 addField("AllowEdit", "char", 1, true, "userCanEdit"); 214 addField("AllowDel", "char", 1, true, "userCanDelete"); 215 setStringFilter(REG_OBJ_CLASS, "stripFilter"); 216 setMultiValued(REG_DOMAIN_ID); 217 setMultiValued("AllowEdit"); 218 setMultiValued("AllowDel"); 219 setLookupObject(REG_DOMAIN_ID, RegistrationDomain.class.getName()); 220 addKey(REG_DOMAIN_ID); 221 addKey(REG_OBJ_CLASS); 222 } 223 224 225 public void update() 226 throws com.jcorporate.expresso.core.db.DBException { 227 if (getField("RecMin").equals("")) { 228 setField("RecMin", "1"); 229 } 230 if (getField("RecMax").equals("")) { 231 setField("RecMax", "1"); 232 } 233 if (getField("RegOrder").equals("")) { 234 setField("RegOrder", "999"); 235 } 236 if (getField("AllowEdit").equals("")) { 237 setField("AllowEdit", "Y"); 238 } 239 if (getField("AllowDel").equals("")) { 240 setField("AllowDel", "Y"); 241 } 242 243 super.update(); 244 } 245 } | Popular Tags |