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?
Accepted answer
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.
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.
One other answer
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
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.