IBM Rational Build Forge Java API - How to use QueryFilter
I refer the link at http://www.ibm.com/developerworks/rational/downloads/08/bf_java_api_guide/index.html
The pdf file did assist with my development work and at the moment I am stagnating when I came across two classes called Log (com.buildforge.services.client.dbo.Log) and QueryFilter (com.buildforge.services.common.db.QueryFilter). My aim is to search for a specific value in any log entries. If the value can be found in a log entry, I like to get the log's Step, Build and Project details. The pdf do not explain in depth how to use com.buildforge.services.common.db.QueryFilter in order for me to query the Log. I tried to search on the IBM site but there are no information on the QueryFilter. Are you able to assist in providing more details about the QueryFilter? Your assistance would be greatly appreciated. Thank you. |
6 answers
I refer the link at http://www.ibm.com/developerworks/rational/downloads/08/bf_java_api_guide/index.html Hi, This is kind of a contrived example of getting some data about a log. The QueryFilter comes in very handy when trying to increase performance by going after particular columns of data that are in the database. However, this requires understanding the database schema.
bju |
Thank you bju.
Where do I find th information about the database schema? Having observe your code, here is my code which give you an idea what I am trying to achieve: APIClientConnection conn = new APIClientConnection("localhost", 3966); conn.authUser("root", "root"); QueryFilter filter = new QueryFilter(); List<ColumnRef> columns = new ArrayList<ColumnRef>(); columns.add(new ColumnRef(APIConstants.KEY_LOG_UUID)); columns.add(new ColumnRef(APIConstants.KEY_LOG_TYPE)); columns.add(new ColumnRef(APIConstants.KEY_LOG_MESSAGE)); filter.setColumnList(columns); filter.setWhere(SqlCond.like(new ColumnRef(APIConstants.KEY_LOG_MESSAGE), "error here")); QueryResponse response = Log.findFiltered(conn, filter); List<Object> rowData = response.getRowData(); if (rowData.size() > 0) { for( Object[] aRow: rowData) { System.out.println("KEY_LOG_UUID: " + aRow); System.out.println("KEY_LOG_TYPE: " + aRow); System.out.println("KEY_LOG_MESSAGE: " + aRow); System.out.println("\n"); } } conn.logout(); conn.close(); How do I query two tables? Here is my plain english query: Return a list of Step's name, Step's start time and Step's duration where the APIConstants.KEY_LOG_MESSAGE contains "error here" I believe the Step table will contains the followings: APIConstants.KEY_STEP_STEP_ID APIConstants.KEY_STEP_START_TIME APIConstants.KEY_STEP_DURATION Your assistance would be greatly appreciated. |
Hi,
This example code doesn't use QueryFilter, but I'm wondering if it would satisfy your requirements. You might adapt it and try it in your environment to see how it performs. I find it quite easier to code and understand than using QueryFilter. If it doesn't perform well enough, it may be useful to look further at a QueryFilter solution.
Brent Ulbricht Build Forge Test |
hi bju,
Thank you for the code. I've looked at your code examples and unfortunately it is not what I am after; the performance is too slow. I prefer the QueryFilter because it is quicker; I am scanning thousands of projects, steps, jobs and logs. It seems the QueryFilter solution is design for one table at a time; hence it will not suit to my solution. Since QueryFilter solution is not feasible, do you have any knowledge of SqlQuery? I tried to find some document pertaining SqlQuery on the IBM site and unfortunately the information is not there. From what I understand, SqlQuery can query multiple tables. I got a code example that query a table and at the moment it is stagnating: APIClientConnection conn = new APIClientConnection("localhost", 3966); conn.authUser("root", "root"); SqlQuery qry = new SqlQuery() .select(new ColumnRef(APIConstants.KEY_LOG_UUID)) .from(new TableRef(APIConstants.KEY_LOG_DBO)) .where( SqlCond.like(new ColumnRef(APIConstants.KEY_LOG_MESSAGE), "custom error=%")); I am unsure how SqlQuery returns a result... Do you have any ideas how the SqlQuery works? |
Neither QueryFilter nor SqlQuery are currently meant for public
consumption, which is why they live down in the common package rather than in the meant-for-public-consumption client package. We can go down the route of explaining the low-level request and return semantics of this undocumented and unintended (for the public) functionality or you can do straight JDBC to the backing database for full access to the entire schema. -steve hi bju, |
Thank you.
Given the response thread above, I shall stick to the current solutions and look into JDBC (BIRT). Thank you very much for your assistance. |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.