Search in sources :

Example 1 with DashboardData

use of io.lumeer.api.model.DashboardData in project engine by Lumeer.

the class DashboardDataCodec method decode.

@Override
public DashboardData decode(final BsonReader reader, final DecoderContext decoderContext) {
    Document document = documentCodec.decode(reader, decoderContext);
    String type = document.getString(TYPE);
    String typeId = document.getString(TYPE_ID);
    String userId = document.getString(USER_ID);
    Object data = document.get(DATA);
    return new DashboardData(type, typeId, userId, data);
}
Also used : DashboardData(io.lumeer.api.model.DashboardData) Document(org.bson.Document)

Example 2 with DashboardData

use of io.lumeer.api.model.DashboardData 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 3 with DashboardData

use of io.lumeer.api.model.DashboardData 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)3 UpdateDashboardData (io.lumeer.engine.api.event.UpdateDashboardData)2 Document (org.bson.Document)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 Bson (org.bson.conversions.Bson)1 Event (org.marvec.pusher.data.Event)1