It's all about the answers!

Ask a question

Using Warning on precondition


Michele Pegoraro (1.8k12114101) | asked Jun 06 '11, 1:10 p.m.
Hi,
I was looking on how to set Warning on my precondition extension. I'm able to set a warning using the following snippet:

IAdvisorInfo info = collector.createProblemInfo("WARNING", "FINTO", "finto");

info.setSeverity(IProcessReport.WARNING);
collector.addInfo(info);


It works well but I've a question: it is possible to switch eclipse view to Team Advisor as for the problems? In this case the warning it's ok, but if I don't go to team advisor I could not view it.

Is it possible?

Thanks,
Michele.

3 answers



permanent link
Jared Burns (4.5k29) | answered Jun 07 '11, 2:58 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,
I was looking on how to set Warning on my precondition extension. I'm able to set a warning using the following snippet:

IAdvisorInfo info = collector.createProblemInfo("WARNING", "FINTO", "finto");

info.setSeverity(IProcessReport.WARNING);
collector.addInfo(info);


It works well but I've a question: it is possible to switch eclipse view to Team Advisor as for the problems? In this case the warning it's ok, but if I don't go to team advisor I could not view it.

Is it possible?

Thanks,
Michele.


Hi, Michele.

As the JavaDoc on IReportInfo#setSeverity(...) indicates, you shouldn't set the severity of your info objects. Although it is regrettably exposed in the API, conceptually it never makes sense to report warnings from preconditions. The model for preconditions is that you create a "problem info" to report a problem. If the end-user wants this problem to only be a warning, they can configure the precondition to be overruleable.

In this way, when your problem is reported, the operation will be stopped, the user will receive feedback in the Team Advisor, and they will have a chance to correct the problem.

I don't recall why the setSeverity(...) method was even exposed on IReportInfo. Given the confusion it can cause, we should probably deprecate it.

- Jared

permanent link
Michele Pegoraro (1.8k12114101) | answered Jun 17 '11, 3:40 a.m.
Hi Jared,
thank you for the answer. I understand this point of view, so if I want an alert I have to put it into a follow-up extension. Because a warning does not stop the execution.
But if I have all my logic put into pre-condition and for a specific case of this logic I don't want to get an error but only a warning how do I have to do? Do I have to duplicate all the logic both in pre-condition and follow-up?

Thanks,
Michele.

permanent link
Jared Burns (4.5k29) | answered Jun 17 '11, 2:24 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I understand this point of view, so if I want an alert I have to put it into a follow-up extension. Because a warning does not stop the execution.
But if I have all my logic put into pre-condition and for a specific case of this logic I don't want to get an error but only a warning how do I have to do? Do I have to duplicate all the logic both in pre-condition and follow-up?


Without knowing more details of your use-case, my answer would be that if you want to show an alert, you should put your logic in a precondition. Your users can then choose whether this alert is a real blocker or just a warning by configuring your precondition as overrulable or not.

Maybe it would help if you could elaborate on the type of check you want to perform?

- Jared

Your answer


Register or to post your answer.