1 /*
2 * This software was designed and created by Jason Carroll.
3 * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4 * The author can be reached at jcarroll@cowsultants.com
5 * ITracker website: http://www.cowsultants.com
6 * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it only under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19 package org.itracker.services;
20
21 import java.util.Date;
22 import java.util.HashSet;
23 import java.util.List;
24 import java.util.Map;
25 import java.util.Set;
26
27 import org.itracker.model.Component;
28 import org.itracker.model.Issue;
29 import org.itracker.model.IssueActivity;
30 import org.itracker.model.IssueAttachment;
31 import org.itracker.model.IssueField;
32 import org.itracker.model.IssueHistory;
33 import org.itracker.model.IssueRelation;
34 import org.itracker.model.IssueSearchQuery;
35 import org.itracker.model.PermissionType;
36 import org.itracker.model.Project;
37 import org.itracker.model.User;
38 import org.itracker.model.Version;
39 import org.itracker.services.exceptions.IssueSearchException;
40 import org.itracker.services.exceptions.ProjectException;
41
42 public interface IssueService {
43
44 Issue getIssue(Integer issueId);
45
46 /**
47 * @deprecated Don't use due to EXPENSIVE memory use.
48 * @return
49 */
50 List<Issue> getAllIssues();
51
52
53 Long getNumberIssues();
54
55 /**
56 * Returns an array of issues that are currently at the given status.
57 * @param status the status to search for
58 * @return an array of issues with the given status
59 */
60 List<Issue> getIssuesWithStatus(int status);
61
62 /**
63 * Returns an array of issues that are currently at the given status or a status
64 * less than the given status.
65 * @param status the status to search for
66 * @return an array of issues with the given status or lower
67 */
68 List<Issue> getIssuesWithStatusLessThan(int status);
69
70 /**
71 * Returns an array of issues that are currently at the given severity.
72 * @param severity the severity to search for
73 * @return an array of issues with the given severity
74 */
75 List<Issue> getIssuesWithSeverity(int severity);
76
77 List<Issue> getIssuesByProjectId(Integer projectId);
78
79 List<Issue> getIssuesByProjectId(Integer projectId, int status);
80
81 List<Issue> getIssuesCreatedByUser(Integer userId);
82
83 List<Issue> getIssuesCreatedByUser(Integer userId, boolean availableProjectsOnly);
84
85 List<Issue> getIssuesOwnedByUser(Integer userId);
86
87 List<Issue> getIssuesOwnedByUser(Integer userId, boolean availableProjectsOnly);
88
89 List<Issue> getIssuesWatchedByUser(Integer userId);
90
91 List<Issue> getIssuesWatchedByUser(Integer userId, boolean availableProjectsOnly);
92
93 List<Issue> getUnassignedIssues();
94
95 List<Issue> getUnassignedIssues(boolean availableProjectsOnly);
96 /**
97 * Creates a new issue in a project.
98 * @param model an Issue representing the new issue information
99 * @param projectId the projectId the issue belongs to
100 * @param userId the id of registered creator of the new issue
101 * @param createdById the id of the actual creator of the issue. This would normally be the same as the userId.
102 * @return an Issue containing the newly created issue, or null if the create failed
103 */
104 Issue createIssue(Issue issue, Integer projectId, Integer userId, Integer createdById)
105 throws ProjectException;
106
107 /**
108 * Save a modified issue to the persistence layer
109 *
110 * @param issueDirty the changed, unsaved issue to update on persistency layer
111 * @param userId the user-id of the changer
112 *
113 */
114 Issue updateIssue(Issue issue, Integer userId) throws ProjectException;
115 Issue systemUpdateIssue(Issue issue, Integer userId) throws ProjectException;
116
117 /**
118 * Moves an issues from its current project to a new project.
119 * @param issue an Issue of the issue to move
120 * @param projectId the id of the target project
121 * @param userId the id of the user that is moving the issue
122 * @return an Issue of the issue after it has been moved
123 */
124 Issue moveIssue(Issue issue, Integer projectId, Integer userId);
125
126 /**
127 *
128 * @param issueId
129 * @param userId
130 * @return
131 */
132 boolean assignIssue(Integer issueId, Integer userId);
133
134 /**
135 *
136 * @param issueId
137 * @param userId
138 * @param assignedByUserId
139 * @return
140 */
141 boolean assignIssue(Integer issueId, Integer userId, Integer assignedByUserId);
142
143 /**
144 * TODO: Add Javadocs here: document this whole class.describe what is the use for this method.
145 * @param issueId
146 * @param fields
147 * @return
148 */
149 boolean setIssueFields(Integer issueId, List<IssueField> fields);
150
151 boolean setIssueComponents(Integer issueId, HashSet<Integer> componentIds, Integer userId);
152
153 boolean setIssueVersions(Integer issueId, HashSet<Integer> versionIds, Integer userId);
154
155 boolean addIssueHistory(IssueHistory history);
156
157 boolean addIssueRelation(Integer issueId, Integer relatedIssueId, int relationType, Integer userId);
158
159 //boolean addIssueActivity(IssueActivityModel model);
160
161 // void updateIssueActivityNotification(Integer issueId, boolean notificationSent);
162
163 boolean addIssueAttachment(IssueAttachment attachment, byte[] data);
164
165 /**
166 * Updates the binary data of the attachment stored in the database.
167 * @param attachmentId the id of the attachment to update
168 * @param data a byte arrray of the binary data for the attachment
169 * @return true if the update was successful
170 */
171 boolean setIssueAttachmentData(Integer attachmentId, byte[] data);
172
173 /**
174 * Updates the binary data of the attachment stored in the database. Used mainly
175 * to take an existing attachment stored on the filesystem and move it into
176 * the database.
177 * @param fileName the filename listed in the database for the localtion of the attachment.
178 * This is the name that was previously used to store the data on the
179 * filesystem, not the original filename of the attachment.
180 * @param data a byte arrray of the binary data for the attachment
181 * @return true if the update was successful
182 */
183 boolean setIssueAttachmentData(String fileName, byte[] data);
184
185 // boolean addIssueNotification(Notification notification);
186
187 boolean removeIssueAttachment(Integer attachmentId);
188
189 //TODO: shall we deprecate this one? why do we need to give it a userId?
190 Integer removeIssueHistoryEntry(Integer entryId, Integer userId);
191
192 void removeIssueRelation(Integer relationId, Integer userId);
193
194 Project getIssueProject(Integer issueId);
195
196 List<Component> getIssueComponents(Integer issueId);
197
198 HashSet<Integer> getIssueComponentIds(Integer issueId);
199
200 List<Version> getIssueVersions(Integer issueId);
201
202 HashSet<Integer> getIssueVersionIds(Integer issueId);
203
204 User getIssueCreator(Integer issueId);
205
206 User getIssueOwner(Integer issueId);
207
208 IssueRelation getIssueRelation(Integer relationId);
209
210 List<IssueActivity> getIssueActivity(Integer issueId);
211
212 List<IssueActivity> getIssueActivity(Integer issueId, boolean notificationSent);
213 /**
214 * @deprecated
215 * @return
216 */
217 List<IssueAttachment> getAllIssueAttachments();
218
219 // /**
220 // * @deprecated use the methods getAllIssueAttachmentSize and getAllIssueAttachmentCount instead.
221 // * @return
222 // */
223 // long[] getAllIssueAttachmentsSizeAndCount();
224
225 Long getAllIssueAttachmentSize();
226
227 // /**
228 // * @deprecated use getAllIssueAttachmentSize instead.
229 // * @return
230 // */
231 // Long totalSystemIssuesAttachmentSize();
232 // /**
233 // * @deprecated use getAllIssuesAttachmentCount instead
234 // * @return
235 // */
236 // Long countSystemIssuesAttachments();
237
238 Long getAllIssueAttachmentCount();
239
240
241 IssueAttachment getIssueAttachment(Integer attachmentId);
242
243 /**
244 * Returns the binary data for an attachment.
245 * @param attachmentId the id of the attachment to obtain the data for
246 * @return a byte array containing the attachment data
247 */
248 byte[] getIssueAttachmentData(Integer attachmentId);
249
250 List<IssueAttachment> getIssueAttachments(Integer issueId);
251
252 int getIssueAttachmentCount(Integer issueId);
253
254 /**
255 * Returns the latest issue history entry for a particular issue.
256 * @param issueId the id of the issue to return the history entry for.
257 * @return the latest IssueHistory, or null if no entries could be found
258 */
259 IssueHistory getLastIssueHistory(Integer issueId);
260
261 List<IssueHistory> getIssueHistory(Integer issueId);
262
263 // /**
264 // * @deprecated Moved to NotificationService
265 // * Retrieves the primary issue notifications. Primary notifications
266 // * are defined as the issue owner (or creator if not assigned), and any project owners.
267 // * This should encompass the list of people that should be notified so that action
268 // * can be taken on an issue that needs immediate attention.
269 // * @param issueId the id of the issue to find notifications for
270 // * @returns an array of NotificationModels
271 // */
272 // List<Notification> getPrimaryIssueNotifications(Integer issueId);
273 //
274 // /**
275 // * Retrieves all notifications for an issue where the notification's user is also active.
276 // * @param issueId the id of the issue to find notifications for
277 // * @returns an array of NotificationModels
278 // * @deprecated Moved to NotificationService
279 // */
280 // List<Notification> getIssueNotifications(Integer issueId);
281 //
282 // /**
283 // * Retrieves an array of issue notifications. The notifications by default
284 // * is the creator and owner of the issue, all project admins for the issue's project,
285 // * and anyone else that has a notfication on file.
286 // * @param issueId the id of the issue to find notifications for
287 // * @param pimaryOnly only include the primary notifications
288 // * @param activeOnly only include the notification if the user is currently active (not locked or deleted)
289 // * @returns an array of NotificationModels
290 // * @see org.itracker.services.implementations.IssueServiceImpl#getPrimaryIssueNotifications
291 // * @deprecated moved to NotificationService
292 // */
293 // boolean removeIssueNotification(Integer notificationId);
294 //
295 // /**
296 // * @deprecated Moved to NotificationService
297 // * @param issueId
298 // * @param primaryOnly
299 // * @param activeOnly
300 // * @return
301 // */
302 // List<Notification> getIssueNotifications(Integer issueId, boolean primaryOnly, boolean activeOnly);
303 // /**
304 // * @deprecated Moved to NotificationService
305 // * @param issueId
306 // * @param userId
307 // * @return
308 // */
309 // boolean hasIssueNotification(Integer issueId, Integer userId);
310
311
312 int getOpenIssueCountByProjectId(Integer projectId);
313
314 int getResolvedIssueCountByProjectId(Integer projectId);
315
316 int getTotalIssueCountByProjectId(Integer projectId);
317
318 Date getLatestIssueDateByProjectId(Integer projectId);
319
320 boolean canViewIssue(Integer issueId, User user);
321
322 boolean canViewIssue(Issue issue, User user);
323
324 public List<Issue> searchIssues(IssueSearchQuery queryModel, User user, Map<Integer, Set<PermissionType>> userPermissions) throws IssueSearchException;
325
326
327 }