use of com.ctrip.platform.dal.daogen.domain.TableSpNames in project dal by ctripcorp.
the class DatabaseResource method getTableSPNames.
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("table_sps")
public Status getTableSPNames(@QueryParam("db_name") String setName) {
Status status = Status.OK;
TableSpNames tableSpNames = new TableSpNames();
List<String> views;
List<String> tables;
List<StoredProcedure> sps;
try {
DatabaseSetEntry databaseSetEntry = SpringBeanGetter.getDaoOfDatabaseSet().getMasterDatabaseSetEntryByDatabaseSetName(setName);
String dbName = databaseSetEntry.getConnectionString();
views = DbUtils.getAllViewNames(dbName);
tables = DbUtils.getAllTableNames(dbName);
sps = DbUtils.getAllSpNames(dbName);
sps = filterSP(tables, sps);
java.util.Collections.sort(views, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o1.toLowerCase().compareTo(o2.toLowerCase());
}
});
java.util.Collections.sort(tables, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o1.toLowerCase().compareTo(o2.toLowerCase());
}
});
java.util.Collections.sort(sps);
tableSpNames.setSps(sps);
tableSpNames.setViews(views);
tableSpNames.setTables(tables);
tableSpNames.setDbType(DbUtils.getDbType(dbName));
status.setInfo(mapper.writeValueAsString(tableSpNames));
} catch (Exception e1) {
status = Status.ERROR;
status.setInfo(e1.getMessage());
return status;
}
return status;
}
Aggregations