API question: specialized types to/from Strings
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?
Thanks,
Ernest
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?
Thanks,
Ernest
4 answers
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?
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?
bump
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?
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?
Hi
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).
Regards
Marcel
Jazz Work Item team
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).
Regards
Marcel
Jazz Work Item team