package com.eactive.eai.rms.data.entity.onl.logger;

import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraLog;
import com.eactive.eai.data.entity.onl.logger.HttpAdapterExtraLogId;
import com.eactive.eai.data.entity.onl.logger.QHttpAdapterExtraLog;
import com.eactive.eai.data.jpa.AbstractDataService;
import com.querydsl.core.types.dsl.BooleanExpression;

@Service
@Transactional
public class HttpAdapterExtraLogService
		extends AbstractDataService<HttpAdapterExtraLog, HttpAdapterExtraLogId, HttpAdapterExtraLogRepository> {

	public Map<Integer, HttpAdapterExtraLog> findByGuid(String guid) {
		BooleanExpression predicate = QHttpAdapterExtraLog.httpAdapterExtraLog.id.guid.eq(guid);
		return StreamSupport.stream(repository.findAll(predicate).spliterator(), false)
				.collect(Collectors.toMap(log -> log.getId().getServiceProcessNumber(), log -> log));
	}

}
