use of io.lumeer.engine.api.event.SelectionListEvent in project engine by Lumeer.
the class PusherFacade method createOrUpdateSelectionListNotification.
public void createOrUpdateSelectionListNotification(final SelectionListEvent selectionListEvent, final String suffix) {
if (isEnabled()) {
try {
Organization organization = organizationDao.getOrganizationById(selectionListEvent.getOrganizationId());
Project project = projectDao.getProjectById(selectionListEvent.getSelectionList().getProjectId());
ObjectWithParent object = new ObjectWithParent(getAppId(), selectionListEvent.getSelectionList(), organization.getId(), project.getId());
ResourceId backup = new ResourceId(getAppId(), selectionListEvent.getSelectionList().getId(), organization.getId(), project.getId());
Set<String> users = resourceAdapter.getProjectReaders(organization, project);
List<Event> events = users.stream().map(userId -> pusherAdapter.createEventForObjectWithParent(object, backup, suffix, userId)).collect(Collectors.toList());
sendNotificationsBatch(events);
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
use of io.lumeer.engine.api.event.SelectionListEvent in project engine by Lumeer.
the class PusherFacade method removeSelectionListNotification.
public void removeSelectionListNotification(@Observes final RemoveSelectionList selectionListEvent) {
if (isEnabled()) {
try {
Organization organization = organizationDao.getOrganizationById(selectionListEvent.getOrganizationId());
Project project = projectDao.getProjectById(selectionListEvent.getSelectionList().getProjectId());
ResourceId resourceId = new ResourceId(getAppId(), selectionListEvent.getSelectionList().getId(), organization.getId());
Set<String> users = resourceAdapter.getProjectReaders(organization, project);
List<Event> events = users.stream().map(userId -> createEventForRemove(selectionListEvent.getSelectionList().getClass().getSimpleName(), resourceId, userId)).collect(Collectors.toList());
sendNotificationsBatch(events);
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
Aggregations