It's all about the answers!

Ask a question

How to extend workitem to store additional data consisting of many key/value pairs java api

mark owusu-ansah (5659) | asked Mar 08 '13, 11:29 a.m.
edited Mar 08 '13, 4:23 p.m.
so  I have  additional   information   that    I want to link to  or store with the defect  work item
 The additional  information  consists of the  up to  10  different  key/value pairs . i think it would look clumsy  adding them as  custom  attributes  but I want to  store them and have them  available to users   for  review and  or  be able to  programmatically  retrive them   later in another part of  my project .
I also need to be able to store those  key value pairs  programmatically via the java api
Is this possible ?   May be using workitem  extensions?   Not  sure how/where  to  begin
Please advise 

2 answers

permanent link
VK L (8177145159) | answered Mar 09 '13, 3:47 a.m.
 Is this a pre-defined data available? and is it constant throughout?


mark owusu-ansah commented Mar 09 '13, 7:50 a.m.

    Well  it would  be constant   in that  we  have a total of  8keys(  and scores). Each  workitem   will store  a max of  4 keys/value  pairs  but those  4 keys  will  be a subset  of the  8.    I hope I am  not confusing  you    but   basically   we need  to create   8keys . The  keys  strings  will remain constant
Each work item  will  store   only 4 keys  and  value  pair
For  now  I am sort of   showing all the 4 keys  and  values(8 fields in all ) for each workitem  and display it in the  default   presentation   and itr looks really clumsy ...
I have something like this
Secondscore  .....

I want to be able to link   to  it , store it  and programmatically   retrieve  it in a nicer manner  .
Any   ideas?

VK L commented Mar 09 '13, 7:56 a.m. | edited Mar 09 '13, 2:27 p.m.

you can choose to display it in a 

1. different tab (or) file attachment
2. Maintain the key-pairs in 1 workitem - and auto-link all new workitems of a type to that common item with the key-value pairs -> when users hover over the link, they can see the details

Not sure if this meets your requirement.

mark owusu-ansah commented Mar 09 '13, 12:17 p.m.

 Thanks  for  your response . The  choices are not   exactly clear to  me .   Here are  a few notes.
 The most important factor  is that  I need to be able to programmatically  store  the  keys/value pairs  with the  workitem  and  later  to be  able to retrieve them  programmatically. Each work item  will have  4 of 8 possible keys and each for any work item will have its own hvalue
Concerning your  mentioned options
1. Will  using a different  tab still  keep it attached  to the workitem ? Are you  saying  just add  a new tab/section for the  presentation and simply  have users  tab  over to see the scores? 
Options  2   interesting and  clean  but will  each  key(relevant to the specific  workitem)  have its own value? When I  click  for more details,  does it take me to another page/tab?
Any links to   start investigating this ?   I am fairly new  to JAZZ/RTC

permanent link
Ralph Schoon (61.6k33643) | answered Mar 09 '13, 1:52 p.m.
 If you are on 4.x you should try to use a string list attribute. You can encode key and value and store it using the API. 

mark owusu-ansah commented Mar 09 '13, 1:59 p.m.

Yes,  I am  no .   Stringlist  attribute?     I have  used   enumeration  but  not stringlist . Will investigate . Up till  now(your comments)  ,,  my best option   looked like  putting the various  key/values  on a separate tab , per earlier  comments,

Any  link to the encoding activities ?    That  sounds interesting and I do need  it for  password that   I may be storing also   so it would be handy
  Thanks for any input

Ralph Schoon commented Mar 09 '13, 2:32 p.m.

With encoding, I mean storing it as a string. You can usually do that. As URL, whatever. Serialized it. With respect to the presentation, you can put it on a separate tab and potentially make it read only in the UI. It is possible to add own value providers and representations. It is also possible to extend the storage service. I would advise against it. 

mark owusu-ansah commented Mar 09 '13, 4:36 p.m.

        For now  I  will avoid value providers . I just need to  store and  retrieve   pro-grammatically. I will  testing now with supplying separate field  for  each value and each  key. Not ideal  but will see how far I can get with it
I have attached a screen  shot  of adding them  to separate   tab.  Thanks

Ralph Schoon commented Mar 11 '13, 3:25 a.m.

If you want to avoid one attribute for each key, use a string list and encode the entries for example as D4_FIRSTCLASSIFIER=<value> where <value> is the data to store. It is easy enough to get the value list of the attribute and manage the data in an extension or Plain Java Client.

mark owusu-ansah commented Mar 11 '13, 1:54 p.m.

     Thanks , I am not  quite  getting your explanation  but I will  review the stringlist   type further and see how it  fits .Or  Are you saying   each workitem  will  have   a stringlist of the  4 classifier keys ( out of  8 )  and  the values   will just be the  scores?   My confusion  is    should I have defined/listed  all 8 possible keys before  I called them  or I can just go ahead  and  add   a stringlist  attribute to the workitem and  that should accommodate the  keys/.values.

Note that  D4_FIRSTCLASSIFIER,etc  are just the labels  to  hold the key name. Then  D4_FIRSTCLASSIFIERSCORE  will  hold the actual  value
Sound  like I  just need to know  how to use the stringlist

Ralph Schoon commented Mar 12 '13, 2:06 a.m.

Mark, in 4.x you can define one attribute to contain a list of strings. The strings stored in the attribute are accessible as a list in Java. Each string can contain arbitrary strings. So you can stuff as many as you want in there. Since the value is not enough in your case you would store the identifier and the value in one string and you will have to split the string later into its parts, to be able to interpret it.

showing 5 of 6 show 1 more comments

Your answer

Register or to post your answer.