It's all about the answers!

Ask a question

Questions RE: Behavior of Custom Providers in RTC 3.0?


Robert Stawicki (5844) | asked Nov 08 '10, 4:27 p.m.
I've become more acquainted with the various value providers in my RTC 3.0 beta (RC0).
https://jazz.net/wiki/bin/view/Main/AttributeValueProviders

I've done a simple default provider, managed to get a sample value SET provider for a couple of custom enumerations (via the Process Config UI), and have a sample simple-type calculated value custom provider in javaScript (with the "dojo" structure).

I have a couple of questions.

First, I noticed that in the samples in the doc regarding the calculated value (valueProvider - javaScript), the provider configuration included custom configuration properties. Specifically, in the Risk Exposure sample, there are the impactAttribute and probabilityAttribute properties.
I'm confused on the intended use of these. When I try to define these in my own sample, I cannot seem to properly reference them via configuration.getChild in my javaScript. Why is that? What exactly are the configuration methods supposed to return? It isnt clear to me.
I set up my dependsOn and custom properties to custom attributes. I am seeing an "object", or undefined or null references. So I have to hard-code a reference to the ID of a custom attribute in my basic-type (string) calculated value javaScript. That gets me by for basic string types.

My sample provider:

<valueProvider id="com.ibm.team.workitem.valueproviders.VALUE_PROVIDER.AparSystemLevelCalculator"
name="Calc APAR SystemLevel from Release"
providerId="com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider">
<script class="com.ibm.sport.rtc.common.AparSystemLevelCalculator"/>
<sourceReleaseAttr id="com.ibm.sport.rtc.workItem.attribute.apar.release"/>
<affectedSysLvlAttr id="com.ibm.sport.rtc.workItem.attribute.apar.systemReleaseLevel"/>
</valueProvider>

...

<attributeDefinition id="com.ibm.sport.rtc.workItem.attribute.apar.systemReleaseLevel" name="systemReleaseLevel" type="smallString">
<valueProvider providerId="com.ibm.team.workitem.valueproviders.VALUE_PROVIDER.AparSystemLevelCalculator"/>
<dependsOn id="com.ibm.sport.rtc.workItem.attribute.apar.release"/>
</attributeDefinition>

...

dojo.provide("com.ibm.sport.rtc.common.AparSystemLevelCalculator");

(function() {

// Cant seem to be able to define this in the provider definition?
var releaseAttrId = "com.ibm.sport.rtc.workItem.attribute.apar.release";

dojo.declare("com.ibm.sport.rtc.common.AparSystemLevelCalculator", null, {

getValue: function(attribute, workItem, configuration) {

// Obtain source Release attribute ID
// var sourceReleaseAttr = configuration.getChild("sourceReleaseAttr");
// var sourceReleaseAttrId = configuration.getChild("sourceReleaseAttr").id;
// var sourceReleaseAttrStr = configuration.getString("sourceReleaseAttr");
// Obtain the workitem value for the attribute
// var releaseValue = workItem.getValue(sourceReleaseAttr);
// var releaseAttrId = "com.ibm.sport.rtc.workItem.attribute.apar.release";
var releaseValue = workItem.getValue(releaseAttrId);
// Obtain resulting System Level attribute ID
// var sysLvlAttr = configuration.getChild("affectedSysLvlAttr");
// var sysLvlAttrId = configuration.getChild("affectedSysLvlAttr").id;
// var sysLvlAttrStr = configuration.getString("affectedSysLvlAttr");
// Obtain the workitem value for the attribute
var sysLvlValue = workItem.getValue(attribute);
var returnSysLvlValue = sysLvlValue;
returnSysLvlValue = releaseValue;

return returnSysLvlValue + "";
},

__sentinel: null
});

})();



==========

This brings me to my 2nd question.
How can I use the calculated value custom provider for custom enumeration attributes?
I know there is the ValueSetProvider, which can filter a set of enumeration choices. However, that does not automatically "select" a choice. I need to keep all choices possible, but select 1 of them based on a selection in another enumeration.
Again, I have been attempting to define custom Provider config properties to reference the enumeration attributes, but the configuration.getChild or getString wont provide anything I can use within the custom provider javaScript. In this case, I think I even tried hard-coding the reference IDs, and still could not reference these attributes or changed values.

