Thursday, September 26, 2013

How to get filtered data by calling webservice in Java

How to get filtered data by calling webservice in Java

I am writing a code where I call a webservice to get the data from
database and then fetch it in the grid by applying some conditions which
is working fine. But since in future the database will be huge so to call
whole data and then refining it will create performance issues. So I want
to get filter data itself from database.
Current Code: Calling webservice code:
RESTClient<AuditInfoObject, ArrayList<AuditInfoObject>> restClient = new
RESTClient<AuditInfoObject, ArrayList<AuditInfoObject>>(
new AuditInfoObject(), new
TypeToken<ArrayList<AuditInfoObject>>() {
}.getType(), CommonConstatnts.SHOW_ALL_AUDIT,
CommonConstatnts.CONTET_TYPE_JSON);
ArrayList<AuditInfoObject> auditInfoList = restClient.getResponse();
AuditInfoObject contains: userID,appID,and othe details.
Here auditinfolist contains the whole data.
Now i apply the condition to filter the data which i recieved by comparing
userId and appId and insert it in grid table.
Code:
try {
for (AuditInfoObject row : auditInfoList) {
if (app.getUserID() == row.getUserID() &&
app.getAppName().equalsIgnoreCase(row.getAppName().trim())) {
GridItem item = new GridItem(appDashBoardGrid, SWT.FILL |
SWT.NONE);
item.setText(0, row.getTimeStamp());
item.setText(1, row.getAction());
item.setText(2, row.getActionData());
item.setText(3, row.getMachineDetail());
}
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
HERE:app.getUserID() is the current userID which i match with the recieved
data userid column i.e row.getUserID() similarly for appID also.
Now I want to call webservice in such a way that the present userID and
appId goes with webservice call match with database and I should get
filtered data before only on that basis so that I can put in grid table
because it will be fast and have good performance.

No comments:

Post a Comment