|
28 | 28 | @EqualsAndHashCode(callSuper = true)
|
29 | 29 | public class Artifact extends PanacheMongoEntityBase {
|
30 | 30 |
|
31 |
| - private static final String ENGAGEMENT_UUID = "engagementUuid"; |
32 |
| - private static final String MODIFIED = "modified"; |
33 |
| - private static final String UUID = "uuid"; |
34 |
| - |
35 |
| - @BsonId |
36 |
| - @DiffIgnore |
37 |
| - @JsonbTransient |
38 |
| - private ObjectId id; |
39 |
| - |
40 |
| - @Id |
41 |
| - private String uuid; |
42 |
| - @DiffIgnore |
43 |
| - private String created; |
44 |
| - @DiffIgnore |
45 |
| - private String modified; |
46 |
| - |
47 |
| - @NotBlank |
48 |
| - private String engagementUuid; |
49 |
| - @NotBlank |
50 |
| - private String title; |
51 |
| - @NotBlank |
52 |
| - private String description; |
53 |
| - @NotBlank |
54 |
| - private String type; |
55 |
| - @NotBlank |
56 |
| - private String linkAddress; |
57 |
| - |
58 |
| - /** |
59 |
| - * Returns an {@link ArtifactCount} containing the count for the total number of |
60 |
| - * {@link Artifact}s in the database. |
61 |
| - * |
62 |
| - * @return |
63 |
| - */ |
64 |
| - public static ArtifactCount countAllArtifacts() { |
65 |
| - return ArtifactCount.builder().count(count()).build(); |
66 |
| - } |
67 |
| - |
68 |
| - /** |
69 |
| - * Returns an {@link ArtifactCount} containing the count for the number of |
70 |
| - * {@link Artifact} matching the engagement uuid. |
71 |
| - * |
72 |
| - * @param engagementUuid |
73 |
| - * @return |
74 |
| - */ |
75 |
| - public static ArtifactCount countArtifactsByEngagementUuid(String engagementUuid) { |
76 |
| - return ArtifactCount.builder().count(count(ENGAGEMENT_UUID, engagementUuid)).build(); |
77 |
| - } |
78 |
| - |
79 |
| - /** |
80 |
| - * Returns {@link List} of {@link Artifact}s sorted descending on modified |
81 |
| - * timestamp using the page specified. |
82 |
| - * |
83 |
| - * @param page |
84 |
| - * @param pageSize |
85 |
| - * @return |
86 |
| - */ |
87 |
| - public static List<Artifact> pagedArtifacts(int page, int pageSize) { |
88 |
| - return findAll(Sort.descending(MODIFIED)).page(page, pageSize).list(); |
89 |
| - } |
90 |
| - |
91 |
| - /** |
92 |
| - * Returns a {@link List} of {@link Artifact}s for the given engagement uuid, |
93 |
| - * sorted descending by modified timestamp using the page specified. |
94 |
| - * |
95 |
| - * @param engagementUuid |
96 |
| - * @param page |
97 |
| - * @param pageSize |
98 |
| - * @return |
99 |
| - */ |
100 |
| - public static List<Artifact> pagedArtifactsByEngagementUuid(String engagementUuid, int page, int pageSize) { |
101 |
| - return find(ENGAGEMENT_UUID, Sort.descending(MODIFIED), engagementUuid).page(page, pageSize).list(); |
102 |
| - } |
103 |
| - |
104 |
| - /** |
105 |
| - * Returns a {@link List} containing all {@link Artifact}s that match the given |
106 |
| - * engagement uuid. |
107 |
| - * |
108 |
| - * @param engagementUuid |
109 |
| - * @return |
110 |
| - */ |
111 |
| - public static List<Artifact> findAllByEngagementUuid(String engagementUuid) { |
112 |
| - return list(ENGAGEMENT_UUID, engagementUuid); |
113 |
| - } |
114 |
| - |
115 |
| - /** |
116 |
| - * Returns and {@link Optional} containing the {@link Artifact} that matches the |
117 |
| - * given uuid. Otherwise, and empty {@link Optional} is returned. |
118 |
| - * |
119 |
| - * @param uuid |
120 |
| - * @return |
121 |
| - */ |
122 |
| - public static Optional<Artifact> findByUuid(String uuid) { |
123 |
| - return find(UUID, uuid).singleResultOptional(); |
124 |
| - } |
125 |
| - |
126 |
| - /** |
127 |
| - * Returns the number of {@link Artifact}s delete with the given uuid. |
128 |
| - * |
129 |
| - * @param uuid |
130 |
| - * @return |
131 |
| - */ |
132 |
| - public static long deleteByUuid(String uuid) { |
133 |
| - return Artifact.delete(UUID, uuid); |
134 |
| - } |
135 |
| - |
136 |
| - /** |
137 |
| - * Removes all {@link Artifact}s from the database. |
138 |
| - */ |
139 |
| - public static long removeAllArtifacts() { |
140 |
| - return deleteAll(); |
141 |
| - } |
| 31 | + private static final String ENGAGEMENT_UUID = "engagementUuid"; |
| 32 | + private static final String MODIFIED = "modified"; |
| 33 | + private static final String UUID = "uuid"; |
| 34 | + |
| 35 | + @BsonId |
| 36 | + @DiffIgnore |
| 37 | + @JsonbTransient |
| 38 | + private ObjectId id; |
| 39 | + |
| 40 | + @Id |
| 41 | + private String uuid; |
| 42 | + @DiffIgnore |
| 43 | + private String created; |
| 44 | + @DiffIgnore |
| 45 | + private String modified; |
| 46 | + |
| 47 | + @NotBlank |
| 48 | + private String engagementUuid; |
| 49 | + @NotBlank |
| 50 | + private String title; |
| 51 | + @NotBlank |
| 52 | + private String description; |
| 53 | + @NotBlank |
| 54 | + private String type; |
| 55 | + @NotBlank |
| 56 | + private String linkAddress; |
| 57 | + |
| 58 | + /** |
| 59 | + * Returns an {@link ArtifactCount} containing the count for the total number of |
| 60 | + * {@link Artifact}s in the database. |
| 61 | + * |
| 62 | + * @return |
| 63 | + */ |
| 64 | + public static ArtifactCount countAllArtifacts() { |
| 65 | + return ArtifactCount.builder().count(count()).build(); |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Returns an {@link ArtifactCount} containing the count for the number of |
| 70 | + * {@link Artifact} matching the engagement uuid. |
| 71 | + * |
| 72 | + * @param engagementUuid |
| 73 | + * @return |
| 74 | + */ |
| 75 | + public static ArtifactCount countArtifactsByEngagementUuid(String engagementUuid) { |
| 76 | + return ArtifactCount.builder().count(count(ENGAGEMENT_UUID, engagementUuid)).build(); |
| 77 | + } |
| 78 | + |
| 79 | + /** |
| 80 | + * Returns {@link List} of {@link Artifact}s sorted descending on modified |
| 81 | + * timestamp using the page specified. |
| 82 | + * |
| 83 | + * @param page |
| 84 | + * @param pageSize |
| 85 | + * @return |
| 86 | + */ |
| 87 | + public static List<Artifact> pagedArtifacts(int page, int pageSize) { |
| 88 | + return findAll(Sort.descending(MODIFIED)).page(page, pageSize).list(); |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Returns a {@link List} of {@link Artifact}s for the given engagement uuid, |
| 93 | + * sorted descending by modified timestamp using the page specified. |
| 94 | + * |
| 95 | + * @param engagementUuid |
| 96 | + * @param page |
| 97 | + * @param pageSize |
| 98 | + * @return |
| 99 | + */ |
| 100 | + public static List<Artifact> pagedArtifactsByEngagementUuid(String engagementUuid, int page, int pageSize) { |
| 101 | + return find(ENGAGEMENT_UUID, Sort.descending(MODIFIED), engagementUuid).page(page, pageSize).list(); |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * Returns a {@link List} containing all {@link Artifact}s that match the given |
| 106 | + * engagement uuid. |
| 107 | + * |
| 108 | + * @param engagementUuid |
| 109 | + * @return |
| 110 | + */ |
| 111 | + public static List<Artifact> findAllByEngagementUuid(String engagementUuid) { |
| 112 | + return list(ENGAGEMENT_UUID, engagementUuid); |
| 113 | + } |
| 114 | + |
| 115 | + /** |
| 116 | + * Returns and {@link Optional} containing the {@link Artifact} that matches the |
| 117 | + * given uuid. Otherwise, and empty {@link Optional} is returned. |
| 118 | + * |
| 119 | + * @param uuid |
| 120 | + * @return |
| 121 | + */ |
| 122 | + public static Optional<Artifact> findByUuid(String uuid) { |
| 123 | + return find(UUID, uuid).singleResultOptional(); |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + * Returns the number of {@link Artifact}s delete with the given uuid. |
| 128 | + * |
| 129 | + * @param uuid |
| 130 | + * @return |
| 131 | + */ |
| 132 | + public static long deleteByUuid(String uuid) { |
| 133 | + return Artifact.delete(UUID, uuid); |
| 134 | + } |
| 135 | + |
| 136 | + /** |
| 137 | + * Removes all {@link Artifact}s from the database. |
| 138 | + */ |
| 139 | + public static long removeAllArtifacts() { |
| 140 | + return deleteAll(); |
| 141 | + } |
142 | 142 |
|
143 | 143 | }
|
0 commit comments