1 package org.kuali.rice.krms.api.engine;
2
3 import java.util.Collections;
4 import java.util.HashMap;
5 import java.util.Map;
6
7 import org.joda.time.DateTime;
8
9 public final class SelectionCriteria {
10
11 private final Long effectiveExecutionTime;
12 private final String eventName;
13 private final Map<String, String> contextQualifiers;
14 private final Map<String, String> agendaQualifiers;
15
16 private SelectionCriteria(String eventName, DateTime effectiveDate) {
17 if (eventName == null || "".equals(eventName.trim())) {
18 throw new IllegalArgumentException("Event name must not be null or empty.");
19 }
20 this.eventName = eventName;
21
22 if (effectiveDate != null) {
23 this.effectiveExecutionTime = effectiveDate.getMillis();
24 } else {
25 this.effectiveExecutionTime = null;
26 }
27
28 this.contextQualifiers = new HashMap<String, String>();
29 this.agendaQualifiers = new HashMap<String, String>();
30 }
31
32
33
34
35
36
37
38
39
40
41 public static SelectionCriteria createCriteria(String eventName, DateTime effectiveExecutionTime, Map<String, String> contextQualifiers, Map<String, String> agendaQualifiers) {
42 SelectionCriteria criteria = new SelectionCriteria(eventName, effectiveExecutionTime);
43 if (contextQualifiers != null) {
44 criteria.contextQualifiers.putAll(contextQualifiers);
45 }
46 if (agendaQualifiers != null) {
47 criteria.agendaQualifiers.putAll(agendaQualifiers);
48 }
49 return criteria;
50 }
51
52 public String getEventName() {
53 return eventName;
54 }
55
56
57
58
59
60
61
62 public Long getEffectiveExecutionTime() {
63 return effectiveExecutionTime;
64 }
65
66 public Map<String, String> getContextQualifiers() {
67 return Collections.unmodifiableMap(contextQualifiers);
68 }
69
70 public Map<String, String> getAgendaQualifiers() {
71 return Collections.unmodifiableMap(agendaQualifiers);
72 }
73
74 }