26
26
* Target table filter for default checks that uses parsed patterns.
27
27
*/
28
28
public class TargetTablePatternFilter {
29
- private SearchPattern connectionPattern ;
30
- private SearchPattern schemaPattern ;
31
- private SearchPattern tablePattern ;
32
- private SearchPattern stagePattern ;
29
+ private SearchPattern [] connectionPattern ;
30
+ private SearchPattern [] schemaPattern ;
31
+ private SearchPattern [] tablePattern ;
32
+ private SearchPattern [] stagePattern ;
33
33
private Integer tablePriority ;
34
- protected SearchPattern labelPattern ;
34
+ protected SearchPattern [] labelPattern ;
35
35
36
36
/**
37
37
* Creates a table pattern search object given a target table pattern specification. Creates search patterns for filled fields.
38
38
* @param tablePatternSpec Target table search pattern.
39
39
*/
40
40
public TargetTablePatternFilter (TargetTablePatternSpec tablePatternSpec ) {
41
41
if (!Strings .isNullOrEmpty (tablePatternSpec .getConnection ())) {
42
- this .connectionPattern = SearchPattern .create (false , tablePatternSpec .getConnection ());
42
+ this .connectionPattern = SearchPattern .createForCommaSeparatedPatterns (false , tablePatternSpec .getConnection ());
43
43
}
44
44
45
45
if (!Strings .isNullOrEmpty (tablePatternSpec .getSchema ())) {
46
- this .schemaPattern = SearchPattern .create (false , tablePatternSpec .getSchema ());
46
+ this .schemaPattern = SearchPattern .createForCommaSeparatedPatterns (false , tablePatternSpec .getSchema ());
47
47
}
48
48
49
49
if (!Strings .isNullOrEmpty (tablePatternSpec .getTable ())) {
50
- this .tablePattern = SearchPattern .create (false , tablePatternSpec .getTable ());
50
+ this .tablePattern = SearchPattern .createForCommaSeparatedPatterns (false , tablePatternSpec .getTable ());
51
51
}
52
52
53
53
if (!Strings .isNullOrEmpty (tablePatternSpec .getStage ())) {
54
- this .stagePattern = SearchPattern .create (false , tablePatternSpec .getStage ());
54
+ this .stagePattern = SearchPattern .createForCommaSeparatedPatterns (false , tablePatternSpec .getStage ());
55
55
}
56
56
57
57
if (!Strings .isNullOrEmpty (tablePatternSpec .getLabel ())) {
58
- this .labelPattern = SearchPattern .create (false , tablePatternSpec .getLabel ());
58
+ this .labelPattern = SearchPattern .createForCommaSeparatedPatterns (false , tablePatternSpec .getLabel ());
59
59
}
60
60
61
61
this .tablePriority = tablePatternSpec .getTablePriority ();
@@ -70,25 +70,25 @@ public TargetTablePatternFilter(TargetTablePatternSpec tablePatternSpec) {
70
70
*/
71
71
public boolean match (ConnectionSpec connectionSpec , TableSpec tableSpec , boolean matchLabels ) {
72
72
if (this .connectionPattern != null ) {
73
- if (!this .connectionPattern . match ( connectionSpec .getConnectionName ())) {
73
+ if (!SearchPattern . matchAny ( this .connectionPattern , connectionSpec .getConnectionName ())) {
74
74
return false ;
75
75
}
76
76
}
77
77
78
78
if (this .schemaPattern != null ) {
79
- if (!this .schemaPattern . match ( tableSpec .getPhysicalTableName ().getSchemaName ())) {
79
+ if (!SearchPattern . matchAny ( this .schemaPattern , tableSpec .getPhysicalTableName ().getSchemaName ())) {
80
80
return false ;
81
81
}
82
82
}
83
83
84
84
if (this .tablePattern != null ) {
85
- if (!this .tablePattern . match ( tableSpec .getPhysicalTableName ().getTableName ())) {
85
+ if (!SearchPattern . matchAny ( this .tablePattern , tableSpec .getPhysicalTableName ().getTableName ())) {
86
86
return false ;
87
87
}
88
88
}
89
89
90
90
if (this .stagePattern != null ) {
91
- if (!this .stagePattern . match ( tableSpec .getStage ())) {
91
+ if (!SearchPattern . matchAny ( this .stagePattern , tableSpec .getStage ())) {
92
92
return false ;
93
93
}
94
94
}
@@ -103,7 +103,7 @@ public boolean match(ConnectionSpec connectionSpec, TableSpec tableSpec, boolean
103
103
LabelSetSpec connectionLabels = connectionSpec .getLabels ();
104
104
if (connectionLabels != null && !connectionLabels .isEmpty ()) {
105
105
for (String label : connectionLabels ) {
106
- if (this .labelPattern . match ( label )) {
106
+ if (SearchPattern . matchAny ( this .labelPattern , label )) {
107
107
return true ;
108
108
}
109
109
}
@@ -112,7 +112,7 @@ public boolean match(ConnectionSpec connectionSpec, TableSpec tableSpec, boolean
112
112
LabelSetSpec tableLabels = tableSpec .getLabels ();
113
113
if (tableLabels != null && !tableLabels .isEmpty ()) {
114
114
for (String label : tableLabels ) {
115
- if (this .labelPattern . match ( label )) {
115
+ if (SearchPattern . matchAny ( this .labelPattern , label )) {
116
116
return true ;
117
117
}
118
118
}
0 commit comments