Skip to content

Commit 7650298

Browse files
JoeSilentJoeVladimir Yalovy
andauthored
[BKNDLSS-25586]: Add support for upserted RT events (#511)
[BKNDLSS-25586]: Add support for upserted RT events Co-authored-by: Vladimir Yalovy <[email protected]>
1 parent cfdd4bb commit 7650298

File tree

3 files changed

+87
-2
lines changed

3 files changed

+87
-2
lines changed

src/com/backendless/rt/data/EventHandler.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ public interface EventHandler<T> extends RTListener
3131

3232
void removeUpdateListeners( String whereClause );
3333

34+
void addUpsertListener( AsyncCallback<T> callback );
35+
36+
void addUpsertListener( String whereClause, AsyncCallback<T> callback );
37+
38+
void removeUpsertListeners();
39+
40+
void removeUpsertListener( AsyncCallback<T> callback );
41+
42+
void removeUpsertListeners( String whereClause );
43+
44+
void removeUpsertListener( String whereClause, AsyncCallback<T> callback );
45+
3446
void addDeleteListener( AsyncCallback<T> callback );
3547

3648
void addDeleteListener( String whereClause, AsyncCallback<T> callback );
@@ -61,6 +73,12 @@ public interface EventHandler<T> extends RTListener
6173

6274
void removeBulkUpdateListeners( String whereClause );
6375

76+
void addBulkUpsertListener( AsyncCallback<List> callback );
77+
78+
void removeBulkUpsertListeners();
79+
80+
void removeBulkUpsertListener( AsyncCallback<List<String>> callback );
81+
6482
void addBulkDeleteListener( AsyncCallback<BulkEvent> callback );
6583

6684
void addBulkDeleteListener( String whereClause, AsyncCallback<BulkEvent> callback );

src/com/backendless/rt/data/EventHandlerImpl.java

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,49 @@ public void removeUpdateListeners( final String whereClause )
115115
removeListeners( ObjectEvents.updated, whereClause );
116116
}
117117

118+
//--------upsert-------
119+
120+
@Override
121+
public void addUpsertListener( AsyncCallback<T> callback )
122+
{
123+
DataSubscription subscription = new DataSubscription( ObjectEvents.upserted, tableName, createCallback( callback ) );
124+
addEventListener( subscription );
125+
}
126+
127+
@Override
128+
public void addUpsertListener( String whereClause, AsyncCallback<T> callback )
129+
{
130+
DataSubscription subscription = new DataSubscription( ObjectEvents.upserted, tableName, createCallback( callback ) )
131+
.withWhere( whereClause );
132+
133+
addEventListener( subscription );
134+
}
135+
136+
@Override
137+
public void removeUpsertListeners()
138+
{
139+
removeListeners( ObjectEvents.upserted );
140+
}
141+
142+
143+
@Override
144+
public void removeUpsertListener( AsyncCallback<T> callback )
145+
{
146+
removeListeners( ObjectEvents.upserted, callback );
147+
}
148+
149+
@Override
150+
public void removeUpsertListeners( String whereClause )
151+
{
152+
removeListeners( ObjectEvents.upserted, whereClause );
153+
}
154+
155+
@Override
156+
public void removeUpsertListener( String whereClause, AsyncCallback<T> callback )
157+
{
158+
removeListeners( ObjectEvents.upserted, whereClause, callback );
159+
}
160+
118161
//--------remove-------
119162

120163
@Override
@@ -221,7 +264,29 @@ public void removeBulkUpdateListeners( final String whereClause )
221264
removeListeners( ObjectEvents.bulk_updated, whereClause );
222265
}
223266

224-
//--------bulk-remove-------
267+
//--------bulk-upsert-------
268+
269+
@Override
270+
public void addBulkUpsertListener( AsyncCallback<List> callback )
271+
{
272+
DataSubscription subscription =
273+
new DataSubscription( ObjectEvents.bulk_upserted, tableName, createCallback( callback, List.class ) );
274+
addEventListener( subscription );
275+
}
276+
277+
@Override
278+
public void removeBulkUpsertListeners()
279+
{
280+
removeListeners( ObjectEvents.bulk_upserted );
281+
}
282+
283+
@Override
284+
public void removeBulkUpsertListener( AsyncCallback<List<String>> callback )
285+
{
286+
removeListeners( ObjectEvents.bulk_upserted, callback );
287+
}
288+
289+
//--------bulk-delete-------
225290

226291
@Override
227292
public void addBulkDeleteListener( AsyncCallback<BulkEvent> callback )

src/com/backendless/rt/data/ObjectEvents.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ public enum ObjectEvents implements RTEvent
88
bulk_created( "bulk-created" ),
99
updated( "updated" ),
1010
bulk_updated( "bulk-updated" ),
11+
upserted( "upserted" ),
12+
bulk_upserted( "bulk-upserted" ),
1113
deleted( "deleted" ),
1214
bulk_deleted( "bulk-deleted" );
1315

@@ -34,4 +36,4 @@ public static ObjectEvents forName( String eventName )
3436

3537
throw new IllegalArgumentException( "There is no object event with name " + eventName );
3638
}
37-
}
39+
}

0 commit comments

Comments
 (0)