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