use of org.marvec.pusher.data.Event in project engine by Lumeer.
the class PusherFacade method createUserNotification.
public void createUserNotification(@Observes final CreateOrUpdateUserNotification createOrUpdateUserNotification) {
if (isEnabled()) {
try {
UserNotification notification = createOrUpdateUserNotification.getUserNotification();
Event event = createEventForObject(notification, CREATE_EVENT_SUFFIX, 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 createAddOrUpdateUserNotification.
public void createAddOrUpdateUserNotification(@Observes final CreateOrUpdateUser createOrUpdateUser) {
if (isEnabled()) {
try {
Organization organization = organizationDao.getOrganizationById(createOrUpdateUser.getOrganizationId());
ObjectWithParent object = new ObjectWithParent(getAppId(), cleanUserFromUserEvent(createOrUpdateUser), 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 reloadGroups.
public void reloadGroups(@Observes final ReloadGroups reloadGroups) {
if (isEnabled()) {
try {
ObjectWithParent object = new ObjectWithParent(getAppId(), reloadGroups.getOrganizationId(), reloadGroups.getOrganizationId());
Organization organization = organizationDao.getOrganizationById(reloadGroups.getOrganizationId());
Set<String> users = resourceAdapter.getOrganizationReaders(organization);
List<Event> events = users.stream().map(userId -> new Event(eventChannel(userId), Group.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 createOrUpdateResourceVariableNotification.
public void createOrUpdateResourceVariableNotification(final ResourceVariableEvent resourceVariableEvent, final String suffix) {
if (isEnabled()) {
try {
ResourceVariable resourceVariable = resourceVariableAdapter.mapVariable(resourceVariableEvent.getVariable());
Organization organization = organizationDao.getOrganizationById(resourceVariable.getOrganizationId());
Set<String> users;
ObjectWithParent object;
ResourceId backup;
if (resourceVariable.getResourceType() == ResourceType.ORGANIZATION) {
object = new ObjectWithParent(getAppId(), resourceVariable, organization.getId());
backup = new ResourceId(getAppId(), resourceVariable.getId(), organization.getId());
users = permissionAdapter.getOrganizationUsersByRole(organization, RoleType.TechConfig);
} else {
Project project = projectDao.getProjectById(resourceVariable.getProjectId());
object = new ObjectWithParent(getAppId(), resourceVariable, organization.getId(), project.getId());
backup = new ResourceId(getAppId(), resourceVariable.getId(), organization.getId(), project.getId());
users = permissionAdapter.getProjectUsersByRole(organization, project, RoleType.TechConfig);
}
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 updateDashboardData.
public void updateDashboardData(@Observes final UpdateDashboardData updateDashboardData) {
if (isEnabled()) {
try {
DashboardData dashboardData = updateDashboardData.getData();
ObjectWithParent object = new ObjectWithParent(getAppId(), dashboardData, getOrganization().getId(), getProject().getId());
DashboardData backupData = new DashboardData(dashboardData.getType(), dashboardData.getTypeId());
ObjectWithParent backupObject = new ObjectWithParent(getAppId(), backupData, getOrganization().getId(), getProject().getId());
Event event = pusherAdapter.createEventForObjectWithParent(object, backupObject, UPDATE_EVENT_SUFFIX, getCurrentUserId());
sendNotificationsBatch(Collections.singletonList(event));
} catch (Exception e) {
log.log(Level.WARNING, "Unable to send push notification: ", e);
}
}
}
Aggregations