Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Getting exception on IQueryResult.hasNext() method

I am making a query to the JTS for work items that were modified after a specific time.  The query works fine if there are work items that meet that criteria.  If there are no work items modified after the provided time then the following method call generates an exception

//
        // This method was created to address the strange problem where the
        // hasNext method is generating an exception when the query did
        // not yield any results.
        //
        private boolean hasNextSafe(IQueryResult<IResolvedResult<IWorkItem>> queried)
        {
            //
            // The queried.hasNext() method is generating an exception when the result is empty, EVEN though the
            // total count above shows there there are results. 
            //
            boolean fContinue = false;
            try
            {
                fContinue = queried.hasNext(null);
            }
            catch(Exception e)
            {
                System.out.println("RTCActionPerformer::hasNextSafe - queried.hasNext generated an exception");
                fContinue = false;
            }
            return fContinue;
           
        } // end of the hasNextSafe method

In the case where there are no work items returned ... the following code seems to yield the results of the previous query ...

ResultSize rs = queried.getResultSize(null);
int iTotal = rs.getTotal();
System.out.println("RTCActionPerformer::processArtifact - " + iTotal + " work items returned");

0 votes



3 answers

Permanent link
I am not sure why you get that. I have never seen this in the past. The code described here works for me: http://rsjazz.wordpress.com/2012/10/29/using-work-item-queris-for-automation/

0 votes


Permanent link
Ralph - thanks for the quick response and pointer.  Looks like a great article and just what I am looking for.  I did not see a link to download the full source code?  Is that available?

0 votes

Comments

Hi Joe, I did not publish the code yet. but you should be able to just cut and paste from the blog. I am still in the process of publishing to https://hub.jazz.net/project/rschoon/Jazz%20In%20Flight but this code is not yet up. I have to do some clean up first.


Permanent link
Ralph - by the way, I have a hunch that maybe there is something that I need to do to close out the previous query that maybe I am not doing.  In the case where I get the exception I am seeing somethings that were clearly from the previous query.

ResultSize rs = queried.getResultSize(null);
int iTotal = rs.getTotal();
System.out.println("RTCActionPerformer::processArtifact - " + iTotal + " work items returned");

Thanks again for your help.

Joe

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details

Question asked: Jun 18 '13, 6:42 p.m.

Question was seen: 5,360 times

Last updated: Jun 19 '13, 8:21 a.m.

Confirmation Cancel Confirm