001    /*
002     * Copyright 2005-2007 The Kuali Foundation
003     *
004     *
005     * Licensed under the Educational Community License, Version 2.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/ecl2.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 org.kuali.rice.kew.docsearch;
018    
019    import org.apache.commons.lang.StringUtils;
020    import org.kuali.rice.kew.util.KEWConstants;
021    import org.kuali.rice.kew.web.KeyValueSort;
022    import org.kuali.rice.kew.web.RowStyleable;
023    
024    import java.io.Serializable;
025    import java.util.ArrayList;
026    import java.util.List;
027    
028    
029    /**
030     * Bean that representing a row displayed in a document search.
031     *
032     * @author Kuali Rice Team (rice.collab@kuali.org)
033     */
034    public class DocSearchDTO implements Serializable, RowStyleable {
035    
036            private static final long serialVersionUID = 7850758046316186962L;
037            private static final String URL_SUFFIX = "?" + KEWConstants.COMMAND_PARAMETER + "=" + KEWConstants.DOCSEARCH_COMMAND + "&" + KEWConstants.ROUTEHEADER_ID_PARAMETER + "=";
038    
039            private Long routeHeaderId;
040            private String docRouteStatusCode;
041            private java.sql.Timestamp dateCreated;
042            private String documentTitle;
043            private String activeIndicatorCode;
044            private String docTypeName;
045            private String docTypeLabel;
046            private String initiatorNetworkId;
047            private String initiatorWorkflowId;
048            private String initiatorName;
049            private String initiatorEmailAddress;
050            private String initiatorLastName;
051            private String initiatorFirstName;
052        private String initiatorTransposedName;
053            private String docTypeHandlerUrl;
054            private String rowStyleClass;
055            private String superUserSearch;
056            private String appDocStatus;
057    
058            private List<KeyValueSort> searchableAttributes = new ArrayList<KeyValueSort>();
059    
060            public DocSearchDTO() {
061            }
062    
063            public String getSuperUserSearch() {
064            return superUserSearch;
065        }
066        public void setSuperUserSearch(String superUserSearch) {
067            this.superUserSearch = superUserSearch;
068        }
069            public String getDocRouteStatusCode() {
070                    return docRouteStatusCode;
071            }
072    
073            public String getDocumentTitle() {
074                    return documentTitle;
075            }
076    
077            public Long getRouteHeaderId() {
078                    return routeHeaderId;
079            }
080    
081            public void setDocRouteStatusCode(String docRouteStatusCode) {
082                    this.docRouteStatusCode = docRouteStatusCode;
083            }
084    
085            public void setDocumentTitle(String documentTitle) {
086                    this.documentTitle = documentTitle;
087            }
088    
089            public void setRouteHeaderId(Long routeHeaderId) {
090                    this.routeHeaderId = routeHeaderId;
091            }
092    
093            public String getActiveIndicatorCode() {
094                    return activeIndicatorCode;
095            }
096    
097            public String getDocTypeName() {
098        return docTypeName;
099      }
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&routeHeaderId=" + this.getRouteHeaderId().toString();
203                } else {
204                    return this.getDocTypeHandlerUrl() + URL_SUFFIX + this.getRouteHeaderId().toString();
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    }