@@ -114,23 +114,23 @@ public void completePartnerRequestTask(@NonNull Partner partner) {
114114 activityRepository .findByLinkIdAndTypeAndRole (partner .getId (),
115115 ActivityType .CONNECTION_REQUEST ,
116116 ActivityRole .CONNECTION_REQUEST_RECIPIENT ).ifPresentOrElse (activity -> {
117- // set to completed and mark accepted
118- activity .setState (ActivityState .CONNECTION_REQUEST_ACCEPTED );
119- activity .setCompleted (true );
120- activityRepository .update (activity );
121- eventPublisher .publishEventAsync (TaskCompletedEvent .builder ().activity (activity ).build ());
122- }, () -> {
123- // add in a completed activity
124- Activity a = Activity .builder ()
125- .linkId (partner .getId ())
126- .partner (partner )
127- .type (ActivityType .CONNECTION_REQUEST )
128- .role (ActivityRole .CONNECTION_REQUEST_RECIPIENT )
129- .state (ActivityState .CONNECTION_REQUEST_ACCEPTED )
130- .completed (true )
131- .build ();
132- activityRepository .save (a );
133- });
117+ // set to completed and mark accepted
118+ activity .setState (ActivityState .CONNECTION_REQUEST_ACCEPTED );
119+ activity .setCompleted (true );
120+ activityRepository .update (activity );
121+ eventPublisher .publishEventAsync (TaskCompletedEvent .builder ().activity (activity ).build ());
122+ }, () -> {
123+ // add in a completed activity
124+ Activity a = Activity .builder ()
125+ .linkId (partner .getId ())
126+ .partner (partner )
127+ .type (ActivityType .CONNECTION_REQUEST )
128+ .role (ActivityRole .CONNECTION_REQUEST_RECIPIENT )
129+ .state (ActivityState .CONNECTION_REQUEST_ACCEPTED )
130+ .completed (true )
131+ .build ();
132+ activityRepository .save (a );
133+ });
134134 }
135135
136136 public void deletePartnerActivities (@ NonNull Partner partner ) {
@@ -158,21 +158,21 @@ public void addPartnerAcceptedActivity(@NonNull Partner partner) {
158158 activityRepository .findByLinkIdAndTypeAndRole (partner .getId (),
159159 ActivityType .CONNECTION_REQUEST ,
160160 ActivityRole .CONNECTION_REQUEST_SENDER ).ifPresentOrElse (activity -> {
161- activity .setState (ActivityState .CONNECTION_REQUEST_ACCEPTED );
162- activity .setCompleted (true );
163- activityRepository .update (activity );
164- }, () -> {
165- // add in a completed activity
166- Activity a = Activity .builder ()
167- .linkId (partner .getId ())
168- .partner (partner )
169- .type (ActivityType .CONNECTION_REQUEST )
170- .role (ActivityRole .CONNECTION_REQUEST_SENDER )
171- .state (ActivityState .CONNECTION_REQUEST_ACCEPTED )
172- .completed (true )
173- .build ();
174- activityRepository .save (a );
175- });
161+ activity .setState (ActivityState .CONNECTION_REQUEST_ACCEPTED );
162+ activity .setCompleted (true );
163+ activityRepository .update (activity );
164+ }, () -> {
165+ // add in a completed activity
166+ Activity a = Activity .builder ()
167+ .linkId (partner .getId ())
168+ .partner (partner )
169+ .type (ActivityType .CONNECTION_REQUEST )
170+ .role (ActivityRole .CONNECTION_REQUEST_SENDER )
171+ .state (ActivityState .CONNECTION_REQUEST_ACCEPTED )
172+ .completed (true )
173+ .build ();
174+ activityRepository .save (a );
175+ });
176176 }
177177
178178 public void addPresentationExchangeTask (@ NonNull PartnerProof partnerProof ) {
@@ -213,24 +213,24 @@ public void completePresentationExchangeTask(@NonNull PartnerProof partnerProof)
213213 activityRepository .findByLinkIdAndTypeAndRole (partnerProof .getId (),
214214 ActivityType .PRESENTATION_EXCHANGE ,
215215 role ).ifPresentOrElse (activity -> {
216- // set to completed and mark accepted
217- activity .setState (state );
218- activity .setCompleted (true );
219- activityRepository .update (activity );
216+ // set to completed and mark accepted
217+ activity .setState (state );
218+ activity .setCompleted (true );
219+ activityRepository .update (activity );
220220
221- eventPublisher .publishEventAsync (TaskCompletedEvent .builder ().activity (activity ).build ());
222- }, () -> {
223- // add in a completed activity
224- Activity a = Activity .builder ()
225- .linkId (partnerProof .getId ())
226- .partner (partner )
227- .type (ActivityType .PRESENTATION_EXCHANGE )
228- .role (role )
229- .state (state )
230- .completed (true )
231- .build ();
232- activityRepository .save (a );
233- });
221+ eventPublisher .publishEventAsync (TaskCompletedEvent .builder ().activity (activity ).build ());
222+ }, () -> {
223+ // add in a completed activity
224+ Activity a = Activity .builder ()
225+ .linkId (partnerProof .getId ())
226+ .partner (partner )
227+ .type (ActivityType .PRESENTATION_EXCHANGE )
228+ .role (role )
229+ .state (state )
230+ .completed (true )
231+ .build ();
232+ activityRepository .save (a );
233+ });
234234 });
235235 }
236236
@@ -242,11 +242,11 @@ public void declinePresentationExchangeTask(@NonNull PartnerProof partnerProof)
242242 activityRepository .findByLinkIdAndTypeAndRole (partnerProof .getId (),
243243 ActivityType .PRESENTATION_EXCHANGE ,
244244 role ).ifPresent (activity -> {
245- activity .setState (ActivityState .PRESENTATION_EXCHANGE_DECLINED );
246- activity .setCompleted (true );
247- activityRepository .update (activity );
248- eventPublisher .publishEventAsync (TaskCompletedEvent .builder ().activity (activity ).build ());
249- });
245+ activity .setState (ActivityState .PRESENTATION_EXCHANGE_DECLINED );
246+ activity .setCompleted (true );
247+ activityRepository .update (activity );
248+ eventPublisher .publishEventAsync (TaskCompletedEvent .builder ().activity (activity ).build ());
249+ });
250250 });
251251 }
252252
@@ -255,9 +255,9 @@ public void deletePresentationExchangeTask(@NonNull PartnerProof partnerProof) {
255255 activityRepository .findByLinkIdAndTypeAndRole (partnerProof .getId (),
256256 ActivityType .PRESENTATION_EXCHANGE ,
257257 role ).ifPresent (activity -> {
258- activityRepository .delete (activity );
259- eventPublisher .publishEventAsync (TaskCompletedEvent .builder ().activity (activity ).build ());
260- });
258+ activityRepository .delete (activity );
259+ eventPublisher .publishEventAsync (TaskCompletedEvent .builder ().activity (activity ).build ());
260+ });
261261 }
262262
263263 private ActivityItem convert (Activity activity ) {
@@ -275,23 +275,23 @@ private ActivityItem convert(Activity activity) {
275275
276276 private ActivityState getPresentationExchangeState (PartnerProof partnerProof ) {
277277 switch (partnerProof .getState ()) {
278- case VERIFIED :
279- case PRESENTATION_ACKED :
280- return ActivityState .PRESENTATION_EXCHANGE_ACCEPTED ;
281- case REQUEST_SENT :
282- case PRESENTATIONS_SENT :
283- return ActivityState .PRESENTATION_EXCHANGE_SENT ;
284- case REQUEST_RECEIVED :
285- case PRESENTATION_RECEIVED :
278+ case VERIFIED :
279+ case PRESENTATION_ACKED :
280+ return ActivityState .PRESENTATION_EXCHANGE_ACCEPTED ;
281+ case REQUEST_SENT :
282+ case PRESENTATIONS_SENT :
283+ return ActivityState .PRESENTATION_EXCHANGE_SENT ;
284+ case REQUEST_RECEIVED :
285+ case PRESENTATION_RECEIVED :
286+ return ActivityState .PRESENTATION_EXCHANGE_RECEIVED ;
287+ default :
288+ switch (partnerProof .getRole ()) {
289+ case VERIFIER :
286290 return ActivityState .PRESENTATION_EXCHANGE_RECEIVED ;
291+ case PROVER :
287292 default :
288- switch (partnerProof .getRole ()) {
289- case VERIFIER :
290- return ActivityState .PRESENTATION_EXCHANGE_RECEIVED ;
291- case PROVER :
292- default :
293- return ActivityState .PRESENTATION_EXCHANGE_SENT ;
294- }
293+ return ActivityState .PRESENTATION_EXCHANGE_SENT ;
294+ }
295295 }
296296 }
297297
0 commit comments