Search in sources :

Example 11 with Event

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);
        }
    }
}
Also used : AppId(io.lumeer.api.model.AppId) Sequence(io.lumeer.api.model.Sequence) RemoveSequence(io.lumeer.engine.api.event.RemoveSequence) RemoveResource(io.lumeer.engine.api.event.RemoveResource) OrganizationUserEvent(io.lumeer.engine.api.event.OrganizationUserEvent) CollectionDao(io.lumeer.storage.api.dao.CollectionDao) Resource(io.lumeer.api.model.common.Resource) ResourceVariableAdapter(io.lumeer.core.adapter.ResourceVariableAdapter) CreateResourceVariable(io.lumeer.engine.api.event.CreateResourceVariable) ResourceCommentDao(io.lumeer.storage.api.dao.ResourceCommentDao) RequestDataKeeper(io.lumeer.core.auth.RequestDataKeeper) ConstraintManager(io.lumeer.core.constraint.ConstraintManager) CreateOrUpdateSequence(io.lumeer.engine.api.event.CreateOrUpdateSequence) CreateOrUpdatePayment(io.lumeer.engine.api.event.CreateOrUpdatePayment) UpdateResourceVariable(io.lumeer.engine.api.event.UpdateResourceVariable) CreateDocument(io.lumeer.engine.api.event.CreateDocument) Set(java.util.Set) LinkInstance(io.lumeer.api.model.LinkInstance) CreateOrUpdateUserNotification(io.lumeer.engine.api.event.CreateOrUpdateUserNotification) LinkType(io.lumeer.api.model.LinkType) Group(io.lumeer.api.model.Group) CreateOrUpdateUser(io.lumeer.engine.api.event.CreateOrUpdateUser) PusherClient(io.lumeer.core.util.PusherClient) RemoveUserNotification(io.lumeer.engine.api.event.RemoveUserNotification) FavoriteItemDao(io.lumeer.storage.api.dao.FavoriteItemDao) ViewAdapter(io.lumeer.core.adapter.ViewAdapter) Utils(io.lumeer.core.util.Utils) CreateDocumentsAndLinks(io.lumeer.engine.api.event.CreateDocumentsAndLinks) UserDao(io.lumeer.storage.api.dao.UserDao) DocumentAdapter(io.lumeer.core.adapter.DocumentAdapter) CreateOrUpdateGroup(io.lumeer.engine.api.event.CreateOrUpdateGroup) RemoveLinkType(io.lumeer.engine.api.event.RemoveLinkType) OrganizationDao(io.lumeer.storage.api.dao.OrganizationDao) FavoriteItem(io.lumeer.engine.api.event.FavoriteItem) ViewDao(io.lumeer.storage.api.dao.ViewDao) RemoveResourceComment(io.lumeer.engine.api.event.RemoveResourceComment) RemoveUser(io.lumeer.engine.api.event.RemoveUser) Permissions(io.lumeer.api.model.Permissions) ResourceAdapter(io.lumeer.core.adapter.ResourceAdapter) ResourceComment(io.lumeer.api.model.ResourceComment) LinkTypeAdapter(io.lumeer.core.adapter.LinkTypeAdapter) DocumentUtils(io.lumeer.core.util.DocumentUtils) RemoveSelectionList(io.lumeer.engine.api.event.RemoveSelectionList) Project(io.lumeer.api.model.Project) LinkInstanceDao(io.lumeer.storage.api.dao.LinkInstanceDao) PermissionAdapter(io.lumeer.core.adapter.PermissionAdapter) CreateSelectionList(io.lumeer.engine.api.event.CreateSelectionList) UpdateLinkType(io.lumeer.engine.api.event.UpdateLinkType) ResourceVariable(io.lumeer.api.model.ResourceVariable) ReloadResourceVariables(io.lumeer.engine.api.event.ReloadResourceVariables) UpdateDocument(io.lumeer.engine.api.event.UpdateDocument) TemplateCreated(io.lumeer.engine.api.event.TemplateCreated) SetDocumentLinks(io.lumeer.engine.api.event.SetDocumentLinks) ProjectDao(io.lumeer.storage.api.dao.ProjectDao) User(io.lumeer.api.model.User) LinkTypeDao(io.lumeer.storage.api.dao.LinkTypeDao) AddFavoriteItem(io.lumeer.engine.api.event.AddFavoriteItem) UpdateCompanyContact(io.lumeer.engine.api.event.UpdateCompanyContact) CreateLinkInstance(io.lumeer.engine.api.event.CreateLinkInstance) CreateResource(io.lumeer.engine.api.event.CreateResource) SelectionList(io.lumeer.api.model.SelectionList) RolesDifference(io.lumeer.api.model.RolesDifference) ResourceType(io.lumeer.api.model.ResourceType) UpdateDashboardData(io.lumeer.engine.api.event.UpdateDashboardData) UpdateResourceComment(io.lumeer.engine.api.event.UpdateResourceComment) Observes(javax.enterprise.event.Observes) ReloadSelectionLists(io.lumeer.engine.api.event.ReloadSelectionLists) RemoveFavoriteItem(io.lumeer.engine.api.event.RemoveFavoriteItem) CollectionAdapter(io.lumeer.core.adapter.CollectionAdapter) RemoveGroup(io.lumeer.engine.api.event.RemoveGroup) RoleType(io.lumeer.api.model.RoleType) View(io.lumeer.api.model.View) UpdateServiceLimits(io.lumeer.engine.api.event.UpdateServiceLimits) Document(io.lumeer.api.model.Document) RemoveDocument(io.lumeer.engine.api.event.RemoveDocument) ResourceVariableEvent(io.lumeer.engine.api.event.ResourceVariableEvent) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) UpdateCurrentUser(io.lumeer.engine.api.event.UpdateCurrentUser) CreateResourceComment(io.lumeer.engine.api.event.CreateResourceComment) DefaultConfigurationProducer(io.lumeer.core.facade.configuration.DefaultConfigurationProducer) List(java.util.List) PostConstruct(javax.annotation.PostConstruct) UpdateResource(io.lumeer.engine.api.event.UpdateResource) ReloadGroups(io.lumeer.engine.api.event.ReloadGroups) WithId(io.lumeer.api.model.common.WithId) LinkInstanceAdapter(io.lumeer.core.adapter.LinkInstanceAdapter) UserNotification(io.lumeer.api.model.UserNotification) CreateLinkType(io.lumeer.engine.api.event.CreateLinkType) SelectionListEvent(io.lumeer.engine.api.event.SelectionListEvent) UpdateDefaultViewConfig(io.lumeer.engine.api.event.UpdateDefaultViewConfig) Event(org.marvec.pusher.data.Event) DashboardData(io.lumeer.api.model.DashboardData) Level(java.util.logging.Level) HashSet(java.util.HashSet) Inject(javax.inject.Inject) DataDao(io.lumeer.storage.api.dao.DataDao) ReloadResourceContent(io.lumeer.engine.api.event.ReloadResourceContent) ReloadLinkTypeContent(io.lumeer.engine.api.event.ReloadLinkTypeContent) Organization(io.lumeer.api.model.Organization) RemoveResourceVariable(io.lumeer.engine.api.event.RemoveResourceVariable) DocumentDao(io.lumeer.storage.api.dao.DocumentDao) ImportResource(io.lumeer.engine.api.event.ImportResource) RemoveLinkInstance(io.lumeer.engine.api.event.RemoveLinkInstance) UpdateLinkInstance(io.lumeer.engine.api.event.UpdateLinkInstance) UpdateSelectionList(io.lumeer.engine.api.event.UpdateSelectionList) PusherAdapter(io.lumeer.core.adapter.PusherAdapter) RequestScoped(javax.enterprise.context.RequestScoped) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) Project(io.lumeer.api.model.Project) Organization(io.lumeer.api.model.Organization) OrganizationUserEvent(io.lumeer.engine.api.event.OrganizationUserEvent) ResourceVariableEvent(io.lumeer.engine.api.event.ResourceVariableEvent) SelectionListEvent(io.lumeer.engine.api.event.SelectionListEvent) Event(org.marvec.pusher.data.Event)

