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