[closed] [EWM] add comments using API
HIROAKI JOSAKO (47●4●30)
| asked Apr 18 '23, 3:14 a.m.
closed Apr 19 '23, 4:00 a.m. by David Honey (1.8k●1●7) I'm thinking of using OSLC (REST API) to add comments to my Workitem.
|
The question has been closed for the following reason: "The question is answered, right answer was accepted" by davidhoney Apr 19 '23, 4:00 a.m.
Accepted answer
Ralph Schoon (63.5k●3●36●46)
| answered Apr 18 '23, 5:30 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER As far as I can tell, I have to agree with David.
See this citation from the API document you provided:
I am only aware of ways to set certain data such as creator, created using the Java APIs. I am not aware if you can also do this using OSLC. I actually did find that out pretty recently for the EWM Plain Java API.
HIROAKI JOSAKO selected this answer as the correct answer
Comments
HIROAKI JOSAKO
commented Apr 18 '23, 8:24 p.m.
I see!
it is sufficient to POST the comment
Ralph Schoon
commented Apr 19 '23, 2:09 a.m.
| edited Apr 19 '23, 2:10 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
For the Plain Java client Libraries, you can only set the creator using com.ibm.team.workitem.common.model.IWorkItem.setCreator(IContributorHandle).
You can only set the creation dates when the work item is not yet created using code like this:
Timestamp cDate = getWorkItem().getCreationDate(); if(cDate==null){ // CreationDate can only be set during work item creation. Object creationDate = calculateTimestamp(parameter); if(creationDate!=null){ getWorkItem().setCreationDate((Timestamp) creationDate); } }
HIROAKI JOSAKO
commented Apr 27 '23, 3:08 a.m.
That's right about the date of creation of work items.
Ralph Schoon
commented Apr 27 '23, 3:49 a.m.
| edited Apr 27 '23, 3:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You should be able to look into the SDK as good as I can.
com.ibm.team.workitem.common.model.IComments does not expose this.
The internal implementation com.ibm.team.workitem.common.internal.model.Comments does not expose this. But you can see the implementation of createComment.
Utils.initNew(comment); does not look promising.
ModelFactory.eINSTANCE.createComment() ultimately calls
com.ibm.team.workitem.common.internal.model.impl.CommentImpl.class
which exposes all the details, but it is an internal class and you would use it unsupported.
Using the EMF capabilities should allow to do a lot more, but is also dangerous.
|
One other answer
David Honey (1.8k●1●7)
| answered Apr 18 '23, 4:22 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER I think it unlikely. I would expect the creator of the comment to be the current authenticated user, and the creation time to be the time it was added to a comment. In other words, I would expect that any
Comments
HIROAKI JOSAKO
commented Apr 18 '23, 4:54 a.m.
After all, yes.
I don't think you will be able to do so using that API.
The page you reference shows the data that is available when you fetch the comments, but that does not imply or state that they are modifiable. That page also states:
The spec you link to says "the creation date and the creator are automatically assigned" which implies you can't set them in the content, i.e. the content for creator is ignored.
HIROAKI JOSAKO
commented Apr 18 '23, 8:12 p.m.
I see, I was mistaken.
|