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 org.itracker.*;
22 import org.itracker.model.*;
23
24 import java.util.*;
25
26 public interface IssueService {
27
28 Issue getIssue(Integer issueId);
29
30 /**
31 * @deprecated Don't use due to EXPENSIVE memory use.
32 */
33 List<Issue> getAllIssues();
34
35
36 Long getNumberIssues();
37
38 /**
39 * Returns an array of issues that are currently at the given status.
40 *
41 * @param status the status to search for
42 * @return an array of issues with the given status
43 */
44 List<Issue> getIssuesWithStatus(int status);
45
46 /**
47 * Returns an array of issues that are currently at the given status or a status
48 * less than the given status.
49 *
50 * @param status the status to search for
51 * @return an array of issues with the given status or lower
52 */
53 List<Issue> getIssuesWithStatusLessThan(int status);
54
55 /**
56 * Returns an array of issues that are currently at the given severity.
57 *
58 * @param severity the severity to search for
59 * @return an array of issues with the given severity
60 */
61 List<Issue> getIssuesWithSeverity(int severity);
62
63 List<Issue> getIssuesByProjectId(Integer projectId);
64
65 List<Issue> getIssuesByProjectId(Integer projectId, int status);
66
67 List<Issue> getIssuesCreatedByUser(Integer userId);
68
69 List<Issue> getIssuesCreatedByUser(Integer userId, boolean availableProjectsOnly);
70
71 List<Issue> getIssuesOwnedByUser(Integer userId);
72
73 List<Issue> getIssuesOwnedByUser(Integer userId, boolean availableProjectsOnly);
74
75 List<Issue> getIssuesWatchedByUser(Integer userId);
76
77 List<Issue> getIssuesWatchedByUser(Integer userId, boolean availableProjectsOnly);
78
79 List<Issue> getUnassignedIssues();
80
81 List<Issue> getUnassignedIssues(boolean availableProjectsOnly);
82
83 public List<Issue> getNextIssues(Integer issueId);
84 public List<Issue> getPreviousIssues(Integer issueId);
85 /**
86 * Creates a new issue in a project.
87 *
88 * @param issue an Issue representing the new issue information
89 * @param projectId the projectId the issue belongs to
90 * @param userId the id of registered creator of the new issue
91 * @param createdById the id of the actual creator of the issue. This would normally be the same as the userId.
92 * @return an Issue containing the newly created issue, or null if the create failed
93 */
94 Issue createIssue(Issue issue, Integer projectId, Integer userId, Integer createdById)
95 throws ProjectException;
96
97 /**
98 * Save a modified issue to the persistence layer
99 *
100 * @param issue the changed, unsaved issue to update on persistency layer
101 * @param userId the user-id of the changer
102 */
103 Issue updateIssue(Issue issue, Integer userId) throws ProjectException;
104
105 Issue systemUpdateIssue(Issue issue, Integer userId) throws ProjectException;
106
107 /**
108 * Moves an issues from its current project to a new project.
109 *
110 * @param issue an Issue of the issue to move
111 * @param projectId the id of the target project
112 * @param userId the id of the user that is moving the issue
113 * @return an Issue of the issue after it has been moved
114 */
115 Issue moveIssue(Issue issue, Integer projectId, Integer userId);
116
117 /**
118 * @param issueId
119 * @param userId
120 * @return
121 */
122 boolean assignIssue(Integer issueId, Integer userId);
123
124 /**
125 * @param issueId
126 * @param userId
127 * @param assignedByUserId
128 * @return
129 */
130 boolean assignIssue(Integer issueId, Integer userId, Integer assignedByUserId);
131
132 /**
133 * TODO: Add Javadocs here: document this whole class.describe what is the use for this method.
134 */
135 boolean setIssueFields(Integer issueId, List<IssueField> fields);
136
137 boolean setIssueComponents(Integer issueId, HashSet<Integer> componentIds, Integer userId);
138
139 boolean setIssueVersions(Integer issueId, HashSet<Integer> versionIds, Integer userId);
140
141 boolean addIssueHistory(IssueHistory history);
142
143 boolean addIssueRelation(Integer issueId, Integer relatedIssueId, IssueRelation.Type relationType, Integer userId);
144
145 boolean addIssueAttachment(IssueAttachment attachment, byte[] data);
146
147 /**
148 * Updates the binary data of the attachment stored in the database.
149 *
150 * @param attachmentId the id of the attachment to update
151 * @param data a byte arrray of the binary data for the attachment
152 * @return true if the update was successful
153 */
154 boolean setIssueAttachmentData(Integer attachmentId, byte[] data);
155
156 /**
157 * Updates the binary data of the attachment stored in the database. Used mainly
158 * to take an existing attachment stored on the filesystem and move it into
159 * the database.
160 *
161 * @param fileName the filename listed in the database for the localtion of the attachment.
162 * This is the name that was previously used to store the data on the
163 * filesystem, not the original filename of the attachment.
164 * @param data a byte arrray of the binary data for the attachment
165 * @return true if the update was successful
166 */
167 boolean setIssueAttachmentData(String fileName, byte[] data);
168
169 // boolean addIssueNotification(Notification notification);
170
171 boolean removeIssueAttachment(Integer attachmentId);
172
173 //TODO: shall we deprecate this one? why do we need to give it a userId?
174 Integer removeIssueHistoryEntry(Integer entryId, Integer userId);
175
176 void removeIssueRelation(Integer relationId, Integer userId);
177
178 Project getIssueProject(Integer issueId);
179
180 List<Component> getIssueComponents(Integer issueId);
181
182 HashSet<Integer> getIssueComponentIds(Integer issueId);
183
184 List<Version> getIssueVersions(Integer issueId);
185
186 HashSet<Integer> getIssueVersionIds(Integer issueId);
187
188 User getIssueCreator(Integer issueId);
189
190 User getIssueOwner(Integer issueId);
191
192 IssueRelation getIssueRelation(Integer relationId);
193
194 List<IssueActivity> getIssueActivity(Integer issueId);
195
196 List<IssueActivity> getIssueActivity(Integer issueId, boolean notificationSent);
197
198 List<IssueAttachment> getAllIssueAttachments();
199
200 Long getAllIssueAttachmentSize();
201
202 Long getAllIssueAttachmentCount();
203
204
205 IssueAttachment getIssueAttachment(Integer attachmentId);
206
207 /**
208 * Returns the binary data for an attachment.
209 *
210 * @param attachmentId the id of the attachment to obtain the data for
211 * @return a byte array containing the attachment data
212 */
213 byte[] getIssueAttachmentData(Integer attachmentId);
214
215 List<IssueAttachment> getIssueAttachments(Integer issueId);
216
217 int getIssueAttachmentCount(Integer issueId);
218
219 /**
220 * Returns the latest issue history entry for a particular issue.
221 *
222 * @param issueId the id of the issue to return the history entry for.
223 * @return the latest IssueHistory, or null if no entries could be found
224 */
225 IssueHistory getLastIssueHistory(Integer issueId);
226
227 List<IssueHistory> getIssueHistory(Integer issueId);
228
229 int getOpenIssueCountByProjectId(Integer projectId);
230
231 int getResolvedIssueCountByProjectId(Integer projectId);
232
233 int getTotalIssueCountByProjectId(Integer projectId);
234
235 Date getLatestIssueDateByProjectId(Integer projectId);
236
237 boolean canViewIssue(Integer issueId, User user);
238
239 boolean canViewIssue(Issue issue, User user);
240
241 public List<Issue> searchIssues(IssueSearchQuery queryModel, User user, Map<Integer, Set<PermissionType>> userPermissions) throws IssueSearchException;
242
243
244 }