View Javadoc

1   /*
2    * Copyright 2005-2008 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.dto;
18  
19  import java.io.Serializable;
20  import java.util.ArrayList;
21  import java.util.Calendar;
22  import java.util.List;
23  
24  /**
25   * Transport object for the DocumentRouteHeaderValue.  Represents a document to the
26   * client programmer
27   *
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  public class RouteHeaderDTO implements Serializable {
31  
32      static final long serialVersionUID = -677289794727007572L;
33  
34      private Long routeHeaderId;
35      private String docRouteStatus;
36      private Calendar dateCreated;
37      private Calendar dateLastModified;
38      private Calendar dateApproved;
39      private Calendar dateFinalized;
40      private String docTitle;
41      private String appDocId;
42      private String initiatorPrincipalId;
43      private String routedByPrincipalId;
44      private Integer docRouteLevel;
45      private String currentRouteNodeNames;
46      private Integer docVersion;
47      private String docTypeName;
48      private String documentUrl;
49      private String appDocStatus;
50      private Calendar appDocStatusDate;
51      private boolean fyiRequested;
52      private boolean ackRequested;
53      private boolean approveRequested;
54      private boolean completeRequested;
55      private boolean userBlanketApprover;
56      private Long docTypeId;
57      private ValidActionsDTO validActions;
58  
59      private NoteDTO[] notes = null;
60      private NoteDTO[] notesToDelete = null;
61      
62  //    private String docStatusPolicy;
63  
64      /**
65       * Probably needs to be an array for web services
66       */
67      private List<KeyValueDTO> variables = new ArrayList<KeyValueDTO>();
68  
69      public RouteHeaderDTO() { }
70  
71      public String getCurrentRouteNodeNames() {
72          return currentRouteNodeNames;
73      }
74  
75      public void setCurrentRouteNodeNames(String currentRouteNodeNames) {
76          this.currentRouteNodeNames = currentRouteNodeNames;
77      }
78  
79      public String getAppDocId() {
80          return appDocId;
81      }
82  
83      public void setAppDocId(String appDocId) {
84          this.appDocId = appDocId;
85      }
86  
87      public Calendar getDateApproved() {
88          return dateApproved;
89      }
90  
91      public void setDateApproved(Calendar dateApproved) {
92          this.dateApproved = dateApproved;
93      }
94  
95      public Calendar getDateCreated() {
96          return dateCreated;
97      }
98  
99      public void setDateCreated(Calendar dateCreated) {
100         this.dateCreated = dateCreated;
101     }
102 
103     public Calendar getDateFinalized() {
104         return dateFinalized;
105     }
106 
107     public void setDateFinalized(Calendar dateFinalized) {
108         this.dateFinalized = dateFinalized;
109     }
110 
111     public Calendar getDateLastModified() {
112         return dateLastModified;
113     }
114 
115     public void setDateLastModified(Calendar dateLastModified) {
116         this.dateLastModified = dateLastModified;
117     }
118 
119     public Integer getDocRouteLevel() {
120         return docRouteLevel;
121     }
122 
123     public void setDocRouteLevel(Integer docRouteLevel) {
124         this.docRouteLevel = docRouteLevel;
125     }
126 
127     public String getDocRouteStatus() {
128         return docRouteStatus;
129     }
130 
131     public void setDocRouteStatus(String docRouteStatus) {
132         this.docRouteStatus = docRouteStatus;
133     }
134 
135     public String getAppDocStatus() {
136         return appDocStatus;
137     }
138 
139     public void setAppDocStatus(String appDocStatus) {
140         this.appDocStatus = appDocStatus;
141     }
142 
143     public Calendar getAppDocStatusDate() {
144         return appDocStatusDate;
145     }
146 
147     public void setAppDocStatusDate(Calendar date) {
148         this.appDocStatusDate = date;
149     }
150     
151 //    public String getDocStatusPolicy() {
152 //        return docStatusPolicy;
153 //    }
154 //
155 //    public void setDocStatusPolicy(String policy) {
156 //        this.docStatusPolicy = policy;
157 //    }
158 
159     public String getDocTitle() {
160         return docTitle;
161     }
162 
163     public void setDocTitle(String docTitle) {
164         this.docTitle = docTitle;
165     }
166 
167     /**
168      * @deprecated this is unreliable user docTypeId to retrieve document type
169      */
170     public String getDocTypeName() {
171         return docTypeName;
172     }
173 
174     /**
175      * @deprecated this is unreliable user docTypeId to retrieve document type
176      */
177     public void setDocTypeName(String docTypeName) {
178         this.docTypeName = docTypeName;
179     }
180 
181     public String getDocumentUrl() {
182         return documentUrl;
183     }
184 
185     public void setDocumentUrl(String documentUrl) {
186         this.documentUrl = documentUrl;
187     }
188 
189     public Integer getDocVersion() {
190         return docVersion;
191     }
192 
193     public void setDocVersion(Integer docVersion) {
194         this.docVersion = docVersion;
195     }
196 
197     public String getInitiatorPrincipalId() {
198 		return this.initiatorPrincipalId;
199 	}
200 
201 	public void setInitiatorPrincipalId(String initiatorPrincipalId) {
202 		this.initiatorPrincipalId = initiatorPrincipalId;
203 	}
204 
205 	public String getRoutedByPrincipalId() {
206 		return this.routedByPrincipalId;
207 	}
208 
209 	public void setRoutedByPrincipalId(String routedByPrincipalId) {
210 		this.routedByPrincipalId = routedByPrincipalId;
211 	}
212 
213 	public Long getRouteHeaderId() {
214         return routeHeaderId;
215     }
216 
217     public void setRouteHeaderId(Long routeHeaderId) {
218         this.routeHeaderId = routeHeaderId;
219     }
220     public boolean isAckRequested() {
221         return ackRequested;
222     }
223     public void setAckRequested(boolean ackRequested) {
224         this.ackRequested = ackRequested;
225     }
226     public boolean isApproveRequested() {
227         return approveRequested;
228     }
229     public void setApproveRequested(boolean approveRequested) {
230         this.approveRequested = approveRequested;
231     }
232     public boolean isCompleteRequested() {
233         return completeRequested;
234     }
235     public void setCompleteRequested(boolean completeRequested) {
236         this.completeRequested = completeRequested;
237     }
238     public boolean isFyiRequested() {
239         return fyiRequested;
240     }
241     public void setFyiRequested(boolean fyiRequested) {
242         this.fyiRequested = fyiRequested;
243     }
244     public boolean isUserBlanketApprover() {
245         return userBlanketApprover;
246     }
247     public void setUserBlanketApprover(boolean userBlanketApprover) {
248         this.userBlanketApprover = userBlanketApprover;
249     }
250 
251 
252     public Long getDocTypeId() {
253         return docTypeId;
254     }
255 
256     public void setDocTypeId(Long docTypeId) {
257         this.docTypeId = docTypeId;
258     }
259 
260 
261    //  ** Modify for adding notes to web service. Modify Date: April 7, 2006
262     public NoteDTO[] getNotes() {
263 		return notes;
264 	}
265 
266 	public void setNotes(NoteDTO[] notes) {
267 		this.notes = notes;
268 	}
269 
270 	public NoteDTO[] getNotesToDelete() {
271 		return notesToDelete;
272 	}
273 
274 	public void setNotesToDelete(NoteDTO[] notesToDelete) {
275 		this.notesToDelete = notesToDelete;
276 	}
277 	// ** Modify Ends
278 
279     private KeyValueDTO findVariable(String name) {
280     	for (KeyValueDTO kvp : variables) {
281             if (isEqual(kvp.getKey(), name)) {
282                 return kvp;
283             }
284         }
285         return null;
286     }
287     public String getVariable(String name) {
288         KeyValueDTO kvp = findVariable(name);
289         if (kvp == null) return null;
290         return kvp.getValue();
291     }
292 
293     public void setVariable(String name, String value) {
294         KeyValueDTO kvp = findVariable(name);
295         if (kvp == null) {
296             if (value == null) {
297                 return;
298             }
299             kvp = new KeyValueDTO();
300             kvp.setKey(name);
301             kvp.setValue(value);
302             variables.add(kvp);
303         } else {
304             // values do not need to be removed from the VO
305             // in fact they CAN'T be, as the DocumentRouteHeaderValue
306             // must observe the null value so the removal actually
307             // propagates (otherwise DocumentRouteHeaderValue can't
308             // guess what you wanted to remove...the alternative is
309             // to just reset all the vars wholesale but that requires
310             // a slightly more complicated implementation (to distinguish
311             // non-variable state in the state table) and is fraught
312             // with peril in general)
313             //if (value == null) {
314             //    LOG.error("Removing value: " + kvp.getKey() + "=" + kvp.getValue());
315             //    variables.remove(kvp);
316             //} else {
317                 kvp.setValue(value);
318             //}
319         }
320     }
321 
322     public List<KeyValueDTO> getVariables() {
323         return variables;
324     }
325 
326     public ValidActionsDTO getValidActions() {
327         return validActions;
328     }
329 
330     public void setValidActions(ValidActionsDTO validActions) {
331         this.validActions = validActions;
332     }
333     
334     private boolean isEqual(String a, String b) {
335         return ((a == null && b == null) || (a != null && a.equals(b)));
336     }
337 
338 }