Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Determine if new comment has been added

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)

0 votes


Accepted answer

Permanent link
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

0 votes

Comments

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

1 vote


One other answer

Permanent link

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.

0 votes

Comments
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!

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!

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?

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 log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,952
× 31

Question asked: May 30 '18, 5:02 a.m.

Question was seen: 2,119 times

Last updated: Jul 16 '18, 8:01 a.m.

Confirmation Cancel Confirm