Coverage Report - org.kuali.rice.kns.rule.event.AddNoteEvent
 
Classes in this File Line Coverage Branch Coverage Complexity
AddNoteEvent
0%
0/12
0%
0/2
1.333
 
 1  
 /*
 2  
  * Copyright 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.rule.event;
 17  
 
 18  
 import org.kuali.rice.kns.bo.Note;
 19  
 import org.kuali.rice.kns.document.Document;
 20  
 import org.kuali.rice.kns.rule.AddNoteRule;
 21  
 import org.kuali.rice.kns.rule.BusinessRule;
 22  
 
 23  
 /**
 24  
  * This class represents the add note event that is part of an eDoc in Kuali. This is triggered when a user presses the add button
 25  
  * for a given note or it could happen when another piece of code calls the create note method in the document service.
 26  
  * 
 27  
  * 
 28  
  */
 29  
 public final class AddNoteEvent extends KualiDocumentEventBase {
 30  
     private Note note;
 31  
 
 32  
     /**
 33  
      * Constructs an AddNoteEvent with the specified errorPathPrefix and document
 34  
      * 
 35  
      * @param document
 36  
      * @param errorPathPrefix
 37  
      */
 38  
     public AddNoteEvent(String errorPathPrefix, Document document, Note note) {
 39  0
         super("creating add note event for document " + KualiDocumentEventBase.getDocumentId(document), errorPathPrefix, document);
 40  0
         this.note = note;
 41  0
     }
 42  
 
 43  
     /**
 44  
      * Constructs an AddNoteEvent with the given document
 45  
      * 
 46  
      * @param document
 47  
      */
 48  
     public AddNoteEvent(Document document, Note note) {
 49  0
         this("", document, note);
 50  0
     }
 51  
 
 52  
     /**
 53  
      * This method retrieves the note associated with this event.
 54  
      * 
 55  
      * @return
 56  
      */
 57  
     public Note getNote() {
 58  0
         return note;
 59  
     }
 60  
 
 61  
     @Override
 62  
     public void validate() {
 63  0
         super.validate();
 64  0
         if (getNote() == null) {
 65  0
             throw new IllegalArgumentException("invalid (null) note");
 66  
         }
 67  0
     }
 68  
 
 69  
     /**
 70  
      * @see org.kuali.rice.kns.rule.event.KualiDocumentEvent#getRuleInterfaceClass()
 71  
      */
 72  
     public Class<? extends BusinessRule> getRuleInterfaceClass() {
 73  0
         return AddNoteRule.class;
 74  
     }
 75  
 
 76  
     /**
 77  
      * @see org.kuali.rice.kns.rule.event.KualiDocumentEvent#invokeRuleMethod(org.kuali.rice.kns.rule.BusinessRule)
 78  
      */
 79  
     public boolean invokeRuleMethod(BusinessRule rule) {
 80  0
         return ((AddNoteRule) rule).processAddNote(getDocument(), getNote());
 81  
     }
 82  
 }