001: /*
002: * Copyright 2005-2006 The Kuali Foundation.
003: *
004: *
005: * Licensed under the Educational Community License, Version 1.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.opensource.org/licenses/ecl1.php
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package edu.iu.uis.eden.docsearch;
018:
019: import java.sql.ResultSet;
020: import java.sql.SQLException;
021: import java.text.DecimalFormat;
022: import java.text.NumberFormat;
023: import java.util.Map;
024:
025: import org.apache.commons.lang.StringUtils;
026:
027: import edu.iu.uis.eden.WorkflowPersistable;
028: import edu.iu.uis.eden.routeheader.DocumentRouteHeaderValue;
029:
030: /**
031: *
032: * @author delyea
033: */
034: public class SearchableAttributeStringValue implements
035: WorkflowPersistable, SearchableAttributeValue {
036:
037: private static final long serialVersionUID = 8696089933682052078L;
038:
039: private static final String ATTRIBUTE_DATABASE_TABLE_NAME = "EN_DOC_HDR_EXT_T";
040: private static final boolean DEFAULT_WILDCARD_ALLOWANCE_POLICY = true;
041: private static final boolean ALLOWS_RANGE_SEARCH = false;
042: private static final boolean ALLOWS_CASE_INSENSITIVE_SEARCH = true;
043: private static final String ATTRIBUTE_XML_REPRESENTATION = SearchableAttribute.DATA_TYPE_STRING;
044:
045: private Long searchableAttributeValueId;
046: private String searchableAttributeKey;
047: private String searchableAttributeValue;
048: protected String ojbConcreteClass; // attribute needed for OJB polymorphism - do not alter!
049:
050: private Long routeHeaderId;
051: private DocumentRouteHeaderValue routeHeader;
052:
053: /**
054: * Default constructor.
055: */
056: public SearchableAttributeStringValue() {
057: super ();
058: this .ojbConcreteClass = this .getClass().getName();
059: }
060:
061: /* (non-Javadoc)
062: * @see edu.iu.uis.eden.docsearch.SearchableAttributeValue#setupAttributeValue(java.lang.String)
063: */
064: public void setupAttributeValue(String value) {
065: this .setSearchableAttributeValue(value);
066: }
067:
068: /* (non-Javadoc)
069: * @see edu.iu.uis.eden.docsearch.SearchableAttributeValue#setupAttributeValue(java.sql.ResultSet, java.lang.String)
070: */
071: public void setupAttributeValue(ResultSet resultSet,
072: String columnName) throws SQLException {
073: this .setSearchableAttributeValue(resultSet
074: .getString(columnName));
075: }
076:
077: /* (non-Javadoc)
078: * @see edu.iu.uis.eden.docsearch.SearchableAttributeValue#getSearchableAttributeDisplayValue()
079: */
080: public String getSearchableAttributeDisplayValue() {
081: return getSearchableAttributeValue();
082: }
083:
084: /* (non-Javadoc)
085: * @see edu.iu.uis.eden.docsearch.SearchableAttributeValue#getSearchableAttributeDisplayValue(java.util.Map)
086: */
087: public String getSearchableAttributeDisplayValue(
088: Map<String, String> displayParameters) {
089: return getSearchableAttributeDisplayValue();
090: }
091:
092: /* (non-Javadoc)
093: * @see edu.iu.uis.eden.docsearch.SearchableAttributeValue#getAttributeDataType()
094: */
095: public String getAttributeDataType() {
096: return ATTRIBUTE_XML_REPRESENTATION;
097: }
098:
099: /* (non-Javadoc)
100: * @see edu.iu.uis.eden.docsearch.SearchableAttributeValue#getAttributeTableName()
101: */
102: public String getAttributeTableName() {
103: return ATTRIBUTE_DATABASE_TABLE_NAME;
104: }
105:
106: /* (non-Javadoc)
107: * @see edu.iu.uis.eden.docsearch.SearchableAttributeValue#allowsWildcardsByDefault()
108: */
109: public boolean allowsWildcards() {
110: return DEFAULT_WILDCARD_ALLOWANCE_POLICY;
111: }
112:
113: /* (non-Javadoc)
114: * @see edu.iu.uis.eden.docsearch.SearchableAttributeValue#allowsCaseInsensitivity()
115: */
116: public boolean allowsCaseInsensitivity() {
117: return ALLOWS_CASE_INSENSITIVE_SEARCH;
118: }
119:
120: /* (non-Javadoc)
121: * @see edu.iu.uis.eden.docsearch.SearchableAttributeValue#allowsRangeSearches()
122: */
123: public boolean allowsRangeSearches() {
124: return ALLOWS_RANGE_SEARCH;
125: }
126:
127: /**
128: * @return true
129: *
130: * @see edu.iu.uis.eden.docsearch.SearchableAttributeValue#isPassesDefaultValidation()
131: */
132: public boolean isPassesDefaultValidation(String valueEntered) {
133: // TODO delyea - length check needed?
134: return true;
135: }
136:
137: /* (non-Javadoc)
138: * @see edu.iu.uis.eden.docsearch.SearchableAttributeValue#isRangeValid(java.lang.String, java.lang.String)
139: */
140: public Boolean isRangeValid(String lowerValue, String upperValue) {
141: if (allowsRangeSearches()) {
142: return true;
143: }
144: return null;
145: }
146:
147: public String getOjbConcreteClass() {
148: return ojbConcreteClass;
149: }
150:
151: public void setOjbConcreteClass(String ojbConcreteClass) {
152: this .ojbConcreteClass = ojbConcreteClass;
153: }
154:
155: public DocumentRouteHeaderValue getRouteHeader() {
156: return routeHeader;
157: }
158:
159: public void setRouteHeader(DocumentRouteHeaderValue routeHeader) {
160: this .routeHeader = routeHeader;
161: }
162:
163: public Long getRouteHeaderId() {
164: return routeHeaderId;
165: }
166:
167: public void setRouteHeaderId(Long routeHeaderId) {
168: this .routeHeaderId = routeHeaderId;
169: }
170:
171: public String getSearchableAttributeKey() {
172: return searchableAttributeKey;
173: }
174:
175: public void setSearchableAttributeKey(String searchableAttributeKey) {
176: this .searchableAttributeKey = searchableAttributeKey;
177: }
178:
179: public String getSearchableAttributeValue() {
180: return searchableAttributeValue;
181: }
182:
183: public void setSearchableAttributeValue(
184: String searchableAttributeValue) {
185: this .searchableAttributeValue = searchableAttributeValue;
186: }
187:
188: public Long getSearchableAttributeValueId() {
189: return searchableAttributeValueId;
190: }
191:
192: public void setSearchableAttributeValueId(
193: Long searchableAttributeValueId) {
194: this .searchableAttributeValueId = searchableAttributeValueId;
195: }
196:
197: /* (non-Javadoc)
198: * @see edu.iu.uis.eden.WorkflowPersistable#copy(boolean)
199: */
200: public Object copy(boolean preserveKeys) {
201: return null;
202: }
203: }
|