Skip to content

Commit 6b6201f

Browse files
committed
Merge pull request #105 from surevine/issue-83
Handle full and minimal parent item references. Closes #83.
2 parents 2dd556b + 94bd6a2 commit 6b6201f

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

src/main/java/org/buddycloud/channelserver/db/jdbc/JDBCNodeStore.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,7 @@ public ClosableIteratorImpl<NodeItem> getNodeItemReplies(String nodeId,
12811281
}
12821282
stmt = conn.prepareStatement(query);
12831283
stmt.setString(1, nodeId);
1284-
stmt.setString(2, itemId);
1284+
stmt.setString(2, "%" + itemId);
12851285
stmt.setTimestamp(3, new java.sql.Timestamp(since.getTime()));
12861286
if (-1 != limit)
12871287
stmt.setInt(4, limit);
@@ -1311,7 +1311,7 @@ public int getCountNodeItemReplies(String nodeId, String itemId)
13111311
try {
13121312
stmt = conn.prepareStatement(dialect.selectCountItemReplies());
13131313
stmt.setString(1, nodeId);
1314-
stmt.setString(2, itemId);
1314+
stmt.setString(2, "%" + itemId);
13151315

13161316
java.sql.ResultSet rs = stmt.executeQuery();
13171317

@@ -1344,7 +1344,7 @@ public ClosableIteratorImpl<NodeItem> getNodeItemThread(String nodeId,
13441344
}
13451345
stmt = conn.prepareStatement(query);
13461346
stmt.setString(1, nodeId);
1347-
stmt.setString(2, itemId);
1347+
stmt.setString(2, "%" + itemId);
13481348
stmt.setString(3, itemId);
13491349
stmt.setTimestamp(4, new java.sql.Timestamp(since.getTime()));
13501350
if (-1 != limit)
@@ -1375,7 +1375,7 @@ public int getCountNodeThread(String nodeId, String itemId)
13751375
try {
13761376
stmt = conn.prepareStatement(dialect.selectCountItemThread());
13771377
stmt.setString(1, nodeId);
1378-
stmt.setString(2, itemId);
1378+
stmt.setString(2, "%" + itemId);
13791379
stmt.setString(3, itemId);
13801380

13811381
java.sql.ResultSet rs = stmt.executeQuery();

src/main/java/org/buddycloud/channelserver/db/jdbc/dialect/Sql92NodeStoreDialect.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,23 +173,23 @@ public class Sql92NodeStoreDialect implements NodeStoreSQLDialect {
173173

174174
private static final String SELECT_ITEM_REPLIES = ""
175175
+ "SELECT \"id\", \"node\", \"xml\", \"updated\", \"in_reply_to\" "
176-
+ "FROM \"items\" WHERE \"node\" = ? AND \"in_reply_to\" = ? "
176+
+ "FROM \"items\" WHERE \"node\" = ? AND \"in_reply_to\" LIKE ? "
177177
+ "AND \"updated\" > ? ORDER BY \"updated\" DESC";
178178

179179
private static final String SELECT_ITEM_THREAD = ""
180180
+ "SELECT \"id\", \"node\", \"xml\", \"updated\", \"in_reply_to\" "
181181
+ "FROM \"items\" WHERE \"node\" = ? "
182-
+ "AND (\"in_reply_to\" = ? OR \"id\" = ?) "
182+
+ "AND (\"in_reply_to\" LIKE ? OR \"id\" = ?) "
183183
+ "AND \"updated\" > ? ORDER BY \"updated\" DESC";
184184

185185
private static final String SELECT_COUNT_ITEM_REPLIES = ""
186186
+ "SELECT COUNT(\"id\") "
187-
+ "FROM \"items\" WHERE \"node\" = ? AND \"in_reply_to\" = ? ";
187+
+ "FROM \"items\" WHERE \"node\" = ? AND \"in_reply_to\" LIKE ? ";
188188

189189
private static final String SELECT_COUNT_ITEM_THREAD = ""
190190
+ "SELECT COUNT(\"id\") "
191191
+ "FROM \"items\" WHERE \"node\" = ? "
192-
+ "AND (\"in_reply_to\" = ? OR \"id\" = ?) ";
192+
+ "AND (\"in_reply_to\" LIKE ? OR \"id\" = ?) ";
193193

194194
private static final String COUNT_SUBSCRIPTIONS_FOR_NODE = "SELECT COUNT(*) "
195195
+ "FROM \"subscriptions\", \"affiliations\" WHERE "

src/test/java/org/buddycloud/channelserver/db/jdbc/JDBCNodeStoreTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,7 @@ public void testCanGetItemRepliesWithResultSetManagement() throws Exception {
19381938
NodeItem testItem3 = new NodeItemImpl(TEST_SERVER1_NODE1_ID, "a8",
19391939
new Date(100), "<entry>payload</entry>", "a5");
19401940
NodeItem testItem4 = new NodeItemImpl(TEST_SERVER1_NODE1_ID, "a9",
1941-
new Date(200), "<entry>payload</entry>", "a5");
1941+
new Date(200), "<entry>payload</entry>", "/full-node-item-id-ref/a5");
19421942
store.addNodeItem(testItem1);
19431943
store.addNodeItem(testItem2);
19441944
store.addNodeItem(testItem3);
@@ -1963,7 +1963,7 @@ public void testCanGetItemRepliesWithResultSetManagement() throws Exception {
19631963
public void testCanGetCountOfItemReplies() throws Exception {
19641964
dbTester.loadData("node_1");
19651965
NodeItem testItem = new NodeItemImpl(TEST_SERVER1_NODE1_ID, "a6",
1966-
new Date(), "<entry>payload</entry>", "a5");
1966+
new Date(), "<entry>payload</entry>", "/full-node-item-id-ref/a5");
19671967
store.addNodeItem(testItem);
19681968

19691969
int items = store.getCountNodeItemReplies(TEST_SERVER1_NODE1_ID, "a5");
@@ -1974,7 +1974,7 @@ public void testCanGetCountOfItemReplies() throws Exception {
19741974
public void testCanGetItemThread() throws Exception {
19751975
dbTester.loadData("node_1");
19761976
NodeItem testItem = new NodeItemImpl(TEST_SERVER1_NODE1_ID, "a6",
1977-
new Date(), "<entry>payload</entry>", "a5");
1977+
new Date(), "<entry>payload</entry>", "/full-node-item-id-ref/a5");
19781978
store.addNodeItem(testItem);
19791979

19801980
ClosableIteratorImpl<NodeItem> items = store.getNodeItemThread(
@@ -1990,6 +1990,7 @@ public void testCanGetItemThread() throws Exception {
19901990
assertEquals(2, count);
19911991
assertSameNodeItem(item, testItem);
19921992
}
1993+
19931994

19941995
@Test
19951996
public void testCanGetItemThreadWithResultSetManagement() throws Exception {
@@ -2000,7 +2001,7 @@ public void testCanGetItemThreadWithResultSetManagement() throws Exception {
20002001
new Date(20), "<entry>payload</entry>", "a100");
20012002
NodeItem testItem2 = new NodeItemImpl(TEST_SERVER1_NODE1_ID, "a7",
20022003
new Date(40), "<entry>payload</entry>", "a100");
2003-
NodeItem testItem3 = new NodeItemImpl(TEST_SERVER1_NODE1_ID, "a8",
2004+
NodeItem testItem3 = new NodeItemImpl(TEST_SERVER1_NODE1_ID, "/full-node-item-id-ref/a8",
20042005
new Date(80), "<entry>payload</entry>", "a100");
20052006
NodeItem testItem4 = new NodeItemImpl(TEST_SERVER1_NODE1_ID, "a9",
20062007
new Date(160), "<entry>payload</entry>", "a100");
@@ -2029,7 +2030,7 @@ public void testCanGetItemThreadWithResultSetManagement() throws Exception {
20292030
public void testCanGetCountOfItemThread() throws Exception {
20302031
dbTester.loadData("node_1");
20312032
NodeItem testItem = new NodeItemImpl(TEST_SERVER1_NODE1_ID, "a6",
2032-
new Date(), "<entry>payload</entry>", "a5");
2033+
new Date(), "<entry>payload</entry>", "/full-node-item-id-ref/a5");
20332034
store.addNodeItem(testItem);
20342035

20352036
int items = store.getCountNodeThread(TEST_SERVER1_NODE1_ID, "a5");

0 commit comments

Comments
 (0)