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());
}
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());
}
One answer
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