Non-working sample with what I've tried so far -

<valueProvider id="com.ibm.team.workitem.valueproviders.VALUE_PROVIDER.AparSymptomKWCalculator"
name="Calc APAR Symptom KW from Symptom Code"
providerId="com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider">
<script class="com.ibm.sport.rtc.common.AparSymptomKWCalculator"/>
<sourceCodeAttr id="com.ibm.sport.rtc.workItem.enumeration.apar.externalSymptomCode"/>
</valueProvider>

...

<attributeDefinition id="com.ibm.sport.rtc.workItem.attribute.apar.symptomKeyword" name="symptomKeyword" type="com.ibm.sport.rtc.workItem.enumeration.apar.symptomKeyword">
<valueProvider providerId="com.ibm.team.workitem.valueproviders.VALUE_PROVIDER.AparSymptomKWCalculator"/>
<dependsOn id="com.ibm.sport.rtc.workItem.attribute.apar.externalSymptomCode"/>
</attributeDefinition>


...

dojo.provide("com.ibm.sport.rtc.common.AparSymptomKWCalculator");

(function() {

// Cant seem to be able to define this in the provider definition?
var sourceSymptomCodeAttr = "com.ibm.sport.rtc.workItem.enumeration.apar.externalSymptomCode";

// Define Symptom Code -- KW mapping array
var symptomKWs = {
"com.ibm.sport.rtc.workItem.enumeration.apar.externalSymptomCode.literal.l1":
"com.ibm.sport.rtc.workItem.enumeration.apar.symptomKeyword.literal.l2",
... etc ...
}

dojo.declare("com.ibm.sport.rtc.common.AparSymptomKWCalculator", null, {

getValue: function(attribute, workItem, configuration) {

// Obtain source Symptom Code attribute ID
// var sourceSymptomCodeAttr = configuration.getChild("sourceCodeAttr").id;
var sourceSymptomCodeAttrObj = configuration.getChild("sourceCodeAttr");
var sourceSymptomCodeAttrId = configuration.getChild("sourceCodeAttr").id;
var sourceSymptomCodeAttrStr = configuration.getString("sourceCodeAttr");
// Obtain the workitem value for the attribute
var symptomCodeValue = workItem.getValue(sourceSymptomCodeAttr);
// Obtain the matching Symptom KW
var symptomKW = symptomKWs[symptomCodeValue];

return "SCV=" + symptomCodeValue + "" +
" .. scOBJ=" + sourceSymptomCodeAttrObj +
" .. scStr=" + sourceSymptomCodeAttrStr +
" .. scId=" + sourceSymptomCodeAttrId +
"";
// return symptomKW + "";
},

__sentinel: null
});

})();

5 answers



permanent link
Kyle Christianson (1261615) | answered Jan 14 '11, 9:51 a.m.
I am also interested in these questions. Anyone have any answers?

permanent link
Robert Stawicki (5844) | answered Jan 14 '11, 2:02 p.m.
I have been told this should work in RTC 3.0 (GA), and that the doc may be out of sync. I opened defect 149859 to address this.

http://jazz.net/jazz/web/projects/Rational%20Team%20Concert#action=com.ibm.team.workitem.viewWorkItem&id=149859

permanent link
Sachin Nairy (5111320) | answered Dec 24 '11, 3:04 p.m.
Dear stawick,
I am trying to write a script to compute the value from multiple attribute and putting in to another attribute using calculated value option. But I am not succeed in that.
If you have any such kind of script which will help me to complete my task, please share with me(sachin.nairy@gmail.com)
Thanks in advance



I've become more acquainted with the various value providers in my RTC 3.0 beta (RC0).
https://jazz.net/wiki/bin/view/Main/AttributeValueProviders

I've done a simple default provider, managed to get a sample value SET provider for a couple of custom enumerations (via the Process Config UI), and have a sample simple-type calculated value custom provider in javaScript (with the "dojo" structure).

I have a couple of questions.

