use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class PusherFacade method reloadSelectionListsNotification.
public void reloadSelectionListsNotification(@Observes final ReloadSelectionLists reloadSelectionLists) {
if (isEnabled()) {
try {
Organization organization = organizationDao.getOrganizationById(reloadSelectionLists.getOrganizationId());
Project project = projectDao.getProjectById(reloadSelectionLists.getProjectId());
ObjectWithParent object = new ObjectWithParent(getAppId(), organization.getId(), organization.getId(), project.getId());
Set<String> users = resourceAdapter.getProjectReaders(organization, project);
List<Event> events = users.stream().map(userId -> new Event(eventChannel(userId), SelectionList.class.getSimpleName() + RELOAD_EVENT_SUFFIX, object)).collect(Collectors.toList());
sendNotificationsBatch(events);
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class AbstractContextualTask method sendPushNotifications.
public void sendPushNotifications(final String sequenceName) {
final Sequence sequence = getDaoContextSnapshot().getSequenceDao().getSequence(sequenceName);
final Set<String> techManagers = permissionAdapter.getProjectUsersByRole(daoContextSnapshot.getOrganization(), daoContextSnapshot.getProject(), RoleType.TechConfig);
final List<Event> events = new ArrayList<>();
techManagers.forEach(manager -> events.add(createEventForSequence(sequence, manager)));
getPusherClient().trigger(events);
}
use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class AbstractContextualTask method sendPushNotifications.
public void sendPushNotifications(final View originalView, final View view, final String suffix) {
if (getPusherClient() != null) {
final Set<String> users = getViewReaders(view);
final List<Event> events = users.stream().map(user -> createEventForView(view, user, suffix)).collect(Collectors.toList());
users.forEach(userId -> {
final User user = permissionAdapter.getUser(userId);
events.addAll(pusherAdapter.checkViewPermissionsChange(daoContextSnapshot.getOrganization(), getDaoContextSnapshot().getProject(), user, originalView, view));
});
getPusherClient().trigger(events);
}
}
use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class PusherFacade method removeUserNotification.
public void removeUserNotification(@Observes final RemoveUserNotification removeUserNotification) {
if (isEnabled()) {
try {
UserNotification notification = removeUserNotification.getUserNotification();
Event event = createEventForRemove(notification.getClass().getSimpleName(), new ResourceId(getAppId(), notification.getId()), notification.getUserId());
sendNotificationsBatch(Collections.singletonList(event));
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class PusherFacade method createFavoriteItemNotification.
private void createFavoriteItemNotification(final FavoriteItem favoriteItem, final String suffix) {
ResourceId resourceId = new ResourceId(getAppId(), favoriteItem.getItemId(), getOrganization().getId(), getProject().getId());
String resource = favoriteItem.getResourceType().toString();
String favoriteItemPrefix = "Favorite" + resource.substring(0, 1).toUpperCase() + resource.substring(1);
Event event = new Event(eventChannel(favoriteItem.getUserId()), favoriteItemPrefix + suffix, resourceId);
sendNotificationsBatch(Collections.singletonList(event));
}
Aggregations