01 /*
02 * Created on Aug 29, 2007
03 *
04 */
05 package com.x8ing.mc.bp.develop;
06
07 import com.x8ing.lsm4j.Condition;
08 import com.x8ing.lsm4j.StateContext;
09 import com.x8ing.mc.bp.BusinessContext;
10
11 /**
12 *
13 * @author Patrick Heusser
14 */
15 public class CostLossCheckCondition implements Condition {
16
17 private boolean trueIfLossIsGreaterThen = false;
18
19 /**
20 * the value of cost loss must be above this value
21 */
22 private double triggerValue = -1;
23
24 public CostLossCheckCondition(boolean trueIfLossIsGreaterThen, double triggerValue) {
25 this.trueIfLossIsGreaterThen = trueIfLossIsGreaterThen;
26 this.triggerValue = triggerValue;
27 }
28
29 /**
30 * @see com.x8ing.lsm4j.Condition#traceInfo()
31 */
32 public String traceInfo() {
33
34 return "";
35 }
36
37 /**
38 * @see com.x8ing.lsm4j.Condition#conditionTrue(com.x8ing.lsm4j.StateContext)
39 */
40 public boolean conditionTrue(StateContext currentContext) {
41
42 BusinessContext businessContext = (BusinessContext) currentContext;
43
44 // log just once this information
45 double totalLoss = businessContext.calculateTotalProcessLossOfAllBugsNotDeployedYet();
46
47 boolean ret = totalLoss >= triggerValue;
48
49 return trueIfLossIsGreaterThen ? !ret : ret;
50
51 }
52
53 }
|