1 | package de.fzi.se.accuracy.jobs; |
2 | |
3 | import java.util.ArrayList; |
4 | import java.util.List; |
5 | |
6 | import org.apache.log4j.Logger; |
7 | import org.eclipse.core.runtime.IProgressMonitor; |
8 | |
9 | import de.uka.ipd.sdq.errorhandling.SeverityAndIssue; |
10 | import de.uka.ipd.sdq.errorhandling.dialogs.issues.DisplayIssuesDialog; |
11 | import de.uka.ipd.sdq.workflow.IJob; |
12 | import de.uka.ipd.sdq.workflow.exceptions.JobFailedException; |
13 | import de.uka.ipd.sdq.workflow.exceptions.RollbackFailedException; |
14 | import de.uka.ipd.sdq.workflow.exceptions.UserCanceledException; |
15 | import de.uka.ipd.sdq.workflow.launchconfig.AbstractWorkflowBasedRunConfiguration; |
16 | import de.uka.ipd.sdq.workflow.pcm.jobs.IIssueReceiver; |
17 | |
18 | public class ShowAccuracyInfluenceAnalysisErrorsJob |
19 | implements IJob, IIssueReceiver { |
20 | /** Logger for this class. */ |
21 | private static final Logger logger = Logger.getLogger(ShowAccuracyInfluenceAnalysisErrorsJob.class); |
22 | |
23 | /** Run configuration. */ |
24 | private final AbstractWorkflowBasedRunConfiguration configuration; |
25 | |
26 | /**List of known issues. */ |
27 | private final List<SeverityAndIssue> issues; |
28 | |
29 | public ShowAccuracyInfluenceAnalysisErrorsJob(AbstractWorkflowBasedRunConfiguration configuration) { |
30 | super(); |
31 | this.configuration = configuration; |
32 | issues = new ArrayList<SeverityAndIssue>(); |
33 | } |
34 | |
35 | @Override |
36 | public void execute(IProgressMonitor monitor) throws JobFailedException, |
37 | UserCanceledException { |
38 | if (issues.size() > 0) { |
39 | logger.warn("Found validation problems in the models"); |
40 | displayValidationErrors(issues); |
41 | logger.warn("Continuing workflow, ignoring model validation issues"); |
42 | } |
43 | |
44 | } |
45 | |
46 | @Override |
47 | public String getName() { |
48 | return "Show accuracy influence analysis errors"; |
49 | } |
50 | |
51 | @Override |
52 | public void rollback(IProgressMonitor monitor) |
53 | throws RollbackFailedException { |
54 | // Intentionally left empty |
55 | } |
56 | |
57 | private void displayValidationErrors( |
58 | List<SeverityAndIssue> overallResult) |
59 | throws UserCanceledException { |
60 | |
61 | /** |
62 | * Disable the IssuesDialog, if job is run in non-interactive mode. |
63 | */ |
64 | if (configuration.isInteractive()) { |
65 | DisplayIssuesDialog runner = new DisplayIssuesDialog(overallResult); |
66 | DisplayIssuesDialog.showDialogSync(runner); |
67 | if (!runner.shouldProceedAfterErrorDialog()) |
68 | throw new UserCanceledException(); |
69 | } |
70 | } |
71 | |
72 | /* (non-Javadoc) |
73 | * @see de.fzi.se.accuracy.jobs.IIssueReceiver#addIssues(java.util.List) |
74 | */ |
75 | public void addIssues(List<SeverityAndIssue> issues) { |
76 | if (issues != null) { |
77 | this.issues.addAll(issues); |
78 | } |
79 | } |
80 | } |