Search in sources :

Example 1 with FlowEventAction

use of org.openkilda.model.history.FlowEventAction in project open-kilda by telstra.

the class HibernateHistoryFlowEventRepository method makeEntity.

@Override
protected HibernateFlowEvent makeEntity(FlowEventData view) {
    HibernateFlowEvent entity = new HibernateFlowEvent();
    FlowEventCloner.INSTANCE.copyWithoutRecordsAndDumps(view, entity);
    for (FlowEventAction entry : view.getEventActions()) {
        HibernateFlowEventAction action = new HibernateFlowEventAction();
        FlowEventActionCloner.INSTANCE.copy(entry.getData(), action);
        entity.addAction(action);
    }
    for (FlowEventDump entry : view.getEventDumps()) {
        HibernateFlowEventDump dump = new HibernateFlowEventDump();
        FlowEventDumpCloner.INSTANCE.copy(entry.getData(), dump);
        entity.addDump(dump);
    }
    return entity;
}
Also used : HibernateFlowEventAction(org.openkilda.persistence.hibernate.entities.history.HibernateFlowEventAction) HibernateFlowEventDump(org.openkilda.persistence.hibernate.entities.history.HibernateFlowEventDump) HibernateFlowEventAction(org.openkilda.persistence.hibernate.entities.history.HibernateFlowEventAction) FlowEventAction(org.openkilda.model.history.FlowEventAction) HibernateFlowEvent(org.openkilda.persistence.hibernate.entities.history.HibernateFlowEvent) FlowEventDump(org.openkilda.model.history.FlowEventDump) HibernateFlowEventDump(org.openkilda.persistence.hibernate.entities.history.HibernateFlowEventDump)

Example 2 with FlowEventAction

use of org.openkilda.model.history.FlowEventAction in project open-kilda by telstra.

the class HistoryService method store.

/**
 * Save history data into data storage.
 *
 * @param historyHolder holder of history information.
 */
public void store(FlowHistoryHolder historyHolder) {
    transactionManager.doInTransaction(() -> {
        String taskId = historyHolder.getTaskId();
        if (historyHolder.getFlowEventData() != null) {
            FlowEvent event = HistoryMapper.INSTANCE.map(historyHolder.getFlowEventData());
            event.setTaskId(taskId);
            flowEventRepository.add(event);
        }
        if (historyHolder.getFlowHistoryData() != null) {
            FlowEventAction history = HistoryMapper.INSTANCE.map(historyHolder.getFlowHistoryData());
            history.setTaskId(taskId);
            flowEventActionRepository.add(history);
        }
        if (historyHolder.getFlowDumpData() != null) {
            FlowEventDump dump = HistoryMapper.INSTANCE.map(historyHolder.getFlowDumpData());
            dump.setTaskId(taskId);
            flowEventDumpRepository.add(dump);
        }
    });
}
Also used : FlowEvent(org.openkilda.model.history.FlowEvent) FlowEventAction(org.openkilda.model.history.FlowEventAction) FlowEventDump(org.openkilda.model.history.FlowEventDump)

Example 3 with FlowEventAction

use of org.openkilda.model.history.FlowEventAction in project open-kilda by telstra.

the class FermaFlowEventRepository method findFlowStatusesByFlowIdAndTimeFrame.

@Override
public List<FlowStatusView> findFlowStatusesByFlowIdAndTimeFrame(String flowId, Instant timeFrom, Instant timeTo, int maxCount) {
    List<FlowStatusView> statuses = new ArrayList<>();
    findByFlowIdAndTimeFrame(flowId, timeFrom, timeTo, maxCount).forEach(flowEvent -> {
        for (FlowEventAction flowEventAction : flowEvent.getEventActions()) {
            String action = flowEventAction.getAction();
            if (action.equals(FlowEvent.FLOW_DELETED_ACTION)) {
                statuses.add(new FlowStatusView(flowEventAction.getTimestamp(), "DELETED"));
            }
            for (String actionPart : FlowEvent.FLOW_STATUS_ACTION_PARTS) {
                if (action.contains(actionPart)) {
                    statuses.add(new FlowStatusView(flowEventAction.getTimestamp(), action.replace(actionPart, "")));
                }
            }
        }
    });
    statuses.sort(Comparator.comparing(FlowStatusView::getTimestamp));
    return statuses;
}
Also used : ArrayList(java.util.ArrayList) FlowEventAction(org.openkilda.model.history.FlowEventAction) FlowStatusView(org.openkilda.model.history.FlowStatusView)

Example 4 with FlowEventAction

use of org.openkilda.model.history.FlowEventAction in project open-kilda by telstra.

the class FermaFlowEventRepositoryTest method buildFlowHistory.

private FlowEventAction buildFlowHistory(String taskId, String action, Instant timestamp) {
    FlowEventAction flowEventAction = new FlowEventAction();
    flowEventAction.setTaskId(taskId);
    flowEventAction.setAction(action);
    flowEventAction.setTimestamp(timestamp);
    return flowEventAction;
}
Also used : FlowEventAction(org.openkilda.model.history.FlowEventAction)

Aggregations

FlowEventAction (org.openkilda.model.history.FlowEventAction)4 FlowEventDump (org.openkilda.model.history.FlowEventDump)2 ArrayList (java.util.ArrayList)1 FlowEvent (org.openkilda.model.history.FlowEvent)1 FlowStatusView (org.openkilda.model.history.FlowStatusView)1 HibernateFlowEvent (org.openkilda.persistence.hibernate.entities.history.HibernateFlowEvent)1 HibernateFlowEventAction (org.openkilda.persistence.hibernate.entities.history.HibernateFlowEventAction)1 HibernateFlowEventDump (org.openkilda.persistence.hibernate.entities.history.HibernateFlowEventDump)1