| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
package org.itracker.model; |
| 20 |
|
|
| 21 |
|
import java.io.Serializable; |
| 22 |
|
import java.util.Comparator; |
| 23 |
|
|
| 24 |
|
import org.apache.commons.lang.builder.CompareToBuilder; |
| 25 |
|
import org.apache.commons.lang.builder.ToStringBuilder; |
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
@author |
| 35 |
|
|
|
|
|
| 23.3% |
Uncovered Elements: 56 (73) |
Complexity: 28 |
Complexity Density: 0.72 |
|
| 36 |
|
public class IssueAttachment extends AbstractEntity implements |
| 37 |
|
Comparable<Entity> { |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
private static final long serialVersionUID = 1L; |
| 43 |
|
|
| 44 |
|
public static final Comparator<IssueAttachment> SIZE_COMPARATOR = new SizeComparator(); |
| 45 |
|
|
| 46 |
|
public static final Comparator<IssueAttachment> ORIGIINAL_FILENAME_COMPARATOR = new OriginalFilenameComparator(); |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
private Issue issue; |
| 50 |
|
|
| 51 |
|
|
| 52 |
|
private String originalFileName; |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
private String fileName; |
| 61 |
|
|
| 62 |
|
|
| 63 |
|
private String type; |
| 64 |
|
|
| 65 |
|
|
| 66 |
|
private long size; |
| 67 |
|
|
| 68 |
|
|
| 69 |
|
private String description; |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
private byte[] fileData; |
| 76 |
|
|
| 77 |
|
|
| 78 |
|
private User user; |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
| 89 |
2
|
public IssueAttachment() {... |
| 90 |
|
} |
| 91 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 92 |
0
|
public IssueAttachment(Issue issue, String originalFileName) {... |
| 93 |
0
|
setIssue(issue); |
| 94 |
0
|
setOriginalFileName(originalFileName); |
| 95 |
|
} |
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 100 |
0
|
public IssueAttachment(Issue issue, String origFileName, String type,... |
| 101 |
|
String description, long size) { |
| 102 |
0
|
this(issue, origFileName); |
| 103 |
0
|
this.setType(type); |
| 104 |
0
|
this.setDescription(description); |
| 105 |
0
|
this.setSize(size); |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 111 |
0
|
public IssueAttachment(Issue issue, String origFileName, String type,... |
| 112 |
|
String description, long size, User user) { |
| 113 |
0
|
this(issue, origFileName, type, description, size); |
| 114 |
0
|
this.setUser(user); |
| 115 |
|
} |
| 116 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 117 |
0
|
public Issue getIssue() {... |
| 118 |
0
|
return (issue); |
| 119 |
|
} |
| 120 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 121 |
0
|
public void setIssue(Issue issue) {... |
| 122 |
0
|
if (issue == null) { |
| 123 |
0
|
throw new IllegalArgumentException("null issue"); |
| 124 |
|
} |
| 125 |
0
|
this.issue = issue; |
| 126 |
|
} |
| 127 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 128 |
0
|
public String getOriginalFileName() {... |
| 129 |
0
|
return originalFileName; |
| 130 |
|
} |
| 131 |
|
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 132 |
1
|
public void setOriginalFileName(String fileName) {... |
| 133 |
1
|
if (fileName == null) { |
| 134 |
0
|
throw new IllegalArgumentException("null fileName"); |
| 135 |
|
} |
| 136 |
1
|
this.originalFileName = fileName; |
| 137 |
|
} |
| 138 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 139 |
0
|
public String getType() {... |
| 140 |
0
|
return type; |
| 141 |
|
} |
| 142 |
|
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 143 |
1
|
public void setType(String mimeType) {... |
| 144 |
1
|
if (mimeType == null) { |
| 145 |
0
|
throw new IllegalArgumentException("null mimeType"); |
| 146 |
|
} |
| 147 |
1
|
this.type = mimeType; |
| 148 |
|
} |
| 149 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 150 |
0
|
public String getFileName() {... |
| 151 |
0
|
return fileName; |
| 152 |
|
} |
| 153 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 154 |
2
|
public void setFileName(String value) {... |
| 155 |
2
|
this.fileName = value; |
| 156 |
|
} |
| 157 |
|
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 158 |
0
|
public String getFileExtension() {... |
| 159 |
0
|
final int lastIndex = this.getOriginalFileName().lastIndexOf('.'); |
| 160 |
|
|
| 161 |
0
|
if (lastIndex > 0) { |
| 162 |
0
|
return this.getOriginalFileName().substring(lastIndex); |
| 163 |
|
} |
| 164 |
0
|
return ""; |
| 165 |
|
} |
| 166 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 167 |
0
|
public byte[] getFileData() {... |
| 168 |
0
|
if (null == fileData) |
| 169 |
0
|
return null; |
| 170 |
0
|
return fileData.clone(); |
| 171 |
|
} |
| 172 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 173 |
0
|
public void setFileData(byte[] value) {... |
| 174 |
0
|
if (null == value) |
| 175 |
0
|
throw new IllegalArgumentException("value must not be null"); |
| 176 |
0
|
fileData = value.clone(); |
| 177 |
|
} |
| 178 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 179 |
0
|
public String getDescription() {... |
| 180 |
0
|
return description; |
| 181 |
|
} |
| 182 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 183 |
1
|
public void setDescription(String value) {... |
| 184 |
1
|
this.description = value; |
| 185 |
|
} |
| 186 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 187 |
0
|
public long getSize() {... |
| 188 |
0
|
return size; |
| 189 |
|
} |
| 190 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 191 |
1
|
public void setSize(long size) {... |
| 192 |
1
|
this.size = size; |
| 193 |
|
} |
| 194 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 195 |
0
|
public User getUser() {... |
| 196 |
0
|
return user; |
| 197 |
|
} |
| 198 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 199 |
1
|
public void setUser(User user) {... |
| 200 |
1
|
this.user = user; |
| 201 |
|
} |
| 202 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 203 |
0
|
@Override... |
| 204 |
|
public String toString() { |
| 205 |
0
|
return new ToStringBuilder(this).append("id", getId()).append("issue", |
| 206 |
|
getIssue()).append("originalfileName", getOriginalFileName()) |
| 207 |
|
.toString(); |
| 208 |
|
} |
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
| 213 |
|
public static class SizeComparator implements Comparator<IssueAttachment>, |
| 214 |
|
Serializable { |
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
private static final long serialVersionUID = 1L; |
| 219 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 220 |
0
|
public int compare(IssueAttachment a, IssueAttachment b) {... |
| 221 |
0
|
return new CompareToBuilder() |
| 222 |
|
.append(a.getSize(), b.getSize()) |
| 223 |
|
.append(a.getOriginalFileName(), b.getOriginalFileName()) |
| 224 |
|
.append(a.getCreateDate(), b.getCreateDate()) |
| 225 |
|
.toComparison(); |
| 226 |
|
} |
| 227 |
|
|
| 228 |
|
} |
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 232 |
|
|
| 233 |
|
@author |
| 234 |
|
|
| 235 |
|
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
| 236 |
|
public static final class OriginalFilenameComparator implements |
| 237 |
|
Comparator<IssueAttachment>, Serializable { |
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
|
private static final long serialVersionUID = 1L; |
| 242 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 243 |
0
|
public int compare(IssueAttachment o1, IssueAttachment o2) {... |
| 244 |
0
|
return new CompareToBuilder() |
| 245 |
|
.append(o1.getOriginalFileName(), o1.getOriginalFileName()) |
| 246 |
|
.append(o1.getCreateDate(), o2.getCreateDate()) |
| 247 |
|
.toComparison(); |
| 248 |
|
|
| 249 |
|
} |
| 250 |
|
|
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
} |