First, I noticed that in the samples in the doc regarding the calculated value (valueProvider - javaScript), the provider configuration included custom configuration properties. Specifically, in the Risk Exposure sample, there are the impactAttribute and probabilityAttribute properties.
I'm confused on the intended use of these. When I try to define these in my own sample, I cannot seem to properly reference them via configuration.getChild in my javaScript. Why is that? What exactly are the configuration methods supposed to return? It isnt clear to me.
I set up my dependsOn and custom properties to custom attributes. I am seeing an "object", or undefined or null references. So I have to hard-code a reference to the ID of a custom attribute in my basic-type (string) calculated value javaScript. That gets me by for basic string types.

My sample provider:

<valueProvider>
<script>
<sourceReleaseAttr>
<affectedSysLvlAttr>
</valueProvider>

...

<attributeDefinition>
<valueProvider>
<dependsOn>
</attributeDefinition>

...

dojo.provide("com.ibm.sport.rtc.common.AparSystemLevelCalculator");

(function() {

// Cant seem to be able to define this in the provider definition?
var releaseAttrId = "com.ibm.sport.rtc.workItem.attribute.apar.release";

dojo.declare("com.ibm.sport.rtc.common.AparSystemLevelCalculator", null, {

getValue: function(attribute, workItem, configuration) {

// Obtain source Release attribute ID
// var sourceReleaseAttr = configuration.getChild("sourceReleaseAttr");
// var sourceReleaseAttrId = configuration.getChild("sourceReleaseAttr").id;
// var sourceReleaseAttrStr = configuration.getString("sourceReleaseAttr");
// Obtain the workitem value for the attribute
// var releaseValue = workItem.getValue(sourceReleaseAttr);
// var releaseAttrId = "com.ibm.sport.rtc.workItem.attribute.apar.release";
var releaseValue = workItem.getValue(releaseAttrId);
// Obtain resulting System Level attribute ID
// var sysLvlAttr = configuration.getChild("affectedSysLvlAttr");
// var sysLvlAttrId = configuration.getChild("affectedSysLvlAttr").id;
// var sysLvlAttrStr = configuration.getString("affectedSysLvlAttr");
// Obtain the workitem value for the attribute
var sysLvlValue = workItem.getValue(attribute);
var returnSysLvlValue = sysLvlValue;
returnSysLvlValue = releaseValue;

return returnSysLvlValue + "";
},

__sentinel: null
});

})();



==========

This brings me to my 2nd question.
How can I use the calculated value custom provider for custom enumeration attributes?
I know there is the ValueSetProvider, which can filter a set of enumeration choices. However, that does not automatically "select" a choice. I need to keep all choices possible, but select 1 of them based on a selection in another enumeration.
Again, I have been attempting to define custom Provider config properties to reference the enumeration attributes, but the configuration.getChild or getString wont provide anything I can use within the custom provider javaScript. In this case, I think I even tried hard-coding the reference IDs, and still could not reference these attributes or changed values.

Non-working sample with what I've tried so far -

<valueProvider>
<script>
<sourceCodeAttr>
</valueProvider>

...

<attributeDefinition>
<valueProvider>
<dependsOn>
</attributeDefinition>


...

dojo.provide("com.ibm.sport.rtc.common.AparSymptomKWCalculator");

(function() {

// Cant seem to be able to define this in the provider definition?
var sourceSymptomCodeAttr = "com.ibm.sport.rtc.workItem.enumeration.apar.externalSymptomCode";

// Define Symptom Code -- KW mapping array
var symptomKWs = {
"com.ibm.sport.rtc.workItem.enumeration.apar.externalSymptomCode.literal.l1":
"com.ibm.sport.rtc.workItem.enumeration.apar.symptomKeyword.literal.l2",
... etc ...
}

dojo.declare("com.ibm.sport.rtc.common.AparSymptomKWCalculator", null, {

getValue: function(attribute, workItem, configuration) {

// Obtain source Symptom Code attribute ID
// var sourceSymptomCodeAttr = configuration.getChild("sourceCodeAttr").id;
var sourceSymptomCodeAttrObj = configuration.getChild("sourceCodeAttr");
var sourceSymptomCodeAttrId = configuration.getChild("sourceCodeAttr").id;
var sourceSymptomCodeAttrStr = configuration.getString("sourceCodeAttr");
// Obtain the workitem value for the attribute
var symptomCodeValue = workItem.getValue(sourceSymptomCodeAttr);
// Obtain the matching Symptom KW
var symptomKW = symptomKWs[symptomCodeValue];

return "SCV=" + symptomCodeValue + "" +
" .. scOBJ=" + sourceSymptomCodeAttrObj +
" .. scStr=" + sourceSymptomCodeAttrStr +
" .. scId=" + sourceSymptomCodeAttrId +
"";
// return symptomKW + "";
},

__sentinel: null
});

})();

