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

How to use Plain Java API query work item with Modified time

Hi, I'm developing on RTC using Plain java api, and trying to query out work item via modified time as filter. My purpose is query out all the work item whose last modified time(there is a named "modified" artifacts) after some specific time. But my code cann't query out any records. Does anybody can help me? Much appreciate.

BTW: I use RTC2.0.

IProcessClientService processClient= (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);
IAuditableClient auditableClient= (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);
URI uri= URI.create(projectAreaName.replaceAll(" ", "%20"));
IProjectArea projectArea= (IProjectArea) processClient.findProcessArea(uri, null, null);
IQueryableAttributeFactory factory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);
IProgressMonitor monitor= new NullProgressMonitor();
IQueryableAttribute queryableAttribute = factory.findAttribute(projectArea, IWorkItem.MODIFIED_PROPERTY, auditableClient, monitor);
String arg1 = "modified";
Calendar instance = Calendar.getInstance();
instance.set(2011,3,9,0,0);
Timestamp after= new Timestamp(instance.getTimeInMillis());
AttributeExpression queryExpression = new AttributeExpression(queryableAttribute, AttributeOperation.GREATER_OR_EQUALS, after);
IQueryableAttribute projectAreaAttribute = factory.findAttribute(projectArea, IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, monitor);
AttributeExpression projectAreaExpression= new AttributeExpression(projectAreaAttribute, AttributeOperation.EQUALS, projectArea);

Term term= new Term(Operator.AND);
term.add(queryExpression);
term.add(projectAreaExpression);

IQueryClient queryClient = (IQueryClient) teamRepository.getClientLibrary(IQueryClient.class);

IQueryResult<IResolvedResult<IWorkItem>> result = queryClient.getResolvedExpressionResults(projectArea, (Expression)term, IWorkItem.FULL_PROFILE);

System.out.println("This is total number: "+result.getResultSize(monitor).getTotal()+"\n");

if(result.hasNext(null)){
IResolvedResult<IWorkItem> resolved = result.next(null);
Date date1 = resolved.getItem().modified();
System.out.println("Modified is :"+date1.toString()+"\n");
System.out.println("Modified by:"+ resolved.getItem().getModifiedBy()+ "\n");
System.out.println("State is:"+resolved.getItem().getFullState().toString()+"\n");
System.out.println("Name="+resolved.getItem().getHTMLSummary());
}

1 vote



One answer

Permanent link
Hi, I'm developing on RTC using Plain java api, and trying to query out work item via modified time as filter. My purpose is query out all the work item whose last modified time(there is a named "modified" artifacts) after some specific time. But my code cann't query out any records. Does anybody can help me? Much appreciate.

BTW: I use RTC2.0.

IProcessClientService processClient= (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class);
IAuditableClient auditableClient= (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);
URI uri= URI.create(projectAreaName.replaceAll(" ", "%20"));
IProjectArea projectArea= (IProjectArea) processClient.findProcessArea(uri, null, null);
IQueryableAttributeFactory factory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);
IProgressMonitor monitor= new NullProgressMonitor();
IQueryableAttribute queryableAttribute = factory.findAttribute(projectArea, IWorkItem.MODIFIED_PROPERTY, auditableClient, monitor);
String arg1 = "modified";
Calendar instance = Calendar.getInstance();
instance.set(2011,3,9,0,0);
Timestamp after= new Timestamp(instance.getTimeInMillis());
AttributeExpression queryExpression = new AttributeExpression(queryableAttribute, AttributeOperation.GREATER_OR_EQUALS, after);
IQueryableAttribute projectAreaAttribute = factory.findAttribute(projectArea, IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, monitor);
AttributeExpression projectAreaExpression= new AttributeExpression(projectAreaAttribute, AttributeOperation.EQUALS, projectArea);

Term term= new Term(Operator.AND);
term.add(queryExpression);
term.add(projectAreaExpression);

IQueryClient queryClient = (IQueryClient) teamRepository.getClientLibrary(IQueryClient.class);

IQueryResult<IResolvedResult<IWorkItem>> result = queryClient.getResolvedExpressionResults(projectArea, (Expression)term, IWorkItem.FULL_PROFILE);

System.out.println("This is total number: "+result.getResultSize(monitor).getTotal()+"\n");

if(result.hasNext(null)){
IResolvedResult<IWorkItem> resolved = result.next(null);
Date date1 = resolved.getItem().modified();
System.out.println("Modified is :"+date1.toString()+"\n");
System.out.println("Modified by:"+ resolved.getItem().getModifiedBy()+ "\n");
System.out.println("State is:"+resolved.getItem().getFullState().toString()+"\n");
System.out.println("Name="+resolved.getItem().getHTMLSummary());
}

Please see if this can help: https://jazz.net/forums/viewtopic.php?t=4649&highlight=last+modified

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
× 10,926
× 14

Question asked: Mar 17 '11, 9:49 a.m.

Question was seen: 9,090 times

Last updated: Nov 13 '12, 4:02 a.m.

Confirmation Cancel Confirm