It's all about the answers!

Ask a question

How to get the list of required attributes that needs to be setted by creating a new work item RTC Java API?


0
1
Kamil Dudek (1313) | asked Jun 15 '15, 7:52 a.m.
Hello,

In my Java client application, I need to create a lot of new Work Items. I have two repositories and several projects area on them, and for each project there are the different fields (attributes) that are required to be set by creating new item. So, here is my question from the topic: is there a way to get list of required attributes from specified project?

Thank you,
Kamil

Accepted answer


permanent link
Ralph Schoon (63.6k33646) | answered Jun 15 '15, 8:03 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You can find it in the work item common (and server)

IWorkItemCommon.findRequiredAttributes(workItem, workflowAction, monitor)

You can also find the read only attributes there.
Kamil Dudek selected this answer as the correct answer

Comments
Kamil Dudek commented Jun 15 '15, 8:44 a.m.

Thank you for your answer! So, can I get the instance of IWorkItemCommon from server using ITeamRepository.getClientLibrary(Class arg)? Could you also tell me, what is the workflowAction? Maybe this question are silly, but I'm only beginning developing in that API :)

Thanks in advance!
Kamil


Ralph Schoon commented Jun 15 '15, 9:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Yes, in the Client API you get the client library. In the server API you get the IWorkItemServer with an analog call.


Ralph Schoon commented Jul 16 '16, 4:49 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Like in https://rsjazz.wordpress.com/2016/07/15/build-on-state-change-work-item-save-participant/ you use com.ibm.team.repository.service.AbstractService as superclass and then you use getService()

2 other answers



permanent link
Hakki Bozkurt (1631328) | answered Jun 15 '15, 8:08 a.m.
edited Jun 15 '15, 8:15 a.m.

hi kamil,

i dont know, how to get list of required attributes but you can try to read this topic:

https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/

its maybe help you...

other way: i have 2 ideas about this topic

1- u can handle error in your java api and set the attribute one by one...

for example:

error message: you can set the summary

if it is set the summary  

i think it is bad idea :)

2- u can list the required fields manuel for each project area (just 1 times) and use this list in your code...

if required attributes changing in time maybe you can try to save the list as xml or config file and read in your java code easyly.


permanent link
Stefano Antoniazzi (1701711) | answered Jul 15 '16, 9:45 a.m.
edited Jul 15 '16, 9:46 a.m.
Adding a snippet (plain java api)

(IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);
String workItemTypeId = ....;
IWorkItemType workItemType = workItemClient.findWorkItemType(projectAreaHandle, workItemTypeId, progressMonitor);
IWorkItemWorkingCopyManager workItemWorkingCopyManager = workItemClient.getWorkItemWorkingCopyManager();
workItemHandle = workItemWorkingCopyManager.connectNew(workItemType, progressMonitor);
WorkItemWorkingCopy workItemWorkingCopy = workItemWorkingCopyManager.getWorkingCopy(workItemHandle);
IWorkItem workItem = workItemWorkingCopy.getWorkItem();
Collection<String> requiredAttributes =  workItemClient.findRequiredAttributes(workItem, null, progressMonitor);
for (String requiredAttribute : requiredAttributes) {
log.trace("requiredAttribute =>" + requiredAttribute + "<=");
}


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.