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

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

0 votes



4 answers

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

0 votes


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

0 votes


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

0 votes


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

0 votes

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,939

Question asked: Apr 17 '09, 5:20 p.m.

Question was seen: 6,551 times

Last updated: Apr 17 '09, 5:20 p.m.

Confirmation Cancel Confirm