View Javadoc

1   /*
2    * Copyright 2009 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.kns.workflow.attribute;
17  
18  import java.sql.ResultSet;
19  import java.sql.SQLException;
20  import java.sql.Statement;
21  import java.util.List;
22  import java.util.Map;
23  
24  import org.kuali.rice.kew.docsearch.DocSearchCriteriaDTO;
25  import org.kuali.rice.kew.docsearch.DocSearchDTO;
26  import org.kuali.rice.kew.docsearch.DocumentSearchContext;
27  import org.kuali.rice.kew.docsearch.DocumentSearchGenerator;
28  import org.kuali.rice.kew.docsearch.DocumentSearchResultComponents;
29  import org.kuali.rice.kew.docsearch.DocumentSearchResultProcessor;
30  import org.kuali.rice.kew.docsearch.SearchableAttribute;
31  import org.kuali.rice.kew.docsearch.SearchableAttributeValue;
32  import org.kuali.rice.kew.docsearch.StandardDocumentSearchGenerator;
33  import org.kuali.rice.kew.docsearch.StandardDocumentSearchResultProcessor;
34  import org.kuali.rice.kew.exception.WorkflowServiceError;
35  import org.kuali.rice.kew.rule.WorkflowAttributeValidationError;
36  import org.kuali.rice.kns.util.MessageMap;
37  import org.kuali.rice.kns.web.ui.Row;
38  
39  public class DataDictionaryDocumentSearchCustomizer implements SearchableAttribute, DocumentSearchGenerator, DocumentSearchResultProcessor {
40      // SEARCH GENERATOR IMPLEMENTATION
41      protected StandardDocumentSearchGenerator documentSearchGenerator = null;
42      // SEARCHABLE ATTRIBUTE IMPLEMENTATION
43      protected SearchableAttribute searchableAttribute = null;
44      // SEARCH RESULT PROCESSOR IMPLEMENTATION
45      protected DocumentSearchResultProcessor searchResultProcessor = null;
46      
47      public DocSearchCriteriaDTO clearSearch(DocSearchCriteriaDTO searchCriteria) {
48          return getDocumentSearchGenerator().clearSearch(searchCriteria);
49      }
50  
51      public String generateSearchSql(DocSearchCriteriaDTO searchCriteria) {
52          return getDocumentSearchGenerator().generateSearchSql(searchCriteria);
53      }
54  
55      public int getDocumentSearchResultSetLimit() {
56          return getDocumentSearchGenerator().getDocumentSearchResultSetLimit();
57      }
58  
59      public List<WorkflowServiceError> performPreSearchConditions(String principalId, DocSearchCriteriaDTO searchCriteria) {
60          return getDocumentSearchGenerator().performPreSearchConditions(principalId, searchCriteria);
61      }
62  
63      public List<DocSearchDTO> processResultSet(Statement searchAttributeStatement, ResultSet resultSet, DocSearchCriteriaDTO searchCriteria, String principalId) throws SQLException {
64          return getDocumentSearchGenerator().processResultSet(searchAttributeStatement, resultSet, searchCriteria, principalId);
65      }
66  
67      @Deprecated
68      public List<DocSearchDTO> processResultSet(Statement searchAttributeStatement, ResultSet resultSet, DocSearchCriteriaDTO searchCriteria) throws SQLException {
69          return getDocumentSearchGenerator().processResultSet(searchAttributeStatement, resultSet, searchCriteria);
70      }    
71  
72      public void setSearchingUser(String principalId) {
73      	getDocumentSearchGenerator().setSearchingUser(principalId);
74      }
75  
76      public List<WorkflowServiceError> validateSearchableAttributes(DocSearchCriteriaDTO searchCriteria) {
77          return getDocumentSearchGenerator().validateSearchableAttributes(searchCriteria);
78      }
79  
80      public boolean isProcessResultSet() {
81          return getDocumentSearchGenerator().isProcessResultSet();
82      }
83      public void setProcessResultSet(boolean isProcessResultSet){
84      	getDocumentSearchGenerator().setProcessResultSet(isProcessResultSet);
85      }
86      public MessageMap getMessageMap(DocSearchCriteriaDTO searchCriteria) {
87          return getDocumentSearchGenerator().getMessageMap(searchCriteria);
88      }    
89  
90      public String getSearchContent(DocumentSearchContext documentSearchContext) {
91          return getSearchableAttribute().getSearchContent(documentSearchContext);
92      }
93  
94      public List<Row> getSearchingRows(DocumentSearchContext documentSearchContext) {
95          return getSearchableAttribute().getSearchingRows(documentSearchContext);
96      }
97  
98      public List<SearchableAttributeValue> getSearchStorageValues(DocumentSearchContext documentSearchContext) {
99          return getSearchableAttribute().getSearchStorageValues(documentSearchContext);
100     }
101 
102     public List<WorkflowAttributeValidationError> validateUserSearchInputs(Map<Object, Object> paramMap, DocumentSearchContext searchContext) {
103         return getSearchableAttribute().validateUserSearchInputs(paramMap, searchContext);
104     }
105 
106 	/**
107 	 * This overridden method calls the currently set searchResultProcessor's processIntoFinalResults
108 	 * 
109 	 * @see org.kuali.rice.kew.docsearch.DocumentSearchResultProcessor#processIntoFinalResults(java.util.List, org.kuali.rice.kew.docsearch.DocSearchCriteriaDTO, java.lang.String)
110 	 */
111 	public DocumentSearchResultComponents processIntoFinalResults(
112 			List<DocSearchDTO> docSearchResultRows,
113 			DocSearchCriteriaDTO criteria, String principalId)
114 			throws SQLException {
115 		
116 		return this.getSearchResultProcessor().processIntoFinalResults(docSearchResultRows, criteria, principalId);
117 	}
118 
119 	/**
120 	 * This overridden method returns the searchResultProcessor
121 	 * 
122 	 * @see org.kuali.rice.kew.docsearch.DocumentSearchResultProcessor#setProcessFinalResults(boolean)
123 	 */
124 	public void setProcessFinalResults(boolean isProcessFinalResults) {
125 		this.getSearchResultProcessor().setProcessFinalResults(isProcessFinalResults);
126 		
127 	}
128 
129 	/**
130 	 * This overridden method returns if the searchResultProcessor has processed final results
131 	 * 
132 	 * @see org.kuali.rice.kew.docsearch.DocumentSearchResultProcessor#isProcessFinalResults()
133 	 */
134 	public boolean isProcessFinalResults() {
135 		return this.getSearchResultProcessor().isProcessFinalResults();
136 	}
137 	
138 	/**
139 	 * @param documentSearchGenerator the documentSearchGenerator to set
140 	 */
141 	public void setDocumentSearchGenerator(
142 			StandardDocumentSearchGenerator documentSearchGenerator) {
143 		this.documentSearchGenerator = documentSearchGenerator;
144 	}
145 	
146 	/**
147 	 * @param searchResultProcessor the searchResultProcessor to set
148 	 */
149 	public void setSearchResultProcessor(
150 			DocumentSearchResultProcessor searchResultProcessor) {
151 		this.searchResultProcessor = searchResultProcessor;
152 	}
153 
154 	/**
155 	 * 
156 	 * This method sets a list of searchable attributes on the DocumentSearchGenerator.
157 	 * Do not confuse this with "setSearchableAttribute"
158 	 * 
159 	 * @param searchableAttributes
160 	 */
161 	public void setSearchableAttributes(List<SearchableAttribute> searchableAttributes) {
162 		getDocumentSearchGenerator().setSearchableAttributes(searchableAttributes);
163     }
164 	
165 	/**
166 	 * @param searchableAttribute the searchableAttribute to set
167 	 */
168 	public void setSearchableAttribute(SearchableAttribute searchableAttribute) {
169 		this.searchableAttribute = searchableAttribute;
170 	}
171 	
172 	/**
173 	 * @return the searchableAttribute
174 	 */
175 	public SearchableAttribute getSearchableAttribute() {
176 		if(this.searchableAttribute == null){
177 			this.searchableAttribute = new DataDictionarySearchableAttribute();
178 		}
179 		return this.searchableAttribute;
180 	}
181 
182 	/**
183 	 * @return the documentSearchGenerator
184 	 */
185 	public StandardDocumentSearchGenerator getDocumentSearchGenerator() {
186 		if(this.documentSearchGenerator == null){
187 			this.documentSearchGenerator = new StandardDocumentSearchGenerator();
188 		}
189 		return this.documentSearchGenerator;
190 	}
191 
192 	/**
193 	 * @return the searchResultProcessor
194 	 */
195 	public DocumentSearchResultProcessor getSearchResultProcessor() {
196 		if(this.searchResultProcessor == null){
197 			this.searchResultProcessor = new StandardDocumentSearchResultProcessor();
198 		}
199 		return this.searchResultProcessor;
200 	}
201 
202 	
203 	
204 
205 }