Search in sources :

Example 1 with CreateOrUpdateGroup

use of io.lumeer.engine.api.event.CreateOrUpdateGroup 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 2 with CreateOrUpdateGroup

use of io.lumeer.engine.api.event.CreateOrUpdateGroup in project engine by Lumeer.

the class MongoGroupDao method createGroup.

@Override
public Group createGroup(final Group group) {
    try {
        databaseCollection().insertOne(group);
        if (createOrUpdateGroupEvent != null) {
            group.setOrganizationId(getOrganization().get().getId());
            createOrUpdateGroupEvent.fire(new CreateOrUpdateGroup(getOrganization().get().getId(), group));
        }
        return group;
    } catch (MongoException ex) {
        throw new StorageException("Cannot create group " + group, ex);
    }
}
Also used : CreateOrUpdateGroup(io.lumeer.engine.api.event.CreateOrUpdateGroup) MongoException(com.mongodb.MongoException) StorageException(io.lumeer.storage.api.exception.StorageException)

Example 3 with CreateOrUpdateGroup

use of io.lumeer.engine.api.event.CreateOrUpdateGroup in project engine by Lumeer.

the class MongoGroupDao method updateGroup.

@Override
public Group updateGroup(final String id, final Group group) {
    FindOneAndReplaceOptions options = new FindOneAndReplaceOptions().returnDocument(ReturnDocument.AFTER).upsert(true);
    try {
        Group returnedGroup = databaseCollection().findOneAndReplace(idFilter(id), group, options);
        if (returnedGroup == null) {
            throw new StorageException("Group '" + id + "' has not been updated.");
        }
        if (createOrUpdateGroupEvent != null) {
            returnedGroup.setOrganizationId(getOrganization().get().getId());
            createOrUpdateGroupEvent.fire(new CreateOrUpdateGroup(getOrganization().get().getId(), returnedGroup));
        }
        return returnedGroup;
    } catch (MongoException ex) {
        throw new StorageException("Cannot update group " + group, ex);
    }
}
Also used : CreateOrUpdateGroup(io.lumeer.engine.api.event.CreateOrUpdateGroup) FindOneAndReplaceOptions(com.mongodb.client.model.FindOneAndReplaceOptions) CreateOrUpdateGroup(io.lumeer.engine.api.event.CreateOrUpdateGroup) RemoveGroup(io.lumeer.engine.api.event.RemoveGroup) Group(io.lumeer.api.model.Group) MongoException(com.mongodb.MongoException) StorageException(io.lumeer.storage.api.exception.StorageException)

Aggregations

CreateOrUpdateGroup (io.lumeer.engine.api.event.CreateOrUpdateGroup)3 MongoException (com.mongodb.MongoException)2 Group (io.lumeer.api.model.Group)2 FindOneAndReplaceOptions (com.mongodb.client.model.FindOneAndReplaceOptions)1 AppId (io.lumeer.api.model.AppId)1 Collection (io.lumeer.api.model.Collection)1 DashboardData (io.lumeer.api.model.DashboardData)1 Document (io.lumeer.api.model.Document)1 LinkInstance (io.lumeer.api.model.LinkInstance)1 LinkType (io.lumeer.api.model.LinkType)1 Organization (io.lumeer.api.model.Organization)1 Permissions (io.lumeer.api.model.Permissions)1 Project (io.lumeer.api.model.Project)1 ResourceComment (io.lumeer.api.model.ResourceComment)1 ResourceType (io.lumeer.api.model.ResourceType)1 ResourceVariable (io.lumeer.api.model.ResourceVariable)1 RoleType (io.lumeer.api.model.RoleType)1 RolesDifference (io.lumeer.api.model.RolesDifference)1 SelectionList (io.lumeer.api.model.SelectionList)1 Sequence (io.lumeer.api.model.Sequence)1