Search in sources :

Example 1 with FlowStatusView

use of org.openkilda.model.history.FlowStatusView 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)

Aggregations

ArrayList (java.util.ArrayList)1 FlowEventAction (org.openkilda.model.history.FlowEventAction)1 FlowStatusView (org.openkilda.model.history.FlowStatusView)1