Ejemplo n.º 1
0
  private static void compareTypeField(Map fieldsDefault, Map fields) {
    for (Iterator i = fieldsDefault.keySet().iterator(); i.hasNext(); ) {

      Object o = i.next();
      SQLField field = (SQLField) fieldsDefault.get(o);
      SQLField fieldDefault = (SQLField) fields.get(o);

      if (field != null && fieldDefault != null && field.getType() != fieldDefault.getType()) {
        System.err.println(
            "---------> Type different Table " + field.getTable() + " -- Field " + field.getName());
      }
    }
  }
Ejemplo n.º 2
0
  private static String getType(SQLField field) {
    String columnName = field.getName();
    String columnType = field.getType().getTypeName();
    StringBuffer result = new StringBuffer();
    // NULL OR NOT NULL
    // field.getType().getSize();
    // String nullable = tableMetaData.getString("IS_NULLABLE");
    String nullString = "NULL";
    DBStructureItemDB db = field.getDB();
    // if ("NO".equalsIgnoreCase(nullable)) {
    // nullString = "NOT NULL";
    // }

    // DEFAULT
    Object defaultValueO = field.getDefaultValue();
    String defaultValue = (defaultValueO == null) ? null : defaultValueO.toString();
    String defaultValueString = "";
    if (defaultValue != null) {
      defaultValueString = " default " + defaultValue;
    }

    int columnSize = field.getType().getSize();
    Integer decimalDigit = (Integer) field.getMetadata("DECIMAL_DIGITS");
    String stringColumnSize = "";
    if (Integer.valueOf(columnSize).intValue() > 0) {
      stringColumnSize = " (" + columnSize;

      if (decimalDigit != null && Integer.valueOf(decimalDigit).intValue() > 0) {
        stringColumnSize += ", " + decimalDigit;
      }

      stringColumnSize += ")";
    }

    if ((columnType.trim().equalsIgnoreCase("character varying")
            || columnType.trim().equalsIgnoreCase("varchar")
            || columnType.trim().equalsIgnoreCase("numeric"))
        && stringColumnSize.length() > 0) {
      result.append(" " + columnType + stringColumnSize + " ");
      result.append(defaultValueString);
    } else {
      result.append(" " + columnType + " ");
      result.append(defaultValueString);
    }
    return result.toString();
  }
Ejemplo n.º 3
0
  public static void addUndefined(SQLBase base) {
    Set<String> tableNames = base.getTableNames();
    for (String tableName : tableNames) {
      SQLTable table = base.getTable(tableName);
      SQLField fieldPrimaryKey = table.getKey();

      if (fieldPrimaryKey != null
          && fieldPrimaryKey.getType().getJavaType().getSuperclass() != null
          && fieldPrimaryKey.getType().getJavaType().getSuperclass() == Number.class) {

        String patch =
            "INSERT INTO \"" + tableName + "\"(\"" + fieldPrimaryKey.getName() + "\") VALUES (1)";
        base.execute(patch);
      }
    }
  }