permanent link
Sachin Nairy (5111320) | answered Dec 27 '11, 8:48 a.m.
Hi Friends,


I had created few custom attribute (integer type)in RTC work item form. I want to add ( arithmetic operation) those values using java script(calculated value option).


dojo.provide("total");
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
(
function() {
dojo.declare("total", null,
{getValue: function(attribute, workItem, configuration)
{
var i1=workItem.getValue(item1);
var i2=workItem.getValue(item2);
var i3=workItem.getValue(item3);
i3=i1+i2;
return i3;
}
}
);
}
)
();

This code is not working for me. I went through couple of link, but nothing is working for me. Please help me to resolve this issue.

https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Configuring_a_script_based_custo

permanent link
Robert Stawicki (5844) | answered Jan 03 '12, 12:12 p.m.
I'm not a jazz or RTC developer, just a somewhat experienced user now. Our scripts have changed quite a bit since the initial post and wont mean much here.

The first thing you may want to check is -

From RTC wiki doc -

To use scripts deployed as process attachments you need to enable this functionality:
Go to administrative page of your RTC server https://your.server.name:9443/ccm/admin.
Open the Server tab.
From the left side-bar open Configuration > Advanced Properties
In the Work Item Component find the Enable Process Attachment Scripts property and set its value to true.
Alternatively you can add the following line to teamserver.properties:

# Allow to use scripts deployed as process attachments
com.ibm.team.workitem.process.scripts.enabled=true


You also have to load your script into the Links section (Attachments) of your project area (or template). Although that is probably the same thing as the Reload button in the Calculated Value section of the Process Configuration.You also need to specify the path as -
/workitem/scripts/common/your-script.js

If you need to reference built-in work item attributes utilizing the WorkItemAttributes, you'll need to add a -

dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

However, you shouldnt need that for customized attributes.

The workItem.getValue(item*) references should refer to the attribute IDs (ie itemX = the ID for attribute itemX). You may hard code them in the script, or use configuration sub-elements of your provider (as we now do for reuse of script function), in which case you'll use the configuration.getChild calls.

You'll need to add your calculated value provider to your resulting attrbute's definition. This is so that the "return i3" sets the value for that attribute.


| attributeDefinition id="com.ibm.sport.rtc.workItem.attribute.apar.systemReleaseLevel" name="systemReleaseLevel" type="smallString" |
| valueProvider providerId="com.ibm.team.workitem.valueproviders.VALUE_PROVIDER.SPoRTAparSystemLevelCalculator"/ |
| dependsOn id="com.ibm.sport.rtc.workItem.attribute.apar.release"/ |
| /attributeDefinition |



Also, you'll want to add a dependsOn for each of the deriving attributes, so that a change will trigger a recalculation.

That is about all of the advice I can offer. We havent used this for integers ourselves - just strings and enumerations so far.



Hi Friends,


I had created few custom attribute (integer type) in RTC work item form. I want to add ( arithmetic operation) those values using java script(calculated value option).

dojo.provide("total");
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
(
function() {
dojo.declare("total", null,
{getValue: function(attribute, workItem, configuration)
{
var i1=workItem.getValue(item1);
var i2=workItem.getValue(item2);
var i3=workItem.getValue(item3);
i3=i1+i2;
return i3;
}
}
);
}
)
();

This code is not working for me. I went through couple of link, but nothing is working for me. Please help me to resolve this issue.

https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Configuring_a_script_based_custo

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.