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; }
Date expiredAt = dto.getExpiredAt(); dto.setExpiredAt(expiredAt != null ? expiredAt : new Date(currentTime + ttl)); dto.setLastTimeModify(new Date(currentTime)); NotificationDto notificationDto = saveNotificationAndIncTopicSecNum(dto); if (notificationDto != null) {
@Override public NotificationDto toDto() { NotificationDto dto = new NotificationDto(); dto.setId(id); dto.setApplicationId(applicationId); dto.setSchemaId(schemaId); dto.setTopicId(topicId); dto.setLastTimeModify(lastModifyTime); dto.setNfVersion(nfVersion); dto.setType(type); dto.setBody(getArrayCopy(body)); dto.setExpiredAt(expiredAt); dto.setSecNum(secNum); return dto; } }
@Override public EndpointNotificationDto toDto() { EndpointNotificationDto dto = new EndpointNotificationDto(); dto.setId(id != null ? id : generateId()); dto.setEndpointKeyHash(endpointKeyHash != null ? endpointKeyHash.array() : null); NotificationDto notificationDto = new NotificationDto(); notificationDto.setSecNum(seqNum); notificationDto.setType(type); notificationDto.setApplicationId(applicationId); notificationDto.setSchemaId(schemaId); notificationDto.setNfVersion(nfVersion); notificationDto.setLastTimeModify(lastModifyTime); notificationDto.setBody(getBytes(body)); notificationDto.setExpiredAt(expiredAt); notificationDto.setTopicId(topicId); dto.setNotificationDto(notificationDto); return dto; } }
@Override public NotificationDto toDto() { NotificationDto dto = new NotificationDto(); dto.setId(getStringId()); dto.setApplicationId(applicationId); dto.setSchemaId(schemaId); dto.setTopicId(topicId); dto.setLastTimeModify(lastModifyTime); dto.setNfVersion(nfVersion); dto.setType(type); dto.setBody(body != null ? getBytes(body) : null); dto.setExpiredAt(expiredAt); dto.setSecNum(seqNum); return dto; }
Date expiredAt = notificationDto.getExpiredAt(); notificationDto.setExpiredAt(expiredAt != null ? expiredAt : new Date(currentTime + ttl)); notificationDto.setLastTimeModify(new Date(currentTime));