It's all about the answers!

Ask a question

API to find the UUID of work item ?


vijayakumar ramesh (1173660) | asked Nov 12 '15, 8:54 a.m.
edited Nov 12 '15, 9:08 a.m.
 IWorkItem storyDetails = (IWorkItem) teamRepository.itemManager().fetchCompleteItem(workItemHandle, ItemManager.DEFAULT, monitor);     
storyDetails.getItemId().toString()
above code gives below result 
[UUID _n-JfsjeBEeWvWq64jXWwMA]
my requirement is only UUID value alone not with in brackets 
Is there any API call which gives diretly just _n-JfsjeBEeWvWq64jXWwMA UUID value?

Accepted answer


permanent link
Ralph Schoon (63.1k33645) | answered Nov 12 '15, 10:27 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You can get that from an ItemHandle or the Item using anItemHandle.getItemId().getUuidValue()
So storyDetails.getItemId().getUuidValue() should give it to you. It is always worth to look at an object like the UUID and check the access methods it provides.
vijayakumar ramesh selected this answer as the correct answer

Comments
vijayakumar ramesh commented Nov 13 '15, 5:47 a.m.

 Thanks Ralph, Sam and Tiago for the support and help.



One other answer



permanent link
Tiago Moura (8387) | answered Nov 12 '15, 9:23 a.m.
 Hi!

The main problem is that the UUID object is represented by the class:
com.ibm.team.repository.common.UUID

and the the toString method is implemented to generate such value.

If you inspect how the com.ibm.team.repository.common.UUID create the UUID value, you will see that the algorithm to create the final value is based on two properties:

lsb - less significant bits
msb - most significant bits

Based on that, I did some hack to get the private fields (lsb and msb) from the com.ibm.team.repository.common.UUID object. With this two values you can instantiate (using this constructor java.util.UUID.UUID(long mostSigBits, long leastSigBits) a java.util.UUID object and finally print the real UUID value.


 


Comments
vijayakumar ramesh commented Nov 12 '15, 9:31 a.m.

 storyDetails.getItemId().toString() 

method prints the [UUID _n-JfsjeBEeWvWq64jXWwMA] this value 

Is it possible to share u r code regarding above LSB and MSB ?


sam detweiler commented Nov 12 '15, 11:39 a.m.

ralph has the right answer below. 

but also, you can manipulate the string pretty easily if you didn't have these methods.. without going thru hacking for private data.

UUID = storyDetails.getItemId().toString()
UUID = UUID.substring(1,UUID.length()-1)

and of course you could add logic to test if the substring() approach was needed.


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.