Examples of StringTemplate


Examples of org.antlr.stringtemplate.StringTemplate

  public String[] getAddAutoIncrementSQL(TableColumnInfo column, DatabaseObjectQualifier qualifier,
    SqlGenerationPreferences prefs)
  {
    // ALTER TABLE <tableName> MODIFY <columnName> MEDIUMINT NOT NULL AUTO_INCREMENT PRIMARY KEY
    final String templateStr = ST_ADD_AUTO_INCREMENT_STYLE_ONE;
    final StringTemplate st = new StringTemplate(templateStr);

    final HashMap<String, String> valuesMap = new HashMap<String, String>();
    valuesMap.put(ST_TABLE_NAME_KEY, column.getTableName());
    valuesMap.put(ST_COLUMN_NAME_KEY, column.getColumnName());
View Full Code Here

Examples of org.antlr.stringtemplate.StringTemplate

    // [ON DELETE {RESTRICT | CASCADE | SET NULL | NO ACTION}]
    // [ON UPDATE {RESTRICT | CASCADE | SET NULL | NO ACTION}]

    final String fkTemplateStr = ST_ADD_FOREIGN_KEY_CONSTRAINT_STYLE_ONE;

    final StringTemplate fkst = new StringTemplate(fkTemplateStr);
    final HashMap<String, String> fkValuesMap = new HashMap<String, String>();
    fkValuesMap.put(ST_CHILD_TABLE_KEY, localTableName);
    if (constraintName != null)
    {
      fkValuesMap.put(ST_CONSTRAINT_KEY, "CONSTRAINT");
      fkValuesMap.put(ST_CONSTRAINT_NAME_KEY, constraintName);
    }
    fkValuesMap.put(ST_PARENT_TABLE_KEY, refTableName);

    StringTemplate ckIndexSt = null;
    HashMap<String, String> ckIndexValuesMap = null;

    if (autoFKIndex)
    {
      // "CREATE $unique$ $storageOption$ INDEX $indexName$ " +
      // "ON $tableName$ ( $columnName; separator=\",\"$ )";

      ckIndexSt = new StringTemplate(ST_CREATE_INDEX_STYLE_TWO);
      ckIndexValuesMap = new HashMap<String, String>();
      ckIndexValuesMap.put(ST_INDEX_NAME_KEY, "fk_child_idx");
      ckIndexValuesMap.put(ST_TABLE_NAME_KEY, localTableName);
    }
View Full Code Here

Examples of org.antlr.stringtemplate.StringTemplate

    // alter_specification:
    // | ADD [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY] [index_name] [index_type] (index_col_name,...)

    final String templateStr = ST_ADD_UNIQUE_CONSTRAINT_STYLE_ONE;

    final StringTemplate st = new StringTemplate(templateStr);
    st.setAttribute(ST_TABLE_NAME_KEY, tableName);
    if (constraintName != null)
    {
      st.setAttribute(ST_CONSTRAINT_KEY, "CONSTRAINT");
      st.setAttribute(ST_CONSTRAINT_NAME_KEY, constraintName);
    }

    // TODO: allow the user to choose the name of the index that is created.
    // if (indexName != null) {
    // st.setAttribute(ST_INDEX_KEY, indexName);
    // st.setAttribute(ST_INDEX_NAME_KEY, indexName);
    // }

    // TODO: allow the user to choose the index type that is created.
    // if (indexType != null) {
    // st.setAttribute(ST_INDEX_TYPE_KEY, indexType);
    // }

    for (final TableColumnInfo columnInfo : columns)
    {
      st.setAttribute(ST_COLUMN_NAME_KEY, columnInfo.getColumnName());
    }

    return new String[] { st.toString() };
  }
View Full Code Here

Examples of org.antlr.stringtemplate.StringTemplate

   
    // MySQL disallows quoted column identifiers.

    final String templateStr = ST_CREATE_INDEX_STYLE_ONE;

    final StringTemplate st = new StringTemplate(templateStr);

    final HashMap<String, String> valuesMap = new HashMap<String, String>();

    if (accessMethod != null && !accessMethod.toLowerCase().equals("default"))
    {
View Full Code Here

Examples of org.antlr.stringtemplate.StringTemplate

    else
    {
      templateStr = ST_UPDATE_STYLE_ONE;
    }

    final StringTemplate st = new StringTemplate(templateStr);

    return DialectUtils.getUpdateSQL(st, tableName, setColumns, setValues, fromTables, whereColumns,
      whereValues, qualifier, prefs, this);
  }
View Full Code Here

