Search in sources :

Example 6 with Event

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);
        }
    }
}
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 7 with Event

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);
        }
    }
}
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 8 with Event

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);
        }
    }
}
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) 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 9 with Event

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);
        }
    }
}
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 10 with Event

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);
        }
    }
}
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