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

Require comments

In RTC 2.0.0.2, is there a way to require a user to enter a comment before saving a work item in a specific state?

I did not see this built-in in the require properties in the Project Configuration.

Is there a way, using the Java API, to get the old copy of the work item and the new copy so that I can compare the comments to see if the user added one (while possibly removing other comments)?

0 votes



One answer

Permanent link
In RTC 2.0.0.2, is there a way to require a user to enter a comment before saving a work item in a specific state?

I did not see this built-in in the require properties in the Project Configuration.

Is there a way, using the Java API, to get the old copy of the work item and the new copy so that I can compare the comments to see if the user added one (while possibly removing other comments)?


You can use an IOperationAdvisor to check it.

And the code itself would be something like this (please review it because I didn't test it at all):


public void run(AdvisableOperation operation,
IProcessConfigurationElement advisorConfiguration,
IAdvisorInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {

Object data = operation.getOperationData();
// The action is save
if (data instanceof ISaveParameter) {
ISaveParameter saveParameter = (ISaveParameter) data;
IAuditable auditable = saveParameter.getNewState();
// WorkItem Object
if (auditable instanceof IWorkItem) {


// New state comments
IWorkItem workItem = (IWorkItem) saveParameter.getNewState();;
IComments newComments = workItem.getComments();


// Old state comments
IWorkItem oldWorkItem = (IWorkItem) saveParameter.getOldState();
IComments oldComments = (oldWorkItem != null) ? oldWorkItem.getComments(): null;

boolean addedComment = false;
if ((newComments != null) && (newComments.getContents().length > 0)) {
if (oldComments==null || oldComments.getContents().length == 0) {
addedComment = true;
} else {
IComment lastOldComment = oldComments.getContents()[oldComments.getContents().length-1];
IComment lastNewComment = newComments.getContents()[newComments.getContents().length-1];
addedComment = lastNewComment.getCreationDate().after(lastOldComment.getCreationDate());
}
}

if (!addedComment) {
IAdvisorInfo info = collector.createProblemInfo("You have to add a new comment", "You have to add a new comment", "error");
collector.addInfo(info);
}
}
}

0 votes

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,938

Question asked: Jul 29 '11, 2:57 p.m.

Question was seen: 4,123 times

Last updated: Jul 29 '11, 2:57 p.m.

Confirmation Cancel Confirm