Example 12 with Event

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);
}
Also used : ArrayList(java.util.ArrayList) Event(org.marvec.pusher.data.Event) BackupDataEvent(org.marvec.pusher.data.BackupDataEvent) Sequence(io.lumeer.api.model.Sequence)

Example 13 with Event

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);
    }
}
Also used : AppId(io.lumeer.api.model.AppId) Sequence(io.lumeer.api.model.Sequence) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.auth.AuthenticatedUser) StringUtils(org.apache.commons.lang3.StringUtils) GenericPrintRequest(io.lumeer.core.task.executor.request.GenericPrintRequest) Map(java.util.Map) RequestDataKeeper(io.lumeer.core.auth.RequestDataKeeper) CollectionAdapter(io.lumeer.core.adapter.CollectionAdapter) ConstraintManager(io.lumeer.core.constraint.ConstraintManager) FunctionFacade(io.lumeer.core.facade.FunctionFacade) RoleType(io.lumeer.api.model.RoleType) View(io.lumeer.api.model.View) Document(io.lumeer.api.model.Document) Set(java.util.Set) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) LinkInstance(io.lumeer.api.model.LinkInstance) PurposeChangeProcessor(io.lumeer.core.facade.detector.PurposeChangeProcessor) LinkType(io.lumeer.api.model.LinkType) Group(io.lumeer.api.model.Group) DefaultConfigurationProducer(io.lumeer.core.facade.configuration.DefaultConfigurationProducer) List(java.util.List) PusherClient(io.lumeer.core.util.PusherClient) ViewAdapter(io.lumeer.core.adapter.ViewAdapter) WithId(io.lumeer.api.model.common.WithId) Utils(io.lumeer.core.util.Utils) FacadeAdapter(io.lumeer.core.adapter.FacadeAdapter) LinkInstanceAdapter(io.lumeer.core.adapter.LinkInstanceAdapter) ChangesTracker(io.lumeer.core.task.executor.ChangesTracker) SendEmailRequest(io.lumeer.core.task.executor.request.SendEmailRequest) DocumentAdapter(io.lumeer.core.adapter.DocumentAdapter) Event(org.marvec.pusher.data.Event) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) HashSet(java.util.HashSet) AbstractConstraintConverter(io.lumeer.core.constraint.AbstractConstraintConverter) TaskProcessingFacade(io.lumeer.core.facade.TaskProcessingFacade) LumeerS3Client(io.lumeer.core.util.LumeerS3Client) PusherFacade(io.lumeer.core.facade.PusherFacade) DaoContextSnapshot(io.lumeer.storage.api.dao.context.DaoContextSnapshot) ResourceAdapter(io.lumeer.core.adapter.ResourceAdapter) BackupDataEvent(org.marvec.pusher.data.BackupDataEvent) UserMessageRequest(io.lumeer.core.task.executor.request.UserMessageRequest) NavigationRequest(io.lumeer.core.task.executor.request.NavigationRequest) FileAttachmentAdapter(io.lumeer.core.adapter.FileAttachmentAdapter) LinkTypeAdapter(io.lumeer.core.adapter.LinkTypeAdapter) Project(io.lumeer.api.model.Project) PermissionAdapter(io.lumeer.core.adapter.PermissionAdapter) PusherAdapter(io.lumeer.core.adapter.PusherAdapter) Collection(io.lumeer.api.model.Collection) User(io.lumeer.api.model.User) AuthenticatedUser(io.lumeer.core.auth.AuthenticatedUser) Event(org.marvec.pusher.data.Event) BackupDataEvent(org.marvec.pusher.data.BackupDataEvent)

