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.krad.datadictionary.parse.BeanTag;
20 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
21 import org.kuali.rice.krad.datadictionary.parse.BeanTags;
22 import org.kuali.rice.krad.service.KRADServiceLocator;
23 import org.kuali.rice.krad.uif.UifConstants;
24
25
26
27
28 @BeanTags({@BeanTag(name = "configurationBasedRegexPatternConstraint"),
29 @BeanTag(name = "phoneNumberPatternConstraint", parent = "phoneNumberPatternConstraint"),
30 @BeanTag(name = "timePatternConstraint", parent = "TimePatternConstraint"),
31 @BeanTag(name = "time24HPatternConstraint", parent = "Time24HPatternConstraint"),
32 @BeanTag(name = "urlPatternConstraint", parent = "UrlPatternConstraint"),
33 @BeanTag(name = "noWhitespacePatternConstraint", parent = "NoWhitespacePatternConstraint"),
34 @BeanTag(name = "javaClassPatternConstraint", parent = "JavaClassPatternConstraint"),
35 @BeanTag(name = "emailAddressPatternConstraint", parent = "EmailAddressPatternConstraint"),
36 @BeanTag(name = "timestampPatternConstraint", parent = "TimestampPatternConstraint"),
37 @BeanTag(name = "yearPatternConstraint", parent = "YearPatternConstraint"),
38 @BeanTag(name = "monthPatternConstraint", parent = "MonthPatternConstraint"),
39 @BeanTag(name = "zipcodePatternConstraint", parent = "ZipcodePatternConstraint")})
40 public class ConfigurationBasedRegexPatternConstraint extends ValidDataPatternConstraint {
41 protected String patternTypeKey;
42
43
44
45
46
47
48 @BeanTagAttribute(name = "patternTypeKey")
49 public String getPatternTypeKey() {
50 return this.patternTypeKey;
51 }
52
53
54
55
56
57
58 public void setPatternTypeKey(String patternTypeKey) {
59 this.patternTypeKey = patternTypeKey;
60 }
61
62
63
64
65 @Override
66 public String getMessageKey() {
67 if (StringUtils.isNotEmpty(messageKey)) {
68 return messageKey;
69 }
70
71 StringBuilder buf = new StringBuilder();
72 buf.append(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX).append(getPatternTypeKey());
73 return buf.toString();
74 }
75
76
77
78
79
80
81
82
83 protected String getRegexString() {
84 return (String) KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString(getPatternTypeKey());
85 }
86
87 }