| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kns.web.spring.form; |
| 17 | |
|
| 18 | |
import org.apache.commons.lang.StringUtils; |
| 19 | |
import org.kuali.rice.kim.bo.Person; |
| 20 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
| 21 | |
import org.kuali.rice.kns.document.Document; |
| 22 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
| 23 | |
import org.kuali.rice.kns.service.KNSServiceLocatorWeb; |
| 24 | |
import org.kuali.rice.kns.workflow.service.KualiWorkflowDocument; |
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
public class DocumentFormBase extends UifFormBase { |
| 32 | |
private static final long serialVersionUID = 2190268505427404480L; |
| 33 | |
|
| 34 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentFormBase.class); |
| 35 | |
|
| 36 | 0 | private String annotation = ""; |
| 37 | |
private String command; |
| 38 | |
|
| 39 | |
private String docId; |
| 40 | |
private String docTypeName; |
| 41 | |
|
| 42 | |
protected Document document; |
| 43 | |
|
| 44 | |
public DocumentFormBase() { |
| 45 | 0 | super(); |
| 46 | |
|
| 47 | 0 | instantiateDocument(); |
| 48 | 0 | } |
| 49 | |
|
| 50 | |
public String getAnnotation() { |
| 51 | 0 | return this.annotation; |
| 52 | |
} |
| 53 | |
|
| 54 | |
public void setAnnotation(String annotation) { |
| 55 | 0 | this.annotation = annotation; |
| 56 | 0 | } |
| 57 | |
|
| 58 | |
public Document getDocument() { |
| 59 | 0 | return this.document; |
| 60 | |
} |
| 61 | |
|
| 62 | |
public void setDocument(Document document) { |
| 63 | 0 | this.document = document; |
| 64 | 0 | } |
| 65 | |
|
| 66 | |
public String getDocTypeName() { |
| 67 | 0 | return this.docTypeName; |
| 68 | |
} |
| 69 | |
|
| 70 | |
public void setDocTypeName(String docTypeName) { |
| 71 | 0 | this.docTypeName = docTypeName; |
| 72 | 0 | } |
| 73 | |
|
| 74 | |
public String getCommand() { |
| 75 | 0 | return this.command; |
| 76 | |
} |
| 77 | |
|
| 78 | |
public void setCommand(String command) { |
| 79 | 0 | this.command = command; |
| 80 | 0 | } |
| 81 | |
|
| 82 | |
public String getDocId() { |
| 83 | 0 | return this.docId; |
| 84 | |
} |
| 85 | |
|
| 86 | |
public void setDocId(String docId) { |
| 87 | 0 | this.docId = docId; |
| 88 | 0 | } |
| 89 | |
|
| 90 | |
protected String getDefaultDocumentTypeName() { |
| 91 | 0 | return ""; |
| 92 | |
} |
| 93 | |
|
| 94 | |
protected void instantiateDocument() { |
| 95 | 0 | if (document == null && StringUtils.isNotBlank(getDefaultDocumentTypeName())) { |
| 96 | 0 | Class<? extends Document> documentClass = KNSServiceLocatorWeb.getDataDictionaryService() |
| 97 | |
.getDocumentClassByTypeName(getDefaultDocumentTypeName()); |
| 98 | |
try { |
| 99 | 0 | Document newDocument = documentClass.newInstance(); |
| 100 | 0 | setDocument(newDocument); |
| 101 | 0 | } catch (Exception e) { |
| 102 | 0 | LOG.error("Unable to instantiate document class " + documentClass.getName() + " document type " |
| 103 | |
+ getDefaultDocumentTypeName()); |
| 104 | 0 | throw new RuntimeException(e); |
| 105 | 0 | } |
| 106 | |
} |
| 107 | 0 | } |
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
public String getDocumentInitiatorNetworkId() { |
| 115 | 0 | String initiatorNetworkId = ""; |
| 116 | 0 | if (getWorkflowDocument() != null) { |
| 117 | 0 | String initiatorPrincipalId = getWorkflowDocument().getRouteHeader().getInitiatorPrincipalId(); |
| 118 | 0 | Person initiator = KIMServiceLocator.getPersonService().getPerson(initiatorPrincipalId); |
| 119 | 0 | if (initiator != null) { |
| 120 | 0 | initiatorNetworkId = initiator.getPrincipalName(); |
| 121 | |
} |
| 122 | |
} |
| 123 | |
|
| 124 | 0 | return initiatorNetworkId; |
| 125 | |
} |
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
|
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
public String getDocumentCreateDate() { |
| 134 | 0 | String createDateStr = ""; |
| 135 | 0 | if (getWorkflowDocument() != null && getWorkflowDocument().getCreateDate() != null) { |
| 136 | 0 | createDateStr = KNSServiceLocator.getDateTimeService().toString(getWorkflowDocument().getCreateDate(), |
| 137 | |
"hh:mm a MM/dd/yyyy"); |
| 138 | |
} |
| 139 | |
|
| 140 | 0 | return createDateStr; |
| 141 | |
} |
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
public KualiWorkflowDocument getWorkflowDocument() { |
| 150 | 0 | return getDocument().getDocumentHeader().getWorkflowDocument(); |
| 151 | |
} |
| 152 | |
|
| 153 | |
} |