/**
  * Constructs an instance.
  *
  * @param sqlBuilder appropriate <code>SelectSQLBuilder</code> instance that maps to the <code>
  *     AbstractDomain</code> sub-class with the primary key.
  * @param primaryKeyColSpec Description of the Parameter
  * @param tableAlias Description of the Parameter
  * @param dataSourceProperties Description of the Parameter
  */
 JRFSelectPKPreparedStatement(
     SelectSQLBuilder sqlBuilder,
     ColumnSpec primaryKeyColSpec,
     String tableAlias,
     DataSourceProperties dataSourceProperties) {
   // Set super class up so protected setPrimaryKeyPreparedValues() can be called.
   super(dataSourceProperties);
   super.setPrimaryKeyColumnSpec(primaryKeyColSpec);
   // Build the SQL
   sqlBuilder.setWhere(primaryKeyColSpec.buildPreparedWhereClause(tableAlias));
   super.sql = sqlBuilder.buildSQL();
 }
Пример #2
0
  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", "");
    }
  }