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

Retrieving enumeration values from a multi-select field

I have a custom attribute defined as shortString with a multi-select checkbox presentation set up with a custom property field with key 'enumeration' and the value being the name of the enumeration I want to display for selection.

What I want to do is programatically retrieve the enumeration values selected. IWorkItem.getValue() returns a comma-separated String of enumeration identifiers matching the selection, and from this I want to retrieve the actual ILiteral objects to call ILiteral.getName() on them to get their displayable names or 'values'.

The problem I'm having is actually resolving the IEnumeration object used in the multi-select checkbox presentation. Normally the attribute type itself is tied to an enumeration, with the enumeration being defined as the attribute type.

In that case it's easy: I just use
IWorkItemCommon.resolveEnumeration(IAttribute, IProgressMonitor)


However for my mult-select checkbox field, the attribute is defined as type 'smallString' and so the call above won't work as theirs no enumeration directly associated with it, only associated with the presentation of it in an editor.

Therefore how can I resolve the enumeration in this situation?

From hunting around I've resolved it in the following manner, but it's not a clean implementation and so I would really like to know if there's a proper way of doing this.

IEnumeration enumeration = ((WorkItemCommon) workItemCommon).internalResolveEnumeration(projectArea, enumerationName, monitor);


You can see that I've had to use an internal method of WorkItemCommon and not available in the IWorkItemCommon interface to resolve it. Is it possible to resolve it through the standard API rather than this internal method?

For scope I've included my whole method for reference:

public String[] getMultiSelectEnumerationValues(final IWorkItem workItem, final String attributeName, final enumerationName, final IProjectAreaHandle projectArea, IWorkItemCommon workItemCommon, final IProgressMonitor monitor)

{
String[] result = null;

final String str = (String) workItem.getValue(attribute);

if(str != null)
{
final IAttribute attribute = workItemCommon.findAttribute(projectArea, fieldIdentifier, monitor);

// TODO Dodgy internal call to resolve the IEnumeration, need to fix
final IEnumeration enumeration = ((WorkItemCommon) workItemCommon).internalResolveEnumeration(projectArea, enumerationName, monitor);

result = str.split(",");

ILiteral currentLiteral;
for (int i = 0; i < result.length; i++)
{
currentLiteral = getEnumerationLiteralByID(enumeration, result[i]);

if(currentLiteral != null)
{
result[i] = currentLiteral.getName();
}
else
{
throw new IllegalArgumentException("Cannot find enumeration literal '" + result[i] + "' for enumeration: " + enumeration);
}
}
}

return result;
}

public ILiteral getEnumerationLiteralByID(final IEnumeration<? extends ILiteral> enumeration, final String identifierName)
{
final Identifier<? extends ILiteral> identifier = Identifier.create(ILiteral.class, identifierName);

return enumeration.findEnumerationLiteral(identifier);
}

Many thanks in advance.

0 votes

Comments

Hi there

I have a similar problem with RTC 3.x and server side extension, here I can see

        final IEnumeration enumeration = ((WorkItemCommon) workItemCommon).internalResolveEnumeration(projectArea, enumerationName, monitor);

has been used, however for workItemServer does not seems to have a similar internal function which cane be used for resolving the enumeration. Also can you please let me know the enumeration name used?

Many thanks in advance.

                    IWorkItemCommon www;
                    www.resolveEnumeration(attribute, monitor)

IWorkItemCommon is a service exported by com.ibm.team.workitem,service jar file

         <provides>
            <providedService interface="com.ibm.team.workitem.common.IWorkItemCommon"/>
            <providedService interface="com.ibm.team.workitem.service.IWorkItemServer"/>

I posted my updated source to dynamically detect and decode the V3 multi-select enum list



2 answers

Permanent link
Hi
This is the only way to do this. Please file an API request on jazz.net (e.g. as enhancement) against Work Items.

Regards

Marcel
Jazz Work Item team

0 votes


Permanent link
Thanks for the quick reply Marcel.

I've raised enhancement Enhancement 83004 to track this.

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

Question asked: May 13 '09, 12:21 p.m.

Question was seen: 6,249 times

Last updated: Jan 25 '13, 12:29 a.m.

Confirmation Cancel Confirm