001 /** 002 * Copyright 2005-2014 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.rice.kew.web; 017 018 import org.apache.commons.lang.StringUtils; 019 import org.kuali.rice.core.api.util.ConcreteKeyValue; 020 import org.kuali.rice.core.api.util.KeyValue; 021 import org.kuali.rice.kew.docsearch.SearchableAttributeValue; 022 023 024 /** 025 * A simple bean for storing key/value pairs that can be used for a number of 026 * tasks. Right now it is used to hold information that will be display on a jsp 027 * for drop down boxes. 028 * 029 * @author Kuali Rice Team (rice.collab@kuali.org) 030 */ 031 public class KeyValueSort implements KeyValue { 032 033 private static final long serialVersionUID = 3575440091286391804L; 034 035 private String userDisplayValue; 036 private Object sortValue; 037 private Class sortClass; 038 private SearchableAttributeValue searchableAttributeValue; 039 private final ConcreteKeyValue keyValue; 040 041 042 public KeyValueSort() { 043 keyValue = new ConcreteKeyValue(); 044 } 045 046 public KeyValueSort(String key, String value) { 047 keyValue = new ConcreteKeyValue(key, value); 048 } 049 050 public KeyValueSort(String key, String value, Object sortValue, SearchableAttributeValue searchableAttributeValue) { 051 this(key,value); 052 this.sortValue = sortValue; 053 this.searchableAttributeValue = searchableAttributeValue; 054 } 055 056 public KeyValueSort(String key, String value, String userDisplayValue, Object sortValue, SearchableAttributeValue searchableAttributeValue) { 057 this(key,value,sortValue,searchableAttributeValue); 058 this.userDisplayValue = userDisplayValue; 059 } 060 061 public KeyValueSort(KeyValueSort kvs) { 062 this(kvs.getKey(),kvs.getValue(),kvs.getUserDisplayValue(),kvs.getSortValue(),kvs.getSearchableAttributeValue()); 063 } 064 065 public Object getSortValue() { 066 return sortValue; 067 } 068 069 public void setSortValue(Object sortValue) { 070 this.sortValue = sortValue; 071 this.sortClass = sortValue.getClass(); 072 } 073 074 public Class getSortClass() { 075 return sortClass; 076 } 077 078 public SearchableAttributeValue getSearchableAttributeValue() { 079 return searchableAttributeValue; 080 } 081 082 public String getUserDisplayValue() { 083 if (StringUtils.isNotBlank(userDisplayValue)) { 084 return userDisplayValue; 085 } 086 return getValue(); 087 } 088 089 @Override 090 public String getKey() { 091 return keyValue.getKey(); 092 } 093 094 @Override 095 public String getValue() { 096 return keyValue.getValue(); 097 } 098 099 public void setKey(String k) { 100 keyValue.setKey(k); 101 } 102 103 public void setValue(String v) { 104 keyValue.setValue(v); 105 } 106 107 }