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.JayMonitorServiceIndex;
import com.jay.monitor.data.server.models.request.trace.ServiceRequest;
import com.jay.monitor.data.server.models.response.trace.ServiceTraceResponse;
import org.springframework.beans.BeanUtils;

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

public class ServiceElasticSearchProcess
    extends AbstractTraceElasticSearch<ServiceRequest, ServiceTraceResponse, JayMonitorServiceIndex> {

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

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

    @Override
    public List<ServiceTraceResponse> builderResponseList(List<JayMonitorServiceIndex> list) {
        List<ServiceTraceResponse> traceResponses = new ArrayList<>();
        if (list != null && list.size() > 0) {
            for (int i = 0; i < list.size(); i++) {
                JayMonitorServiceIndex jayMonitorSQLIndex = list.get(i);
                ServiceTraceResponse traceResponse = new ServiceTraceResponse();
                BeanUtils.copyProperties(jayMonitorSQLIndex, traceResponse);
                traceResponses.add(traceResponse);
            }
        }
        return traceResponses;
    }

}
