*/
public class DropColumnsBuilder {
+ private static final String ALTER_TABLE = "ALTER TABLE ";
+
private final Dialect dialect;
private final String tableName;
private final String[] columns;
switch (dialect.getId()) {
case PostgreSql.ID:
case MySql.ID:
- StringBuilder sql = new StringBuilder().append("ALTER TABLE ").append(tableName).append(" ");
+ StringBuilder sql = new StringBuilder().append(ALTER_TABLE).append(tableName).append(" ");
dropColumns(sql, "DROP COLUMN ", columns);
return Collections.singletonList(sql.toString());
case MsSql.ID:
}
private String getOracleStatement() {
- StringBuilder sql2 = new StringBuilder().append("ALTER TABLE ").append(tableName).append(" ");
+ StringBuilder sql2 = new StringBuilder().append(ALTER_TABLE).append(tableName).append(" ");
sql2.append("DROP (");
dropColumns(sql2, "", columns);
sql2.append(")");
}
private String getMsSQLStatement(String... columnNames) {
- StringBuilder sql1 = new StringBuilder().append("ALTER TABLE ").append(tableName).append(" ");
+ StringBuilder sql1 = new StringBuilder().append(ALTER_TABLE).append(tableName).append(" ");
sql1.append("DROP COLUMN ");
dropColumns(sql1, "", columnNames);
return sql1.toString();
@Override
public void handle(Request request, Response response) throws Exception {
- JsonWriter jsonWriter = response.newJsonWriter().setSerializeEmptys(false);
+ try (JsonWriter jsonWriter = response.newJsonWriter()) {
+ jsonWriter.setSerializeEmptys(false);
- writeResponse(jsonWriter);
+ writeResponse(jsonWriter);
- jsonWriter.close();
+ jsonWriter.close();
+ }
}
private void writeResponse(JsonWriter jsonWriter) {
String description = ruleDefinition.getDescription();
RuleDto.Format descriptionFormat = ruleDefinition.getDescriptionFormat();
- org.sonar.api.rules.Rule apiRule = new org.sonar.api.rules.Rule();
+ Rule apiRule = new Rule();
apiRule
.setName(ruleDefinition.getName())
.setLanguage(ruleDefinition.getLanguage())