| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ConfigurationBasedRegexPatternConstraint |
|
| 1.5;1.5 |
| 1 | /** | |
| 2 | * Copyright 2005-2011 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.opensource.org/licenses/ecl2.php | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | package org.kuali.rice.krad.datadictionary.validation.constraint; | |
| 17 | ||
| 18 | import org.apache.commons.lang.StringUtils; | |
| 19 | import org.kuali.rice.krad.service.KRADServiceLocator; | |
| 20 | import org.kuali.rice.krad.uif.UifConstants; | |
| 21 | ||
| 22 | /** | |
| 23 | * | |
| 24 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 25 | */ | |
| 26 | 74 | public class ConfigurationBasedRegexPatternConstraint extends ValidDataPatternConstraint { |
| 27 | /** | |
| 28 | * the key used to identify the validation pattern | |
| 29 | */ | |
| 30 | protected String patternTypeKey; | |
| 31 | ||
| 32 | /** | |
| 33 | * the key used to identify the validation pattern | |
| 34 | * | |
| 35 | * @return the patternTypeKey | |
| 36 | */ | |
| 37 | public String getPatternTypeKey() { | |
| 38 | 74 | return this.patternTypeKey; |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * the key used to identify the validation pattern | |
| 43 | * | |
| 44 | * @param patternTypeKey the patternTypeKey to set | |
| 45 | */ | |
| 46 | public void setPatternTypeKey(String patternTypeKey) { | |
| 47 | 0 | this.patternTypeKey = patternTypeKey; |
| 48 | 0 | } |
| 49 | ||
| 50 | /** | |
| 51 | * This overridden method ... | |
| 52 | * | |
| 53 | * @see org.kuali.rice.krad.datadictionary.validation.constraint.BaseConstraint#getLabelKey() | |
| 54 | */ | |
| 55 | @Override | |
| 56 | public String getLabelKey() { | |
| 57 | 74 | if(StringUtils.isNotEmpty(labelKey)){ |
| 58 | 0 | return labelKey; |
| 59 | } | |
| 60 | else{ | |
| 61 | 74 | StringBuilder buf = new StringBuilder(); |
| 62 | 74 | buf.append(UifConstants.Messages.VALIDATION_MSG_KEY_PREFIX).append(getPatternTypeKey()); |
| 63 | 74 | return buf.toString(); |
| 64 | } | |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * This method implementation uses the key returned by {@link #getPatternTypePropertyString()} to fetch the | |
| 69 | * validationPattern's regex string from the ConfigurationService which should not include the start(^) and end($) symbols | |
| 70 | */ | |
| 71 | protected String getRegexString() { | |
| 72 | // return (String) KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString("validationPatternRegex." + getPatternTypeName()); | |
| 73 | 0 | return (String) KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString(getPatternTypeKey()); |
| 74 | } | |
| 75 | ||
| 76 | } |