1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.web.struts.form; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.apache.struts.action.ActionErrors; |
20 | |
import org.apache.struts.action.ActionMapping; |
21 | |
import org.apache.struts.upload.FormFile; |
22 | |
import org.kuali.rice.core.api.services.CoreApiServiceLocator; |
23 | |
import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator; |
24 | |
import org.kuali.rice.core.util.RiceKeyConstants; |
25 | |
import org.kuali.rice.core.web.format.NoOpStringFormatter; |
26 | |
import org.kuali.rice.core.web.format.TimestampAMPMFormatter; |
27 | |
import org.kuali.rice.kew.exception.WorkflowException; |
28 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
29 | |
import org.kuali.rice.kim.bo.Person; |
30 | |
import org.kuali.rice.kim.util.KimConstants; |
31 | |
import org.kuali.rice.kns.bo.AdHocRoutePerson; |
32 | |
import org.kuali.rice.kns.bo.AdHocRouteWorkgroup; |
33 | |
import org.kuali.rice.kns.bo.Note; |
34 | |
import org.kuali.rice.kns.datadictionary.DataDictionary; |
35 | |
import org.kuali.rice.kns.datadictionary.DocumentEntry; |
36 | |
import org.kuali.rice.kns.datadictionary.HeaderNavigation; |
37 | |
import org.kuali.rice.kns.document.Document; |
38 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
39 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
40 | |
import org.kuali.rice.kns.service.ModuleService; |
41 | |
import org.kuali.rice.kns.service.SessionDocumentService; |
42 | |
import org.kuali.rice.kns.util.GlobalVariables; |
43 | |
import org.kuali.rice.kns.util.KNSConstants; |
44 | |
import org.kuali.rice.kns.util.MessageMap; |
45 | |
import org.kuali.rice.kns.util.ObjectUtils; |
46 | |
import org.kuali.rice.kns.util.UrlFactory; |
47 | |
import org.kuali.rice.kns.util.WebUtils; |
48 | |
import org.kuali.rice.kns.web.derivedvaluesetter.DerivedValuesSetter; |
49 | |
import org.kuali.rice.kns.web.ui.HeaderField; |
50 | |
import org.kuali.rice.kns.workflow.service.KualiWorkflowDocument; |
51 | |
import org.springframework.util.AutoPopulatingList; |
52 | |
|
53 | |
import javax.servlet.http.HttpServletRequest; |
54 | |
import java.io.Serializable; |
55 | |
import java.util.ArrayList; |
56 | |
import java.util.HashMap; |
57 | |
import java.util.List; |
58 | |
import java.util.Map; |
59 | |
import java.util.Properties; |
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
public abstract class KualiDocumentFormBase extends KualiForm implements Serializable { |
66 | |
private static final long serialVersionUID = 916061016201941821L; |
67 | |
|
68 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(KualiDocumentFormBase.class); |
69 | |
|
70 | |
private Document document; |
71 | 0 | private String annotation = ""; |
72 | |
private String command; |
73 | |
|
74 | |
private String docId; |
75 | |
private String docTypeName; |
76 | |
|
77 | |
private List<String> additionalScriptFiles; |
78 | |
|
79 | |
private AdHocRoutePerson newAdHocRoutePerson; |
80 | |
private AdHocRouteWorkgroup newAdHocRouteWorkgroup; |
81 | |
|
82 | |
private Note newNote; |
83 | |
|
84 | |
|
85 | |
private List boNotes; |
86 | |
|
87 | 0 | protected FormFile attachmentFile = new BlankFormFile(); |
88 | |
|
89 | |
protected Map editingMode; |
90 | |
protected Map documentActions; |
91 | |
protected boolean suppressAllButtons; |
92 | |
|
93 | |
protected Map adHocActionRequestCodes; |
94 | |
private boolean returnToActionList; |
95 | |
|
96 | |
|
97 | |
private String formKey; |
98 | |
private String docNum; |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
private MessageMap errorMapFromPreviousRequest; |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
@Override |
111 | |
public void addRequiredNonEditableProperties(){ |
112 | 0 | super.addRequiredNonEditableProperties(); |
113 | 0 | registerRequiredNonEditableProperty(KNSConstants.DOCUMENT_TYPE_NAME); |
114 | 0 | registerRequiredNonEditableProperty(KNSConstants.FORM_KEY); |
115 | 0 | registerRequiredNonEditableProperty(KNSConstants.NEW_NOTE_NOTE_TYPE_CODE); |
116 | 0 | } |
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
public String getDocNum() { |
122 | 0 | return this.docNum; |
123 | |
} |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public void setDocNum(String docNum) { |
130 | 0 | this.docNum = docNum; |
131 | 0 | } |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
@SuppressWarnings("unchecked") |
137 | |
public KualiDocumentFormBase() { |
138 | 0 | super(); |
139 | |
|
140 | 0 | instantiateDocument(); |
141 | 0 | newNote = new Note(); |
142 | 0 | this.editingMode = new HashMap(); |
143 | |
|
144 | 0 | this.additionalScriptFiles = new AutoPopulatingList<String>(String.class); |
145 | |
|
146 | |
|
147 | 0 | newAdHocRoutePerson = new AdHocRoutePerson(); |
148 | |
|
149 | |
|
150 | 0 | newAdHocRouteWorkgroup = new AdHocRouteWorkgroup(); |
151 | |
|
152 | |
|
153 | 0 | setFormatterType("document.documentHeader.note.finDocNotePostedDttmStamp", TimestampAMPMFormatter.class); |
154 | 0 | setFormatterType("document.documentHeader.note.attachment.finDocNotePostedDttmStamp", TimestampAMPMFormatter.class); |
155 | |
|
156 | |
|
157 | 0 | setFormatterType("document.documentHeader.boNote.notePostedTimestamp",TimestampAMPMFormatter.class); |
158 | 0 | setFormatterType("document.documentBusinessObject.boNote.notePostedTimestamp",TimestampAMPMFormatter.class); |
159 | |
|
160 | 0 | setFormatterType("editingMode", NoOpStringFormatter.class); |
161 | 0 | setFormatterType("editableAccounts", NoOpStringFormatter.class); |
162 | |
|
163 | 0 | setDocumentActions(new HashMap()); |
164 | 0 | suppressAllButtons = false; |
165 | |
|
166 | 0 | initializeHeaderNavigationTabs(); |
167 | 0 | } |
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
@Override |
173 | |
public void populate(HttpServletRequest request) { |
174 | 0 | super.populate(request); |
175 | |
|
176 | 0 | KualiWorkflowDocument workflowDocument = null; |
177 | |
|
178 | 0 | if (hasDocumentId()) { |
179 | |
|
180 | |
|
181 | |
try { |
182 | 0 | SessionDocumentService sessionDocumentService = KNSServiceLocatorWeb.getSessionDocumentService(); |
183 | 0 | workflowDocument = sessionDocumentService.getDocumentFromSession( GlobalVariables.getUserSession(), getDocument().getDocumentNumber()); |
184 | 0 | if ( workflowDocument == null) |
185 | |
{ |
186 | |
|
187 | |
|
188 | 0 | Person person = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(KNSConstants.SYSTEM_USER); |
189 | 0 | workflowDocument = KNSServiceLocatorWeb.getWorkflowDocumentService().loadWorkflowDocument(getDocument().getDocumentNumber(), person); |
190 | 0 | sessionDocumentService.addDocumentToUserSession(GlobalVariables.getUserSession(), workflowDocument); |
191 | 0 | if (workflowDocument == null) |
192 | |
{ |
193 | 0 | throw new WorkflowException("Unable to retrieve workflow document # " + getDocument().getDocumentNumber() + " from workflow document service createWorkflowDocument"); |
194 | |
} |
195 | |
else |
196 | |
{ |
197 | 0 | LOG.debug("Retrieved workflow Document ID: " + workflowDocument.getDocumentId()); |
198 | |
} |
199 | |
} |
200 | |
|
201 | 0 | getDocument().getDocumentHeader().setWorkflowDocument(workflowDocument); |
202 | 0 | } catch (WorkflowException e) { |
203 | 0 | LOG.warn("Error while instantiating workflowDoc", e); |
204 | 0 | throw new RuntimeException("error populating documentHeader.workflowDocument", e); |
205 | 0 | } |
206 | |
} |
207 | 0 | if (workflowDocument != null) { |
208 | |
|
209 | 0 | populateHeaderFields(workflowDocument); |
210 | |
} |
211 | 0 | } |
212 | |
|
213 | |
protected String getPersonInquiryUrlLink(Person user, String linkBody) { |
214 | 0 | StringBuffer urlBuffer = new StringBuffer(); |
215 | |
|
216 | 0 | if(user != null && StringUtils.isNotEmpty(linkBody) ) { |
217 | 0 | ModuleService moduleService = KNSServiceLocatorWeb.getKualiModuleService().getResponsibleModuleService(Person.class); |
218 | 0 | Map<String, String[]> parameters = new HashMap<String, String[]>(); |
219 | 0 | parameters.put(KimConstants.AttributeConstants.PRINCIPAL_ID, new String[] { user.getPrincipalId() }); |
220 | 0 | String inquiryUrl = moduleService.getExternalizableBusinessObjectInquiryUrl(Person.class, parameters); |
221 | 0 | if(!StringUtils.equals(KimConstants.EntityTypes.SYSTEM, user.getEntityTypeCode())){ |
222 | 0 | urlBuffer.append("<a href='"); |
223 | 0 | urlBuffer.append(inquiryUrl); |
224 | 0 | urlBuffer.append("' "); |
225 | 0 | urlBuffer.append("target='_blank'"); |
226 | 0 | urlBuffer.append("title='Person Inquiry'>"); |
227 | 0 | urlBuffer.append(linkBody); |
228 | 0 | urlBuffer.append("</a>"); |
229 | |
} else{ |
230 | 0 | urlBuffer.append(linkBody); |
231 | |
} |
232 | |
} |
233 | |
|
234 | 0 | return urlBuffer.toString(); |
235 | |
} |
236 | |
|
237 | |
protected String getDocumentHandlerUrl(String documentId) { |
238 | 0 | Properties parameters = new Properties(); |
239 | 0 | parameters.put(KNSConstants.PARAMETER_DOC_ID, documentId); |
240 | 0 | parameters.put(KNSConstants.PARAMETER_COMMAND, KNSConstants.METHOD_DISPLAY_DOC_SEARCH_VIEW); |
241 | 0 | return UrlFactory.parameterizeUrl(KNSServiceLocator.getKualiConfigurationService().getPropertyString(KNSConstants.WORKFLOW_URL_KEY) + "/" + KNSConstants.DOC_HANDLER_ACTION, parameters); |
242 | |
} |
243 | |
|
244 | |
protected String buildHtmlLink(String url, String linkBody) { |
245 | 0 | StringBuffer urlBuffer = new StringBuffer(); |
246 | |
|
247 | 0 | if(StringUtils.isNotEmpty(url) && StringUtils.isNotEmpty(linkBody) ) { |
248 | 0 | urlBuffer.append("<a href='").append(url).append("'>").append(linkBody).append("</a>"); |
249 | |
} |
250 | |
|
251 | 0 | return urlBuffer.toString(); |
252 | |
} |
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
public void populateHeaderFields(KualiWorkflowDocument workflowDocument) { |
261 | 0 | getDocInfo().clear(); |
262 | 0 | getDocInfo().addAll(getStandardHeaderFields(workflowDocument)); |
263 | 0 | } |
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
protected List<HeaderField> getStandardHeaderFields(KualiWorkflowDocument workflowDocument) { |
274 | 0 | List<HeaderField> headerFields = new ArrayList<HeaderField>(); |
275 | 0 | setNumColumns(2); |
276 | |
|
277 | 0 | HeaderField docTemplateNumber = null; |
278 | 0 | if ((ObjectUtils.isNotNull(getDocument())) && (ObjectUtils.isNotNull(getDocument().getDocumentHeader())) && (StringUtils.isNotBlank(getDocument().getDocumentHeader().getDocumentTemplateNumber()))) { |
279 | 0 | String templateDocumentNumber = getDocument().getDocumentHeader().getDocumentTemplateNumber(); |
280 | 0 | docTemplateNumber = new HeaderField(KNSConstants.DocumentFormHeaderFieldIds.DOCUMENT_TEMPLATE_NUMBER, "DataDictionary.DocumentHeader.attributes.documentTemplateNumber", |
281 | |
templateDocumentNumber, buildHtmlLink(getDocumentHandlerUrl(templateDocumentNumber), templateDocumentNumber)); |
282 | |
} |
283 | |
|
284 | 0 | HeaderField docNumber = new HeaderField("DataDictionary.DocumentHeader.attributes.documentNumber", workflowDocument != null? getDocument().getDocumentNumber() : null); |
285 | 0 | docNumber.setId(KNSConstants.DocumentFormHeaderFieldIds.DOCUMENT_NUMBER); |
286 | 0 | HeaderField docStatus = new HeaderField("DataDictionary.AttributeReferenceDummy.attributes.workflowDocumentStatus", workflowDocument != null? workflowDocument.getStatusDisplayValue() : null); |
287 | 0 | docStatus.setId(KNSConstants.DocumentFormHeaderFieldIds.DOCUMENT_WORKFLOW_STATUS); |
288 | 0 | String initiatorNetworkId = null; |
289 | 0 | Person user = null; |
290 | 0 | if (workflowDocument != null) { |
291 | 0 | if (getInitiator() == null) { |
292 | 0 | LOG.warn("User Not Found while attempting to build inquiry link for document header fields"); |
293 | |
} else { |
294 | 0 | user = getInitiator(); |
295 | 0 | initiatorNetworkId = getInitiator().getPrincipalName(); |
296 | |
} |
297 | |
} |
298 | 0 | String inquiryUrl = getPersonInquiryUrlLink(user, workflowDocument != null? initiatorNetworkId:null); |
299 | |
|
300 | 0 | HeaderField docInitiator = new HeaderField(KNSConstants.DocumentFormHeaderFieldIds.DOCUMENT_INITIATOR, "DataDictionary.AttributeReferenceDummy.attributes.initiatorNetworkId", |
301 | |
workflowDocument != null? initiatorNetworkId : null, workflowDocument != null? inquiryUrl : null); |
302 | |
|
303 | 0 | String createDateStr = null; |
304 | 0 | if(workflowDocument != null && workflowDocument.getCreateDate() != null) { |
305 | 0 | createDateStr = CoreApiServiceLocator.getDateTimeService().toString(workflowDocument.getCreateDate(), "hh:mm a MM/dd/yyyy"); |
306 | |
} |
307 | |
|
308 | 0 | HeaderField docCreateDate = new HeaderField("DataDictionary.AttributeReferenceDummy.attributes.createDate", createDateStr); |
309 | 0 | docCreateDate.setId(KNSConstants.DocumentFormHeaderFieldIds.DOCUMENT_CREATE_DATE); |
310 | 0 | if (ObjectUtils.isNotNull(docTemplateNumber)) { |
311 | 0 | setNumColumns(3); |
312 | |
} |
313 | |
|
314 | 0 | headerFields.add(docNumber); |
315 | 0 | headerFields.add(docStatus); |
316 | 0 | if (ObjectUtils.isNotNull(docTemplateNumber)) { |
317 | 0 | headerFields.add(docTemplateNumber); |
318 | |
} |
319 | 0 | headerFields.add(docInitiator); |
320 | 0 | headerFields.add(docCreateDate); |
321 | 0 | if (ObjectUtils.isNotNull(docTemplateNumber)) { |
322 | |
|
323 | 0 | headerFields.add(HeaderField.EMPTY_FIELD); |
324 | |
} |
325 | 0 | return headerFields; |
326 | |
} |
327 | |
|
328 | |
|
329 | |
|
330 | |
|
331 | |
|
332 | |
@Override |
333 | |
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { |
334 | |
|
335 | 0 | setAnnotation(StringUtils.stripToNull(getAnnotation())); |
336 | 0 | int diff = StringUtils.defaultString(getAnnotation()).length() - KNSConstants.DOCUMENT_ANNOTATION_MAX_LENGTH; |
337 | 0 | if (diff > 0) { |
338 | 0 | GlobalVariables.getMessageMap().putError("annotation", RiceKeyConstants.ERROR_DOCUMENT_ANNOTATION_MAX_LENGTH_EXCEEDED, new String[] { Integer.toString(KNSConstants.DOCUMENT_ANNOTATION_MAX_LENGTH), Integer.toString(diff) }); |
339 | |
} |
340 | 0 | return super.validate(mapping, request); |
341 | |
} |
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | |
final public boolean isFormDocumentInitialized() { |
347 | 0 | boolean initialized = false; |
348 | |
|
349 | 0 | if (document != null) { |
350 | 0 | if (document.getDocumentHeader() != null) { |
351 | 0 | initialized = document.getDocumentHeader().hasWorkflowDocument(); |
352 | |
} |
353 | |
} |
354 | |
|
355 | 0 | return initialized; |
356 | |
} |
357 | |
|
358 | |
|
359 | |
|
360 | |
|
361 | |
|
362 | |
|
363 | |
@SuppressWarnings("unchecked") |
364 | |
public Map getEditingMode() { |
365 | 0 | return editingMode; |
366 | |
} |
367 | |
|
368 | |
|
369 | |
|
370 | |
|
371 | |
@SuppressWarnings("unchecked") |
372 | |
public void setEditingMode(Map editingMode) { |
373 | 0 | this.editingMode = editingMode; |
374 | 0 | } |
375 | |
|
376 | |
|
377 | |
|
378 | |
|
379 | |
@SuppressWarnings("unchecked") |
380 | |
public Map getDocumentActions() { |
381 | 0 | return this.documentActions; |
382 | |
} |
383 | |
|
384 | |
|
385 | |
|
386 | |
|
387 | |
@SuppressWarnings("unchecked") |
388 | |
public void setDocumentActions(Map documentActions) { |
389 | 0 | this.documentActions = documentActions; |
390 | 0 | } |
391 | |
|
392 | |
|
393 | |
|
394 | |
|
395 | |
|
396 | |
|
397 | |
@SuppressWarnings("unchecked") |
398 | |
public void setAdHocActionRequestCodes(Map adHocActionRequestCodes) { |
399 | 0 | this.adHocActionRequestCodes = adHocActionRequestCodes; |
400 | 0 | } |
401 | |
|
402 | |
|
403 | |
|
404 | |
|
405 | |
@SuppressWarnings("unchecked") |
406 | |
public Map getAdHocActionRequestCodes() { |
407 | |
|
408 | |
|
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
|
423 | 0 | return adHocActionRequestCodes; |
424 | |
} |
425 | |
|
426 | |
|
427 | |
|
428 | |
|
429 | |
|
430 | |
public List<AdHocRoutePerson> getAdHocRoutePersons() { |
431 | 0 | return document.getAdHocRoutePersons(); |
432 | |
} |
433 | |
|
434 | |
|
435 | |
|
436 | |
|
437 | |
|
438 | |
public FormFile getAttachmentFile() { |
439 | 0 | return attachmentFile; |
440 | |
} |
441 | |
|
442 | |
|
443 | |
|
444 | |
|
445 | |
public void setAttachmentFile(FormFile attachmentFile) { |
446 | 0 | this.attachmentFile = attachmentFile; |
447 | 0 | } |
448 | |
|
449 | |
|
450 | |
|
451 | |
|
452 | |
|
453 | |
|
454 | |
|
455 | |
public void setAdHocRoutePersons(List<AdHocRoutePerson> adHocRouteRecipients) { |
456 | 0 | document.setAdHocRoutePersons(adHocRouteRecipients); |
457 | 0 | } |
458 | |
|
459 | |
|
460 | |
|
461 | |
|
462 | |
|
463 | |
|
464 | |
public List<AdHocRouteWorkgroup> getAdHocRouteWorkgroups() { |
465 | 0 | return document.getAdHocRouteWorkgroups(); |
466 | |
} |
467 | |
|
468 | |
|
469 | |
|
470 | |
|
471 | |
|
472 | |
|
473 | |
public void setAdHocRouteWorkgroups(List<AdHocRouteWorkgroup> adHocRouteWorkgroups) { |
474 | 0 | document.setAdHocRouteWorkgroups(adHocRouteWorkgroups); |
475 | 0 | } |
476 | |
|
477 | |
|
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
public AdHocRoutePerson getAdHocRoutePerson(int index) { |
484 | 0 | while (getAdHocRoutePersons().size() <= index) { |
485 | 0 | getAdHocRoutePersons().add(new AdHocRoutePerson()); |
486 | |
} |
487 | 0 | return getAdHocRoutePersons().get(index); |
488 | |
} |
489 | |
|
490 | |
|
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
public AdHocRouteWorkgroup getAdHocRouteWorkgroup(int index) { |
497 | 0 | while (getAdHocRouteWorkgroups().size() <= index) { |
498 | 0 | getAdHocRouteWorkgroups().add(new AdHocRouteWorkgroup()); |
499 | |
} |
500 | 0 | return getAdHocRouteWorkgroups().get(index); |
501 | |
} |
502 | |
|
503 | |
|
504 | |
|
505 | |
|
506 | |
public AdHocRoutePerson getNewAdHocRoutePerson() { |
507 | 0 | return newAdHocRoutePerson; |
508 | |
} |
509 | |
|
510 | |
|
511 | |
|
512 | |
|
513 | |
|
514 | |
|
515 | |
public void setNewAdHocRoutePerson(AdHocRoutePerson newAdHocRoutePerson) { |
516 | 0 | this.newAdHocRoutePerson = newAdHocRoutePerson; |
517 | 0 | } |
518 | |
|
519 | |
|
520 | |
|
521 | |
|
522 | |
public AdHocRouteWorkgroup getNewAdHocRouteWorkgroup() { |
523 | 0 | return newAdHocRouteWorkgroup; |
524 | |
} |
525 | |
|
526 | |
|
527 | |
|
528 | |
|
529 | |
|
530 | |
|
531 | |
public void setNewAdHocRouteWorkgroup(AdHocRouteWorkgroup newAdHocRouteWorkgroup) { |
532 | 0 | this.newAdHocRouteWorkgroup = newAdHocRouteWorkgroup; |
533 | 0 | } |
534 | |
|
535 | |
|
536 | |
|
537 | |
|
538 | |
public Document getDocument() { |
539 | 0 | return document; |
540 | |
} |
541 | |
|
542 | |
|
543 | |
|
544 | |
|
545 | |
public void setDocument(Document document) { |
546 | 0 | this.document = document; |
547 | 0 | if(document != null && StringUtils.isNotEmpty(document.getDocumentNumber())) { |
548 | 0 | populateHeaderFields(document.getDocumentHeader().getWorkflowDocument()); |
549 | |
} |
550 | 0 | } |
551 | |
|
552 | |
|
553 | |
|
554 | |
|
555 | |
public KualiWorkflowDocument getWorkflowDocument() { |
556 | 0 | return getDocument().getDocumentHeader().getWorkflowDocument(); |
557 | |
} |
558 | |
|
559 | |
|
560 | |
|
561 | |
|
562 | |
|
563 | |
public boolean isHasWorkflowDocument() { |
564 | 0 | if ( getDocument() == null || getDocument().getDocumentHeader() == null ) { |
565 | 0 | return false; |
566 | |
} |
567 | 0 | return getDocument().getDocumentHeader().hasWorkflowDocument(); |
568 | |
} |
569 | |
|
570 | |
|
571 | |
|
572 | |
|
573 | |
public boolean isUserDocumentInitiator() { |
574 | 0 | if (getWorkflowDocument() != null) { |
575 | 0 | return getWorkflowDocument().getRouteHeader().getInitiatorPrincipalId().equalsIgnoreCase( |
576 | |
GlobalVariables.getUserSession().getPrincipalId()); |
577 | |
} |
578 | 0 | return false; |
579 | |
} |
580 | |
|
581 | |
public Person getInitiator() { |
582 | 0 | String initiatorPrincipalId = getWorkflowDocument().getRouteHeader().getInitiatorPrincipalId(); |
583 | 0 | return KimApiServiceLocator.getPersonService().getPerson(initiatorPrincipalId); |
584 | |
} |
585 | |
|
586 | |
|
587 | |
|
588 | |
|
589 | |
public boolean isDocumentEnRoute() { |
590 | 0 | return getWorkflowDocument().stateIsEnroute(); |
591 | |
} |
592 | |
|
593 | |
|
594 | |
|
595 | |
|
596 | |
public void setAnnotation(String annotation) { |
597 | 0 | this.annotation = annotation; |
598 | 0 | } |
599 | |
|
600 | |
|
601 | |
|
602 | |
|
603 | |
public String getAnnotation() { |
604 | 0 | return annotation; |
605 | |
} |
606 | |
|
607 | |
|
608 | |
|
609 | |
|
610 | |
public String getCommand() { |
611 | 0 | return command; |
612 | |
} |
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
public void setCommand(String command) { |
620 | 0 | this.command = command; |
621 | 0 | } |
622 | |
|
623 | |
|
624 | |
|
625 | |
|
626 | |
public String getDocId() { |
627 | 0 | return docId; |
628 | |
} |
629 | |
|
630 | |
|
631 | |
|
632 | |
|
633 | |
|
634 | |
|
635 | |
public void setDocId(String docId) { |
636 | 0 | this.docId = docId; |
637 | 0 | } |
638 | |
|
639 | |
|
640 | |
|
641 | |
|
642 | |
|
643 | |
|
644 | |
public String getDocTypeName() { |
645 | 0 | return docTypeName; |
646 | |
} |
647 | |
|
648 | |
|
649 | |
|
650 | |
|
651 | |
|
652 | |
|
653 | |
public void setDocTypeName(String docTypeName) { |
654 | 0 | this.docTypeName = docTypeName; |
655 | 0 | } |
656 | |
|
657 | |
|
658 | |
|
659 | |
|
660 | |
|
661 | |
|
662 | |
public String getInitiatorNetworkId() { |
663 | 0 | return this.getWorkflowDocument().getRouteHeader().getInitiatorPrincipalId(); |
664 | |
} |
665 | |
|
666 | |
|
667 | |
|
668 | |
|
669 | |
|
670 | |
|
671 | |
public final boolean isSuppressAllButtons() { |
672 | 0 | return suppressAllButtons; |
673 | |
} |
674 | |
|
675 | |
|
676 | |
|
677 | |
|
678 | |
|
679 | |
|
680 | |
public final void setSuppressAllButtons(boolean suppressAllButtons) { |
681 | 0 | this.suppressAllButtons = suppressAllButtons; |
682 | 0 | } |
683 | |
|
684 | |
|
685 | |
|
686 | |
|
687 | |
|
688 | |
public boolean hasDocumentId() { |
689 | 0 | boolean hasDocId = false; |
690 | |
|
691 | 0 | Document d = getDocument(); |
692 | 0 | if (d != null) { |
693 | 0 | String docHeaderId = d.getDocumentNumber(); |
694 | |
|
695 | 0 | hasDocId = StringUtils.isNotBlank(docHeaderId); |
696 | |
} |
697 | |
|
698 | 0 | return hasDocId; |
699 | |
} |
700 | |
|
701 | |
|
702 | |
|
703 | |
|
704 | |
|
705 | |
|
706 | |
|
707 | |
public void setReturnToActionList(boolean returnToActionList) { |
708 | 0 | this.returnToActionList = returnToActionList; |
709 | 0 | } |
710 | |
|
711 | |
public boolean isReturnToActionList() { |
712 | 0 | return returnToActionList; |
713 | |
} |
714 | |
|
715 | |
public List<String> getAdditionalScriptFiles() { |
716 | 0 | return additionalScriptFiles; |
717 | |
} |
718 | |
|
719 | |
public void setAdditionalScriptFiles(List<String> additionalScriptFiles) { |
720 | 0 | this.additionalScriptFiles = additionalScriptFiles; |
721 | 0 | } |
722 | |
|
723 | |
public void setAdditionalScriptFile( int index, String scriptFile ) { |
724 | 0 | additionalScriptFiles.set( index, scriptFile ); |
725 | 0 | } |
726 | |
|
727 | |
public String getAdditionalScriptFile( int index ) { |
728 | 0 | return additionalScriptFiles.get( index ); |
729 | |
} |
730 | |
|
731 | |
public Note getNewNote() { |
732 | 0 | return newNote; |
733 | |
} |
734 | |
|
735 | |
public void setNewNote(Note newNote) { |
736 | 0 | this.newNote = newNote; |
737 | 0 | } |
738 | |
|
739 | |
|
740 | |
|
741 | |
|
742 | |
|
743 | |
@SuppressWarnings("unchecked") |
744 | |
public List getBoNotes() { |
745 | 0 | return boNotes; |
746 | |
} |
747 | |
|
748 | |
|
749 | |
|
750 | |
|
751 | |
|
752 | |
@SuppressWarnings("unchecked") |
753 | |
public void setBoNotes(List boNotes) { |
754 | 0 | this.boNotes = boNotes; |
755 | 0 | } |
756 | |
|
757 | |
public String getFormKey() { |
758 | 0 | return this.formKey; |
759 | |
} |
760 | |
|
761 | |
public void setFormKey(String formKey) { |
762 | 0 | this.formKey = formKey; |
763 | 0 | } |
764 | |
|
765 | |
|
766 | |
|
767 | |
|
768 | |
|
769 | |
|
770 | |
@Override |
771 | |
public void reset(ActionMapping mapping, HttpServletRequest request) { |
772 | 0 | super.reset(mapping, request); |
773 | 0 | this.setMethodToCall(null); |
774 | 0 | this.setRefreshCaller(null); |
775 | 0 | this.setAnchor(null); |
776 | 0 | this.setCurrentTabIndex(0); |
777 | |
|
778 | 0 | } |
779 | |
|
780 | |
|
781 | |
|
782 | |
|
783 | |
|
784 | |
|
785 | |
|
786 | |
@Override |
787 | |
protected void customInitMaxUploadSizes() { |
788 | 0 | super.customInitMaxUploadSizes(); |
789 | 0 | addMaxUploadSize(CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(KNSConstants.KNS_NAMESPACE, KNSConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, KNSConstants.ATTACHMENT_MAX_FILE_SIZE_PARM_NM)); |
790 | 0 | } |
791 | |
|
792 | |
|
793 | |
|
794 | |
|
795 | |
|
796 | |
|
797 | |
|
798 | |
|
799 | |
|
800 | |
@Override |
801 | |
public boolean shouldPropertyBePopulatedInForm(String requestParameterName, HttpServletRequest request) { |
802 | 0 | for ( String prefix : KNSConstants.ALWAYS_VALID_PARAMETER_PREFIXES ) { |
803 | 0 | if (requestParameterName.startsWith(prefix)) { |
804 | 0 | return true; |
805 | |
} |
806 | |
} |
807 | |
|
808 | 0 | if (StringUtils.equalsIgnoreCase(getMethodToCall(), KNSConstants.DOC_HANDLER_METHOD)) { |
809 | 0 | return true; |
810 | |
} |
811 | 0 | if (WebUtils.isDocumentSession(getDocument(), this)) { |
812 | 0 | return isPropertyEditable(requestParameterName) || isPropertyNonEditableButRequired(requestParameterName); |
813 | |
} |
814 | 0 | return true; |
815 | |
} |
816 | |
|
817 | |
|
818 | |
|
819 | |
|
820 | |
|
821 | |
|
822 | |
@Override |
823 | |
public boolean shouldMethodToCallParameterBeUsed( |
824 | |
String methodToCallParameterName, |
825 | |
String methodToCallParameterValue, HttpServletRequest request) { |
826 | 0 | if (StringUtils.equals(methodToCallParameterName, KNSConstants.DISPATCH_REQUEST_PARAMETER) && |
827 | |
StringUtils.equals(methodToCallParameterValue, KNSConstants.DOC_HANDLER_METHOD)) { |
828 | 0 | return true; |
829 | |
} |
830 | 0 | return super.shouldMethodToCallParameterBeUsed(methodToCallParameterName, |
831 | |
methodToCallParameterValue, request); |
832 | |
} |
833 | |
|
834 | |
public MessageMap getMessageMapFromPreviousRequest() { |
835 | 0 | return this.errorMapFromPreviousRequest; |
836 | |
} |
837 | |
|
838 | |
public void setMessageMapFromPreviousRequest(MessageMap errorMapFromPreviousRequest) { |
839 | 0 | this.errorMapFromPreviousRequest = errorMapFromPreviousRequest; |
840 | 0 | } |
841 | |
|
842 | |
@Override |
843 | |
public void setDerivedValuesOnForm(HttpServletRequest request) { |
844 | 0 | super.setDerivedValuesOnForm(request); |
845 | |
|
846 | 0 | String docTypeName = getDocTypeName(); |
847 | 0 | if (StringUtils.isNotBlank(docTypeName)) { |
848 | 0 | DataDictionary dataDictionary = KNSServiceLocatorWeb.getDataDictionaryService().getDataDictionary(); |
849 | 0 | Class<? extends DerivedValuesSetter> derivedValuesSetterClass = dataDictionary.getDocumentEntry(docTypeName).getDerivedValuesSetterClass(); |
850 | 0 | if (derivedValuesSetterClass != null) { |
851 | 0 | DerivedValuesSetter derivedValuesSetter = null; |
852 | |
try { |
853 | 0 | derivedValuesSetter = derivedValuesSetterClass.newInstance(); |
854 | |
} |
855 | 0 | catch (Exception e) { |
856 | 0 | LOG.error("Unable to instantiate class " + derivedValuesSetterClass.getName(), e); |
857 | 0 | throw new RuntimeException("Unable to instantiate class " + derivedValuesSetterClass.getName(), e); |
858 | 0 | } |
859 | 0 | derivedValuesSetter.setDerivedValues(this, request); |
860 | |
} |
861 | |
} |
862 | 0 | } |
863 | |
|
864 | |
protected String getDefaultDocumentTypeName() { |
865 | 0 | return ""; |
866 | |
} |
867 | |
|
868 | |
|
869 | |
protected void instantiateDocument() { |
870 | 0 | if (document == null && StringUtils.isNotBlank(getDefaultDocumentTypeName())) { |
871 | 0 | Class<? extends Document> documentClass = getDocumentClass(); |
872 | |
try { |
873 | 0 | Document document = documentClass.newInstance(); |
874 | 0 | setDocument(document); |
875 | 0 | } catch (Exception e) { |
876 | 0 | LOG.error("Unable to instantiate document class " + documentClass.getName() + " document type " + getDefaultDocumentTypeName()); |
877 | 0 | throw new RuntimeException(e); |
878 | 0 | } |
879 | |
} |
880 | 0 | } |
881 | |
|
882 | |
|
883 | |
private Class<? extends Document> getDocumentClass() { |
884 | 0 | return KNSServiceLocatorWeb.getDataDictionaryService().getDocumentClassByTypeName(getDefaultDocumentTypeName()); |
885 | |
} |
886 | |
|
887 | |
|
888 | |
protected void initializeHeaderNavigationTabs() { |
889 | 0 | if (StringUtils.isNotBlank(getDefaultDocumentTypeName())) { |
890 | 0 | final DocumentEntry docEntry = KNSServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDocumentEntry(getDocumentClass().getName()); |
891 | 0 | final List<HeaderNavigation> navList = docEntry.getHeaderNavigationList(); |
892 | 0 | final HeaderNavigation[] list = new HeaderNavigation[navList.size()]; |
893 | 0 | super.setHeaderNavigationTabs(navList.toArray(list)); |
894 | |
} |
895 | 0 | } |
896 | |
} |