| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
package org.kuali.rice.kns.service.impl; |
| 17 |
|
|
| 18 |
|
import java.util.List; |
| 19 |
|
|
| 20 |
|
import org.apache.commons.lang.StringUtils; |
| 21 |
|
import org.kuali.rice.kns.bo.Note; |
| 22 |
|
import org.kuali.rice.kns.bo.PersistableBusinessObject; |
| 23 |
|
import org.kuali.rice.kns.dao.NoteDao; |
| 24 |
|
import org.kuali.rice.kns.service.AttachmentService; |
| 25 |
|
import org.kuali.rice.kns.service.NoteService; |
| 26 |
|
import org.kuali.rice.kns.util.ObjectUtils; |
| 27 |
|
import org.springframework.transaction.annotation.Transactional; |
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
@author |
| 33 |
|
|
| 34 |
|
@Transactional |
|
|
|
| 0% |
Uncovered Elements: 66 (66) |
Complexity: 21 |
Complexity Density: 0.58 |
|
| 35 |
|
public class NoteServiceImpl implements NoteService { |
| 36 |
|
|
| 37 |
|
private NoteDao noteDao; |
| 38 |
|
|
| 39 |
|
private AttachmentService attachmentService; |
| 40 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 41 |
0
|
public NoteServiceImpl() {... |
| 42 |
0
|
super(); |
| 43 |
|
} |
| 44 |
|
|
| 45 |
|
|
| 46 |
|
@see |
| 47 |
|
|
|
|
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 48 |
0
|
public void saveNoteList(List<Note> notes) {... |
| 49 |
0
|
if (notes != null) { |
| 50 |
0
|
for (Note note : notes) { |
| 51 |
0
|
if (StringUtils.isBlank(note.getRemoteObjectIdentifier())) { |
| 52 |
0
|
throw new IllegalStateException("The remote object identifier must be established on a Note before it can be saved. The following note in the given list had a null or empty remote object identifier: " + note); |
| 53 |
|
} |
| 54 |
0
|
save(note); |
| 55 |
|
} |
| 56 |
|
} |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
|
| 60 |
|
@see |
| 61 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 62 |
0
|
public Note save(Note note) {... |
| 63 |
0
|
validateNoteNotNull(note); |
| 64 |
0
|
if (StringUtils.isBlank(note.getRemoteObjectIdentifier())) { |
| 65 |
0
|
throw new IllegalStateException("The remote object identifier must be established on a Note before it can be saved. Given note had a null or empty remote object identifier."); |
| 66 |
|
} |
| 67 |
0
|
noteDao.save(note); |
| 68 |
|
|
| 69 |
0
|
if (note.getAttachment() != null) { |
| 70 |
0
|
attachmentService.moveAttachmentWherePending(note); |
| 71 |
|
} |
| 72 |
0
|
return note; |
| 73 |
|
} |
| 74 |
|
|
| 75 |
|
|
| 76 |
|
@see |
| 77 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 78 |
0
|
public List<Note> getByRemoteObjectId(String remoteObjectId) {... |
| 79 |
0
|
if (StringUtils.isBlank(remoteObjectId)) { |
| 80 |
0
|
throw new IllegalArgumentException("The remoteObjectId must not be null or blank."); |
| 81 |
|
} |
| 82 |
0
|
return noteDao.findByremoteObjectId(remoteObjectId); |
| 83 |
|
} |
| 84 |
|
|
| 85 |
|
|
| 86 |
|
@see |
| 87 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 88 |
0
|
public Note getNoteByNoteId(Long noteId) {... |
| 89 |
0
|
if (noteId == null) { |
| 90 |
0
|
throw new IllegalArgumentException("The noteId must not be null."); |
| 91 |
|
} |
| 92 |
0
|
return noteDao.getNoteByNoteId(noteId); |
| 93 |
|
} |
| 94 |
|
|
| 95 |
|
|
| 96 |
|
@see |
| 97 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 98 |
0
|
public void deleteNote(Note note) {... |
| 99 |
0
|
validateNoteNotNull(note); |
| 100 |
0
|
noteDao.deleteNote(note); |
| 101 |
|
} |
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
@see |
| 107 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 108 |
0
|
public Note createNote(Note noteToCopy, PersistableBusinessObject bo, String authorPrincipalId) {... |
| 109 |
0
|
validateNoteNotNull(noteToCopy); |
| 110 |
0
|
if (bo == null) { |
| 111 |
0
|
throw new IllegalArgumentException("The bo must not be null."); |
| 112 |
|
} |
| 113 |
0
|
if (StringUtils.isBlank(authorPrincipalId)) { |
| 114 |
0
|
throw new IllegalArgumentException("The authorPrincipalId must not be null."); |
| 115 |
|
} |
| 116 |
|
|
| 117 |
|
|
| 118 |
0
|
Note tmpNote = (Note) ObjectUtils.deepCopy(noteToCopy); |
| 119 |
0
|
tmpNote.setRemoteObjectIdentifier(bo.getObjectId()); |
| 120 |
0
|
tmpNote.setAuthorUniversalIdentifier(authorPrincipalId); |
| 121 |
0
|
return tmpNote; |
| 122 |
|
} |
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
@param |
| 128 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 129 |
0
|
public void setNoteDao(NoteDao d) {... |
| 130 |
0
|
this.noteDao = d; |
| 131 |
|
} |
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 136 |
0
|
protected NoteDao getNoteDao() {... |
| 137 |
0
|
return noteDao; |
| 138 |
|
} |
| 139 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 140 |
0
|
public void setAttachmentService(AttachmentService attachmentService) {... |
| 141 |
0
|
this.attachmentService = attachmentService; |
| 142 |
|
} |
| 143 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 144 |
0
|
protected AttachmentService getAttachmentService() {... |
| 145 |
0
|
return this.attachmentService; |
| 146 |
|
} |
| 147 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 148 |
0
|
private void validateNoteNotNull(Note note) {... |
| 149 |
0
|
if (note == null) { |
| 150 |
0
|
throw new IllegalArgumentException("Note must not be null."); |
| 151 |
|
} |
| 152 |
|
} |
| 153 |
|
|
| 154 |
|
} |