It's all about the answers!

Ask a question

API question: specialized types to/from Strings

Ernest Crvich (19211918) | asked Apr 17 '09, 5:20 p.m.
While you can seemingly call IWorkItem.setValue() with any attribute regardless of type (I'm hoping that can be used for custom attributes as well), you do have to pass in an object of the correct type. However, most of these types have a very obvious string-like representation.

As one example, setting a value for the "category" attribute requires converting a value like "Backlog" into an ICategoryHandle as follows:

workItemClient.findCategoryByNamePath( projectArea,
Arrays.asList( categoryName.split( "/" ) ), null );

My question is if there is an already-provided mechanism for most of the built-in types to convert from strings. Or, if I'm going to have to write my own library to do this myself. Similar question for converting *to* strings...will the toString() method produce the expected result?


4 answers

permanent link
Ernest Crvich (19211918) | answered Apr 23 '09, 7:24 p.m.
Ok, so I'm assuming that no response to this means there are no built-in converters, so...

How does one go from IContributorHandle to a String that represents the userid? The "Handle" objects seem to be pretty useless for getting that sort of info. e.g., for ICategoryHandle, I see to have to call IWorkItemClient.resolveHierarchicalName() to get the String representation. I couldn't find an equivalent method in either IWorkItemClient or IContributorManager.

Any ideas?

permanent link
Ernest Crvich (19211918) | answered May 07 '09, 7:18 p.m.

How do you get the contributor name (as a String) from the IContributorHandle object returned from, say, IWorkItem.getOwner()? The IContributorManager class has a handy method to go from String to IContributor (which is what I use for setOwner(), for example), but I don't see anything to go from a Handle to a String.

Similarly, what about IProjectAreaHandle? How do you get the project name (as a String) armed only from that?

permanent link
Marcel Bihr, Jazz Work Item team (1.4k) | answered May 11 '09, 3:40 a.m.
Every handle class has a corresponding Item class where the 'full info' is available (handle is just some sort of pointer). You can use the IItemManager (ITeamRepository#itemManager()) to resolve a handle to an item (e.g. from IContributorHandle to IContributor).


Jazz Work Item team

permanent link
Ernest Crvich (19211918) | answered May 11 '09, 12:07 p.m.
You can use the IItemManager (ITeamRepository#itemManager()) to resolve a handle to an item (e.g. from IContributorHandle to IContributor).

Awesome, that worked perfectly, thanks a ton, Marcel!

Your answer

Register or to post your answer.