It's all about the answers!

Ask a question

Risk Exposure Example Query


kaushambi Singh (5611611) | asked Feb 01 '10, 5:14 a.m.
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



permanent link
Patrick Streule (4.9k21) | answered Feb 01 '10, 7:08 a.m.
JAZZ DEVELOPER
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.

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

permanent link
Shelby Phillips (29624621) | answered Feb 01 '10, 1:53 p.m.

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?

permanent link
Patrick Streule (4.9k21) | answered Feb 02 '10, 5:08 a.m.
JAZZ DEVELOPER
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?

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

permanent link
Shelby Phillips (29624621) | answered Feb 02 '10, 11:13 a.m.

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?

permanent link
Patrick Streule (4.9k21) | answered Feb 02 '10, 1:53 p.m.
JAZZ DEVELOPER
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

permanent link
kaushambi Singh (5611611) | answered Feb 03 '10, 5:34 a.m.
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?

permanent link
Patrick Streule (4.9k21) | answered Feb 03 '10, 6:53 a.m.
JAZZ DEVELOPER
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

Please suggest what else can be tried on to get the correct output?

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

permanent link
Shelby Phillips (29624621) | answered Feb 03 '10, 11:32 a.m.

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)

permanent link
Patrick Streule (4.9k21) | answered Feb 04 '10, 1:23 p.m.
JAZZ DEVELOPER
This did not work either. Error output:

java.lang.ClassCastException: org.mozilla.javascript.NativeString
incompatible with java.lang.Double

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

permanent link
Shelby Phillips (29624621) | answered Feb 05 '10, 12:39 p.m.
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


Yes, confirmed. It is set to "string"

Your answer


Register or 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.