aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/tools/zusammen-tools/src/main/java/org/openecomp/core/tools/store/NotificationHandler.java
blob: cc7daf6058471d67a76076acc5d160ade7fab94e (plain)
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
package org.openecomp.core.tools.store;

import com.datastax.driver.mapping.annotations.Accessor;
import com.datastax.driver.mapping.annotations.Query;
import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;

import java.util.HashSet;
import java.util.Set;

public class NotificationHandler {

  public void registerNotificationForUserOnEntity(String user, String entityId) {

    Set<String> userSet = new HashSet<>();
    userSet.add(user);
    NoSqlDbFactory.getInstance().createInterface().getMappingManager()
        .createAccessor(NotificationAccessor.class)
        .updateNotificationSubscription(userSet, entityId);
  }

  @Accessor
  interface NotificationAccessor {

    @Query("UPDATE dox.notification_subscribers SET subscribers = subscribers + ? where " +
        "entity_id = ?")
    void updateNotificationSubscription(Set<String> users, String entityId);
  }
}