use of org.marvec.pusher.data.Event 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 org.marvec.pusher.data.Event 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);
}
}
}
use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class PusherFacade method createAddOrUpdateGroupNotification.
public void createAddOrUpdateGroupNotification(@Observes final CreateOrUpdateGroup createOrUpdateGroup) {
if (isEnabled()) {
try {
Organization organization = organizationDao.getOrganizationById(createOrUpdateGroup.getOrganizationId());
ObjectWithParent object = new ObjectWithParent(getAppId(), createOrUpdateGroup.getGroup(), organization.getId());
Set<String> users = resourceAdapter.getOrganizationReaders(organization);
List<Event> events = users.stream().map(userId -> createEventForObjectWithParent(object, UPDATE_EVENT_SUFFIX, userId)).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 PusherFacade method reloadResourceVariablesNotification.
public void reloadResourceVariablesNotification(@Observes final ReloadResourceVariables reloadResourceVariables) {
if (isEnabled()) {
try {
Organization organization = organizationDao.getOrganizationById(reloadResourceVariables.getOrganizationId());
Project project = projectDao.getProjectById(reloadResourceVariables.getProjectId());
ObjectWithParent object = new ObjectWithParent(getAppId(), organization.getId(), organization.getId(), project.getId());
Set<String> users = permissionAdapter.getProjectUsersByRole(organization, project, RoleType.TechConfig);
List<Event> events = users.stream().map(userId -> new Event(eventChannel(userId), ResourceVariable.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 PusherFacade method updateCurrentUserNotification.
public void updateCurrentUserNotification(@Observes final UpdateCurrentUser updateCurrentUser) {
if (isEnabled()) {
try {
String userId = updateCurrentUser.getUser().getId();
ObjectWithParent object = new ObjectWithParent(getAppId(), userId, Utils.computeIfNotNull(getOrganization(), Organization::getId));
Event event = new Event(eventChannel(userId), "CurrentUser" + RELOAD_EVENT_SUFFIX, object);
sendNotificationsBatch(Collections.singletonList(event));
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
Aggregations