How to get dependent enumaration?
![]()
Hi,
i have found the solution for fetching dependent enumation. public List<Identifier<extends>> getValueSet(IAttribute attribute, IWorkItem workItem, IWorkItemCommon workItemCommon, 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; } |
2 answers
![]()
Ralph Schoon (62.0k●3●36●43)
| answered Apr 17 '12, 9:55 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Thanks for sharing!
|
![]()
Hi,
IWorkItem workItem1 = null; ProviderConfiguration providerConfiguration= ((WorkItemCommon) workItemCommon).getProviderConfiguration(attribute, monitor); IConfiguration configuration= providerConfiguration != null ? providerConfiguration.getValueSetProviderConfiguration() : null; Thanks, Pugazh |