001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.sys.document.validation.impl; 017 018 import org.kuali.kfs.sys.document.validation.ValidationFieldConvertible; 019 020 /** 021 * A simple class to create field conversions to specify in validations. 022 */ 023 public class ValidationFieldConversion implements ValidationFieldConvertible { 024 private String sourceEventProperty; 025 private String targetValidationProperty; 026 /** 027 * Gets the sourceEventProperty attribute, the property of the event to transfer to the validation 028 * @return Returns the sourceEventProperty. 029 */ 030 public String getSourceEventProperty() { 031 return sourceEventProperty; 032 } 033 /** 034 * Sets the sourceEventProperty attribute value, the property of the event to transfer to the validation 035 * @param sourceEventProperty The sourceEventProperty to set. 036 */ 037 public void setSourceEventProperty(String sourceEventProperty) { 038 this.sourceEventProperty = cleanParameterProperty(sourceEventProperty); 039 } 040 /** 041 * Gets the targetValidationProperty attribute, the property on the validation to transfer information from the event to 042 * @return Returns the targetValidationProperty. 043 */ 044 public String getTargetValidationProperty() { 045 return targetValidationProperty; 046 } 047 /** 048 * Sets the targetValidationProperty attribute value, the property on the validation to transfer information from the event to 049 * @param targetValidationProperty The targetValidationProperty to set. 050 */ 051 public void setTargetValidationProperty(String targetValidationProperty) { 052 this.targetValidationProperty = targetValidationProperty; 053 } 054 055 /** 056 * Removes extraneous information from a single property 057 * @param property a property name to clean up 058 * @return a cleaned up parameter property 059 */ 060 private String cleanParameterProperty(String property) { 061 return (property.startsWith("event.") ? property.replaceFirst("^event\\.", "") : property); 062 } 063 }