-
Notifications
You must be signed in to change notification settings - Fork 2
/
people_filter_criteria.py
127 lines (92 loc) · 3.81 KB
/
people_filter_criteria.py
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
117
118
119
120
121
122
123
124
125
__author__ = 'David Oreper'
class FilterCriteria:
def __init__(self,):
pass
def matches(self, aPerson):
return True
class KeyMatchesCriteria(FilterCriteria):
def __init__(self, expectedValue):
FilterCriteria.__init__(self)
self.expectedValue = expectedValue or ""
def _matches(self, actualValue):
return actualValue.lower() == self.expectedValue.lower()
class ProductCriteria(KeyMatchesCriteria):
def matches(self, aPerson):
return self._matches(aPerson.getProduct())
class FunctionalGroupCriteria(KeyMatchesCriteria):
def matches(self, aPerson):
return self._matches(aPerson.getFunction())
class FeatureTeamCriteria(KeyMatchesCriteria):
def matches(self, aPerson):
return self._matches(aPerson.getFeatureTeam())
class LocationCriteria(KeyMatchesCriteria):
def matches(self, aPerson):
return self._matches(aPerson.getLocation())
class CostCenterCriteria(KeyMatchesCriteria):
def matches(self, aPerson):
return self._matches(aPerson.getCostCenter())
class ManagerCriteria(FilterCriteria):
def __init__(self, manager):
FilterCriteria.__init__(self)
self.manager = manager
def matches(self, aPerson):
personManager = aPerson.getManagerFullName()
# Do explicit checks to make sure the manager field is populated before evaluating to avoid case
# where person has no manager set and falsely matches because manager we're checking has one of these
# fields empty
if self.manager:
if self.manager.getFullName() and (personManager == self.manager.getFullName()):
return True
if self.manager.getRawName() and (personManager == self.manager.getRawName()):
return True
if self.manager.getNormalizedRawName() and (personManager == self.manager.getNormalizedRawName()):
return True
if self.manager.getRawNickName():
if personManager == self.manager.getPreferredName():
return True
return False
return not personManager
class ManagerEmptyCriteria(FilterCriteria):
def __init__(self):
FilterCriteria.__init__(self)
def matches(self, aPerson):
personManager = aPerson.getManagerFullName().lower().strip()
if personManager == "" or personManager == "tbd":
return True
return False
class IsInternCriteria(FilterCriteria):
def __init__(self, isIntern):
FilterCriteria.__init__(self)
self.isIntern = isIntern
def matches(self, aPerson):
return aPerson.isIntern() == self.isIntern
class IsExpatCriteria(FilterCriteria):
def __init__(self, isExpat):
FilterCriteria.__init__(self)
self.isExpat = isExpat
def matches(self, aPerson):
return aPerson.isExpat() == self.isExpat
class IsTBHCriteria(FilterCriteria):
def __init__(self, isTBH):
FilterCriteria.__init__(self)
self.isTBH = isTBH
def matches(self, aPerson):
return aPerson.isTBH() == self.isTBH
class IsProductManagerCriteria(FilterCriteria):
def __init__(self, isProductManager):
FilterCriteria.__init__(self)
self.isProductManager = isProductManager
def matches(self, aPerson):
return aPerson.isProductManager() == self.isProductManager
class IsCrossFuncCriteria(FilterCriteria):
def __init__(self, isCrossFunc):
FilterCriteria.__init__(self)
self.isCrossFunc = isCrossFunc
def matches(self, aPerson):
return aPerson.isCrossFunc() == self.isCrossFunc
class IsManagerCriteria(FilterCriteria):
def __init__(self, isManager):
FilterCriteria.__init__(self)
self.isManager = isManager
def matches(self, aPerson):
return aPerson.isManager() == self.isManager