View Javadoc

1   /**
2    * Copyright 2005-2013 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;
17  
18  import org.kuali.rice.core.framework.persistence.jdbc.sql.SQLUtils;
19  import org.kuali.rice.krad.datadictionary.exception.AttributeValidationException;
20  import org.kuali.rice.krad.util.DataTypeUtil;
21  
22  import java.util.List;
23  
24  /**
25   * A class that implements the required accessors and legacy processing for an attribute value reader. This provides a
26   * convenient base class
27   * from which other attribute value readers can be derived.
28   *
29   * @author Kuali Rice Team (rice.collab@kuali.org)
30   */
31  public abstract class BaseAttributeValueReader implements AttributeValueReader {
32  
33      protected String entryName;
34      protected String attributeName;
35  
36      @Override
37      public List<String> getCleanSearchableValues(String attributeKey) throws AttributeValidationException {
38          Class<?> attributeType = getType(attributeKey);
39          Object rawValue = getValue(attributeKey);
40  
41          String attributeInValue = rawValue != null ? rawValue.toString() : "";
42          String attributeDataType = DataTypeUtil.determineDataType(attributeType);
43          return SQLUtils.getCleanedSearchableValues(attributeInValue, attributeDataType);
44      }
45  
46      /**
47       * @return the currentName
48       */
49      @Override
50      public String getAttributeName() {
51          return this.attributeName;
52      }
53  
54      /**
55       * @param currentName the currentName to set
56       */
57      @Override
58      public void setAttributeName(String currentName) {
59          this.attributeName = currentName;
60      }
61  
62      /**
63       * @return the entryName
64       */
65      @Override
66      public String getEntryName() {
67          return this.entryName;
68      }
69  
70      @Override
71      public abstract AttributeValueReader clone();
72  
73  }