rtc检查java代码,如何使用RTC Java API根据修改的日期和时间获取工作项

I want to query RTC with modified date.

My query is to check modified date is same as given date and time but the response that I am getting is based on given date and it is ignoring time.

Response:

Queried Date: 08/07/2015 15:44:09

Id: 2583 Modified date :2015-08-07 14:43:19.157

Id: 2582 Modified date :2015-08-07 14:43:19.419

Ideally, both the records should not be received in response as it is before given time.

Below is my code:

IQueryableAttributeFactory factory = QueryableAttributes.getFactory( IWorkItem.ITEM_TYPE );

IQueryableAttribute recAttr1 = factory.findAttribute(projectArea, IItem.MODIFIED_PROPERTY, auditableClient, null );

IQueryableAttribute recAttr2 = factory.findAttribute(projectArea, IWorkItem.TYPE_PROPERTY, auditableClient, null );

Date date = new Date();

date.setDate(date.getDate()-6);

DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");

String reportDate = df.format(date);

System.out.println("Date: "+reportDate);

Timestamp timeStamp = new Timestamp(date.getTime());

AttributeExpression recExpr1 = new AttributeExpression(recAttr1, AttributeOperation.EQUALS, timeStamp );

Term term= new Term(Operator.AND);

term.add(recExpr1);

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

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

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

while(result.hasNext(null)){

IResolvedResult resolvedWorkItem = result.next(null);

IWorkItem workItem = resolvedWorkItem.getItem();

Date date1 = resolvedWorkItem.getItem().modified();

System.out.println("Id: "+workItem.getId());

System.out.println("Modified date :"+date1.toString()+"\n");

}

Can I get result not only based on date but also on time?

I strongly feel that the back-end logic of RTC is completely ignoring time and querying database only based on date.

解决方案

I have the exact same problem. I thought maybe the results were cached somewhere, but that wasn't it.

I haven't found a way to do this via RTC query, but it should be possible to filter out these records in your code after RTC query returned. Save the time you used to perform the search, then use that to skip any records by doing:

if (workItem.modified().getTime() < lastModified)

continue;

I know this isn't ideal, but at least there's a way to get the desired set to work with.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值