Revision 46773
Added by Claudio Atzori about 7 years ago
DbManagerInternalController.java | ||
---|---|---|
47 | 47 |
public @ResponseBody List<Map<String, Object>> listTables(@RequestParam(value = "db", required = true) String db) throws Exception { |
48 | 48 |
|
49 | 49 |
final List<Map<String, Object>> tables = new ArrayList<Map<String, Object>>(); |
50 |
final Map<String, String> logSize = new HashMap<String, String>(); |
|
51 |
|
|
50 |
|
|
52 | 51 |
final String sql = IOUtils.toString(getClass().getResourceAsStream("tables_info.sql")); |
53 | 52 |
|
54 | 53 |
final SqlRowSet rows = core.getDbUtils().executeSql(db, sql, SqlRowSet.class); |
55 | 54 |
while (rows.next()) { |
56 | 55 |
final String tname = rows.getString("name"); |
57 |
if (tname.endsWith("_log")) { |
|
58 |
logSize.put(tname.substring(0, tname.length() - 4), rows.getString("total")); |
|
59 |
} else { |
|
60 |
final Map<String, Object> t = new HashMap<String, Object>(); |
|
61 |
t.put("name", rows.getString("name")); |
|
62 |
t.put("view", rows.getString("kind").equalsIgnoreCase("v")); |
|
63 |
t.put("data", rows.getString("data")); |
|
64 |
t.put("indices", rows.getString("indices")); |
|
65 |
t.put("total", rows.getString("total")); |
|
66 |
t.put("managed", core.getDbUtils().isManagedTable(db, tname)); |
|
67 |
t.put("logged", core.getDbUtils().isLoggedTable(db, tname)); |
|
68 |
t.put("dnetIdentifier", core.getDbUtils().getDefaultDnetIdentifier(db, tname)); |
|
69 |
tables.add(t); |
|
70 |
} |
|
56 |
|
|
57 |
final Map<String, Object> t = new HashMap<String, Object>(); |
|
58 |
t.put("name", rows.getString("name")); |
|
59 |
t.put("view", rows.getString("kind").equalsIgnoreCase("v")); |
|
60 |
t.put("data", rows.getString("data")); |
|
61 |
t.put("indices", rows.getString("indices")); |
|
62 |
t.put("total", rows.getString("total")); |
|
63 |
t.put("managed", core.getDbUtils().isManagedTable(db, tname)); |
|
64 |
t.put("dnetIdentifier", core.getDbUtils().getDefaultDnetIdentifier(db, tname)); |
|
65 |
tables.add(t); |
|
71 | 66 |
} |
72 |
for (Map<String, Object> t : tables) { |
|
73 |
if (logSize.containsKey(t.get("name"))) { |
|
74 |
t.put("logdata", logSize.get(t.get("name"))); |
|
75 |
} else { |
|
76 |
t.put("logdata", "-"); |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
67 |
|
|
80 | 68 |
return tables; |
81 | 69 |
} |
82 | 70 |
|
... | ... | |
134 | 122 |
return true; |
135 | 123 |
} |
136 | 124 |
|
137 |
@RequestMapping("/ui/changeTableLog.do") |
|
138 |
public @ResponseBody boolean changeTableLog(@RequestParam(value = "db", required = true) final String db, |
|
139 |
@RequestParam(value = "t", required = true) final String t) throws Exception { |
|
140 |
|
|
141 |
if (core.getDbUtils().isManagedTable(db, t)) { |
|
142 |
if (core.getDbUtils().isLoggedTable(db, t)) { |
|
143 |
core.getDbUtils().removeLogTable(db, t); |
|
144 |
} else { |
|
145 |
core.getDbUtils().addLogTable(db, t); |
|
146 |
} |
|
147 |
} |
|
148 |
|
|
149 |
return true; |
|
150 |
} |
|
151 |
|
|
152 | 125 |
@RequestMapping("/ui/describeTable.do") |
153 | 126 |
public @ResponseBody List<Map<?, ?>> describeTable(@RequestParam(value = "db", required = true) final String db, |
154 | 127 |
@RequestParam(value = "t", required = true) final String t) throws Exception { |
Also available in: Unified diff
removed table logging bloatware