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

How to get dependent enumaration?

Hi,

i have found the solution for fetching dependent enumation.

Let me know how to pass configuration value to this function.



public List<Identifier<extends>> getValueSet(IAttribute attribute, IWorkItem workItem, IWorkItemCommon workItemCommon, IConfiguration configuration, IProgressMonitor monitor) throws TeamRepositoryException {
if (workItem == null) {
List<extends> literals= workItemCommon.resolveEnumeration(attribute, monitor).getEnumerationLiterals();
List<Identifier<extends>> identifiers= new ArrayList<Identifier<extends>>();
for (ILiteral l: literals) {
identifiers.add(l.getIdentifier2());
}
return identifiers;
}

IAttribute filterAttribute= findFilterAttribute(attribute, workItem, workItemCommon, configuration, monitor);

if (filterAttribute == null) {
throw new IllegalArgumentException(NLS.bind(Messages.getString("FilteringValueSetProvider.FILTER_ATTRIBUTE_NOT_DEFINED"), workItem.getId(), attribute.getDisplayName())); //$NON-NLS-1$
}
if (!workItem.hasAttribute(filterAttribute)) {
throw new IllegalStateException(NLS.bind(Messages.getString("FilteringValueSetProvider.FILTER_ATTRIBUTE_NOT_FOUND"), workItem.getId(), attribute.getDisplayName())); //$NON-NLS-1$
}

Object filterValue= workItem.getValue(filterAttribute);
if (filterValue instanceof Identifier<?>) {
filterValue= ((Identifier<?>) filterValue).getStringIdentifier();
}
final IEnumeration<extends> enumeration= workItemCommon.resolveEnumeration(attribute, monitor);
if (enumeration == null) {
throw new IllegalStateException(NLS.bind(Messages.getString("FilteringValueSetProvider.ENUMERATION_OF_FILTER_ATTRIBUTE_NOT_FOUND"), workItem.getId(), attribute.getDisplayName())); //$NON-NLS-1$
}

AttributeType attributeType= AttributeTypes.getAttributeType(attribute.getAttributeType());

List<String> literalIds= ValueProviderUtil.getMappedLiterals(configuration, (String) filterValue);
List<ILiteral> literals= new ArrayList<ILiteral>();
for (String literalId: literalIds) {
ILiteral lit= enumeration.findEnumerationLiteral((Identifier<extends>)attributeType.valueOf(literalId, null));
if (lit != null) {
literals.add(lit);
}
}
Collections.sort(literals, new Comparator<ILiteral>() {
public int compare(ILiteral o1, ILiteral o2) {
return enumeration.getEnumerationLiterals().indexOf(o1) - enumeration.getEnumerationLiterals().indexOf(o2);
}
});
List<Identifier<extends>> filteredValues= new ArrayList<Identifier<extends>>();
for (ILiteral lit: literals) {
filteredValues.add(lit.getIdentifier2());
}
return filteredValues;
}

0 votes



2 answers

Permanent link
Thanks for sharing!

0 votes


Permanent link
Hi,

find the solution for calling above get value method.

IWorkItem workItem1 = null;

ProviderConfiguration providerConfiguration= ((WorkItemCommon) workItemCommon).getProviderConfiguration(attribute, monitor);
IConfiguration configuration= providerConfiguration != null ? providerConfiguration.getValueSetProviderConfiguration() : null;

List<ILiteral> test= obj.getValueSet(attribute,workItem1,workItemCommon,configuration,monitor,getEnumarationLiteral(filterid,filterValue).getStringIdentifier());

Thanks,
Pugazh

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

Question asked: Apr 17 '12, 8:14 a.m.

Question was seen: 4,818 times

Last updated: Apr 17 '12, 8:14 a.m.

Confirmation Cancel Confirm