It's all about the answers!

Ask a question

Determine if new comment has been added


Ilona Krammer (159227) | asked May 30 '18, 5:02 a.m.
edited May 30 '18, 5:09 a.m.
How would it be possible to determine if a new comment has been added?

simply making it mandatory with a precondition doesn't seem to work (and I need a custom error message anyway) so I was going for a Java extension.
And I'm guessing I must be kind of blind or something - but I can't seem to find how to determine if a comment has just been added with the current save operation or if it's an older comment.

Sorry if this is an obvious question and I'm just not seeing it. Hoping someone can help.

(using RTC 6.0.5 iFIx004 and using the built in comments attribute)

Accepted answer


permanent link
Ilona Krammer (159227) | answered Jul 16 '18, 7:47 a.m.
Since all of the possible options include some "discouraged access" I decided on checking for a comment that does not have an internalID - simply because it was the easiest and fastest way to do it. Since every single option is discouraged it doesn't really seem to matter.

Obviously I have to closely monitor this with each iFix and each new version, but at least it works now!
Ralph Schoon selected this answer as the correct answer

Comments
1
Ralph Schoon commented Jul 16 '18, 8:01 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I would not expect this API to change. It has been very stable for years now. I would suggest to check the extensions for major releases however.

It is unfortunate that there is the unavoidable discouraged access, however strictly speaking any API could change and supported is only the client API that is documented in the Plain Java Client Libraries javadoc.

Having said that I have not seen any deprecation or other API change affecting my code since RTC 3.x

One other answer



permanent link
Ralph Schoon (60.5k33643) | answered May 30 '18, 5:24 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited May 30 '18, 5:25 a.m.

Hi Illona,

comments are not an attribute. There is an attribute name to represent them in various contexts, but there is not really an attribute representing them. Comments are a collection. The API is explained here: https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ in the comments section.

As far as I can tell you can not use comments in required attributes. After you have one already what would the semantic be?

You could try to write a custom pre-condition/advisor. Here are some examples: https://rsjazz.wordpress.com/?s=advisor&submit=Search The Approach I would try to use is to compare the old state and the new state. Get both sates and get the comments collection. Iterate the collection to look for differences e.g. compare the data available on comments. I don't know if that is going to work for you. There is only a limited amount of data available in comments to judge from.

Another approach might be a special text attribute. You could use a follow up action to copy the information from that attribute to a comment and clean it, if you want to make it mandatory again.

Just a thought.


Comments
Ilona Krammer commented May 30 '18, 6:00 a.m.
Sorry about the wrong definition of comments - I was thinking about the built in attribute list, but I am aware that comments are not an attribute.

I'd hoped there would be some information about a comment entry, like an id or something like that that may not be set immediately when the comment is saved.

I hoped I can get around comparing comment lists from the previous and the current states. But I guess I'll do that.

In case you have any other ideas - I'm all ears!

Ralph Schoon commented May 30 '18, 6:46 a.m. | edited May 30 '18, 6:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

The object that represents the comment com.ibm.team.workitem.common.model.IComment

has some attributes - creator and creationdate but I don't know what you have to expect / how the data will show in the work item save context. You will have to play with it.
You can iterate the comments and try comparing the creationdate. If that is enough and works, fine!


Ilona Krammer commented Jun 06 '18, 2:04 a.m.
I found out that the new comment does not have an internal id yet - but accessing that property gives me an "discouraged access"

since there are lab pdfs that actually state that you can ignore those warnings - what are they for and what do they really mean?

Ralph Schoon commented Jun 07 '18, 5:14 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

This is more an Eclipse question, I think. The warning is based on which packages are configured as accessible in the plugin as far as I can tell. There is no mechanism to prevent you from doing the call as of today.

Basically you are calling some unsupported API as far as i can tell. You should be aware there could be API changes.

Your answer


Register or to post your answer.