-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCustomerUnit.java
116 lines (92 loc) · 3.97 KB
/
CustomerUnit.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package org.demo.rsotf;
import org.demo.rsotf.model.*;
import org.demo.rsotf.services.StoreLocationService;
import org.kie.kogito.rules.DataSource;
import org.kie.kogito.rules.DataStore;
import org.kie.kogito.rules.RuleUnitData;
import org.kie.kogito.rules.SingletonStore;
import javax.inject.Inject;
import java.util.LinkedList;
import java.util.List;
public class CustomerUnit implements RuleUnitData {
private final DataStore<Department> departmentDataStore;
private SingletonStore<CustomerMovement> customerMovements;
private SingletonStore<CustomerState> customerState;
private DataStore<CustomerFocus> customerFocus;
private SingletonStore<CustomerState> browsingCustomer;
// Number of "steps" in the same department to treat a customer as focused
private int requiredNumberOfSteps = 3;
@Inject
private StoreLocationService storeLocationService;
public CustomerUnit() {
this(DataSource.createSingleton(),
DataSource.createSingleton(),
DataSource.createStore(),
DataSource.createStore(),
CustomerUnit.getDepartments(), DataSource.createSingleton());
System.out.println("Creating data sources");
}
public CustomerUnit(
SingletonStore<CustomerMovement> customerMovements,
SingletonStore<CustomerState> customerState,
DataStore<CustomerFocus> customerFocus,
DataStore<Department> departmentDataStore,
List<Department> departments, SingletonStore<CustomerState> browsingCustomer) {
this.customerMovements = customerMovements;
this.customerState = customerState;
this.departmentDataStore = departmentDataStore;
this.browsingCustomer = browsingCustomer;
for (Department d : departments) {
departmentDataStore.add(d);
}
this.storeLocationService = new StoreLocationService();
}
private static List<Department> getDepartments() {
List<Department> departments = new LinkedList<>();
departments.add(new Department("Women", new Area(444, 443, 666, 879), ""));
departments.add(new Department("Boys", new Area(672, 443, 992, 658), ""));
departments.add(new Department("Girls", new Area(998, 443, 1317, 658), ""));
departments.add(new Department("Men", new Area(672, 664, 1317, 879), ""));
departments.add(new Department("Sports",new Area(614, 984, 1186, 1292), ""));
return departments;
}
public SingletonStore<CustomerState> getCustomerState() {
return customerState;
}
public void setCustomerState(SingletonStore<CustomerState> customerState) {
this.customerState = customerState;
}
public SingletonStore<CustomerMovement> getCustomerMovements() {
return customerMovements;
}
public void setCustomerMovements(SingletonStore<CustomerMovement> customerMovements) {
this.customerMovements = customerMovements;
}
public StoreLocationService getStoreLocationService() {
return storeLocationService;
}
public void setStoreLocationService(StoreLocationService storeLocationService) {
this.storeLocationService = storeLocationService;
}
public DataStore<Department> getDepartmentDataStore() {
return departmentDataStore;
}
public DataStore<CustomerFocus> getCustomerFocus() {
return customerFocus;
}
public void setCustomerFocus(DataStore<CustomerFocus> customerFocus) {
this.customerFocus = customerFocus;
}
public int getRequiredNumberOfSteps() {
return requiredNumberOfSteps;
}
public void setRequiredNumberOfSteps(int requiredNumberOfSteps) {
this.requiredNumberOfSteps = requiredNumberOfSteps;
}
public SingletonStore<CustomerState> getBrowsingCustomer() {
return browsingCustomer;
}
public void setBrowsingCustomer(SingletonStore<CustomerState> browsingCustomer) {
this.browsingCustomer = browsingCustomer;
}
}