congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
NotificationDao
Code IndexAdd Tabnine to your IDE (free)

How to use
NotificationDao
in
org.kaaproject.kaa.server.common.dao.impl

Best Java code snippets using org.kaaproject.kaa.server.common.dao.impl.NotificationDao (Showing top 13 results out of 315)

origin: kaaproject/kaa

@Override
public NotificationDto findNotificationById(String id) {
 NotificationDto dto = null;
 LOG.debug("Find notification by id [{}] ", id);
 if (StringUtils.isNotBlank(id)) {
  dto = getDto(notificationDao.findById(id));
 }
 LOG.trace("Found notification object {} by id [{}] ", dto, id);
 return dto;
}
origin: kaaproject/kaa

@Override
public List<NotificationDto> findNotificationsByTopicId(String topicId) {
 validateId(topicId, "Can't find notifications. Invalid topic id: " + topicId);
 return convertDtoList(notificationDao.findNotificationsByTopicId(topicId));
}
origin: kaaproject/kaa

@Override
public List<NotificationDto> findNotificationsByTopicIdAndVersionAndStartSecNum(
    String topicId, int seqNum, int sysNfVersion, int userNfVersion) {
 validateSqlId(topicId, "Can't find notifications. Invalid topic id: " + topicId);
 return convertDtoList(notificationDao.findNotificationsByTopicIdAndVersionAndStartSecNum(
     topicId, seqNum, sysNfVersion, userNfVersion));
}
origin: kaaproject/kaa

@Test
public void testRemoveById() throws Exception {
 NotificationDto expected = generateNotifications(null, null, null, 1, NotificationTypeDto.USER).get(0);
 notificationDao.removeById(expected.getId());
 Assert.assertNull(notificationDao.findById(expected.getId()));
}
origin: kaaproject/kaa

/**
 * Sends a notification and increments a topic sequence number.
 *
 * @param dto notification
 * @return    saved notification
 */
public NotificationDto saveNotificationAndIncTopicSecNum(NotificationDto dto) {
 NotificationDto notificationDto = null;
 Topic topic = topicDao.getNextSeqNumber(dto.getTopicId());
 if (topic != null) {
  dto.setSecNum(topic.getSequenceNumber());
  Notification savedDto = notificationDao.save(dto);
  notificationDto = savedDto != null ? savedDto.toDto() : null;
 } else {
  LOG.warn("Can't find topic by id.");
 }
 return notificationDto;
}
origin: kaaproject/kaa

@Override
public List<UpdateNotificationDto<EndpointGroupDto>> removeTopicById(String id) {
 validateId(id, "Can't remove topic. Invalid topic id " + id);
 TopicDto topic = findTopicById(id);
 List<UpdateNotificationDto<EndpointGroupDto>> notificationList = new LinkedList<>();
 if (topic != null) {
  List<EndpointGroup> groups = endpointGroupDao.findEndpointGroupsByTopicIdAndAppId(
      topic.getApplicationId(), id);
  if (groups != null && !groups.isEmpty()) {
   for (EndpointGroup eg : groups) {
    notificationList.add(endpointService.removeTopicFromEndpointGroup(eg.getId().toString(),
        id));
   }
  }
  topicDao.removeById(id);
  notificationDao.removeNotificationsByTopicId(id);
 }
 return notificationList;
}
origin: kaaproject/kaa

@Test
public void testRemoveById() {
 NotificationDto notification = generateNotificationsDto(null, null, 1, null).get(0);
 Assert.assertNotNull(notification.getId());
 notificationDao.removeById(notification.getId());
 Notification found = notificationDao.findById(notification.getId());
 Assert.assertNull(found);
}
origin: kaaproject/kaa

