package com.jay.monitor.data.server.store.es;

import com.jay.monitor.data.core.enums.MsgTypeEnums;
import com.jay.monitor.data.server.models.entity.es.JayMonitorMQIndex;
import com.jay.monitor.data.server.models.response.trace.MQTraceResponse;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class MQElasticSearchProcess
    extends AbstractTraceElasticSearch<JayMonitorMQIndex, MQTraceResponse, JayMonitorMQIndex> {

    @Override
    public Class getIndexClass() {
        return JayMonitorMQIndex.class;
    }

    @Override
    public MsgTypeEnums msgTypeEnums() {
        return MsgTypeEnums.MQ;
    }

    @Override
    public List<MQTraceResponse> builderResponseList(List<JayMonitorMQIndex> list) {
        List<MQTraceResponse> mqTraceResponses = new ArrayList<>();
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                JayMonitorMQIndex jayMonitorMQIndex = list.get(i);
                MQTraceResponse mqTraceResponse = new MQTraceResponse();
                BeanUtils.copyProperties(jayMonitorMQIndex, mqTraceResponse);
                mqTraceResponses.add(mqTraceResponse);
            }
        }
        return mqTraceResponses;
    }

}
