Unable to setValue for a custom Attribute
Hi,
i am using plain java API to get connected with RTC from eclipse.
I have n number of custom attributes.
Some of them I can set value using the literal value ( workItem.setValue(attrWic,"ILiteral:cmoCategory.literal.l4");)
but some I am not able to set the value
When I do getValue i get different scenarios.
Scenario 1
workItem.getValue(iAttribute1).toString(); returns affected_environments.literal.l1
Scenario 2
workItem.getValue(iAttribute2).toString(); returns com.ibm.team.workitem.common.model.ILiteral:cmoCategory.literal.l3
Anything that has output like scenario 2 I am unable to setValue() I am getting following error message
Exception occurred during playback of script [Script1] [CRFCN0019E: RationalTest
ScriptException on line 48 of script Script1 - java.lang.ClassCastException: jav
a.lang.String incompatible with com.ibm.team.workitem.common.model.Identifier.].
Please suggest me how to set value for such custom attributes.
Thanks
i am using plain java API to get connected with RTC from eclipse.
I have n number of custom attributes.
Some of them I can set value using the literal value ( workItem.setValue(attrWic,"ILiteral:cmoCategory.literal.l4");)
but some I am not able to set the value
When I do getValue i get different scenarios.
Scenario 1
workItem.getValue(iAttribute1).toString(); returns affected_environments.literal.l1
Scenario 2
workItem.getValue(iAttribute2).toString(); returns com.ibm.team.workitem.common.model.ILiteral:cmoCategory.literal.l3
Anything that has output like scenario 2 I am unable to setValue() I am getting following error message
Exception occurred during playback of script [Script1] [CRFCN0019E: RationalTest
ScriptException on line 48 of script Script1 - java.lang.ClassCastException: jav
a.lang.String incompatible with com.ibm.team.workitem.common.model.Identifier.].
Please suggest me how to set value for such custom attributes.
Thanks
2 answers
My experience is that the literal ID follows the colon (:) in the result of workItem.getValue(iAttribute2).toString()
Look at your Process Source for the enumeration. You're likely to find id="cmoCategory.literal.l3" but not the other.
So try split(":") to get the parts, use the 2nd for the value to workItem.setValue() method.
Look at your Process Source for the enumeration. You're likely to find id="cmoCategory.literal.l3" but not the other.
So try split(":") to get the parts, use the 2nd for the value to workItem.setValue() method.
There is some code that might help here: https://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/ . I am not sure what the issue is.
Comments
Hi Ralph,
Thanks for the reply
Your suggestion worked partially
I used 1 of your method in the link
i.e.
private static Identifier getLiteralEqualsString(String name, IAttributeHandle ia)
This method only returned me the literal ID for scenario 2(com.ibm.team.workitem.common.model.ILiteral:cmoCategory.literal.l3 ) where else it dint return anything at all for the Scenario 1
workItem.getValue(iAttribute1).toString(); returns affected_environments.literal.l1
please help me out how to get value from the custom attributes for scenario 1
Thanks
for your time
I am not sure I understand what you are asking. You need to cast to the correct thing. If you getValue(IAttribute) on an enumeration type attribute you get an Identifier.
Object prio = workItem.getValue(priority); if (prio instanceof Identifier<?>) { Identifier<?> identifier = (Identifier<?>) prio; System.out.print("\tIdentifier: " + identifier.getStringIdentifier()); }The code gets the identifier and you would have to look up a display value analog to the way it is described in the post. I am not aware of an easier way - which does not mean there is none that I haven't found.
This code only works for scenario 2 did not return any value for the first scenario .
Any other suggestion?
Thanks
Scenario 1 does not make sense to me, so you might want to be more explicit about the use case and what you want to achieve.
You might also want to read http://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ and search for Casting...