[SOLVED] AssertionFailedException when try getvalue of enum
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
IAttribute attribute = workItemService.findAttribute(wi.getProjectArea(), "tipoFuncaoComboBox", monitor);
Accepted answer
Comments
I was read this, but when ever I try the start point of this post that is: workItem.getValue(iAttribute); I get the org.eclipse.core.runtime.AssertionFailedException: assertion failed.
So I am using server side code, then I had to translate some code to the server side api, as below. However the same exception persists on the line that has this comment: //AssertionFailedException: assertion failed.
// this will throw exception if not enumeration
IEnumeration<ILiteral> enumeration = (IEnumeration<ILiteral>) workItemService.resolveEnumeration(attribute, monitor);
if (enumeration != null) {
String[] iaval = attribute.getValue(auditableCommon, wi, monitor).toString().split(":"); //AssertionFailedException: assertion failed.
if (iaval.length > 1 && iaval[1] != null) {
List<ILiteral> enumerationLiterals = enumeration.getEnumerationLiterals();
for (ILiteral literal : enumerationLiterals) {
if (literal.getIdentifier2().getStringIdentifier().equalsIgnoreCase(iaval[1])) {
System.out.println("\t\t\t\t --> attribute id=" + attribute.getIdentifier() + ", type" + "=" + attribute.getAttributeType() + " literal=" + literal.getIdentifier2().getStringIdentifier() + " literal name=" + literal.getName());
break;
}
}
}
}
I can't debug your code. Here is some code I wrote on the server. It is basically the same as on the client, except the services IWorkitemServer and IWorkItemCommon used instead of Client Libraries.
// Get the references for the trigger work item, we need it to add new // links IWorkItemReferences triggerItemReferences = iWorkItemServer .resolveWorkItemReferences(resolvedTriggerItem, monitor);// Iterate the enumeration literals and create IEnumeration<? extends ILiteral> targetEnumeration = iWorkItemCommon .resolveEnumeration(enumerationAttribute, monitor); List<? extends ILiteral> literals = targetEnumeration .getEnumerationLiterals(); for (ILiteral targetLiteral : literals) { // Skip literals that are on the ignore list if (parsedConfig.fSkipLiterals.contains(targetLiteral .getIdentifier2().getStringIdentifier())) { continue; }
...........
I would suggest to look into the links provided in the answers and debug your code on Jetty as suggested in https://jazz.net/library/article/1000 to understand where your code is wrong.
1 vote
4 other answers
Comments
Joao,
how to iterate the children and get their values can be found here: https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/
Please be aware that you are not supposed to modify the work item that is saved during a precondition/advisor, see https://rsjazz.wordpress.com/2012/12/14/do-not-modify-the-triggering-element-in-an-operationadvisor/ because the extension point assumes the item is unmodified.
Please spend a bit more time to talk about your use case and which context (client/server) it is supposed to run in, next time.
Finally please pick Sam's answer as the correct one, as it answers your initial question as far as I can tell, so he should get his credit for the effort of answering.
1 vote
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.enum's don't have 'values', you have to 'resolve' them
see my sample in
https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes
see the code following this line
" // this will throw exception if not enumeration"
1 vote