View Javadoc

1   /*
2    * Copyright 2005-2007 The Kuali Foundation
3    *
4    *
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    * http://www.opensource.org/licenses/ecl2.php
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.kuali.rice.kew.docsearch;
18  
19  import java.io.Serializable;
20  import java.util.ArrayList;
21  import java.util.List;
22  
23  import org.apache.commons.lang.StringUtils;
24  import org.kuali.rice.kew.util.KEWConstants;
25  import org.kuali.rice.kew.web.KeyValueSort;
26  import org.kuali.rice.kew.web.RowStyleable;
27  
28  
29  /**
30   * Bean that representing a row displayed in a document search.
31   *
32   * @author Kuali Rice Team (rice.collab@kuali.org)
33   */
34  public class DocSearchDTO implements Serializable, RowStyleable {
35  
36  	private static final long serialVersionUID = 7850758046316186962L;
37  	private static final String URL_SUFFIX = "?" + KEWConstants.COMMAND_PARAMETER + "=" + KEWConstants.DOCSEARCH_COMMAND + "&" + KEWConstants.DOCUMENT_ID_PARAMETER + "=";
38  
39  	private String documentId;
40  	private String docRouteStatusCode;
41  	private java.sql.Timestamp dateCreated;
42  	private String documentTitle;
43  	private String activeIndicatorCode;
44  	private String docTypeName;
45  	private String docTypeLabel;
46  	private String initiatorNetworkId;
47  	private String initiatorWorkflowId;
48  	private String initiatorName;
49  	private String initiatorEmailAddress;
50  	private String initiatorLastName;
51  	private String initiatorFirstName;
52      private String initiatorTransposedName;
53  	private String docTypeHandlerUrl;
54  	private String rowStyleClass;
55  	private String superUserSearch;
56  	private String appDocStatus;
57  
58  	private List<KeyValueSort> searchableAttributes = new ArrayList<KeyValueSort>();
59  
60  	public DocSearchDTO() {
61  	}
62  
63  	public String getSuperUserSearch() {
64          return superUserSearch;
65      }
66      public void setSuperUserSearch(String superUserSearch) {
67          this.superUserSearch = superUserSearch;
68      }
69  	public String getDocRouteStatusCode() {
70  		return docRouteStatusCode;
71  	}
72  
73  	public String getDocumentTitle() {
74  		return documentTitle;
75  	}
76  
77  	public String getDocumentId() {
78  		return documentId;
79  	}
80  
81  	public void setDocRouteStatusCode(String docRouteStatusCode) {
82  		this.docRouteStatusCode = docRouteStatusCode;
83  	}
84  
85  	public void setDocumentTitle(String documentTitle) {
86  		this.documentTitle = documentTitle;
87  	}
88  
89  	public void setDocumentId(String documentId) {
90  		this.documentId = documentId;
91  	}
92  
93  	public String getActiveIndicatorCode() {
94  		return activeIndicatorCode;
95  	}
96  
97  	public String getDocTypeName() {
98      return docTypeName;
99    }
100 
101   public void setDocTypeName(String docTypeName) {
102     this.docTypeName = docTypeName;
103   }
104 
105   public String getDocTypeLabel() {
106 		return docTypeLabel;
107 	}
108 
109 	public String getDocTypeHandlerUrl() {
110 		return docTypeHandlerUrl;
111 	}
112 
113 	public String getInitiatorWorkflowId() {
114 		return initiatorWorkflowId;
115 	}
116 
117 	public String getInitiatorEmailAddress() {
118 		return initiatorEmailAddress;
119 	}
120 
121 	public String getInitiatorName() {
122 		return initiatorName;
123 	}
124 
125 	public void setActiveIndicatorCode(String activeIndicatorCode) {
126 		this.activeIndicatorCode = activeIndicatorCode;
127 	}
128 
129 	public void setDocTypeLabel(String docTypeLabel) {
130 		this.docTypeLabel = docTypeLabel;
131 	}
132 
133 	public void setDocTypeHandlerUrl(String docTypeHandlerUrl) {
134 		this.docTypeHandlerUrl = docTypeHandlerUrl;
135 	}
136 
137 	public void setInitiatorWorkflowId(String initiatorEmplId) {
138 		this.initiatorWorkflowId = initiatorEmplId;
139 	}
140 
141 	public void setInitiatorEmailAddress(String initiatorEmailAddress) {
142 		this.initiatorEmailAddress = initiatorEmailAddress;
143 	}
144 
145 	public void setInitiatorName(String initiatorName) {
146 		this.initiatorName = initiatorName;
147 	}
148 
149 	public java.sql.Timestamp getDateCreated() {
150 		return dateCreated;
151 	}
152 
153 	public void setDateCreated(java.sql.Timestamp dateCreated) {
154 		this.dateCreated = dateCreated;
155 	}
156 
157 	public String getInitiatorNetworkId() {
158 		return initiatorNetworkId;
159 	}
160 
161 	public void setInitiatorNetworkId(String string) {
162 		initiatorNetworkId = string;
163 	}
164 
165 	public String getInitiatorFirstName() {
166 		return initiatorFirstName;
167 	}
168 
169 	public String getInitiatorLastName() {
170 		return initiatorLastName;
171 	}
172 
173 	public void setInitiatorFirstName(String initiatorFirstName) {
174 		this.initiatorFirstName = initiatorFirstName;
175 	}
176 
177 	public void setInitiatorLastName(String initiatorLastName) {
178 		this.initiatorLastName = initiatorLastName;
179 	}
180 
181 	public String getAppDocStatus() {
182 		return this.appDocStatus;
183 	}
184 
185 	public void setAppDocStatus(String appDocStatus) {
186 		this.appDocStatus = appDocStatus;
187 	}
188 
189     public String getDocRouteStatusCodeDesc() {
190         if (this.docRouteStatusCode == null || org.kuali.rice.kew.util.CodeTranslator.getRouteStatusLabel(docRouteStatusCode) == null || "".equalsIgnoreCase(org.kuali.rice.kew.util.CodeTranslator.getRouteStatusLabel(docRouteStatusCode))) {
191             return KEWConstants.UNKNOWN_STATUS;
192         } else {
193             return org.kuali.rice.kew.util.CodeTranslator.getRouteStatusLabel(docRouteStatusCode);
194         }
195     }
196 
197     public String getDocHandlerUrl() {
198         if (StringUtils.isBlank(getDocTypeHandlerUrl())) {
199             return "";
200         } else {
201             if (isUsingSuperUserSearch()) {
202                 return "SuperUser.do?command=displayFrame&documentId=" + this.getDocumentId();
203             } else {
204                 return this.getDocTypeHandlerUrl() + URL_SUFFIX + this.getDocumentId();
205             }
206         }
207     }
208 
209     public boolean isUsingSuperUserSearch() {
210     	return DocSearchCriteriaDTO.SUPER_USER_SEARCH_INDICATOR_STRING.equalsIgnoreCase(superUserSearch);
211     }
212 
213     public String getRowStyleClass() {
214         return rowStyleClass;
215     }
216 
217     public void setRowStyleClass(String rowStyleClass) {
218         this.rowStyleClass = rowStyleClass;
219     }
220 
221     public String getInitiatorTransposedName() {
222         return initiatorTransposedName;
223     }
224 
225     public void setInitiatorTransposedName(String initiatorTransposedName) {
226         this.initiatorTransposedName = initiatorTransposedName;
227     }
228 
229     /**
230      * Method for the JSP to use to pull in searchable attributes by name
231      * instead of by index location which is unreliable
232      *
233      * @param key Key of KeyValueSort trying to be retrieved
234      * @return  the matching KeyValueSort in list of searchable attributes or an empty KeyValueSort
235      */
236     public KeyValueSort getSearchableAttribute(String key) {
237     	KeyValueSort returnPair = new KeyValueSort("","","",null);
238     	if (key == null) {
239     		return returnPair;
240     	}
241         for (KeyValueSort searchableAttribute : searchableAttributes)
242         {
243             if (key.equals(searchableAttribute.getKey()))
244             {
245                 returnPair = searchableAttribute;
246                 break;
247             }
248         }
249     	return returnPair;
250     }
251 
252     public void addSearchableAttribute(KeyValueSort searchableAttribute) {
253     	searchableAttributes.add(searchableAttribute);
254     }
255 	/**
256 	 * @param searchableAttributes The searchableAttributes to set.
257 	 */
258 	public void setSearchableAttributes(List<KeyValueSort> searchableAttributes) {
259 		this.searchableAttributes = searchableAttributes;
260 	}
261 	/**
262 	 * @return Returns the searchableAttributes.
263 	 */
264 	public List<KeyValueSort> getSearchableAttributes() {
265 		return searchableAttributes;
266 	}
267 }