Coverage Report - org.kuali.rice.kns.document.Document
 
Classes in this File Line Coverage Branch Coverage Complexity
Document
N/A
N/A
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.document;
 17  
 
 18  
 import java.util.List;
 19  
 import java.util.Map;
 20  
 
 21  
 import org.kuali.rice.kew.dto.ActionTakenEventDTO;
 22  
 import org.kuali.rice.kew.dto.DocumentRouteLevelChangeDTO;
 23  
 import org.kuali.rice.kew.dto.DocumentRouteStatusChangeDTO;
 24  
 import org.kuali.rice.kim.bo.Person;
 25  
 import org.kuali.rice.kns.bo.AdHocRoutePerson;
 26  
 import org.kuali.rice.kns.bo.AdHocRouteWorkgroup;
 27  
 import org.kuali.rice.kns.bo.DocumentHeader;
 28  
 import org.kuali.rice.kns.bo.Note;
 29  
 import org.kuali.rice.kns.bo.PersistableBusinessObject;
 30  
 import org.kuali.rice.kns.document.authorization.PessimisticLock;
 31  
 import org.kuali.rice.kns.exception.ValidationException;
 32  
 import org.kuali.rice.kns.rule.event.KualiDocumentEvent;
 33  
 import org.kuali.rice.kns.service.DocumentSerializerService;
 34  
 import org.kuali.rice.kns.util.NoteType;
 35  
 import org.kuali.rice.kns.util.documentserializer.PropertySerializabilityEvaluator;
 36  
 import org.kuali.rice.kns.web.struts.action.KualiDocumentActionBase;
 37  
 import org.kuali.rice.kns.workflow.KualiDocumentXmlMaterializer;
 38  
 
 39  
 
 40  
 /**
 41  
  * This is the Document interface. All entities that are regarded as "eDocs" in the system, including Maintenance documents and
 42  
  * Transaction Processing documents should implement this interface as it defines methods that are necessary to interact with the
 43  
  * underlying frameworks and components (i.e. notes, attachments, workflow, etc).
 44  
  */
 45  
 public interface Document extends PersistableBusinessObject {
 46  
         
 47  
     /**
 48  
      * This retrieves the standard <code>DocumentHeader</code> object, which contains standard meta-data about a document.
 49  
      * 
 50  
      * @return document header since all docs will have a document header
 51  
      */
 52  
     public DocumentHeader getDocumentHeader();
 53  
 
 54  
     /**
 55  
      * Sets the associated <code>DocumentHeader</code> for this document.
 56  
      * 
 57  
      * @param documentHeader
 58  
      */
 59  
     public void setDocumentHeader(DocumentHeader documentHeader);
 60  
 
 61  
     /**
 62  
      * All documents have a document header id. This is the quick accessor to that unique identifier and should return the same
 63  
      * value as documentHeader.getDocumentHeaderId().
 64  
      * 
 65  
      * @return doc header id
 66  
      */
 67  
     public String getDocumentNumber();
 68  
 
 69  
     /**
 70  
      * setter for document header id
 71  
      * 
 72  
      * @param documentHeaderId
 73  
      */
 74  
     public void setDocumentNumber(String documentHeaderId);
 75  
 
 76  
     /**
 77  
      * This is the method to integrate with workflow, where we will actually populate the workflow defined data structure(s) so that
 78  
      * workflow can routed based on this data. This method is responsible for passing over the proper Kuali (client system) data
 79  
      * that will be used by workflow to determine how the document is actually routed.
 80  
      */
 81  
     public void populateDocumentForRouting();
 82  
 
 83  
     /**
 84  
      * This is a method where we can get the xml of a document that the workflow system will use to base it's routing and search
 85  
      * attributes on.
 86  
      * 
 87  
      * @return the document serialized to an xml string
 88  
      */
 89  
     public String serializeDocumentToXml();
 90  
     
 91  
     /**
 92  
      * This method is used to get the xml that should be used in a Route Report.  In it's default implementation this will call the
 93  
      * methods prepareForSave() and populateDocumentForRouting().
 94  
      */
 95  
     public String getXmlForRouteReport();
 96  
     
 97  
     /**
 98  
      * method to integrate with workflow, where we will actually handle the transitions of levels for documents
 99  
      */
 100  
     public void doRouteLevelChange(DocumentRouteLevelChangeDTO levelChangeEvent);
 101  
     
 102  
     /**
 103  
      * method to integrate with workflow where we will be able to perform logic for an action taken being performed on a document
 104  
      */
 105  
     public void doActionTaken(ActionTakenEventDTO event);
 106  
     
 107  
     /**
 108  
      * This method will be called after the Workflow engine has completely finished processing a document.
 109  
      * 
 110  
      * @param successfullyProcessed - true if the document was processed successfully, false otherwise
 111  
      */
 112  
     public void afterWorkflowEngineProcess(boolean successfullyProcessed);
 113  
     
 114  
     /**
 115  
      * This method will be called before the Workflow engine has begun processing a document.
 116  
      */
 117  
     public void beforeWorkflowEngineProcess();
 118  
     
 119  
     /**
 120  
      * This method will be called before the Workflow engine has begun processing a document.
 121  
      */
 122  
     public List<Long> getWorkflowEngineDocumentIdsToLock();
 123  
 
 124  
     /**
 125  
      * Getter method to get the document title as it will appear in and be searchable in workflow.
 126  
      */
 127  
     public String getDocumentTitle();
 128  
 
 129  
     /**
 130  
      * getter method to get the list of ad hoc route persons associated with a document at a point in time, this list is only valid
 131  
      * for a given users version of a document as this state is only persisted in workflow itself when someone takes an action on a
 132  
      * document
 133  
      */
 134  
     public List<AdHocRoutePerson> getAdHocRoutePersons();
 135  
 
 136  
     /**
 137  
      * getter method to get the list of ad hoc route workgroups associated with a document at a point in time, this list is only
 138  
      * valid for a given users version of a document as this state is only persisted in workflow itself when someone takes an action
 139  
      * on a document
 140  
      */
 141  
     public List<AdHocRouteWorkgroup> getAdHocRouteWorkgroups();
 142  
 
 143  
     /**
 144  
      * setter method to set the list of ad hoc route persons associated with a document at a point in time, this list is only valid
 145  
      * for a given users version of a document as this state is only persisted in workflow itself when someone takes an action on a
 146  
      * document
 147  
      * 
 148  
      * @param adHocRoutePersons
 149  
      */
 150  
     public void setAdHocRoutePersons(List<AdHocRoutePerson> adHocRoutePersons);
 151  
 
 152  
     /**
 153  
      * setter method to set the list of ad hoc route workgroups associated with a document at a point in time, this list is only
 154  
      * valid for a given users version of a document as this state is only persisted in workflow itself when someone takes an action
 155  
      * on a document
 156  
      * 
 157  
      * @param adHocRouteWorkgroups
 158  
      */
 159  
     public void setAdHocRouteWorkgroups(List<AdHocRouteWorkgroup> adHocRouteWorkgroups);
 160  
 
 161  
     /**
 162  
      * This method provides a hook that will be called before the document is saved. This method is useful for applying document
 163  
      * level data to children. For example, if someone changes data at the document level, and that data needs to be propagated to
 164  
      * child objects or child lists of objects, you can use this method to update the child object or iterate through the list of
 165  
      * child objects and apply the document level data to them. Any document that follows this paradigm will need to make use of
 166  
      * this method to apply all of those changes.
 167  
      */
 168  
     public void prepareForSave();
 169  
 
 170  
     /**
 171  
      * Sends document off to the rules engine to verify business rules.
 172  
      * 
 173  
      * @param document - document to validate
 174  
      * @param event - indicates which document event was requested
 175  
      * @throws ValidationException - containing the MessageMap from the validation session.
 176  
      */
 177  
     public void validateBusinessRules(KualiDocumentEvent event);
 178  
     
 179  
     /**
 180  
      * Do any work on the document that requires the KualiDocumentEvent before the save.
 181  
      * 
 182  
      * @param event - indicates which document event was requested
 183  
      */
 184  
     public void prepareForSave(KualiDocumentEvent event);
 185  
     
 186  
     /**
 187  
      * Do any work on the document after the save.
 188  
      * 
 189  
      * @param event - indicates which document event was requested
 190  
      */
 191  
     public void postProcessSave(KualiDocumentEvent event);
 192  
     
 193  
     /**
 194  
      * This method provides a hook that will be called after a document is retrieved, but before it is returned from the
 195  
      * DocumentService.
 196  
      */
 197  
     public void processAfterRetrieve();
 198  
 
 199  
     /**
 200  
      * This method returns whether or not this document can be copied.
 201  
      * 
 202  
      * @return True if it can be copied, false if not.
 203  
      */
 204  
     public boolean getAllowsCopy();
 205  
     
 206  
     /**
 207  
      * Generate any necessary events required during the save event generation
 208  
      * 
 209  
      * @return a list of document events that were triggered by the save event
 210  
      */
 211  
     public List<KualiDocumentEvent> generateSaveEvents();
 212  
     
 213  
    /**
 214  
      * Handle the doRouteStatusChange event from the post processor
 215  
      * 
 216  
      */
 217  
     public void doRouteStatusChange(DocumentRouteStatusChangeDTO statusChangeEvent);
 218  
     
 219  
     /**
 220  
      * Returns the note type which should be used for notes associated with this document.
 221  
      * This method should never return null.
 222  
      * 
 223  
      * @return the note type supported by this document, this value should never be null
 224  
      */
 225  
     public NoteType getNoteType();
 226  
     
 227  
     /**
 228  
      * Return the target PersistableBusinessObject that notes associated with this document should be attached to.
 229  
      * In general, this method should never return null.  However, it is permissible that it will return a 
 230  
      * business object which has not been persisted yet (and therefore does not have it's unique object id
 231  
      * established).  This is only valid in cases where the note type is {@link NoteType#BUSINESS_OBJECT}.
 232  
      * 
 233  
      * In these cases it's the responsibility for implementers of the Document interface to handle storing transient
 234  
      * copies of the document notes (in XML or otherwise) until the underlying note target has been persisted and can be attached
 235  
      * to the document's notes via it's object id.
 236  
      * 
 237  
      * @return the PersistableBusinessObject with which notes on this document should be associated
 238  
      */
 239  
     public PersistableBusinessObject getNoteTarget();
 240  
     
 241  
     /**
 242  
      * Adds the given Note to the document's list of Notes.
 243  
      * 
 244  
      * @param note the Note to add, must be non-null
 245  
      */
 246  
     public void addNote(Note note);
 247  
     
 248  
     /**
 249  
      * Returns a mutable list of all notes on the document.
 250  
      * 
 251  
      * @return the list of notes associated with this document, if this document has no notes then an empty list will be returned
 252  
      */
 253  
     public List<Note> getNotes();
 254  
     
 255  
     /**
 256  
          * Sets the document's list of notes to the given list.
 257  
          * 
 258  
          * @param notes the list of notes to set on the document, must be non-null
 259  
          */
 260  
         public void setNotes(List<Note> notes);
 261  
     
 262  
     /**
 263  
      * Retrieves the note at the given index.
 264  
      * 
 265  
      * @param index the zero-based index of the note to retrieve
 266  
      * @return the note located at the given index
 267  
      * @throws IndexOutOfBoundsException if the index is out of range
 268  
      */
 269  
     public Note getNote(int index);
 270  
     
 271  
     /**
 272  
      * Removes the given note from the document's list of notes.
 273  
      * 
 274  
      * @param note the note to remove from the document's list of notes, must be non-null
 275  
      * @return true if the note was successfully removed, false if the list did not contain the given note
 276  
      */
 277  
     public boolean removeNote(Note note);
 278  
     
 279  
     /**
 280  
      * This method gets a list of the {@link PessimisticLock} objects associated with this document
 281  
      * 
 282  
      */
 283  
     public List<PessimisticLock> getPessimisticLocks();
 284  
     
 285  
     /**
 286  
      * This method updates the list of {@link PessimisticLock} objects on the document if changes could
 287  
      * have been made
 288  
      */
 289  
     public void refreshPessimisticLocks();
 290  
     
 291  
     /**
 292  
      * This method adds a new {@link PessimisticLock} to the document
 293  
      * 
 294  
      * NOTE: LOCKS ADDED VIA THIS METHOD WILL NOT BE SAVED WITH THE DOCUMENT
 295  
      * 
 296  
      * @param lock - the lock to add to the document
 297  
      */
 298  
     public void addPessimisticLock(PessimisticLock lock);
 299  
     
 300  
     /**
 301  
      * This is a method that is used by Kuali Pessimistic Locking to get the names (method to call values)
 302  
      * of the {@link KualiDocumentActionBase} methods that should release locks
 303  
      * 
 304  
      * @return the list of method names of an action that should clear locks for the current user
 305  
      */
 306  
     public List<String> getLockClearningMethodNames();
 307  
     /**
 308  
      * Returns an evaluator object that determines whether a given property relative to the root object ({@link #wrapDocumentWithMetadataForXmlSerialization()}
 309  
      * is serializable during the document serialization process.
 310  
      * 
 311  
      * @return a fully initialized evaluator object, ready to be used for workflow routing
 312  
      * 
 313  
      * @see DocumentSerializerService
 314  
      * @see #wrapDocumentWithMetadataForXmlSerialization()
 315  
      */
 316  
     
 317  
     public String getBasePathToDocumentDuringSerialization();
 318  
     
 319  
     /**
 320  
      * Returns an evaluator object that determines whether a given property relative to the root object ({@link #wrapDocumentWithMetadataForXmlSerialization()}
 321  
      * is serializable during the document serialization process.
 322  
      * 
 323  
      * @return a fully initialized evaluator object, ready to be used for workflow routing
 324  
      * 
 325  
      * @see DocumentSerializerService
 326  
      * @see #wrapDocumentWithMetadataForXmlSerialization()
 327  
      */
 328  
     public PropertySerializabilityEvaluator getDocumentPropertySerizabilityEvaluator();
 329  
     
 330  
     /**
 331  
      * This method will return the root object to be serialized for workflow routing.  If necessary, this method will wrap this document object with a wrapper (i.e. contains a reference back to this document).  This
 332  
      * wrapper may also contain references to additional objects that provide metadata useful to the workflow engine.
 333  
      * 
 334  
      * If no wrappers are necessary, then this object may return "this"
 335  
      * 
 336  
      * @return a wrapper object (most likely containing a reference to "this"), or "this" itself.
 337  
      * @see KualiDocumentXmlMaterializer
 338  
      */
 339  
     public Object wrapDocumentWithMetadataForXmlSerialization();
 340  
     
 341  
     /**
 342  
      * This method returns whether or not this document supports custom lock descriptors for pessimistic locking.
 343  
      * 
 344  
      * @return True if the document can generate custom lock descriptors, false otherwise.
 345  
      * @see #getCustomLockDescriptor(Map, Person)
 346  
      */
 347  
     public boolean useCustomLockDescriptors();
 348  
     
 349  
     /**
 350  
      * Generates a custom lock descriptor for pessimistic locking. This method should not be called unless {@link #useCustomLockDescriptors()} returns true.
 351  
      * 
 352  
      * @param user The user trying to establish the lock.
 353  
      * @return A String representing the lock descriptor.
 354  
      * @see #useCustomLockDescriptors()
 355  
      * @see org.kuali.rice.kns.service.PessimisticLockService
 356  
      * @see org.kuali.rice.kns.service.impl.PessimisticLockServiceImpl
 357  
      */
 358  
     public String getCustomLockDescriptor(Person user);
 359  
 }