use of com.ctrip.platform.dal.daogen.entity.DalApi in project dal by ctripcorp.
the class GenTaskByTableViewResource method getApiList.
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("apiList")
public Status getApiList(@FormParam("db_name") String db_set_name, @FormParam("table_names") String table_names, @FormParam("sql_style") String sql_style) {
Status status = Status.OK();
try {
String connectionString = AllInOneNameUtils.getAllInOneNameByNameOnly(db_set_name);
List<DalApi> apis = null;
DatabaseCategory dbCategory = DbUtils.getDatabaseCategory(connectionString);
if ("csharp".equalsIgnoreCase(sql_style)) {
if (dbCategory == DatabaseCategory.MySql) {
apis = BeanGetter.getDalApiDao().getDalApiByLanguageAndDbtype("csharp", "MySQL");
} else {
apis = BeanGetter.getDalApiDao().getDalApiByLanguageAndDbtype("csharp", "SQLServer");
}
} else {
if (dbCategory == DatabaseCategory.MySql) {
apis = BeanGetter.getDalApiDao().getDalApiByLanguageAndDbtype("java", "MySQL");
} else {
// SpType spType =
// spType(databaseSetEntry.getConnectionString(),
// table_names);
// apis =
// BeanGetter.getDalApiDao().getDalApiByLanguageAndDbtypeAndSptype("java",
// "SQLServer", spType.getValue());
apis = BeanGetter.getDalApiDao().getDalApiByLanguageAndDbtype("java", "SQLServer");
}
}
for (DalApi api : apis) {
String method_declaration = api.getMethod_declaration();
method_declaration = method_declaration.replaceAll("<", "<");
method_declaration = method_declaration.replaceAll(">", ">");
api.setMethod_declaration(method_declaration);
}
java.util.Collections.sort(apis, new Comparator<DalApi>() {
@Override
public int compare(DalApi o1, DalApi o2) {
return o1.getMethod_declaration().compareToIgnoreCase(o2.getMethod_declaration());
}
});
status.setInfo(mapper.writeValueAsString(apis));
} catch (Throwable e) {
LoggerManager.getInstance().error(e);
status = Status.ERROR();
status.setInfo(e.getMessage());
return status;
}
return status;
}
Aggregations