It's all about the answers!

Ask a question

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


1
1
varathan anandaraj (8512) | asked Dec 15 '16, 4:09 a.m.
edited Dec 17 '16, 6:34 a.m.
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 

Accepted answer


permanent link
varathan anandaraj (8512) | answered Dec 17 '16, 6:28 a.m.
edited Dec 17 '16, 6:31 a.m.

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

3 other answers



permanent link
SEC Servizi (97123660) | answered Mar 15 '19, 9:00 a.m.
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.

permanent link
Ralph Schoon (63.1k33646) | answered Dec 16 '16, 4:32 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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/

Comments
Ralph Schoon commented Dec 16 '16, 4:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


varathan anandaraj commented Dec 16 '16, 5:05 a.m.

I could not see related to attachment expression .


Geoffrey Clemm commented Dec 16 '16, 1:07 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


varathan anandaraj commented Dec 17 '16, 6:29 a.m.

thanks for your response.


permanent link
Ralph Schoon (63.1k33646) | answered Dec 16 '16, 3:24 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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()



Comments
varathan anandaraj commented Dec 16 '16, 4:27 a.m.

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 ?


Your answer


Register or 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.