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

import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.eactive.eai.data.entity.onl.transformer.function.Function;
import com.eactive.eai.data.entity.onl.transformer.function.QFunction;
import com.eactive.eai.data.jpa.AbstractDataService;
import com.querydsl.core.types.dsl.BooleanExpression;

@Service
@Transactional
public class FunctionService extends AbstractDataService<Function, String, FunctionRepository> {

	public Page<Function> findAll(Pageable pageable, String searchCnvsnFuntnName) {
		QFunction qFunction = QFunction.function;
		if (StringUtils.isNotBlank(searchCnvsnFuntnName)) {
			BooleanExpression predicate = qFunction.cnvsnfuntnname
				.containsIgnoreCase(searchCnvsnFuntnName);
			return repository.findAll(predicate, pageable);
		} else {
			return repository.findAll(pageable);
		}
	}

}
