It's all about the answers!

Ask a question

How to update custom attribute value of test case in RQM through OSLC?


Anurag Patel (174) | asked Dec 06 '17, 1:49 a.m.

 Hi all,


I am trying to update RQM test case custom attribute value through OSLC code but does not work. Please guide me. I pasted source code in following section


Map<QName, Object> vstIdExtended = new HashMap<QName, Object>();
vstIdExtended.put(testRecordIdQname, "56");
vstIdExtended.put(vstRecordIdQname, "55");
testCase.setExtendedProperties(vstIdExtended);
//update test record
ClientResponse updateResourceResponse = null;
ClientResponse response = null;
response = client.getResource(testCase.getAbout().toString(), OslcMediaType.APPLICATION_RDF_XML);
String etag = response.getHeaders().getFirst(OSLCConstants.ETAG);
updateResourceResponse = client.updateResource(testCase.getAbout().toString(), testCase,OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_RDF_XML, etag);
updateResourceResponse.consumeContent();
int status = updateResourceResponse.getStatusCode();
System.out.println("Status Code="+status);

It gives me response code 200 but in RQM attribute value is not updated

3 answers



permanent link
Elohim Arranaga (1411) | answered Dec 07 '17, 11:51 a.m.
JAZZ DEVELOPER

 Hi Anurag, I think it would be easier if you post the final xml that you are sending. Also include if you  can the version are you using (6.0, 6.0.1, etc). 


In general terms the gold rule is, send the same xml formatting that you receive when do a get when you send the data, for example: 
In QM 6.0.5:
I am receiving for a custom attribute called priority with current value of 2:

.....
<projectnaUbYZE_EeeSX84ET4iniA_testPlan:priority rdf:datatype="http://www.w3.org/2001/XMLSchema#string">value 2 </projectnaUbYZE_EeeSX84ET4iniA_testPlan:priority>
.....


And I am doing a put with the same format but value changed with:
...
<projectnaUbYZE_EeeSX84ET4iniA_testPlan:priority rdf:datatype="http://www.w3.org/2001/XMLSchema#string">My new value for priority </projectnaUbYZE_EeeSX84ET4iniA_testPlan:priority>
...

Note: The namespace "projectnaUbYZE_EeeSX84ET4iniA_testPlan" translates to: 
xmlns:projectnaUbYZE_EeeSX84ET4iniA_testPlan="https://<server>:<port>/qm/oslc_qm/contexts/<project_area_item_id>/shape/resource/com.ibm.rqm.planning.VersionedTestPlan#"

And the data is updated successfully.

Hope this helps. 


Comments
Anurag Patel commented Dec 08 '17, 2:41 a.m.

 Thanks Elohim Arranaga for your valuable efforts. Now I am able to update custom attributes but single attribute is updates at single time. I want to update all custom attribute at single time. Can you please suggest way


Elohim Arranaga commented Dec 08 '17, 3:50 p.m.
JAZZ DEVELOPER

 Hi Anurag, you can send multiple entries, one for each custom attribute you need to update in a single put request for a resource (in this scenario, your test case). If they are not updating please follow up with support to open up a defect because that is not the expected behavior. 


Anurag Patel commented Jan 10, 1:00 a.m.

 Thanks @Elohim Arranaga ...my requirement is I need to update custom attribute of custom test case template which I created. There are multiple custom attributes but when I am trying to update all only one attribute is updated. I create multiple one put request for each custom attribute. Can you tell me please what is wrong?


permanent link
Elohim Arranaga (1411) | answered Jan 11, 1:13 p.m.
JAZZ DEVELOPER

 Hi Anurag, you can follow up with support on this problem, if you are sending updates for all the attributes in the http request and only one is being updated then we have a potential defect, you need to open up a ticket for support so we can investigate the problem more thoroughly.


Comments
Anurag Patel commented Jan 12, 8:31 a.m.

 Hi @Elohim Arranga Now problem is quite solved. i can update 2 custom attributes at a time. But when I tried two to update third custom attribute, third value can updated in RQM successfully, but it deletes my first two values only third value is updated.


permanent link
Anurag Patel (174) | answered Jan 12, 4:46 a.m.

  Hi @Elohim Arranga Thanks for your reply I pasted my code below for custom attribute, note "ecu" is my custom attribute: See I put two custom attribute in map and then update it in single operation, Can you please see the code  and guide me whats's wrong in code?


Map<QName, Object> customAttribute = new HashMap<QName, Object>();
customAttribute.put(testCaseSymptom, "Rishi");
customAttribute.put(testRecordIdQname ,"xyz");
testCase.setExtendedProperties(customAttribute);
ClientResponse updateResourceResponse = null;
ClientResponse response = null;
response = client.getResource(testCase.getAbout().toString(), OslcMediaType.APPLICATION_RDF_XML);
String etag = response.getHeaders().getFirst(OSLCConstants.ETAG);
System.out.println("Etag :"+etag);
updateResourceResponse = client.updateResource(testCase.getAbout().toString(), testCase,OslcMediaType.APPLICATION_RDF_XML, OslcMediaType.APPLICATION_RDF_XML, etag);

Your answer


Register or to post your answer.