Coverage Report - org.kuali.rice.kew.notes.service.impl.NoteServiceImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
NoteServiceImpl
0%
0/39
0%
0/8
2.182
 
 1  
 /**
 2  
  * Copyright 2005-2011 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.kew.notes.service.impl;
 17  
 
 18  
 import java.io.File;
 19  
 import java.util.Iterator;
 20  
 import java.util.List;
 21  
 
 22  
 import org.kuali.rice.kew.notes.Attachment;
 23  
 import org.kuali.rice.kew.notes.Note;
 24  
 import org.kuali.rice.kew.notes.dao.NoteDAO;
 25  
 import org.kuali.rice.kew.notes.service.AttachmentService;
 26  
 import org.kuali.rice.kew.notes.service.NoteService;
 27  
 
 28  
 
 29  0
 public class NoteServiceImpl implements NoteService {
 30  
 
 31  
         private NoteDAO noteDAO;
 32  
 
 33  
         private AttachmentService attachmentService;
 34  
 
 35  
         public Note getNoteByNoteId(String noteId) {
 36  0
                 return getNoteDAO().getNoteByNoteId(noteId);
 37  
         }
 38  
 
 39  
         public List<Note> getNotesByDocumentId(String documentId) {
 40  0
                 return getNoteDAO().getNotesByDocumentId(documentId);
 41  
         }
 42  
 
 43  
         public void saveNote(Note note) {
 44  
                 try {
 45  0
                         if (! note.getAttachments().isEmpty()){
 46  0
                                 for (Iterator iter = note.getAttachments().iterator(); iter.hasNext();) {
 47  0
                                         Attachment attachment = (Attachment) iter.next();
 48  0
                                         if (attachment.getAttachedObject()!= null){
 49  0
                                                 attachmentService.persistAttachedFileAndSetAttachmentBusinessObjectValue(attachment);
 50  
                                         }
 51  0
                                 }
 52  
                         }
 53  0
                         getNoteDAO().saveNote(note);
 54  0
                 } catch (Exception e) {
 55  0
                         throw new RuntimeException(e);
 56  0
                 }
 57  0
         }
 58  
 
 59  
         public void deleteNote(Note note) {
 60  
                 try {
 61  0
                         for (Iterator iter = note.getAttachments().iterator(); iter.hasNext();) {
 62  0
                                 Attachment attachment = (Attachment) iter.next();
 63  0
                                 attachmentService.deleteAttachedFile(attachment);
 64  0
                         }
 65  0
                         getNoteDAO().deleteNote(note);
 66  0
                 } catch (Exception e) {
 67  0
                         throw new RuntimeException("caught exception deleting attachment", e);
 68  0
                 }
 69  0
         }
 70  
 
 71  
         public NoteDAO getNoteDAO() {
 72  0
                 return noteDAO;
 73  
         }
 74  
 
 75  
         public void setNoteDAO(NoteDAO noteDAO) {
 76  0
                 this.noteDAO = noteDAO;
 77  0
         }
 78  
 
 79  
         public void deleteAttachment(Attachment attachment) {
 80  0
                 this.noteDAO.deleteAttachment(attachment);
 81  
                 try {
 82  0
                         attachmentService.deleteAttachedFile(attachment);
 83  0
                 } catch (Exception e) {
 84  0
                         throw new RuntimeException("caught exception deleting attachment", e);
 85  0
                 }
 86  0
         }
 87  
 
 88  
         public File findAttachmentFile(Attachment attachment) {
 89  
                 try {
 90  0
                         return attachmentService.findAttachedFile(attachment);
 91  0
                 } catch (Exception e) {
 92  0
                         throw new RuntimeException(e);
 93  
                 }
 94  
 
 95  
         }
 96  
 
 97  
         public Attachment findAttachment(String attachmentId) {
 98  0
                 return noteDAO.findAttachment(attachmentId);
 99  
         }
 100  
 
 101  
         public AttachmentService getAttachmentService() {
 102  0
                 return attachmentService;
 103  
         }
 104  
 
 105  
         public void setAttachmentService(AttachmentService attachmentService) {
 106  0
                 this.attachmentService = attachmentService;
 107  0
         }
 108  
 }