Risk Exposure Example Query
The Risk Exposure example posted on https://jazz.net/wiki/bin/view/Main/AttributeValueProviders#Examples works now in my environment.Hoewever there is small change required in the calculation. In the line where multiplication of impact and probability is returned, what we want is a decimal value like this: return impact * (probability / 100). We want to have probability value divided by 100 and then multiplied to impact value. When I do this it doesnot show the change. Probably it is not reading a decimal value. What needs to be done to implement this.
|
11 answers
The Risk Exposure example posted on We currently don't support floating point custom attributes, only Integer and Long. See https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/61040 -- Regards, Patrick Jazz Work Item Team |
Are there options for converting the value to a string and then displaying the string as a presentation? What would the steps be to implement this? |
Are there options for converting the value to a string and then There are two options that are both not optimal: 1) Use an attribute of type string and modify the value calculator to return a string. --> You lose the ability to query for 'risk > x' 2) Write a presentation for numbers that divides the number by a certain factor. --> This would need to be done both for the Eclipse UI and Web UI --> Currently it is not possible to provide a custom presentation for the query results -- Regards, Patrick Jazz Work Item Team |
What is the syntax in the JS to perform #1? |
What is the syntax in the JS to perform #1? Say you have impact and probability and you calculate a float like this: var risk = impact * probability / 100; return risk.toFixed(2); This would return a string with two digit precision. -- Regards, Patrick Jazz Work Item Team |
I tried to implement the toFixed() method in ExposureProvider.js but it doesnot give the desired output.It throws the error.
I Tried: var exposure = impact * (probability / 100); return exposure.toFixed(2); Also, in Process Configuration Source (XML), in the value Providers I retured Risk Exposure as string type instead of long. The error I am recieving is as below: java.lang.ClassCastException: java.lang.String incompatible with java.lang.Double at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.convert(ScriptAttributeValueProvider.java:90) at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.getValue(ScriptAttributeValueProvider.java:56) at com.ibm.team.workitem.common.internal.attributeValueProviders.AttributeValueProviderRegistry$SafeValueProvider.getValue(AttributeValueProviderRegistry.java:42) at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.getValue(AttributeImpl.java:857) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:596) at $Proxy21.getValue(Unknown Source) at com.ibm.team.workitem.client.internal.DependencyHandler$Worker.runProtected(DependencyHandler.java:51) at com.ibm.team.foundation.client.util.FoundationJob.run(FoundationJob.java:68) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) Please suggest what else can be tried on to get the correct output? |
I tried to implement the toFixed() method in ExposureProvider.js but I mistakenly thought that toFixed would return a string. You can explicitly return a String using: return new String(exposure.toFixed(2)); -- Regards, Patrick Jazz Work Item Team |
This did not work either. Error output: java.lang.ClassCastException: org.mozilla.javascript.NativeString incompatible with java.lang.Double at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.convert(ScriptAttributeValueProvider.java:90) at com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider.getValue(ScriptAttributeValueProvider.java:56) at com.ibm.team.workitem.common.internal.attributeValueProviders.AttributeValueProviderRegistry$SafeValueProvider.getValue(AttributeValueProviderRegistry.java:42) at com.ibm.team.workitem.common.internal.model.impl.AttributeImpl.getValue(AttributeImpl.java:857) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:618) at com.ibm.team.repository.common.internal.util.ItemStore$ItemInvocationHandler.invoke(ItemStore.java:596) at $Proxy21.getValue(Unknown Source) at com.ibm.team.workitem.client.internal.DependencyHandler$Worker.runProtected(DependencyHandler.java:51) at com.ibm.team.foundation.client.util.FoundationJob.run(FoundationJob.java:68) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) |
This did not work either. Error output: And you are sure your value provider is now bound to a string attribute? And not the Integer based one that you used before? The converter is based on the attribute type and it looks like you use the same setup but now return a string instead of an number. -- Regards, Patrick Jazz Work Item Team |
And you are sure your value provider is now bound to a string attribute? Yes, confirmed. It is set to "string" |
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.