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