Search in sources :

Example 1 with UpdateDashboardData

use of io.lumeer.engine.api.event.UpdateDashboardData 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);
        }
    }
}
Also used : UpdateDashboardData(io.lumeer.engine.api.event.UpdateDashboardData) DashboardData(io.lumeer.api.model.DashboardData) 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 UpdateDashboardData

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

the class MongoDashboardDataDao method update.

@Override
public DashboardData update(final DashboardData data) {
    FindOneAndUpdateOptions options = new FindOneAndUpdateOptions().returnDocument(ReturnDocument.AFTER).upsert(true);
    try {
        Bson update = new Document("$set", data);
        final DashboardData returnedData = databaseCollection().findOneAndUpdate(dataFilter(data), update, options);
        if (updateEvent != null) {
            updateEvent.fire(new UpdateDashboardData(returnedData));
        }
        return returnedData;
    } catch (MongoException ex) {
        throw new StorageException("Cannot update dashboard data " + data, ex);
    }
}
Also used : MongoException(com.mongodb.MongoException) DashboardData(io.lumeer.api.model.DashboardData) UpdateDashboardData(io.lumeer.engine.api.event.UpdateDashboardData) UpdateDashboardData(io.lumeer.engine.api.event.UpdateDashboardData) FindOneAndUpdateOptions(com.mongodb.client.model.FindOneAndUpdateOptions) Document(org.bson.Document) ReturnDocument(com.mongodb.client.model.ReturnDocument) StorageException(io.lumeer.storage.api.exception.StorageException) Bson(org.bson.conversions.Bson)

Aggregations

DashboardData (io.lumeer.api.model.DashboardData)2 UpdateDashboardData (io.lumeer.engine.api.event.UpdateDashboardData)2 MongoException (com.mongodb.MongoException)1 FindOneAndUpdateOptions (com.mongodb.client.model.FindOneAndUpdateOptions)1 ReturnDocument (com.mongodb.client.model.ReturnDocument)1 OrganizationUserEvent (io.lumeer.engine.api.event.OrganizationUserEvent)1 ResourceVariableEvent (io.lumeer.engine.api.event.ResourceVariableEvent)1 SelectionListEvent (io.lumeer.engine.api.event.SelectionListEvent)1 StorageException (io.lumeer.storage.api.exception.StorageException)1 Document (org.bson.Document)1 Bson (org.bson.conversions.Bson)1 Event (org.marvec.pusher.data.Event)1