@@ -333,7 +333,8 @@ public static Result signalNotification(ResourceSpaceTypes originType, Notificat
333
333
String resourceText = "" ;
334
334
Date resourceDate = new Date ();
335
335
String associatedUser = "" ;
336
-
336
+ Long resourceId = null ;
337
+ Map <String , Long > urls = new HashMap <>();
337
338
Boolean originIsResourceSpace = false ;
338
339
if (origin instanceof ResourceSpace ) {
339
340
originIsResourceSpace = true ;
@@ -392,10 +393,14 @@ public static Result signalNotification(ResourceSpaceTypes originType, Notificat
392
393
resourceText = ((Contribution ) resource ).getText ();
393
394
resourceDate = resource .getCreation ();
394
395
resourceType = ((Contribution ) resource ).getType ().toString ();
396
+ resourceId = ((Contribution ) resource ).getContributionId ();
395
397
if (resourceType .equals ("BRAINSTORMING" )) resourceType = "IDEA" ;
396
398
title = "[AppCivist] New " + resourceType + " in " + originName ;
397
399
int numAuthors = ((Contribution ) resource ).getAuthors ().size ();
398
400
associatedUser = ((Contribution ) resource ).getAuthors ().get (0 ).getName () + (numAuthors > 1 ? " et. al." : "" );
401
+ Contribution contribution = (Contribution ) resource ;
402
+ setContributionUrl (contribution , urls );
403
+
399
404
break ;
400
405
case UPDATED_CONTRIBUTION_IDEA :
401
406
case UPDATED_CONTRIBUTION_PROPOSAL :
@@ -408,10 +413,12 @@ public static Result signalNotification(ResourceSpaceTypes originType, Notificat
408
413
resourceText = ((Contribution ) resource ).getText ();
409
414
resourceDate = resource .getLastUpdate ();
410
415
resourceType = ((Contribution ) resource ).getType ().toString ();
416
+ resourceId = ((Contribution ) resource ).getContributionId ();
411
417
if (resourceType .equals ("BRAINSTORMING" )) resourceType = "IDEA" ;
412
418
title = "[AppCivist] Updated " + resourceType + " in " + originName ;
413
419
numAuthors = ((Contribution ) resource ).getAuthors ().size ();
414
420
associatedUser = ((Contribution ) resource ).getAuthors ().get (0 ).getName () + (numAuthors > 1 ? " et. al." : "" );
421
+ setContributionUrl ((Contribution ) resource , urls );
415
422
break ;
416
423
// case NEW_CONTRIBUTION_FEEDBACK:
417
424
// case UPDATED_CONTRIBUTION_FEEDBACK:
@@ -430,10 +437,12 @@ public static Result signalNotification(ResourceSpaceTypes originType, Notificat
430
437
resourceUuid = ((Campaign ) resource ).getUuid ();
431
438
resourceTitle = ((Campaign ) resource ).getTitle ();
432
439
resourceText = ((Campaign ) resource ).getGoal ();
440
+ resourceId = ((Campaign ) resource ).getCampaignId ();
433
441
resourceDate = resource .getCreation ();
434
442
resourceType = AppcivistResourceTypes .CAMPAIGN .toString ();
435
443
title = "[AppCivist] New " + resourceType + " in " + originName ;
436
444
Logger .info ("Title: " + title );
445
+ setCampaignUrl (((Campaign ) resource ).getCampaignId (), urls );
437
446
// TODO: add creator to campaign associatedUser = ((Campaign) resource).getCreator().getName();
438
447
break ;
439
448
case NEW_CONTRIBUTION_FEEDBACK :
@@ -442,24 +451,29 @@ public static Result signalNotification(ResourceSpaceTypes originType, Notificat
442
451
resourceUuid = ((Campaign ) resource ).getUuid ();
443
452
resourceTitle = ((Campaign ) resource ).getTitle ();
444
453
resourceText = ((Campaign ) resource ).getGoal ();
454
+ resourceId = ((Campaign ) resource ).getCampaignId ();
445
455
resourceDate = resource .getLastUpdate ();
446
456
resourceType = AppcivistResourceTypes .CAMPAIGN .toString ();
447
457
title = "[AppCivist] Updated " + resourceType + " in " + originName ;
458
+ setCampaignUrl (((Campaign ) resource ).getCampaignId (), urls );
448
459
// TODO: add creator to campaign associatedUser = ((Campaign) resource).getCreator().getName();
449
460
break ;
450
461
case NEW_WORKING_GROUP :
451
462
resourceUuid = ((WorkingGroup ) resource ).getUuid ();
452
463
resourceTitle = ((WorkingGroup ) resource ).getName ();
453
464
resourceText = ((WorkingGroup ) resource ).getText ();
465
+ resourceId = ((WorkingGroup ) resource ).getGroupId ();
454
466
resourceDate = resource .getCreation ();
455
467
resourceType = AppcivistResourceTypes .WORKING_GROUP .toString ();
456
468
title = "[AppCivist] New " + resourceType + " in " + originName ;
457
469
associatedUser = ((WorkingGroup ) resource ).getCreator ().getName ();
470
+ setWorkingGroupUrl (resourceId , urls );
458
471
break ;
459
472
case UPDATED_WORKING_GROUP :
460
473
resourceUuid = ((WorkingGroup ) resource ).getUuid ();
461
474
resourceTitle = ((WorkingGroup ) resource ).getName ();
462
475
resourceText = ((WorkingGroup ) resource ).getText ();
476
+ resourceId = ((WorkingGroup ) resource ).getGroupId ();
463
477
resourceDate = resource .getLastUpdate ();
464
478
resourceType = AppcivistResourceTypes .WORKING_GROUP .toString ();
465
479
title = "[AppCivist] Updated " + resourceType + " in " + originName ;
@@ -468,22 +482,9 @@ public static Result signalNotification(ResourceSpaceTypes originType, Notificat
468
482
} else {
469
483
associatedUser = "" ;
470
484
}
485
+ setWorkingGroupUrl (resourceId , urls );
471
486
break ;
472
487
case NEW_VOTING_BALLOT :
473
- Logger .info ("NEW_VOTING_BALLOT" );
474
- WorkingGroup wg = (WorkingGroup ) resource ;
475
- //TODO: HOW TO KNOW WHAT BALLOT IS THE LAST
476
- Ballot lastBallot = wg .getBallots ().get (wg .getBallots ().size () - 1 );
477
- resourceUuid = lastBallot .getUuid ();
478
- resourceTitle = lastBallot .getDecisionType ();
479
- resourceText = lastBallot .getNotes ();
480
- resourceDate = lastBallot .getCreatedAt ();
481
- resourceType = AppcivistResourceTypes .BALLOT .toString ();
482
- title = "[AppCivist] Updated " + resourceType + " in " + originName ;
483
- //TODO: how to get the associatedUser
484
- associatedUser = "" ;
485
- Logger .info ("DATOS NOTIFICACION( " + originUUID + ", " + originType + ", " + originName + ", " + eventName + ", " + title + ", " + text + ", " + resourceUuid + ", " + resourceTitle + ", " + resourceText + ", " + resourceDate + ", " + resourceType + ", " + associatedUser + ")" );
486
- break ;
487
488
case UPDATED_VOTING_BALLOT :
488
489
// // TODO: how to describe updated ballots that are not descendants of AppCivistBaseModel
489
490
WorkingGroup uwg = (WorkingGroup ) resource ;
@@ -494,6 +495,7 @@ public static Result signalNotification(ResourceSpaceTypes originType, Notificat
494
495
resourceText = ulastBallot .getNotes ();
495
496
resourceDate = ulastBallot .getCreatedAt ();
496
497
resourceType = AppcivistResourceTypes .BALLOT .toString ();
498
+ resourceId = ulastBallot .getId ();
497
499
title = "[AppCivist] Updated " + resourceType + " in " + originName ;
498
500
//TODO: how to get the associatedUser
499
501
associatedUser = "" ;
@@ -503,26 +505,20 @@ public static Result signalNotification(ResourceSpaceTypes originType, Notificat
503
505
case UPDATED_MILESTONE :
504
506
case MILESTONE_PASSED :
505
507
case MILESTONE_UPCOMING :
506
- resourceUuid = ((ComponentMilestone ) resource ).getUuid ();
507
- resourceTitle = ((ComponentMilestone ) resource ).getTitle ();
508
- resourceText = ((ComponentMilestone ) resource ).getDescription ();
509
- resourceDate = ((ComponentMilestone ) resource ).getDate ();
510
- resourceType = "MILESTONE" ;
511
- // TODO: add creator to milestones associatedUser = ((ComponentMilestone) resource).getCreator().getName();
512
- break ;
513
508
case MILESTONE_UPCOMING_IN_A_WEEK :
514
- resourceUuid = ((ComponentMilestone ) resource ).getUuid ();
515
- resourceTitle = ((ComponentMilestone ) resource ).getTitle ();
516
- resourceText = ((ComponentMilestone ) resource ).getDescription ();
517
- resourceDate = ((ComponentMilestone ) resource ).getDate ();
518
- resourceType = "MILESTONE" ;
519
- break ;
520
509
case MILESTONE_UPCOMING_IN_A_DAY :
510
+ // TODO: add creator to milestones associatedUser = ((ComponentMilestone) resource).getCreator().getName();
521
511
resourceUuid = ((ComponentMilestone ) resource ).getUuid ();
522
512
resourceTitle = ((ComponentMilestone ) resource ).getTitle ();
523
513
resourceText = ((ComponentMilestone ) resource ).getDescription ();
524
514
resourceDate = ((ComponentMilestone ) resource ).getDate ();
515
+ resourceId = ((ComponentMilestone ) resource ).getComponentMilestoneId ();
525
516
resourceType = "MILESTONE" ;
517
+ try {
518
+ setCampaignUrl (((ComponentMilestone ) resource ).getContainingSpaces ().get (0 ).getCampaign ().getCampaignId (), urls );
519
+ } catch (Exception e ) {
520
+ Logger .error ("Error setting milestone campaign id: none campaign foung" );
521
+ }
526
522
break ;
527
523
case MEMBER_JOINED :
528
524
break ;
@@ -531,72 +527,71 @@ public static Result signalNotification(ResourceSpaceTypes originType, Notificat
531
527
case UPDATED_CONTRIBUTION_HISTORY :
532
528
break ;
533
529
case BALLOT_UPCOMING_IN_A_DAY :
534
- resourceUuid = ((Campaign ) resource ).getUuid ();
535
- resourceTitle = ((Campaign ) resource ).getTitle ();
536
- resourceText = ((Campaign ) resource ).getGoal ();
537
- resourceDate = resource .getLastUpdate ();
538
- resourceType = AppcivistResourceTypes .BALLOT .toString ();
539
- break ;
540
530
case BALLOT_UPCOMING_IN_A_WEEK :
541
- resourceUuid = ((Campaign ) resource ).getUuid ();
542
- resourceTitle = ((Campaign ) resource ).getTitle ();
543
- resourceText = ((Campaign ) resource ).getGoal ();
544
- resourceDate = resource .getLastUpdate ();
545
- resourceType = AppcivistResourceTypes .BALLOT .toString ();
546
- break ;
547
531
case BALLOT_UPCOMING_IN_A_MONTH :
548
- resourceUuid = ((Campaign ) resource ).getUuid ();
549
- resourceTitle = ((Campaign ) resource ).getTitle ();
550
- resourceText = ((Campaign ) resource ).getGoal ();
551
- resourceDate = resource .getLastUpdate ();
552
- resourceType = AppcivistResourceTypes .BALLOT .toString ();
553
- break ;
554
532
case BALLOT_ENDING_IN_A_DAY :
555
- resourceUuid = ((Campaign ) resource ).getUuid ();
556
- resourceTitle = ((Campaign ) resource ).getTitle ();
557
- resourceText = ((Campaign ) resource ).getGoal ();
558
- resourceDate = resource .getLastUpdate ();
559
- resourceType = AppcivistResourceTypes .BALLOT .toString ();
560
- break ;
561
533
case BALLOT_ENDING_IN_A_WEEK :
562
- resourceUuid = ((Campaign ) resource ).getUuid ();
563
- resourceTitle = ((Campaign ) resource ).getTitle ();
564
- resourceText = ((Campaign ) resource ).getGoal ();
565
- resourceDate = resource .getLastUpdate ();
566
- resourceType = AppcivistResourceTypes .BALLOT .toString ();
567
- break ;
568
534
case BALLOT_ENDING_IN_A_MONTH :
569
535
resourceUuid = ((Campaign ) resource ).getUuid ();
570
536
resourceTitle = ((Campaign ) resource ).getTitle ();
571
537
resourceText = ((Campaign ) resource ).getGoal ();
538
+ resourceId = ((Campaign ) resource ).getCampaignId ();
572
539
resourceDate = resource .getLastUpdate ();
573
540
resourceType = AppcivistResourceTypes .BALLOT .toString ();
541
+ setCampaignUrl (resourceId , urls );
574
542
break ;
575
543
case NEWSLETTER :
576
544
switch (originType ) {
577
545
case CAMPAIGN :
578
546
resourceUuid = ((Campaign ) resource ).getUuid ();
579
547
resourceTitle = ((Campaign ) resource ).getTitle ();
580
548
resourceText = ((Campaign ) resource ).getGoal ();
549
+ resourceId = ((Campaign ) resource ).getCampaignId ();
581
550
resourceDate = resource .getLastUpdate ();
582
551
resourceType = AppcivistResourceTypes .CAMPAIGN .toString ();
583
552
title = "[AppCivist] New Newsletter for " + resourceType ;
553
+ setCampaignUrl (resourceId , urls );
584
554
break ;
585
555
case WORKING_GROUP :
586
556
resourceUuid = ((WorkingGroup ) resource ).getUuid ();
587
557
resourceTitle = ((WorkingGroup ) resource ).getName ();
588
558
resourceText = ((WorkingGroup ) resource ).getText ();
559
+ resourceId = ((WorkingGroup ) resource ).getGroupId ();
589
560
resourceDate = resource .getCreation ();
590
561
resourceType = AppcivistResourceTypes .WORKING_GROUP .toString ();
591
562
title = "[AppCivist] New Newsletter for " + resourceType ;
563
+ setWorkingGroupUrl (resourceId , urls );
592
564
break ;
593
565
}
594
566
default :
595
567
break ;
596
568
}
597
- Logger .info ("Sending signalNotification( " + originUUID + ", " + originType + ", " + originName + ", " + eventName + ", " + title + ", " + text + ", " + resourceUuid + ", " + resourceTitle + ", " + resourceText + ", " + resourceDate + ", " + resourceType + ", " + associatedUser + ")" );
598
- return signalNotification (originUUID , originType , originName , eventName , title , text , resourceUuid , resourceTitle , resourceText , resourceDate , resourceType , associatedUser , subscriptionType , userParam );
569
+ Logger .info ("Sending signalNotification( " + originUUID + ", " + originType + ", " + originName + ", " + eventName + ", " + title + ", " + text + ", " + resourceUuid + ", " + resourceTitle + ", " + resourceText + ", " + resourceDate + ", " + resourceType + ", " + associatedUser + "," +resourceId +")" );
570
+ return signalNotification (originUUID , originType , originName , eventName , title , text , resourceUuid , resourceTitle , resourceText , resourceDate , resourceType , associatedUser , subscriptionType , userParam , resourceId , urls );
571
+
572
+ }
599
573
574
+ private static void setContributionUrl (Contribution contribution , Map <String , Long > urls ) {
575
+ urls .put ("contributionId" , contribution .getContributionId ());
576
+ if (!contribution .getWorkingGroups ().isEmpty ()) {
577
+ setWorkingGroupUrl (contribution .getWorkingGroups ().get (0 ).getGroupId (), urls );
578
+ }
579
+ }
580
+
581
+ private static void setWorkingGroupUrl (Long workingGroupId , Map <String , Long > urls ) {
582
+ WorkingGroup workingGroup = WorkingGroup .read (workingGroupId );
583
+ urls .put ("workingGroupId" , workingGroupId );
584
+ if (!workingGroup .getCampaigns ().isEmpty ()) {
585
+ setCampaignUrl (workingGroup .getCampaigns ().get (0 ), urls );
586
+ }
587
+ }
588
+
589
+ private static void setCampaignUrl (Long campaignId , Map <String , Long > urls ) {
590
+ urls .put ("campaignId" , campaignId );
591
+ Campaign campaign = Campaign .find .byId (campaignId );
592
+ if (!campaign .getAssemblies ().isEmpty ()){
593
+ urls .put ("assemblyId" , campaign .getAssemblies ().get (0 ));
594
+ }
600
595
}
601
596
602
597
// TODO: signalNotification for non AppCivistBaseModel Resources: VotingBallot
@@ -611,7 +606,8 @@ public static Result signalNotification(UUID origin,
611
606
String resourceType ,
612
607
String associatedUser ,
613
608
SubscriptionTypes subscriptionType ,
614
- User userParam ) {
609
+ User userParam ,
610
+ Long resourceID , Map <String , Long > urls ) {
615
611
// 1. Prepare the notification event data
616
612
NotificationEventSignal notificationEvent = new NotificationEventSignal ();
617
613
notificationEvent .setSpaceType (originType );
@@ -634,6 +630,7 @@ public static Result signalNotification(UUID origin,
634
630
data .put ("notificationDate" , notificationDate );
635
631
data .put ("associatedUser" , associatedUser );
636
632
data .put ("signaled" , false );
633
+ data .put ("originIds" , urls );
637
634
try {
638
635
if (subscriptionType .equals (SubscriptionTypes .NEWSLETTER )) {
639
636
0 commit comments