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.api.util.RiceKeyConstants; |
24 | |
import org.kuali.rice.core.framework.services.CoreFrameworkServiceLocator; |
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.api.exception.WorkflowException; |
29 | |
import org.kuali.rice.kim.api.KimConstants; |
30 | |
import org.kuali.rice.kim.api.identity.Person; |
31 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
32 | |
import org.kuali.rice.kns.datadictionary.HeaderNavigation; |
33 | |
import org.kuali.rice.kns.datadictionary.KNSDocumentEntry; |
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.krad.document.Document; |
42 | |
import org.kuali.rice.krad.service.KRADServiceLocator; |
43 | |
import org.kuali.rice.krad.service.KRADServiceLocatorWeb; |
44 | |
import org.kuali.rice.krad.service.ModuleService; |
45 | |
import org.kuali.rice.krad.service.SessionDocumentService; |
46 | |
import org.kuali.rice.krad.util.GlobalVariables; |
47 | |
import org.kuali.rice.krad.util.KRADConstants; |
48 | |
import org.kuali.rice.krad.util.MessageMap; |
49 | |
import org.kuali.rice.krad.util.ObjectUtils; |
50 | |
import org.kuali.rice.krad.util.UrlFactory; |
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(KRADConstants.DOCUMENT_TYPE_NAME); |
114 | 0 | registerRequiredNonEditableProperty(KRADConstants.FORM_KEY); |
115 | 0 | registerRequiredNonEditableProperty(KRADConstants.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 | WorkflowDocument workflowDocument = null; |
177 | |
|
178 | 0 | if (hasDocumentId()) { |
179 | |
|
180 | |
|
181 | |
try { |
182 | 0 | SessionDocumentService sessionDocumentService = KRADServiceLocatorWeb.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(KRADConstants.SYSTEM_USER); |
189 | 0 | workflowDocument = KRADServiceLocatorWeb.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 = KRADServiceLocatorWeb.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(KRADConstants.PARAMETER_DOC_ID, documentId); |
240 | 0 | parameters.put(KRADConstants.PARAMETER_COMMAND, KRADConstants.METHOD_DISPLAY_DOC_SEARCH_VIEW); |
241 | 0 | return UrlFactory.parameterizeUrl( |
242 | |
KRADServiceLocator.getKualiConfigurationService().getPropertyValueAsString( |
243 | |
KRADConstants.WORKFLOW_URL_KEY) + "/" + KRADConstants.DOC_HANDLER_ACTION, parameters); |
244 | |
} |
245 | |
|
246 | |
protected String buildHtmlLink(String url, String linkBody) { |
247 | 0 | StringBuffer urlBuffer = new StringBuffer(); |
248 | |
|
249 | 0 | if(StringUtils.isNotEmpty(url) && StringUtils.isNotEmpty(linkBody) ) { |
250 | 0 | urlBuffer.append("<a href='").append(url).append("'>").append(linkBody).append("</a>"); |
251 | |
} |
252 | |
|
253 | 0 | return urlBuffer.toString(); |
254 | |
} |
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
|
260 | |
|
261 | |
|
262 | |
public void populateHeaderFields(WorkflowDocument workflowDocument) { |
263 | 0 | getDocInfo().clear(); |
264 | 0 | getDocInfo().addAll(getStandardHeaderFields(workflowDocument)); |
265 | 0 | } |
266 | |
|
267 | |
|
268 | |
|
269 | |
|
270 | |
|
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
protected List<HeaderField> getStandardHeaderFields(WorkflowDocument workflowDocument) { |
276 | 0 | List<HeaderField> headerFields = new ArrayList<HeaderField>(); |
277 | 0 | setNumColumns(2); |
278 | |
|
279 | 0 | HeaderField docTemplateNumber = null; |
280 | 0 | if ((ObjectUtils.isNotNull(getDocument())) && (ObjectUtils.isNotNull(getDocument().getDocumentHeader())) && (StringUtils.isNotBlank(getDocument().getDocumentHeader().getDocumentTemplateNumber()))) { |
281 | 0 | String templateDocumentNumber = getDocument().getDocumentHeader().getDocumentTemplateNumber(); |
282 | 0 | docTemplateNumber = new HeaderField(KRADConstants.DocumentFormHeaderFieldIds.DOCUMENT_TEMPLATE_NUMBER, "DataDictionary.DocumentHeader.attributes.documentTemplateNumber", |
283 | |
templateDocumentNumber, buildHtmlLink(getDocumentHandlerUrl(templateDocumentNumber), templateDocumentNumber)); |
284 | |
} |
285 | |
|
286 | 0 | HeaderField docNumber = new HeaderField("DataDictionary.DocumentHeader.attributes.documentNumber", workflowDocument != null? getDocument().getDocumentNumber() : null); |
287 | 0 | docNumber.setId(KRADConstants.DocumentFormHeaderFieldIds.DOCUMENT_NUMBER); |
288 | 0 | HeaderField docStatus = new HeaderField("DataDictionary.AttributeReferenceDummy.attributes.workflowDocumentStatus", workflowDocument != null? workflowDocument.getStatus().getLabel() : null); |
289 | 0 | docStatus.setId(KRADConstants.DocumentFormHeaderFieldIds.DOCUMENT_WORKFLOW_STATUS); |
290 | 0 | String initiatorNetworkId = null; |
291 | 0 | Person user = null; |
292 | 0 | if (workflowDocument != null) { |
293 | 0 | if (getInitiator() == null) { |
294 | 0 | LOG.warn("User Not Found while attempting to build inquiry link for document header fields"); |
295 | |
} else { |
296 | 0 | user = getInitiator(); |
297 | 0 | initiatorNetworkId = getInitiator().getPrincipalName(); |
298 | |
} |
299 | |
} |
300 | 0 | String inquiryUrl = getPersonInquiryUrlLink(user, workflowDocument != null? initiatorNetworkId:null); |
301 | |
|
302 | 0 | HeaderField docInitiator = new HeaderField(KRADConstants.DocumentFormHeaderFieldIds.DOCUMENT_INITIATOR, "DataDictionary.AttributeReferenceDummy.attributes.initiatorNetworkId", |
303 | |
workflowDocument != null? initiatorNetworkId : null, workflowDocument != null? inquiryUrl : null); |
304 | |
|
305 | 0 | String createDateStr = null; |
306 | 0 | if(workflowDocument != null && workflowDocument.getDateCreated() != null) { |
307 | 0 | createDateStr = CoreApiServiceLocator.getDateTimeService().toString(workflowDocument.getDateCreated().toDate(), "hh:mm a MM/dd/yyyy"); |
308 | |
} |
309 | |
|
310 | 0 | HeaderField docCreateDate = new HeaderField("DataDictionary.AttributeReferenceDummy.attributes.createDate", createDateStr); |
311 | 0 | docCreateDate.setId(KRADConstants.DocumentFormHeaderFieldIds.DOCUMENT_CREATE_DATE); |
312 | 0 | if (ObjectUtils.isNotNull(docTemplateNumber)) { |
313 | 0 | setNumColumns(3); |
314 | |
} |
315 | |
|
316 | 0 | headerFields.add(docNumber); |
317 | 0 | headerFields.add(docStatus); |
318 | 0 | if (ObjectUtils.isNotNull(docTemplateNumber)) { |
319 | 0 | headerFields.add(docTemplateNumber); |
320 | |
} |
321 | 0 | headerFields.add(docInitiator); |
322 | 0 | headerFields.add(docCreateDate); |
323 | 0 | if (ObjectUtils.isNotNull(docTemplateNumber)) { |
324 | |
|
325 | 0 | headerFields.add(HeaderField.EMPTY_FIELD); |
326 | |
} |
327 | 0 | return headerFields; |
328 | |
} |
329 | |
|
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
@Override |
335 | |
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { |
336 | |
|
337 | 0 | setAnnotation(StringUtils.stripToNull(getAnnotation())); |
338 | 0 | int diff = StringUtils.defaultString(getAnnotation()).length() - KRADConstants.DOCUMENT_ANNOTATION_MAX_LENGTH; |
339 | 0 | if (diff > 0) { |
340 | 0 | GlobalVariables.getMessageMap().putError("annotation", RiceKeyConstants.ERROR_DOCUMENT_ANNOTATION_MAX_LENGTH_EXCEEDED, new String[] { Integer.toString(KRADConstants.DOCUMENT_ANNOTATION_MAX_LENGTH), Integer.toString(diff) }); |
341 | |
} |
342 | 0 | return super.validate(mapping, request); |
343 | |
} |
344 | |
|
345 | |
|
346 | |
|
347 | |
|
348 | |
final public boolean isFormDocumentInitialized() { |
349 | 0 | boolean initialized = false; |
350 | |
|
351 | 0 | if (document != null) { |
352 | 0 | if (document.getDocumentHeader() != null) { |
353 | 0 | initialized = document.getDocumentHeader().hasWorkflowDocument(); |
354 | |
} |
355 | |
} |
356 | |
|
357 | 0 | return initialized; |
358 | |
} |
359 | |
|
360 | |
|
361 | |
|
362 | |
|
363 | |
|
364 | |
|
365 | |
@SuppressWarnings("unchecked") |
366 | |
public Map getEditingMode() { |
367 | 0 | return editingMode; |
368 | |
} |
369 | |
|
370 | |
|
371 | |
|
372 | |
|
373 | |
@SuppressWarnings("unchecked") |
374 | |
public void setEditingMode(Map editingMode) { |
375 | 0 | this.editingMode = editingMode; |
376 | 0 | } |
377 | |
|
378 | |
|
379 | |
|
380 | |
|
381 | |
@SuppressWarnings("unchecked") |
382 | |
public Map getDocumentActions() { |
383 | 0 | return this.documentActions; |
384 | |
} |
385 | |
|
386 | |
|
387 | |
|
388 | |
|
389 | |
@SuppressWarnings("unchecked") |
390 | |
public void setDocumentActions(Map documentActions) { |
391 | 0 | this.documentActions = documentActions; |
392 | 0 | } |
393 | |
|
394 | |
|
395 | |
|
396 | |
|
397 | |
|
398 | |
|
399 | |
@SuppressWarnings("unchecked") |
400 | |
public void setAdHocActionRequestCodes(Map adHocActionRequestCodes) { |
401 | 0 | this.adHocActionRequestCodes = adHocActionRequestCodes; |
402 | 0 | } |
403 | |
|
404 | |
|
405 | |
|
406 | |
|
407 | |
@SuppressWarnings("unchecked") |
408 | |
public Map getAdHocActionRequestCodes() { |
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
|
414 | |
|
415 | |
|
416 | |
|
417 | |
|
418 | |
|
419 | |
|
420 | |
|
421 | |
|
422 | |
|
423 | |
|
424 | |
|
425 | 0 | return adHocActionRequestCodes; |
426 | |
} |
427 | |
|
428 | |
|
429 | |
|
430 | |
|
431 | |
|
432 | |
public List<AdHocRoutePerson> getAdHocRoutePersons() { |
433 | 0 | return document.getAdHocRoutePersons(); |
434 | |
} |
435 | |
|
436 | |
|
437 | |
|
438 | |
|
439 | |
|
440 | |
public FormFile getAttachmentFile() { |
441 | 0 | return attachmentFile; |
442 | |
} |
443 | |
|
444 | |
|
445 | |
|
446 | |
|
447 | |
public void setAttachmentFile(FormFile attachmentFile) { |
448 | 0 | this.attachmentFile = attachmentFile; |
449 | 0 | } |
450 | |
|
451 | |
|
452 | |
|
453 | |
|
454 | |
|
455 | |
|
456 | |
|
457 | |
public void setAdHocRoutePersons(List<AdHocRoutePerson> adHocRouteRecipients) { |
458 | 0 | document.setAdHocRoutePersons(adHocRouteRecipients); |
459 | 0 | } |
460 | |
|
461 | |
|
462 | |
|
463 | |
|
464 | |
|
465 | |
|
466 | |
public List<AdHocRouteWorkgroup> getAdHocRouteWorkgroups() { |
467 | 0 | return document.getAdHocRouteWorkgroups(); |
468 | |
} |
469 | |
|
470 | |
|
471 | |
|
472 | |
|
473 | |
|
474 | |
|
475 | |
public void setAdHocRouteWorkgroups(List<AdHocRouteWorkgroup> adHocRouteWorkgroups) { |
476 | 0 | document.setAdHocRouteWorkgroups(adHocRouteWorkgroups); |
477 | 0 | } |
478 | |
|
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
public AdHocRoutePerson getAdHocRoutePerson(int index) { |
486 | 0 | while (getAdHocRoutePersons().size() <= index) { |
487 | 0 | getAdHocRoutePersons().add(new AdHocRoutePerson()); |
488 | |
} |
489 | 0 | return getAdHocRoutePersons().get(index); |
490 | |
} |
491 | |
|
492 | |
|
493 | |
|
494 | |
|
495 | |
|
496 | |
|
497 | |
|
498 | |
public AdHocRouteWorkgroup getAdHocRouteWorkgroup(int index) { |
499 | 0 | while (getAdHocRouteWorkgroups().size() <= index) { |
500 | 0 | getAdHocRouteWorkgroups().add(new AdHocRouteWorkgroup()); |
501 | |
} |
502 | 0 | return getAdHocRouteWorkgroups().get(index); |
503 | |
} |
504 | |
|
505 | |
|
506 | |
|
507 | |
|
508 | |
public AdHocRoutePerson getNewAdHocRoutePerson() { |
509 | 0 | return newAdHocRoutePerson; |
510 | |
} |
511 | |
|
512 | |
|
513 | |
|
514 | |
|
515 | |
|
516 | |
|
517 | |
public void setNewAdHocRoutePerson(AdHocRoutePerson newAdHocRoutePerson) { |
518 | 0 | this.newAdHocRoutePerson = newAdHocRoutePerson; |
519 | 0 | } |
520 | |
|
521 | |
|
522 | |
|
523 | |
|
524 | |
public AdHocRouteWorkgroup getNewAdHocRouteWorkgroup() { |
525 | 0 | return newAdHocRouteWorkgroup; |
526 | |
} |
527 | |
|
528 | |
|
529 | |
|
530 | |
|
531 | |
|
532 | |
|
533 | |
public void setNewAdHocRouteWorkgroup(AdHocRouteWorkgroup newAdHocRouteWorkgroup) { |
534 | 0 | this.newAdHocRouteWorkgroup = newAdHocRouteWorkgroup; |
535 | 0 | } |
536 | |
|
537 | |
|
538 | |
|
539 | |
|
540 | |
public Document getDocument() { |
541 | 0 | return document; |
542 | |
} |
543 | |
|
544 | |
|
545 | |
|
546 | |
|
547 | |
public void setDocument(Document document) { |
548 | 0 | this.document = document; |
549 | 0 | if(document != null && StringUtils.isNotEmpty(document.getDocumentNumber())) { |
550 | 0 | populateHeaderFields(document.getDocumentHeader().getWorkflowDocument()); |
551 | |
} |
552 | 0 | } |
553 | |
|
554 | |
|
555 | |
|
556 | |
|
557 | |
public WorkflowDocument getWorkflowDocument() { |
558 | 0 | return getDocument().getDocumentHeader().getWorkflowDocument(); |
559 | |
} |
560 | |
|
561 | |
|
562 | |
|
563 | |
|
564 | |
|
565 | |
public boolean isHasWorkflowDocument() { |
566 | 0 | if ( getDocument() == null || getDocument().getDocumentHeader() == null ) { |
567 | 0 | return false; |
568 | |
} |
569 | 0 | return getDocument().getDocumentHeader().hasWorkflowDocument(); |
570 | |
} |
571 | |
|
572 | |
|
573 | |
|
574 | |
|
575 | |
public boolean isUserDocumentInitiator() { |
576 | 0 | if (getWorkflowDocument() != null) { |
577 | 0 | return getWorkflowDocument().getInitiatorPrincipalId().equalsIgnoreCase( |
578 | |
GlobalVariables.getUserSession().getPrincipalId()); |
579 | |
} |
580 | 0 | return false; |
581 | |
} |
582 | |
|
583 | |
public Person getInitiator() { |
584 | 0 | String initiatorPrincipalId = getWorkflowDocument().getInitiatorPrincipalId(); |
585 | 0 | return KimApiServiceLocator.getPersonService().getPerson(initiatorPrincipalId); |
586 | |
} |
587 | |
|
588 | |
|
589 | |
|
590 | |
|
591 | |
public boolean isDocumentEnRoute() { |
592 | 0 | return getWorkflowDocument().isEnroute(); |
593 | |
} |
594 | |
|
595 | |
|
596 | |
|
597 | |
|
598 | |
public void setAnnotation(String annotation) { |
599 | 0 | this.annotation = annotation; |
600 | 0 | } |
601 | |
|
602 | |
|
603 | |
|
604 | |
|
605 | |
public String getAnnotation() { |
606 | 0 | return annotation; |
607 | |
} |
608 | |
|
609 | |
|
610 | |
|
611 | |
|
612 | |
public String getCommand() { |
613 | 0 | return command; |
614 | |
} |
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
|
621 | |
public void setCommand(String command) { |
622 | 0 | this.command = command; |
623 | 0 | } |
624 | |
|
625 | |
|
626 | |
|
627 | |
|
628 | |
public String getDocId() { |
629 | 0 | return docId; |
630 | |
} |
631 | |
|
632 | |
|
633 | |
|
634 | |
|
635 | |
|
636 | |
|
637 | |
public void setDocId(String docId) { |
638 | 0 | this.docId = docId; |
639 | 0 | } |
640 | |
|
641 | |
|
642 | |
|
643 | |
|
644 | |
|
645 | |
|
646 | |
public String getDocTypeName() { |
647 | 0 | return docTypeName; |
648 | |
} |
649 | |
|
650 | |
|
651 | |
|
652 | |
|
653 | |
|
654 | |
|
655 | |
public void setDocTypeName(String docTypeName) { |
656 | 0 | this.docTypeName = docTypeName; |
657 | 0 | } |
658 | |
|
659 | |
|
660 | |
|
661 | |
|
662 | |
|
663 | |
|
664 | |
public String getInitiatorNetworkId() { |
665 | 0 | return this.getWorkflowDocument().getInitiatorPrincipalId(); |
666 | |
} |
667 | |
|
668 | |
|
669 | |
|
670 | |
|
671 | |
|
672 | |
|
673 | |
public final boolean isSuppressAllButtons() { |
674 | 0 | return suppressAllButtons; |
675 | |
} |
676 | |
|
677 | |
|
678 | |
|
679 | |
|
680 | |
|
681 | |
|
682 | |
public final void setSuppressAllButtons(boolean suppressAllButtons) { |
683 | 0 | this.suppressAllButtons = suppressAllButtons; |
684 | 0 | } |
685 | |
|
686 | |
|
687 | |
|
688 | |
|
689 | |
|
690 | |
public boolean hasDocumentId() { |
691 | 0 | boolean hasDocId = false; |
692 | |
|
693 | 0 | Document d = getDocument(); |
694 | 0 | if (d != null) { |
695 | 0 | String docHeaderId = d.getDocumentNumber(); |
696 | |
|
697 | 0 | hasDocId = StringUtils.isNotBlank(docHeaderId); |
698 | |
} |
699 | |
|
700 | 0 | return hasDocId; |
701 | |
} |
702 | |
|
703 | |
|
704 | |
|
705 | |
|
706 | |
|
707 | |
|
708 | |
|
709 | |
public void setReturnToActionList(boolean returnToActionList) { |
710 | 0 | this.returnToActionList = returnToActionList; |
711 | 0 | } |
712 | |
|
713 | |
public boolean isReturnToActionList() { |
714 | 0 | return returnToActionList; |
715 | |
} |
716 | |
|
717 | |
public List<String> getAdditionalScriptFiles() { |
718 | 0 | return additionalScriptFiles; |
719 | |
} |
720 | |
|
721 | |
public void setAdditionalScriptFiles(List<String> additionalScriptFiles) { |
722 | 0 | this.additionalScriptFiles = additionalScriptFiles; |
723 | 0 | } |
724 | |
|
725 | |
public void setAdditionalScriptFile( int index, String scriptFile ) { |
726 | 0 | additionalScriptFiles.set( index, scriptFile ); |
727 | 0 | } |
728 | |
|
729 | |
public String getAdditionalScriptFile( int index ) { |
730 | 0 | return additionalScriptFiles.get( index ); |
731 | |
} |
732 | |
|
733 | |
public Note getNewNote() { |
734 | 0 | return newNote; |
735 | |
} |
736 | |
|
737 | |
public void setNewNote(Note newNote) { |
738 | 0 | this.newNote = newNote; |
739 | 0 | } |
740 | |
|
741 | |
|
742 | |
|
743 | |
|
744 | |
|
745 | |
@SuppressWarnings("unchecked") |
746 | |
public List getBoNotes() { |
747 | 0 | return boNotes; |
748 | |
} |
749 | |
|
750 | |
|
751 | |
|
752 | |
|
753 | |
|
754 | |
@SuppressWarnings("unchecked") |
755 | |
public void setBoNotes(List boNotes) { |
756 | 0 | this.boNotes = boNotes; |
757 | 0 | } |
758 | |
|
759 | |
public String getFormKey() { |
760 | 0 | return this.formKey; |
761 | |
} |
762 | |
|
763 | |
public void setFormKey(String formKey) { |
764 | 0 | this.formKey = formKey; |
765 | 0 | } |
766 | |
|
767 | |
|
768 | |
|
769 | |
|
770 | |
|
771 | |
|
772 | |
@Override |
773 | |
public void reset(ActionMapping mapping, HttpServletRequest request) { |
774 | 0 | super.reset(mapping, request); |
775 | 0 | this.setMethodToCall(null); |
776 | 0 | this.setRefreshCaller(null); |
777 | 0 | this.setAnchor(null); |
778 | 0 | this.setCurrentTabIndex(0); |
779 | |
|
780 | 0 | } |
781 | |
|
782 | |
|
783 | |
|
784 | |
|
785 | |
|
786 | |
|
787 | |
|
788 | |
@Override |
789 | |
protected void customInitMaxUploadSizes() { |
790 | 0 | super.customInitMaxUploadSizes(); |
791 | 0 | addMaxUploadSize(CoreFrameworkServiceLocator.getParameterService().getParameterValueAsString(KRADConstants.KRAD_NAMESPACE, KRADConstants.DetailTypes.DOCUMENT_DETAIL_TYPE, KRADConstants.ATTACHMENT_MAX_FILE_SIZE_PARM_NM)); |
792 | 0 | } |
793 | |
|
794 | |
|
795 | |
|
796 | |
|
797 | |
|
798 | |
|
799 | |
|
800 | |
|
801 | |
|
802 | |
@Override |
803 | |
public boolean shouldPropertyBePopulatedInForm(String requestParameterName, HttpServletRequest request) { |
804 | 0 | for ( String prefix : KRADConstants.ALWAYS_VALID_PARAMETER_PREFIXES ) { |
805 | 0 | if (requestParameterName.startsWith(prefix)) { |
806 | 0 | return true; |
807 | |
} |
808 | |
} |
809 | |
|
810 | 0 | if (StringUtils.equalsIgnoreCase(getMethodToCall(), KRADConstants.DOC_HANDLER_METHOD)) { |
811 | 0 | return true; |
812 | |
} |
813 | 0 | if (WebUtils.isDocumentSession(getDocument(), this)) { |
814 | 0 | return isPropertyEditable(requestParameterName) || isPropertyNonEditableButRequired(requestParameterName); |
815 | |
} |
816 | 0 | return true; |
817 | |
} |
818 | |
|
819 | |
|
820 | |
|
821 | |
|
822 | |
|
823 | |
|
824 | |
@Override |
825 | |
public boolean shouldMethodToCallParameterBeUsed( |
826 | |
String methodToCallParameterName, |
827 | |
String methodToCallParameterValue, HttpServletRequest request) { |
828 | 0 | if (StringUtils.equals(methodToCallParameterName, KRADConstants.DISPATCH_REQUEST_PARAMETER) && |
829 | |
StringUtils.equals(methodToCallParameterValue, KRADConstants.DOC_HANDLER_METHOD)) { |
830 | 0 | return true; |
831 | |
} |
832 | 0 | return super.shouldMethodToCallParameterBeUsed(methodToCallParameterName, |
833 | |
methodToCallParameterValue, request); |
834 | |
} |
835 | |
|
836 | |
public MessageMap getMessageMapFromPreviousRequest() { |
837 | 0 | return this.errorMapFromPreviousRequest; |
838 | |
} |
839 | |
|
840 | |
public void setMessageMapFromPreviousRequest(MessageMap errorMapFromPreviousRequest) { |
841 | 0 | this.errorMapFromPreviousRequest = errorMapFromPreviousRequest; |
842 | 0 | } |
843 | |
|
844 | |
@Override |
845 | |
public void setDerivedValuesOnForm(HttpServletRequest request) { |
846 | 0 | super.setDerivedValuesOnForm(request); |
847 | |
|
848 | 0 | String docTypeName = getDocTypeName(); |
849 | 0 | if (StringUtils.isNotBlank(docTypeName)) { |
850 | 0 | DataDictionary dataDictionary = KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary(); |
851 | |
|
852 | 0 | Class<? extends DerivedValuesSetter> derivedValuesSetterClass = null; |
853 | 0 | KNSDocumentEntry documentEntry = (KNSDocumentEntry) dataDictionary.getDocumentEntry(docTypeName); |
854 | 0 | derivedValuesSetterClass = (documentEntry).getDerivedValuesSetterClass(); |
855 | |
|
856 | 0 | if (derivedValuesSetterClass != null) { |
857 | 0 | DerivedValuesSetter derivedValuesSetter = null; |
858 | |
try { |
859 | 0 | derivedValuesSetter = derivedValuesSetterClass.newInstance(); |
860 | |
} |
861 | |
|
862 | 0 | catch (Exception e) { |
863 | 0 | LOG.error("Unable to instantiate class " + derivedValuesSetterClass.getName(), e); |
864 | 0 | throw new RuntimeException("Unable to instantiate class " + derivedValuesSetterClass.getName(), e); |
865 | 0 | } |
866 | 0 | derivedValuesSetter.setDerivedValues(this, request); |
867 | |
} |
868 | |
} |
869 | 0 | } |
870 | |
|
871 | |
protected String getDefaultDocumentTypeName() { |
872 | 0 | return ""; |
873 | |
} |
874 | |
|
875 | |
|
876 | |
protected void instantiateDocument() { |
877 | 0 | if (document == null && StringUtils.isNotBlank(getDefaultDocumentTypeName())) { |
878 | 0 | Class<? extends Document> documentClass = getDocumentClass(); |
879 | |
try { |
880 | 0 | Document document = documentClass.newInstance(); |
881 | 0 | setDocument(document); |
882 | 0 | } catch (Exception e) { |
883 | 0 | LOG.error("Unable to instantiate document class " + documentClass.getName() + " document type " + getDefaultDocumentTypeName()); |
884 | 0 | throw new RuntimeException(e); |
885 | 0 | } |
886 | |
} |
887 | 0 | } |
888 | |
|
889 | |
|
890 | |
private Class<? extends Document> getDocumentClass() { |
891 | 0 | return KRADServiceLocatorWeb.getDataDictionaryService().getDocumentClassByTypeName(getDefaultDocumentTypeName()); |
892 | |
} |
893 | |
|
894 | |
|
895 | |
protected void initializeHeaderNavigationTabs() { |
896 | 0 | if (StringUtils.isNotBlank(getDefaultDocumentTypeName())) { |
897 | 0 | final KNSDocumentEntry docEntry = (KNSDocumentEntry) KRADServiceLocatorWeb.getDataDictionaryService().getDataDictionary().getDocumentEntry(getDocumentClass().getName()); |
898 | 0 | final List<HeaderNavigation> navList = docEntry.getHeaderNavigationList(); |
899 | 0 | final HeaderNavigation[] list = new HeaderNavigation[navList.size()]; |
900 | 0 | super.setHeaderNavigationTabs(navList.toArray(list)); |
901 | |
} |
902 | 0 | } |
903 | |
} |