Examples of org.antlr.stringtemplate.StringTemplate

    // "ALTER TABLE $tableName$ " +
    // "ALTER $columnName$ SET DATA TYPE $dataType$";

    final String templateString = ST_ALTER_COLUMN_SET_DATA_TYPE_STYLE_ONE;
    final StringTemplate st = new StringTemplate(templateString);

    final HashMap<String, String> valuesMap =
      DialectUtils.getValuesMap(ST_TABLE_NAME_KEY, from.getTableName());
    valuesMap.put(ST_COLUMN_NAME_KEY, from.getColumnName());
    valuesMap.put(ST_DATA_TYPE_KEY, DialectUtils.getTypeName(to, this));
View Full Code Here

Examples of org.antlr.stringtemplate.StringTemplate

  @Override
  public String[] getColumnNullableAlterSQL(final TableColumnInfo info,
    final DatabaseObjectQualifier qualifier, final SqlGenerationPreferences prefs)
  {
    // "ALTER TABLE $tableName$ ALTER COLUMN $columnName$ SET $nullable$";
    final StringTemplate st = new StringTemplate(ST_ALTER_COLUMN_NULL_STYLE_ONE);
    final HashMap<String, String> valuesMap =
      DialectUtils.getValuesMap(ST_TABLE_NAME_KEY, info.getTableName(), ST_COLUMN_NAME_KEY,
        info.getColumnName());

    if (info.isNullable().equalsIgnoreCase("YES"))
View Full Code Here

Examples of org.antlr.stringtemplate.StringTemplate

  @Override
  public String getColumnNameAlterSQL(final TableColumnInfo from, final TableColumnInfo to,
    final DatabaseObjectQualifier qualifier, final SqlGenerationPreferences prefs)
  {
    // "ALTER TABLE $tableName$ RENAME COLUMN $oldColumnName$ to $newColumnName$";
    final StringTemplate st = new StringTemplate(ST_ALTER_COLUMN_NAME_STYLE_ONE);

    final HashMap<String, String> valuesMap =
      DialectUtils.getValuesMap(ST_TABLE_NAME_KEY, from.getTableName(), ST_OLD_COLUMN_NAME_KEY,
        from.getColumnName(), ST_NEW_COLUMN_NAME_KEY, to.getColumnName());
View Full Code Here

Examples of org.antlr.stringtemplate.StringTemplate

    final DatabaseObjectQualifier qualifier, final SqlGenerationPreferences prefs)
  {
    // alter table TEST ALTER MYCHAR SET DEFAULT 'FOO'
    // alter table TEST ALTER MYCHAR DROP DEFAULT

    StringTemplate st = null;
    final HashMap<String, String> valuesMap =
      DialectUtils.getValuesMap(ST_TABLE_NAME_KEY, info.getTableName(), ST_COLUMN_NAME_KEY,
        info.getColumnName());

    if (info.getDefaultValue() != null)
    {
      // add a default value
      // "ALTER TABLE $tableName$ " +
      // "ALTER $columnName$ SET DEFAULT $defaultValue$";
      st = new StringTemplate(ST_ALTER_COLUMN_SET_DEFAULT_STYLE_ONE);
      if (JDBCTypeMapper.isNumberType(info.getDataType()))
      {
        valuesMap.put(ST_DEFAULT_VALUE_KEY, info.getDefaultValue());
      }
      else
      {
        valuesMap.put(ST_DEFAULT_VALUE_KEY, "'" + info.getDefaultValue() + "'");
      }
    }
    else
    {
      // drop the existing default value.
      // "ALTER TABLE $tableName$ " +
      // "ALTER $columnName$ DROP DEFAULT";
      st = new StringTemplate(ST_ALTER_COLUMN_DROP_DEFAULT_STYLE_ONE);

    }
    return DialectUtils.bindTemplateAttributes(this, st, valuesMap, qualifier, prefs);
  }
View Full Code Here

Examples of org.antlr.stringtemplate.StringTemplate

    // "ALTER TABLE $tableName$ " +
    // "ADD CONSTRAINT $constraintName$ UNIQUE ($columnName; separator=\",\"$)";

    final String templateStr = ST_ADD_UNIQUE_CONSTRAINT_STYLE_TWO;

    final StringTemplate st = new StringTemplate(templateStr);

    final HashMap<String, String> valuesMap =
      DialectUtils.getValuesMap(ST_TABLE_NAME_KEY, tableName, ST_CONSTRAINT_NAME_KEY, constraintName);

    return new String[] { DialectUtils.getAddUniqueConstraintSQL(st, valuesMap, columns, qualifier, prefs,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.