It's all about the answers!

Ask a question

Return a list of categories from a script based value set provider?


0
1
Alexander Maret-Huskinson (112) | asked Aug 21 '14, 3:29 a.m.
edited Aug 21 '14, 4:31 a.m.
I'm trying to filter the list of categories, displayed by the "Filed Against" editor presentation, by using a script based value set provider. However, for some reason I can not return more than one category. Returning an array with one item works, returning multipe entries does not.

This works:
dojo.provide("com.example.ValueSetProvider");

(function() {
    dojo.declare("com.example.ValueSetProvider", null, {

        getValueSet: function(attributeId, workItem, configuration) {
       
            var result= [];
            result.push("_WStlQChtEeS6O_h3MSj9RQ");
            return result;
           
        }
   });
})();

This does not:
dojo.provide("com.example.ValueSetProvider");

(function() {
    dojo.declare("com.example.ValueSetProvider", null, {

        getValueSet: function(attributeId, workItem, configuration) {
        	
            var result= [];
            result.push("_WStlQChtEeS6O_h3MSj9RQ");
            result.push("_ABClQChtEeS6O_h3MSj9DE");
            return result;
            
        }
   });
})();

Is it possible at all to return more than one category when using a script based value set provider?

3 answers



permanent link
Eric Jodet (6.3k5111120) | answered Aug 22 '14, 3:31 a.m.
JAZZ DEVELOPER
 Hello Alexander,
this should work as the VSP is designed to return an Array - so expect the Array to be able to have more than 1 element.

Comments
Alexander Maret-Huskinson commented Aug 22 '14, 3:39 a.m.

Well, unfortunately it does not. My second example throws an error 500 even though the IDs are correct. 


Each ID on its own shows up correctly in the "Filed Against" dropdown. Returning both IDs however throws an error 500.




permanent link
Eric Jodet (6.3k5111120) | answered Aug 22 '14, 3:44 a.m.
JAZZ DEVELOPER
 Can you try with OOTB template?

/*******************************************************************************
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation 2011. All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights: 
* Use, duplication or disclosure restricted by GSA ADP Schedule
* Contract with IBM Corp.
*******************************************************************************/
dojo.provide("com.example.ValueSetProvider");

(function() {
    dojo.declare("com.example.ValueSetProvider", null, {

        getValueSet: function(attributeId, workItem, configuration) {
       
            var result= [];
            result.push("a");
            result.push("b");
            return result;
           
        }
   });
})();

Comments
Alexander Maret-Huskinson commented Aug 22 '14, 3:49 a.m.

I did. The examples above are the OOTB templates except for the values I push into the results-array. These are exactly the scripts I have tried, they are a 1:1 copy & paste from the Eclipse IDE.



Eric Jodet commented Aug 22 '14, 3:52 a.m.
JAZZ DEVELOPER

 yes - I recognized the template.

Did you try to output (console.log()) the content of the array ?
You may want to use Firebug to check for any error in the console.


Alexander Maret-Huskinson commented Aug 25 '14, 5:14 a.m. | edited Aug 25 '14, 5:17 a.m.

Sorry for the late answer, the system didn't notify me about your reply.


I do indeed get an error message and a stack trace whenever I have more than one category identifier in my results array. I'll post the stacktrace as a new reply as it is too long for a comment.


permanent link
Alexander Maret-Huskinson (112) | answered Aug 25 '14, 5:15 a.m.
Here is the stacktrace I get whenever I have more than one identifier in my results array:

*** Error: Error loading properties for editing the work item | Details: com.ibm.team.workitem.common.internal.model.impl.CategoryHandleImpl incompatible with com.ibm.team.workitem.common.model.ICategory
com.ibm.team.workitem.service.internal.AttributeComparatorFactory$CategoryComparator.compare(AttributeComparatorFactory.java:188)
java.util.Arrays.mergeSort(Arrays.java:2874)
java.util.Arrays.sort(Arrays.java:3251)
java.util.Arrays.sort(Arrays.java:3269)
com.ibm.team.workitem.service.internal.rest.UIItemConverter.convertToDTOs(UIItemConverter.java:134)
com.ibm.team.workitem.service.internal.rest.WorkItemRestService.getValues(WorkItemRestService.java:1698)
com.ibm.team.workitem.service.internal.rest.WorkItemRestService.getAllValues(WorkItemRestService.java:1480)
com.ibm.team.workitem.service.internal.rest.WorkItemRestService.getWorkItemEditableProperties(WorkItemRestService.java:1414)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
java.lang.reflect.Method.invoke(Method.java:611)
org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.invoke(ExportProxyServiceRecord.java:361)
org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord.access$0(ExportProxyServiceRecord.java:347)
org.eclipse.soda.sat.core.internal.record.ExportProxyServiceRecord$ExportedServiceInvocationHandler.invoke(ExportProxyServiceRecord.java:56)
com.sun.proxy.$Proxy1219.getWorkItemEditableProperties(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
java.lang.reflect.Method.invoke(Method.java:611)
com.ibm.team.repository.servlet.AbstractTeamServerServlet.doModelledRestService(AbstractTeamServerServlet.java:530)
com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest2(AbstractTeamServerServlet.java:2359)
com.ibm.team.repository.servlet.AbstractTeamServerServlet.handleRequest(AbstractTeamServerServlet.java:2153)
com.ibm.team.repository.servlet.AbstractTeamServerServlet.service(AbstractTeamServerServlet.java:1963)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:76)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.eclipse.equinox.servletbridge.BridgeServlet.service(BridgeServlet.java:120)
com.ibm.team.repository.server.servletbridge.JazzServlet.service(JazzServlet.java:74)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
com.ibm.team.repository.server.servletbridge.BridgeFilter.processDelegate(BridgeFilter.java:165)
com.ibm.team.repository.server.servletbridge.BridgeFilter.doFilter(BridgeFilter.java:198)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:336)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
org.apache.coyote.ajp.AjpProcessor.process(AjpProcessor.java:200)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:906)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:929)
java.lang.Thread.run(Thread.java:761)
Error opening work item
com.ibm.team.workitem.common.internal.model.impl.CategoryHandleImpl incompatible with com.ibm.team.workitem.common.model.ICategory


Comments
Eric Jodet commented Aug 25 '14, 5:59 a.m.
JAZZ DEVELOPER

 Hello Alexander,

I tested on my side and it works OK.
Given the above, I don't think the script itself is a problem,
rather the attribute type where it's used.

I used my sample for feed a String List attribute - works fine.

As the script returns an Array of String - your attribute must be of that type , or compatible,
or you'll get an error (like the one you have)

Eric


Alexander Maret-Huskinson commented Aug 25 '14, 6:56 a.m.

Hello Eric,


yes, it works with string lists but I really need to filter the "Filed Against" attribute.

To me this looks like a bug. The system properly detects that those identifiers are category handles and converts them into a CategoryHandleImpl instance. Unfortunately the sort method expects elements which implement the ICategory interface and therefore fails. It works with only one element as a list with only one element does not get sorted.

Should I open a bug report or is this really the expected behaviour? If it is the expected behaviour there would be no way to filter the "Filed Against" attribute with a value set provider. Or is there?

I think the fix shouldn't be too complicated. The category handles simply have to be converted to elements which do implement the ICategory interface before passing them to the sort method.

Alex

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.