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