| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| DocumentService |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Copyright 2005-2007 The Kuali Foundation | |
| 3 | * | |
| 4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.opensource.org/licenses/ecl2.php | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | package org.kuali.rice.kns.service; | |
| 17 | ||
| 18 | import java.util.List; | |
| 19 | ||
| 20 | import org.kuali.rice.kew.exception.WorkflowException; | |
| 21 | import org.kuali.rice.kns.bo.AdHocRouteRecipient; | |
| 22 | import org.kuali.rice.kns.bo.Note; | |
| 23 | import org.kuali.rice.kns.bo.PersistableBusinessObject; | |
| 24 | import org.kuali.rice.kns.document.Document; | |
| 25 | import org.kuali.rice.kns.rule.event.SaveEvent; | |
| 26 | ||
| 27 | ||
| 28 | ||
| 29 | /** | |
| 30 | * This is the DocumentService interface which must have an implementation that accompanies it. This interfaces defines all of the | |
| 31 | * generally required methods for all document instances | |
| 32 | * | |
| 33 | * | |
| 34 | */ | |
| 35 | ||
| 36 | // TODO put exceptions that are kuali based into here instead of implementation based | |
| 37 | public interface DocumentService { | |
| 38 | ||
| 39 | /** | |
| 40 | * @param documentHeaderId | |
| 41 | * @return true if a document with the given documentHeaderId exists | |
| 42 | */ | |
| 43 | public boolean documentExists(String documentHeaderId); | |
| 44 | ||
| 45 | /** | |
| 46 | * get a new blank document instance based on the document type name | |
| 47 | * | |
| 48 | * @param documentTypeName | |
| 49 | * @return | |
| 50 | */ | |
| 51 | public Document getNewDocument(String documentTypeName) throws WorkflowException; | |
| 52 | ||
| 53 | /** | |
| 54 | * get a new blank document instance having the given Document class | |
| 55 | * | |
| 56 | * @param documentClass | |
| 57 | * @return | |
| 58 | */ | |
| 59 | public Document getNewDocument(Class documentClass) throws WorkflowException; | |
| 60 | ||
| 61 | /** | |
| 62 | * get a document based on the document header id which is the primary key for all document types | |
| 63 | * | |
| 64 | * @param documentHeaderId | |
| 65 | * @return | |
| 66 | */ | |
| 67 | public Document getByDocumentHeaderId(String documentHeaderId) throws WorkflowException; | |
| 68 | /** | |
| 69 | * get a document based on the document header id which is the primary key for all document types. Using this method | |
| 70 | * does not require that GlobalVariables.getUserSession() be populated. Therefore, this method can be used when a HTTP request | |
| 71 | * is not being processed (e.g. during workflow indexing/post-processing). | |
| 72 | * | |
| 73 | * @param documentHeaderId | |
| 74 | * @return | |
| 75 | */ | |
| 76 | public Document getByDocumentHeaderIdSessionless(String documentHeaderId) throws WorkflowException; | |
| 77 | ||
| 78 | /** | |
| 79 | * This method retrieves a list of fully-populated documents given a list of document header id values. | |
| 80 | * | |
| 81 | * @param clazz | |
| 82 | * @param documentHeaderIds | |
| 83 | * @return List of fully-populated documents | |
| 84 | * @throws WorkflowException | |
| 85 | */ | |
| 86 | public List getDocumentsByListOfDocumentHeaderIds(Class clazz, List documentHeaderIds) throws WorkflowException; | |
| 87 | ||
| 88 | /** | |
| 89 | * | |
| 90 | * This method is to allow for documents to be updated which is currently used to update the document status as well as to allow | |
| 91 | * for locked docs to be unlocked | |
| 92 | * | |
| 93 | * @param document | |
| 94 | */ | |
| 95 | public void updateDocument(Document document); | |
| 96 | ||
| 97 | /** | |
| 98 | * This is a helper method that performs the same as the {@link #saveDocument(Document, Class)} method. The convenience | |
| 99 | * of this method is that the event being used is the standard SaveDocumentEvent. | |
| 100 | * | |
| 101 | * @see org.kuali.rice.kns.service.DocumentService#saveDocument(Document, Class) | |
| 102 | */ | |
| 103 | public Document saveDocument(Document document) throws WorkflowException; | |
| 104 | ||
| 105 | /** | |
| 106 | * Saves the passed-in document. This will persist it both to the Kuali database, and also initiate it (if necessary) within | |
| 107 | * workflow, so its available in the initiator's action list. This method uses the passed in KualiDocumentEvent class when saving | |
| 108 | * the document. The KualiDocumentEvent class must implement the {@link SaveEvent} interface. | |
| 109 | * | |
| 110 | * Note that the system does not support passing in Workflow Annotations or AdHoc Route Recipients on a SaveDocument call. These | |
| 111 | * are sent to workflow on a routeDocument action, or any of the others which actually causes a routing action to happen in | |
| 112 | * workflow. | |
| 113 | * | |
| 114 | * NOTE: This method will not check the document action flags to check if a save is valid | |
| 115 | * | |
| 116 | * @param document The document to be saved | |
| 117 | * @param kualiDocumentEventClass The event class to use when saving (class must implement the SaveEvent interface) | |
| 118 | * @return the document that was passed in | |
| 119 | * @throws WorkflowException | |
| 120 | */ | |
| 121 | public Document saveDocument(Document document, Class kualiDocumentEventClass) throws WorkflowException; | |
| 122 | ||
| 123 | /** | |
| 124 | * start the route the document for approval, optionally providing a list of ad hoc recipients, and additionally provideing a | |
| 125 | * annotation to show up in the route log for the document | |
| 126 | * | |
| 127 | * @param document | |
| 128 | * @param annotation | |
| 129 | * @param adHocRoutingRecipients | |
| 130 | * @return | |
| 131 | * @throws ValidationErrorList | |
| 132 | */ | |
| 133 | public Document routeDocument(Document document, String annotation, List adHocRoutingRecipients) throws WorkflowException; | |
| 134 | ||
| 135 | /** | |
| 136 | * approve this document, optionally providing an annotation which will show up in the route log for this document for this | |
| 137 | * action taken, and optionally providing a list of ad hoc recipients for the document | |
| 138 | * | |
| 139 | * @param document | |
| 140 | * @param annotation | |
| 141 | * @param adHocRoutingRecipients | |
| 142 | * @return | |
| 143 | * @throws ValidationErrorList | |
| 144 | */ | |
| 145 | public Document approveDocument(Document document, String annotation, List adHocRoutingRecipients) throws WorkflowException; | |
| 146 | ||
| 147 | /** | |
| 148 | * approve this document as super user, optionally providing an annotation which will show up in the route log for this document | |
| 149 | * for this action taken | |
| 150 | * | |
| 151 | * @param document | |
| 152 | * @param annotation | |
| 153 | * @return | |
| 154 | * @throws ValidationErrorList | |
| 155 | */ | |
| 156 | public Document superUserApproveDocument(Document document, String annotation) throws WorkflowException; | |
| 157 | ||
| 158 | /** | |
| 159 | * cancel this document as super user, optionally providing an annotation which will show up in the route log for this document | |
| 160 | * for this action taken | |
| 161 | * | |
| 162 | * @param document | |
| 163 | * @param annotation | |
| 164 | * @return | |
| 165 | * @throws WorkflowException | |
| 166 | */ | |
| 167 | public Document superUserCancelDocument(Document document, String annotation) throws WorkflowException; | |
| 168 | ||
| 169 | /** | |
| 170 | * disapprove this document as super user, optionally providing an annotation which will show up in the route log for this document | |
| 171 | * for this action taken | |
| 172 | * | |
| 173 | * @param document | |
| 174 | * @param annotation | |
| 175 | * @return | |
| 176 | * @throws WorkflowException | |
| 177 | */ | |
| 178 | public Document superUserDisapproveDocument(Document document, String annotation) throws WorkflowException; | |
| 179 | ||
| 180 | /** | |
| 181 | * disapprove this document, optionally providing an annotation for the disapproval which will show up in the route log for the | |
| 182 | * document for this action taken | |
| 183 | * | |
| 184 | * @param document | |
| 185 | * @param annotation | |
| 186 | * @return Document | |
| 187 | * @throws Exception | |
| 188 | */ | |
| 189 | public Document disapproveDocument(Document document, String annotation) throws Exception; | |
| 190 | ||
| 191 | /** | |
| 192 | * cancel this document, optionally providing an annotation for the disapproval which will show up in the route log for the | |
| 193 | * document for this action taken | |
| 194 | * | |
| 195 | * @param document | |
| 196 | * @param annotation | |
| 197 | * @return | |
| 198 | */ | |
| 199 | public Document cancelDocument(Document document, String annotation) throws WorkflowException; | |
| 200 | ||
| 201 | /** | |
| 202 | * acknowledge this document, optionally providing an annotation for the acknowledgement which will show up in the route log for | |
| 203 | * the document for this acknowledgement, additionally optionally provide a list of ad hoc recipients that should recieve this | |
| 204 | * document. The list of ad hoc recipients for this document should have an action requested of acknowledge or fyi as all other | |
| 205 | * actions requested will be discarded as invalid based on the action being taken being an acknowledgement. | |
| 206 | * | |
| 207 | * @param document | |
| 208 | * @param annotation | |
| 209 | * @param adHocRecipients | |
| 210 | * @return | |
| 211 | */ | |
| 212 | public Document acknowledgeDocument(Document document, String annotation, List adHocRecipients) throws WorkflowException; | |
| 213 | ||
| 214 | /** | |
| 215 | * blanket approve this document which will approve the document and stand in for an approve for all typically generated | |
| 216 | * approval actions requested for this document. The user must have blanket approval authority for this document by being | |
| 217 | * registered as a user in the blanket approval workgroup that is associated with this document type. Optionally an annotation | |
| 218 | * can be provided which will show up for this action taken on the document in the route log. Additionally optionally provide a | |
| 219 | * list of ad hoc recipients for this document, which should be restricted to actions requested of acknowledge and fyi as all | |
| 220 | * other actions requested will be discarded | |
| 221 | * | |
| 222 | * @param document | |
| 223 | * @param annotation | |
| 224 | * @param adHocRecipients | |
| 225 | * @return | |
| 226 | * @throws ValidationErrorList | |
| 227 | */ | |
| 228 | public Document blanketApproveDocument(Document document, String annotation, List adHocRecipients) throws WorkflowException; | |
| 229 | ||
| 230 | /** | |
| 231 | * clear the fyi request for this document, optionally providing a list of ad hoc recipients for this document, which should be | |
| 232 | * restricted to action requested of fyi as all other actions requested will be discarded | |
| 233 | * | |
| 234 | * @param document | |
| 235 | * @param adHocRecipients | |
| 236 | * @return | |
| 237 | */ | |
| 238 | public Document clearDocumentFyi(Document document, List adHocRecipients) throws WorkflowException; | |
| 239 | ||
| 240 | /** | |
| 241 | * Sets the title and app document id in the flex document | |
| 242 | * | |
| 243 | * @param document | |
| 244 | * @throws WorkflowException | |
| 245 | */ | |
| 246 | public void prepareWorkflowDocument(Document document) throws WorkflowException; | |
| 247 | ||
| 248 | ||
| 249 | /** | |
| 250 | * | |
| 251 | * This method creates a note from a given document and note text | |
| 252 | * @param document | |
| 253 | * @param text | |
| 254 | * @return | |
| 255 | * @throws Exception | |
| 256 | */ | |
| 257 | public Note createNoteFromDocument(Document document, String text) throws Exception; | |
| 258 | ||
| 259 | /** | |
| 260 | * | |
| 261 | * This method adds a note to a document | |
| 262 | * @param document | |
| 263 | * @param note | |
| 264 | * @return the added Note | |
| 265 | */ | |
| 266 | public boolean addNoteToDocument(Document document, Note note); | |
| 267 | ||
| 268 | /** | |
| 269 | * | |
| 270 | * This method gets the parent for a note from a document | |
| 271 | * @param document | |
| 272 | * @param newNote | |
| 273 | * @return Business Object that the note is attached to. | |
| 274 | */ | |
| 275 | public PersistableBusinessObject getNoteParent(Document document, Note newNote); | |
| 276 | ||
| 277 | public void sendAdHocRequests(Document document, String annotation, List<AdHocRouteRecipient> adHocRecipients) throws WorkflowException; | |
| 278 | } |