/
DiscussionThreadDAO.java
215 lines (189 loc) · 4.92 KB
/
DiscussionThreadDAO.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
package org.sagebionetworks.repo.model.dao.discussion;
import java.util.List;
import java.util.Set;
import org.sagebionetworks.repo.model.discussion.DiscussionFilter;
import org.sagebionetworks.repo.model.discussion.DiscussionThreadBundle;
import org.sagebionetworks.repo.model.discussion.DiscussionThreadEntityReference;
import org.sagebionetworks.repo.model.discussion.DiscussionThreadOrder;
import org.sagebionetworks.repo.model.discussion.DiscussionThreadStat;
import org.sagebionetworks.repo.model.discussion.EntityThreadCounts;
public interface DiscussionThreadDAO {
/**
* Create a new discussion thread
*
* @param forumId
* @param threadId
* @param title
* @param messageKey
* @param userId
* @return
*/
public DiscussionThreadBundle createThread(String forumId, String threadId,
String title, String messageKey, long userId);
/**
* Get a discussion thread
*
* @param threadId
* @param filter
* @return
*/
public DiscussionThreadBundle getThread(long threadId, DiscussionFilter filter);
/**
* Get the number of discussion thread in a given forum
*
* @param forumId
* @param filter
* @return
*/
public long getThreadCountForForum(long forumId, DiscussionFilter filter);
/**
* Get a paginated list of discussion thread for a forum given forumId,
* the order of the discussion thread, limit and offset
*
* @param forumId
* @param limit
* @param offset
* @param order
* @param ascending
* @param filter
* @return
*/
public List<DiscussionThreadBundle> getThreadsForForum(long forumId,
Long limit, Long offset, DiscussionThreadOrder order, Boolean ascending,
DiscussionFilter filter);
/**
* Mark a discussion thread as deleted
*
* @param threadId
*/
public void markThreadAsDeleted(long threadId);
/**
* Update a discussion thread message
*
* @param threadId
* @param newMessageKey
*/
public DiscussionThreadBundle updateMessageKey(long threadId, String newMessageKey);
/**
* Update a discussion thread title
*
* @param threadId
* @param title
*/
public DiscussionThreadBundle updateTitle(long threadId, String title);
/**
* insert ignore a record into THREAD_VIEW table
*
* @param threadId
* @param userId
*/
public void updateThreadView(long threadId, long userId);
/**
* count the number of users who viewed this thread
*
* @param threadId
*/
public long countThreadView(long threadId);
/**
* Get the etag before attempt to update
*
* @param threadId
* @return
*/
public String getEtagForUpdate(long threadId);
/**
* Get all thread Id
*
* @param limit
* @param offset
* @return
*/
public List<Long> getAllThreadId(Long limit, Long offset);
/**
* Pin a thread
*
* @param threadId
*/
public void pinThread(long threadId);
/**
* Unpin a thread
* @param threadId
*/
public void unpinThread(long threadId);
/**
* Return the projectID that this thread belong to
*
* @param threadId
* @return
*/
public String getProjectId(String threadId);
/**
* Return the author of the thread
*
* @param threadId
* @return
*/
public String getAuthorForUpdate(String threadId);
/**
*
* @param threadId
* @return true is the thread has been marked as deleted,
* false otherwise.
*/
public boolean isThreadDeleted(String threadId);
/**
*
* @param entityId
* @param limit
* @param offset
* @param order
* @param ascending
* @param filter
* @param projectIds
* @return a list of threads that are in the given projectIds and referenced
* the given enityId
*/
public List<DiscussionThreadBundle> getThreadsForEntity(long entityId,
Long limit, Long offset, DiscussionThreadOrder order, Boolean ascending,
DiscussionFilter filter, Set<Long> projectIds);
/**
* Insert a batch of references from a thread to an entity
*
* @param refs
*/
public void insertEntityReference(List<DiscussionThreadEntityReference> refs);
/**
* Get a list of projectIds that threads, which mentioned entityIds, belongs to.
*
* @param list
* @return
*/
public Set<Long> getDistinctProjectIdsOfThreadsReferencesEntityIds(List<Long> list);
/**
* @param entityIds
* @param projectIds
* @return number of threads, within a range or projects, that mentioned a
* particular entity, for a list of entityIds.
*/
public EntityThreadCounts getThreadCounts(List<Long> entityIds, Set<Long> projectIds);
/**
* @param entityId
* @param filter
* @param projectIds
* @return number of threads, within a range or projects, that mentioned a
* particular entity, for a given entityId
*/
public long getThreadCountForEntity(long entityId, DiscussionFilter filter, Set<Long> projectIds);
/**
* Update the statistic of a thread
*
* @param stats
*/
public void updateThreadStats(List<DiscussionThreadStat> stats);
/**
* Mark a discussion thread as not deleted
*
* @param threadId
*/
public void markThreadAsNotDeleted(long threadId);
}