protected List<NotificationDto> generateNotifications(String topicId, String appId, String schemaId, int count, NotificationTypeDto type) {
 List<NotificationDto> notifications = new ArrayList<>(count);
 NotificationDto notification;
 for (int i = 0; i < count; i++) {
  notification = new NotificationDto();
  notification.setApplicationId(appId != null ? appId : UUID.randomUUID().toString());
  notification.setSchemaId(schemaId != null ? schemaId : UUID.randomUUID().toString());
  notification.setTopicId(topicId != null ? topicId : UUID.randomUUID().toString());
  notification.setType(type != null ? type : NotificationTypeDto.USER);
  notification.setSecNum(i);
  notification.setBody(UUID.randomUUID().toString().getBytes());
  notification.setLastTimeModify(new Date(System.currentTimeMillis()));
  notification.setNfVersion(1);
  notification.setExpiredAt(new Date(System.currentTimeMillis() + 7 * 24 * 3600 * 1000));
  notifications.add(notificationDao.save(notification).toDto());
 }
 return notifications;
}
origin: stackoverflow.com

 class OrderManager {
  private OrderDAO oDao;
  private NotificationDao nDao;

  public saveOrder(OrderDTO o) {
   Long orderId = oDao.save(o);
   NotificationDTO n = new NotificationDTO();
   n.setType(NotificationType.ORDER_CREATED);
   n.setEntityId(orderId);
   nDao.save(n);
  }
}
origin: kaaproject/kaa

@Test
public void testSave() throws Exception {
 NotificationDto expected = generateNotifications(null, null, null, 1, NotificationTypeDto.USER).get(0);
 NotificationDto found = notificationDao.findById(expected.getId()).toDto();
 Assert.assertEquals(expected, found);
}
origin: kaaproject/kaa

@Test
public void testFindNotificationsByTopicId() throws Exception {
 String topicId = UUID.randomUUID().toString();
 List<NotificationDto> expectedList = new ArrayList<>();
 expectedList.addAll(generateNotifications(topicId, null, null, 2, NotificationTypeDto.USER));
 expectedList.addAll(generateNotifications(topicId, null, null, 1, NotificationTypeDto.SYSTEM));
 List<CassandraNotification> found = notificationDao.findNotificationsByTopicId(topicId);
 Assert.assertEquals(expectedList.size(), found.size());
}
origin: kaaproject/kaa

@Test
public void testFindNotificationsByTopicIdAndVersionAndStartSecNum() throws Exception {
 String topicId = UUID.randomUUID().toString();
 List<NotificationDto> expectedList = new ArrayList<>();
 expectedList.addAll(generateNotifications(topicId, null, null, 7, NotificationTypeDto.USER));
 List<CassandraNotification> foundList = notificationDao.findNotificationsByTopicIdAndVersionAndStartSecNum(topicId, 3, 0, 1);
 Assert.assertEquals(3, foundList.size());
 for (int i = 0; i < foundList.size(); i++) {
  CassandraNotification notification = foundList.get(i);
  Assert.assertEquals(NotificationTypeDto.USER, notification.getType());
  Assert.assertEquals(topicId, notification.getTopicId());
  Assert.assertTrue(3 < notification.getSeqNum());
 }
}
origin: kaaproject/kaa

@Test
public void testRemoveNotificationsByTopicId() throws Exception {
 String topicId = UUID.randomUUID().toString();
 List<NotificationDto> expectedList = new ArrayList<>();
 expectedList.addAll(generateNotifications(topicId, null, null, 2, NotificationTypeDto.USER));
 expectedList.addAll(generateNotifications(topicId, null, null, 1, NotificationTypeDto.SYSTEM));
 List<CassandraNotification> found = notificationDao.findNotificationsByTopicId(topicId);
 Assert.assertEquals(expectedList.size(), found.size());
}
org.kaaproject.kaa.server.common.dao.implNotificationDao

Javadoc

The Interface NotificationDao.

Most used methods

  • findById
  • save
  • findNotificationsByTopicId
    Find notifications by topic id.
  • findNotificationsByTopicIdAndVersionAndStartSecNum
    Find notifications by topic id, notification schema version and start sequence number.
  • removeById
  • removeNotificationsByTopicId
    Removes the notifications by topic id.

Popular in Java

  • Making http requests using okhttp
  • addToBackStack (FragmentTransaction)
  • getSystemService (Context)
  • setScale (BigDecimal)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Iterator (java.util)
    An iterator over a sequence of objects, such as a collection.If a collection has been changed since
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • JFrame (javax.swing)
  • JList (javax.swing)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now