[SOLVED] AssertionFailedException when try getvalue of enum
Hi,
Any one knows how to get combobox (as a enum type) selected value? So, I have a work item that has a enum attribute and one advisor to get this enum value, but when I try to get it, I take a Assert failed like below:
Caused by: org.eclipse.core.runtime.AssertionFailedException: assertion failed:
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.getValue(WorkItemImpl.java:2848)
at com.ibm.team.workitem.common.internal.attributeValueProviders.FallbackProvider.getValue(FallbackProvider.java:33)
at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.getValue(AttributeImpl.java:898)
at com.ibm.team.advisors.apf.APFAdvisor.runCommon(APFAdvisor.java:163)
at com.ibm.team.advisors.apf.APFAdvisor.run(APFAdvisor.java:39)
... 111 more
The interesting thing is that I can get the attribute but can not the selected value.. below my code:
IAttribute attribute = workItemService.findAttribute(wi.getProjectArea(), "tipoFuncaoComboBox", monitor);
Object test1 = ((IWorkItem) wi.getWorkingCopy()).getValue(attribute); //fail
Object test2 = wi.getValue(attribute); //fail
Object test3 = attribute.getValue(auditableCommon, wi, monitor); //fail
The process template is: http://www.heypasteit.com/clip/0YIC
Accepted answer
This post should provide you with some examples, I believe: http://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/
Comments
1 vote
4 other answers
Hi friends,
So, I discovered that enum resolver is to simple as explained by @Ralph Schoon and @sam detweiler. However, my case is a bit different, because I need the enum value of a work item child (second level), and when I try to get the enum value on the on save action of the parent of parent work item, I can not access the enum value of the second level child, as described below:
WI_A (parent);
WI_B (child first level);
WI_C (child scond level);
OR
WI_C is child of WI_B that is child of WI_A.
So, I have to obtain all the values from WIB_B and WI_C, at the on save (precondition advisor) of the WI_A. But, as mentioned above, I can not do it, or I can not know how to do it, and I am so glad if any one can help. But, I will close this thread as solved, and open another one more specific for this situation, that I think is different for this one.
Comments
1 vote
This thing is simple a lot, the sercret is how to obtain the children as my source code fragment below.. Look for this comment //SECRET :)
IWorkItemReferences processoElementarChildWorkItemAllRefs = workItemService.resolveWorkItemReferences(funcionalidadeWi, monitor);List<IReference> processoElementarChildWorkItemAllRefschildList = getChildReferences(processoElementarChildWorkItemAllRefs);
IReference parentEndpoint = IReferenceFactory.INSTANCE.createReferenceToItem(funcionalidadeWi);
for (Object element : processoElementarChildWorkItemAllRefschildList) {IReference iReference = (IReference) element;ILink link = iReference.getLink();if (link.getOtherEndpointDescriptor(parentEndpoint) == WorkItemEndPoints.CHILD_WORK_ITEMS) {IWorkItem child = workItemServer.getAuditableCommon().resolveAuditable((IWorkItemHandle) link.getOtherRef(parentEndpoint).resolve(), WorkItem.FULL_PROFILE, monitor);//SECRET :)IAttribute pf = workItemService.findAttribute(child.getProjectArea(), "pf", monitor);String teste = getPF(child, pf, monitor);
IAttribute attributeT1enum_ = workItemService.findAttribute(child.getProjectArea(), "t1enum", monitor);IAttribute attributeT1enumList_ = workItemService.findAttribute(child.getProjectArea(), "t1enumlist", monitor);
IEnumeration<ILiteral> enumerationT1enum_ = (IEnumeration<ILiteral>) workItemService.resolveEnumeration(attributeT1enum_, monitor);IEnumeration<ILiteral> enumerationT1enumList_ = (IEnumeration<ILiteral>) workItemService.resolveEnumeration(attributeT1enumList_, monitor);
com.ibm.team.workitem.common.model.Identifier attributeT1enumiaval_ = (Identifier) child.getValue(attributeT1enum_);List attributeT1enumListiaval_ = (List) child.getValue(attributeT1enumList_);
System.out.println(teste);}}
Comments
sam detweiler
Sep 10 '13, 9:57 a.m.1 vote