/** Sets LOV. */ public void setListOfValues(List listOfValues) { if (listOfValues.size() > 0) { StringBuffer buf = new StringBuffer(); buf.append(" java.util.ArrayList lov = new ArrayList();\n"); Iterator iter = listOfValues.iterator(); while (iter.hasNext()) { ListOfValuesXMLEntity e = (ListOfValuesXMLEntity) iter.next(); String value = e.getValue(); if (!e.getValue().startsWith("new")) { if (type == T_TEXT) value = "\"" + e.getValue() + "\""; else if (type == T_NUMERIC) { if (jrfColumnClassName.equals("java.lang.Long")) value = "new Long(" + e.getValue() + ")"; else if (jrfColumnClassName.equals("java.lang.Short")) value = "new Short(" + e.getValue() + ")"; else if (jrfColumnClassName.equals("java.lang.Integer")) value = "new Integer(" + e.getValue() + ")"; else if (jrfColumnClassName.equals("java.lang.Double")) value = "new Double(" + e.getValue() + ")"; else if (jrfColumnClassName.equals("java.lang.Float")) value = "new Float(" + e.getValue() + ")"; else throw new IllegalArgumentException( this + ": Unsupported list of value number type (long,short,double,float and integer supported)"); } else throw new IllegalArgumentException( this + ": Unsupported list of value literal; use 'new X.."); } buf.append(" lov.add(" + value + ");\n"); } super.transientKeys.put("listOfValues", "lov"); super.transientKeys.put("listOfValuesAdd", buf.toString()); } }
public String getColumnSpecDeclare(String entity, boolean respectCompoundKey) throws CodeGenException { super.transientKeys.put("numeric", ""); super.transientKeys.put("text", ""); if (type == T_NUMERIC) { String scale = (String) super.transientKeys.get("scale"); if (!scale.equals("0")) { super.transientKeys.put( "numeric", " colVar.setPrecision(" + super.transientKeys.get("precision") + ");\n" + " colVar.setScale(" + super.transientKeys.get("scale") + ");\n"); } } else if (type == T_TEXT) { super.transientKeys.put( "text", " colVar.setMaxLength(" + super.transientKeys.get("size") + ");\n"); } super.transientKeys.put("colOption", getColumnOption(respectCompoundKey)); super.transientKeys.put("getterSetter", getterSetter); super.transientKeys.put("entity", entity); return CodeGenUtil.generateFromTemplate( CodeGenUtil.TEMPLATE_TAG_BEGIN, CodeGenUtil.TEMPLATE_TAG_END, specCreateTemplateBase, super.transientKeys); }
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", ""); } }