01: package org.osbl.riskmanagement.process;
02:
03: import org.concern.*;
04: import org.concern.controller.*;
05:
06: import org.osbl.riskmanagement.model.*;
07:
08: import java.math.BigDecimal;
09:
10: public class Update extends AbstractSynchronousActivity<Risk> {
11: Integer mediumThreshold;
12: Integer highThreshold;
13: Integer criticalThreshold;
14:
15: public void setMediumThreshold(Integer mediumThreshold) {
16: this .mediumThreshold = mediumThreshold;
17: }
18:
19: public void setHighThreshold(Integer highThreshold) {
20: this .highThreshold = highThreshold;
21: }
22:
23: public void setCriticalThreshold(Integer criticalThreshold) {
24: this .criticalThreshold = criticalThreshold;
25: }
26:
27: public void execute(Risk risk) throws ActivityExecutionException {
28: /*PROTECTED REGION ID(org.osbl.riskmanagement.process.Update.execute) ENABLED START*/
29: risk.setCriticality(criticality(risk));
30: /*PROTECTED REGION END*/
31: }
32:
33: private Criticality criticality(Risk risk) {
34: BigDecimal amount = risk.getAmount();
35: BigDecimal probability = risk.getProbability();
36: BigDecimal coverage = risk.getCoverage();
37: if (amount == null || probability == null || coverage == null)
38: return Criticality.UNKNOWN;
39:
40: BigDecimal percentage = amount.multiply(probability).divide(
41: coverage, 2);
42: System.out.println("percentage = " + percentage);
43: if (percentage.intValue() > criticalThreshold)
44: return Criticality.CRITICAL;
45: else if (percentage.intValue() > highThreshold)
46: return Criticality.HIGH;
47: else if (percentage.intValue() > mediumThreshold)
48: return Criticality.MEDIUM;
49: else
50: return Criticality.LOW;
51: }
52: }
|