// To update this list, create a properties file called // dbtype2jrfimpl.properties and specify translations as // char=StringColumnSpec // and so forth. static { dbTypeToJrfImplMap = new Properties(); dbTypeToJrfImplMap.put("char", "net.sf.jrf.column.columnspecs.StringColumnSpec"); dbTypeToJrfImplMap.put("int", "net.sf.jrf.column.columnspecs.LongColumnSpec"); dbTypeToJrfImplMap.put("long", "net.sf.jrf.column.columnspecs.LongColumnSpec"); dbTypeToJrfImplMap.put("short", "net.sf.jrf.column.columnspecs.ShortColumnSpec"); dbTypeToJrfImplMap.put("double", "net.sf.jrf.column.columnspecs.DoubleColumnSpec"); dbTypeToJrfImplMap.put("boolean", "net.sf.jrf.column.columnspecs.BooleanColumnSpec"); dbTypeToJrfImplMap.put("date", "net.sf.jrf.column.columnspecs.DateColumnSpec"); dbTypeToJrfImplMap.put("datetime", "net.sf.jrf.column.columnspecs.DateColumnSpec"); // Let user override or add more. net.sf.jrf.util.PropertiesHelper.updatePropertiesForBundle( "dbtype2jrfimpl", dbTypeToJrfImplMap); }
public void resolveImpliedKeys() { String util = (String) super.transientKeys.get("jrfImpl"); if (util == null) { util = (String) super.transientKeys.get("dbType"); if (util == null) throw new IllegalArgumentException(this + ": neither jrfImpl or dbType is specified."); String t = (String) dbTypeToJrfImplMap.getProperty(util); if (t == null) { throw new IllegalArgumentException( this + ": no JRF column impl translation found for " + util); } util = t; } // fill out if required. if (util.indexOf(".") == -1) { util = "net.sf.jrf.column.columnspecs." + util; } super.transientKeys.put("jrfImpl", util); try { ColumnSpec spec = (ColumnSpec) Class.forName(util).newInstance(); if (spec instanceof DayOfWeekColumnSpec) type = T_DOW; else if (spec instanceof TextColumnSpec) type = T_TEXT; else if (spec instanceof NumericColumnSpec) type = T_NUMERIC; else if (spec instanceof DateColumnSpec) type = T_DATE; else type = T_OTHER; jrfColumnClassName = spec.getColumnClass().getName(); } catch (Exception ne) { throw new IllegalArgumentException(this + ": No such class: " + util); } if (nullable && type != T_DOW) { // If is nullable -- CANNOT be a primitive -- override default. usePrimitives = false; } util = (String) super.transientKeys.get("objectName"); if (util == null) { if (initCapNameOnly) { util = (String) super.transientKeys.get("name"); super.transientKeys.put( "objectName", java.lang.Character.toUpperCase(util.charAt(0)) + util.substring(1)); } else super.transientKeys.put( "objectName", JRFGeneratorUtil.databaseNameToFieldName((String) super.transientKeys.get("name"))); util = (String) super.transientKeys.get("objectName"); } super.transientKeys.put("propertyName", generatePropertyName(util)); getterSetter = super.transientKeys.get("objectName") + "GetterSetter"; fieldName = "f_" + ((String) super.transientKeys.get("objectName")); util = (String) transientKeys.get("maxValue"); if (util == null) { super.transientKeys.put("maxValue", "null"); } util = (String) super.transientKeys.get("minValue"); if (util == null) { super.transientKeys.put("minValue", "null"); } util = (String) super.transientKeys.get("default"); if (util == null || type == T_DOW) { super.transientKeys.put("default", "null"); } if (type == T_DOW) { if (util == null) { defaultBeanValue = "net.sf.jrf.column.columnspecs.DayOfWeekColumnSpec.NULLDAYOFWEEK"; } else { defaultBeanValue = util; } } if (util != null) { if (!util.startsWith("new")) { super.transientKeys.put( "default", JRFGeneratorUtil.getLiteralValueCode(jrfColumnClassName, util)); } } util = (String) super.transientKeys.get("size"); if (util == null) { super.transientKeys.put("size", "255"); } super.transientKeys.put("listOfValues", "null"); super.transientKeys.put("listOfValuesAdd", ""); setDescriptionColor(primaryKey ? defaultPKColor : defaultColor); util = (String) super.transientKeys.get("writeOnce"); if (util.equals("true") && !primaryKey) { super.transientKeys.put("writeOnceAdd", " colVar.setWriteOnce(true);"); } else { super.transientKeys.put("writeOnceAdd", ""); } }