Example 14 with Event

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);
        }
    }
}
Also used : CreateOrUpdateUserNotification(io.lumeer.engine.api.event.CreateOrUpdateUserNotification) RemoveUserNotification(io.lumeer.engine.api.event.RemoveUserNotification) UserNotification(io.lumeer.api.model.UserNotification) OrganizationUserEvent(io.lumeer.engine.api.event.OrganizationUserEvent) ResourceVariableEvent(io.lumeer.engine.api.event.ResourceVariableEvent) SelectionListEvent(io.lumeer.engine.api.event.SelectionListEvent) Event(org.marvec.pusher.data.Event)

Example 15 with Event

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));
}
Also used : OrganizationUserEvent(io.lumeer.engine.api.event.OrganizationUserEvent) ResourceVariableEvent(io.lumeer.engine.api.event.ResourceVariableEvent) SelectionListEvent(io.lumeer.engine.api.event.SelectionListEvent) Event(org.marvec.pusher.data.Event)

Aggregations

Event (org.marvec.pusher.data.Event)22 OrganizationUserEvent (io.lumeer.engine.api.event.OrganizationUserEvent)16 ResourceVariableEvent (io.lumeer.engine.api.event.ResourceVariableEvent)16 SelectionListEvent (io.lumeer.engine.api.event.SelectionListEvent)16 View (io.lumeer.api.model.View)14 Collection (io.lumeer.api.model.Collection)13 LinkType (io.lumeer.api.model.LinkType)13 Sequence (io.lumeer.api.model.Sequence)13 AppId (io.lumeer.api.model.AppId)12 DashboardData (io.lumeer.api.model.DashboardData)12 Document (io.lumeer.api.model.Document)12 Group (io.lumeer.api.model.Group)12 LinkInstance (io.lumeer.api.model.LinkInstance)12 Project (io.lumeer.api.model.Project)12 RoleType (io.lumeer.api.model.RoleType)12 User (io.lumeer.api.model.User)12 WithId (io.lumeer.api.model.common.WithId)12 CollectionAdapter (io.lumeer.core.adapter.CollectionAdapter)12 DocumentAdapter (io.lumeer.core.adapter.DocumentAdapter)12 LinkInstanceAdapter (io.lumeer.core.adapter.LinkInstanceAdapter)12