1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary.validation.constraint;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.core.api.CoreApiServiceLocator;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
21 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
22 import org.kuali.rice.krad.datadictionary.parse.BeanTags;
23 import org.kuali.rice.krad.uif.UifConstants;
24
25
26
27
28
29
30
31 @BeanTags({@BeanTag(name = "configurationBasedRegexPatternConstraint-bean"),
32 @BeanTag(name = "phoneNumberPatternConstraint-bean", parent = "PhoneNumberPatternConstraint"),
33 @BeanTag(name = "timePatternConstraint-bean", parent = "TimePatternConstraint"),
34 @BeanTag(name = "time24HPatternConstraint-bean", parent = "Time24HPatternConstraint"),
35 @BeanTag(name = "urlPatternConstraint-bean", parent = "UrlPatternConstraint"),
36 @BeanTag(name = "noWhitespacePatternConstraint-bean", parent = "NoWhitespacePatternConstraint"),
37 @BeanTag(name = "javaClassPatternConstraint-bean", parent = "JavaClassPatternConstraint"),
38 @BeanTag(name = "emailAddressPatternConstraint-bean", parent = "EmailAddressPatternConstraint"),
39 @BeanTag(name = "timestampPatternConstraint-bean", parent = "TimestampPatternConstraint"),
40 @BeanTag(name = "yearPatternConstraint-bean", parent = "YearPatternConstraint"),
41 @BeanTag(name = "monthPatternConstraint-bean", parent = "MonthPatternConstraint"),
42 @BeanTag(name = "zipcodePatternConstraint-bean", parent = "ZipcodePatternConstraint")})
43 public class ConfigurationBasedRegexPatternConstraint extends ValidDataPatternConstraint {
44 protected String patternTypeKey;
45
46
47
48
49
50
51 @BeanTagAttribute(name = "patternTypeKey")
52 public String getPatternTypeKey() {
53 return this.patternTypeKey;
54 }
55
56
57
58
59
60
61 public void setPatternTypeKey(String patternTypeKey) {
62 this.patternTypeKey = patternTypeKey;
63 }
64
65
66
67
68
69
70
71 @Override
72 public String getMessageKey() {
73 if (StringUtils.isNotEmpty(messageKey)) {
74 return messageKey;
75 }
76
77 StringBuilder buf = new StringBuilder();
78 buf.append(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX).append(getPatternTypeKey());
79 return buf.toString();
80 }
81
82
83
84
85
86
87
88
89 @Override
90 protected String getRegexString() {
91 if ( StringUtils.isBlank(getPatternTypeKey())) {
92 throw new IllegalArgumentException("patternTypeKey is null, configuration of " + this.getClass().getName() + " is incomplete" );
93 }
94 return CoreApiServiceLocator.getKualiConfigurationService().getPropertyValueAsString(getPatternTypeKey());
95 }
96
97 }