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.servlet.CheckLogin; 70 71 72 81 public class UserPreferenceDef 82 extends SecurityDBObject { 83 84 public static final String PREF_CODE = UserPreference.PREF_CODE; 85 public static final String CLASS_NAME = UserPreference.CLASS_NAME; 86 public static final String DESCRIPTION = "Descrip"; 87 public static final String DEFAULT_VALUE = "DefaultVal"; 88 89 92 public static final String ANY_CLASS = "*"; 93 public static final String PRIMARY_GROUP_PREF = "PrimaryGroupPref"; 94 95 99 public UserPreferenceDef() 100 throws DBException { 101 super(); 102 } 103 104 105 112 public UserPreferenceDef(int uid) 113 throws DBException { 114 super(uid); 115 } 116 117 124 public UserPreferenceDef(ControllerRequest request) 125 throws DBException { 126 super(request); 127 } 128 129 133 public void setupFields() 134 throws DBException { 135 setTargetTable("USERPREFDEF"); 136 setDescription("DBuserPrefDef"); 137 setCharset("ISO-8859-1"); 138 addField(CLASS_NAME, "varchar", 128, false, "className"); 139 addField(PREF_CODE, "varchar", 30, false, "prefCode"); 140 addField(DESCRIPTION, "varchar", 132, true, "description"); 141 addField(DEFAULT_VALUE, "varchar", 80, true, "defaultValue"); 142 setStringFilter(CLASS_NAME, "stripFilter"); 143 setStringFilter(PREF_CODE, "stripFilter"); 144 addKey(CLASS_NAME); 145 addKey(PREF_CODE); 146 addDetail("com.jcorporate.expresso.services.dbobj.UserPreferenceVal", 147 "ClassName|PrefCode", "ClassName|PrefCode"); 148 addDetail("com.jcorporate.expresso.services.dbobj.UserPreference", 149 "ClassName|PrefCode", "ClassName|PrefCode"); 150 } 151 152 153 156 public synchronized void populateDefaultValues() 157 throws DBException { 158 159 UserPreferenceDef oneDef = new UserPreferenceDef(); 161 oneDef.setDataContext(getDataContext()); 162 oneDef.setField(CLASS_NAME, 163 com.jcorporate.expresso.core.servlet.CheckLogin.class.getName()); 164 oneDef.setField(PREF_CODE, "language"); 165 166 if (!oneDef.find()) { 167 oneDef.setField(DEFAULT_VALUE, "Browser"); 168 oneDef.setField(DESCRIPTION, "Language"); 169 oneDef.add(); 170 } 171 172 UserPreferenceVal oneVal = new UserPreferenceVal(); 174 oneVal.setDataContext(getDataContext()); 175 oneVal.setField(CLASS_NAME, CheckLogin.class.getName()); 176 oneVal.setField(PREF_CODE, "language"); 177 oneVal.setField(UserPreference.PREF_VALUE, "Browser"); 178 oneVal.setField(DESCRIPTION, "Browser Default"); 179 oneVal.addIfNeeded(); 180 oneVal.clear(); 181 oneVal.setField(CLASS_NAME, CheckLogin.class.getName()); 182 oneVal.setField(PREF_CODE, "language"); 183 oneVal.setField(DESCRIPTION, "Spanish"); 184 oneVal.setField(UserPreference.PREF_VALUE, "es"); 185 oneVal.addIfNeeded(); 186 oneVal.clear(); 187 oneVal.setField(CLASS_NAME, CheckLogin.class.getName()); 188 oneVal.setField(PREF_CODE, "language"); 189 oneVal.setField(DESCRIPTION, "French"); 190 oneVal.setField(UserPreference.PREF_VALUE, "fr"); 191 oneVal.addIfNeeded(); 192 193 194 oneDef.clear(); 196 oneDef.setField(CLASS_NAME, CheckLogin.class.getName()); 197 oneDef.setField(PREF_CODE, "country"); 198 oneDef.setField(DEFAULT_VALUE, "default"); 199 oneDef.setField(DESCRIPTION, "Country"); 200 oneDef.addIfNeeded(); 201 202 203 oneVal.clear(); 205 oneVal.setField(CLASS_NAME, CheckLogin.class.getName()); 206 oneVal.setField(PREF_CODE, "country"); 207 oneVal.setField(DESCRIPTION, "Default"); 208 oneVal.setField(UserPreference.PREF_VALUE, "default"); 209 oneVal.addIfNeeded(); 210 211 212 oneDef.clear(); 214 oneDef.setField(CLASS_NAME, ANY_CLASS); 215 oneDef.setField(PREF_CODE, PRIMARY_GROUP_PREF); 216 oneDef.setField(DESCRIPTION, "Primary Group"); 217 oneDef.setField(DEFAULT_VALUE, UserGroup.DEMO_GROUP); 218 oneDef.addIfNeeded(); 219 220 } 221 } | Popular Tags |