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

API to find the UUID of work item ?

 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?

0 votes


Accepted answer

Permanent link
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

0 votes

Comments

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




One other answer

Permanent link
 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.


 

0 votes

Comments

 storyDetails.getItemId().toString() 

method prints the [UUID _n-JfsjeBEeWvWq64jXWwMA] this value 

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

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 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
× 10,938
× 7,495
× 1,700

Question asked: Nov 12 '15, 8:54 a.m.

Question was seen: 7,771 times

Last updated: Nov 13 '15, 5:47 a.m.

Confirmation Cancel Confirm