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