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

How to create the workItem Query for attachment file size more then 1MB by JAZZ API ?

I am trying to create a query that filters on work item attachment file size .
For example I want to return all work items that have files(Attachment) which more then 1024KB by Java API 

1

1 vote


Accepted answer

Permanent link

I got the result by JAVA API using the below logic:

IQueryableAttribute attachmentAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectAreaObject, "link:com.ibm.team.workitem.linktype.attachment:target",auditableCommonObject, monitor);


attachmentAttribute = attachmentAttribute.getChildAttribute(CONTENT).getChildAttribute(CONTENT_LENGTH);

Expression exAttachmentSize = new AttributeExpression(attachmentAttribute , AttributeOperation.GREATER_OR_EQUALS, 1048576);

term.add(exAttachmentSize);

Ralph Schoon selected this answer as the correct answer

2 votes


3 other answers

Permanent link
Since this is not supported in the UI Query Editor, I would assume there is no way to query for this. You would likely have to go through all work items, their attachments and you might even have do get all the content to get at the length.

com.ibm.team.repository.common.IContent.getRawLength()

e.g. com.ibm.team.workitem.common.model.IAttachment.getContent().getRawLength()


0 votes

Comments

No . I able to see in UI Query editor (Attachments>Content>Content Length) . it is working fine also . I want same login should we implement in Java API ?


Permanent link
Then see these API examples:

https://rsjazz.wordpress.com/2012/10/29/using-work-item-queris-for-automation/
https://rsjazz.wordpress.com/2012/11/19/using-an-expression-to-synchronize-attributes-for-work-items-of-a-specific-type/

0 votes

Comments

I still don't see it in the work item query editor at least in 6.0.

I could not see related to attachment expression .

For some reason, the Attachments -> Content -> Content_Length query term is only available in the Eclipse UI (not in the Web UI).   And if you view a query in the Web UI with that query term, you see there is a term, but no information about that term.

thanks for your response.


Permanent link
IQueryableAttribute attachmentAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectAreaObject, "link:com.ibm.team.workitem.linktype.attachment:target",auditableCommonObject, monitor);
You could use com.ibm.team.workitem.common.internal.expression.QueryableLinkAttribute#createIdentifier to get the value for parameter attributeIdentifier of com.ibm.team.workitem.common.expression.IQueryableAttributeFactory#findAttribute.
Cheers.

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: Dec 15 '16, 4:09 a.m.

Question was seen: 1,930 times

Last updated: Mar 15 '19, 9:00 a.m.

Confirmation Cancel Confirm