Skip to content

Commit 7b8bfc0

Browse files
committed
- Removed app-specific code from the QueryService
- Updated User interface git-svn-id: svn://192.168.0.80/JavaXT/javaxt-express@1256 2c7b0aa6-e0b2-3c4e-bb4a-8b65b6c465ff
1 parent 0a692fa commit 7b8bfc0

File tree

2 files changed

+14
-43
lines changed

2 files changed

+14
-43
lines changed

src/javaxt/express/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
public interface User {
44
public Long getID();
5-
public int getAccessLevel();
5+
public Integer getAccessLevel();
66
}

src/javaxt/express/services/QueryService.java

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import javaxt.json.*;
1414
import javaxt.utils.Console;
1515

16-
import net.sf.jsqlparser.expression.Expression;
1716
import net.sf.jsqlparser.parser.*;
1817
import net.sf.jsqlparser.statement.select.*;
1918
import net.sf.jsqlparser.statement.Statement;
@@ -192,43 +191,7 @@ else if (statement instanceof Select){
192191

193192

194193
//Check whether the select statement has illegal or unsupported functions
195-
PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
196-
Iterator<SelectItem> it = plainSelect.getSelectItems().iterator();
197-
while (it.hasNext()){
198-
SelectItem selectItem = it.next();
199-
200-
String functionName = null;
201-
if (selectItem instanceof SelectExpressionItem){
202-
SelectExpressionItem si = (SelectExpressionItem) selectItem;
203-
Expression expression = si.getExpression();
204-
205-
try{
206-
net.sf.jsqlparser.expression.Function f = (net.sf.jsqlparser.expression.Function) expression;
207-
functionName = f.getName().toUpperCase();
208-
209-
}
210-
catch(Exception e){
211-
try{
212-
SubSelect ss = (SubSelect) expression;
213-
functionName = "SELECT";
214-
}
215-
catch(Exception ex){
216-
}
217-
}
218-
}
219-
else if (selectItem instanceof AllColumns){}
220-
else if (selectItem instanceof AllTableColumns){}
221-
else{
222-
throw new IllegalArgumentException("Unsupported select expression");
223-
}
224-
225-
226-
if (functionName!=null){
227-
if (functionName.equals("COUNT")){
228-
//throw new IllegalArgumentException(functionName + " statements are not currently supported");
229-
}
230-
}
231-
}
194+
checkSelect((PlainSelect) select.getSelectBody());
232195

233196

234197

@@ -295,6 +258,15 @@ else if (selectItem instanceof AllTableColumns){}
295258
}
296259

297260

261+
//**************************************************************************
262+
//** checkSelect
263+
//**************************************************************************
264+
/** Used to check whether the select statement has illegal or unsupported
265+
* functions
266+
*/
267+
protected void checkSelect(PlainSelect plainSelect){}
268+
269+
298270
//**************************************************************************
299271
//** Writer
300272
//**************************************************************************
@@ -662,18 +634,16 @@ private Integer getPid(String key, Connection conn) throws SQLException {
662634
//**************************************************************************
663635
/** Returns a list of tables and columns
664636
*/
665-
private ServiceResponse getTables(ServiceRequest request, Database database) {
637+
public ServiceResponse getTables(ServiceRequest request, Database database) {
666638
Connection conn = null;
667639
try{
668640

669641
JSONArray arr = new JSONArray();
670642
conn = database.getConnection();
671643
for (Table table : Database.getTables(conn)){
672-
673-
if (table.getName().startsWith("device_location_")) continue; //skip partition tables
674-
675644
JSONArray columns = new JSONArray();
676645
for (Column column : table.getColumns()){
646+
677647
JSONObject col = new JSONObject();
678648
col.set("name", column.getName());
679649
col.set("type", column.getType());
@@ -685,6 +655,7 @@ private ServiceResponse getTables(ServiceRequest request, Database database) {
685655

686656
JSONObject json = new JSONObject();
687657
json.set("name", table.getName());
658+
json.set("schema", table.getSchema());
688659
json.set("columns", columns);
689660
arr.add(json);
690661
}

0 commit comments

Comments
 (0)