/*
* Copyright 2021 E.J.I.E., S.A.
*
* Licencia con arreglo a la EUPL, Versión 1.1 exclusivamente (la «Licencia»);
* Solo podrá usarse esta obra si se respeta la Licencia.
* Puede obtenerse una copia de la Licencia en
*
* http://ec.europa.eu/idabc/eupl.html
*
* Salvo cuando lo exija la legislación aplicable o se acuerde por escrito,
* el programa distribuido con arreglo a la Licencia se distribuye «TAL CUAL»,
* SIN GARANT�?AS NI CONDICIONES DE NINGÚN TIPO, ni expresas ni implícitas.
* Véase la Licencia en el idioma concreto que rige los permisos y limitaciones
* que establece la Licencia.
*/
package com.ejie.ad74a.dao.ae01b;

import com.ejie.ad74a.model.ae01b.ConceptosIngreso;
import com.ejie.ad74a.model.ae01b.ConceptosLiq;
import com.ejie.ad74a.model.ae01b.Liquidaciones;
import com.ejie.ad74a.util.UtilSQL;
import com.ejie.x38.dao.RowNumResultSetExtractor;
import com.ejie.x38.dto.TableManager;
import com.ejie.x38.dto.TableRequestDto;
import com.ejie.x38.dto.TableRowDto;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.sql.DataSource;
import org.springframework.dao.support.DataAccessUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * ConceptosLiqDaoImpl generated by UDA, 28-jun-2023 10:59:26.
 * 
 * @author UDA
 */

@Repository
@Transactional
public class ConceptosLiqDaoImpl implements ConceptosLiqDao {

	/**
	 * StringBuilder initilization value
	 */
	public static final int STRING_BUILDER_INIT = 4096;

	protected static final String[] ORDER_BY_WHITE_LIST = new String[] { "IDLIQUIDACION01", "IDCONCEPTO01", "IMPORTE01",
			"NUMLINEA01", "USUALTA01", "FALTA01", "USUMODIF01", "FMODIF01" };

	private JdbcTemplate jdbcTemplate;

	/*
	 * ROW_MAPPERS
	 */
	private RowMapper<ConceptosLiq> rwMap = new RowMapper<ConceptosLiq>() {
		public ConceptosLiq mapRow(ResultSet resultSet, int rowNum) throws SQLException {
			return new ConceptosLiq(new Liquidaciones(UtilSQL.getLong(resultSet, "IDLIQUIDACION01")),
					new ConceptosIngreso(UtilSQL.getLong(resultSet, "IDCONCEPTO01")),
					resultSet.getBigDecimal("IMPORTE01"), UtilSQL.getInt(resultSet, "NUMLINEA01"),
					resultSet.getString("USUALTA01"), resultSet.getDate("FALTA01"), resultSet.getString("USUMODIF01"),
					resultSet.getDate("FMODIF01"));
		}
	};

	private RowMapper<ConceptosLiq> rwMapPK = new RowMapper<ConceptosLiq>() {
		public ConceptosLiq mapRow(ResultSet resultSet, int rowNum) throws SQLException {
			return new ConceptosLiq(new Liquidaciones(UtilSQL.getLong(resultSet, "IDLIQUIDACION01")),
					new ConceptosIngreso(UtilSQL.getLong(resultSet, "IDCONCEPTO01")));
		}
	};

	/**
	 * Method use to set the datasource.
	 *
	 * @param dataSource DataSource
	 *
	 * @return
	 */
	@Resource
	public void setDataSource(DataSource dataSource) {
		this.jdbcTemplate = new JdbcTemplate(dataSource);
	}

	/*
	 * OPERACIONES CRUD
	 */

	/**
	 * Inserts a single row in the ConceptosLiq table.
	 *
	 * @param conceptosliq ConceptosLiq
	 *
	 * @return ConceptosLiq
	 */
	public ConceptosLiq add(ConceptosLiq conceptosliq) {
		String query = "INSERT INTO AE01B.CONCEPTOS_LIQ (ID_LIQUIDACION_01, ID_CONCEPTO_01, IMPORTE_01, NUMLINEA_01, USU_ALTA_01, F_ALTA_01, USU_MODIF_01, F_MODIF_01) "
				+ "VALUES (:idLiquidacion01,:idConcepto01,:importe01,:numLinea01,:usuAlta01, :fAlta01, :usuModif01, :fModif01)";

		Object liquidacionesIdLiquidaciones00Aux = null;
		if (conceptosliq.getLiquidaciones() != null && conceptosliq.getLiquidaciones().getIdLiquidacion00() != null) {
			liquidacionesIdLiquidaciones00Aux = conceptosliq.getLiquidaciones().getIdLiquidacion00();
		}
		Object conceptosIngresoIdConcepto31Aux = null;
		if (conceptosliq.getConceptosIngreso() != null
				&& conceptosliq.getConceptosIngreso().getIdConcepto31() != null) {
			conceptosIngresoIdConcepto31Aux = conceptosliq.getConceptosIngreso().getIdConcepto31();
		}

		MapSqlParameterSource parameters = new MapSqlParameterSource()
				.addValue("idLiquidacion01", liquidacionesIdLiquidaciones00Aux)
				.addValue("idConcepto01", conceptosIngresoIdConcepto31Aux)
				.addValue("importe01", conceptosliq.getImporte01()).addValue("numLinea01", conceptosliq.getNumlinea01())
				.addValue("usuAlta01", conceptosliq.getUsuAlta01()).addValue("fAlta01", conceptosliq.getfAlta01())
				.addValue("usuModif01", conceptosliq.getUsuModif01()).addValue("fModif01", conceptosliq.getfModif01());

		NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
		namedParameterJdbcTemplate.update(query, parameters);

		return conceptosliq;
	}

	/**
	 * Updates a single row in the ConceptosLiq table.
	 *
	 * @param conceptosliq ConceptosLiq
	 *
	 * @return ConceptosLiq
	 */
	public ConceptosLiq update(ConceptosLiq conceptosliq) {
		String query = "UPDATE AE01B.CONCEPTOS_LIQ SET IMPORTE_01=?, NUMLINEA_01=?, USU_MODIF_01=?, F_MODIF_01=? WHERE ID_LIQUIDACION_01=? AND ID_CONCEPTO_01=?";
		Object liquidacionesIdLiquidaciones00Aux = null;
		if (conceptosliq.getLiquidaciones() != null && conceptosliq.getLiquidaciones().getIdLiquidacion00() != null) {
			liquidacionesIdLiquidaciones00Aux = conceptosliq.getLiquidaciones().getIdLiquidacion00();
		}
		Object conceptosIngresoIdConcepto31Aux = null;
		if (conceptosliq.getConceptosIngreso() != null
				&& conceptosliq.getConceptosIngreso().getIdConcepto31() != null) {
			conceptosIngresoIdConcepto31Aux = conceptosliq.getConceptosIngreso().getIdConcepto31();
		}
		this.jdbcTemplate.update(query, conceptosliq.getImporte01(), conceptosliq.getNumlinea01(),
				conceptosliq.getUsuModif01(), conceptosliq.getfModif01(), liquidacionesIdLiquidaciones00Aux,
				conceptosIngresoIdConcepto31Aux);
		return conceptosliq;
	}

	/**
	 * Finds a single row in the ConceptosLiq table.
	 *
	 * @param conceptosliq ConceptosLiq
	 *
	 * @return ConceptosLiq
	 */
	@Transactional(readOnly = true)
	public ConceptosLiq find(ConceptosLiq conceptosliq) {
		String query = "SELECT t1.ID_LIQUIDACION_01 IDLIQUIDACION01, t1.ID_CONCEPTO_01 IDCONCEPTO01, t1.IMPORTE_01 IMPORTE01, t1.NUMLINEA_01 NUMLINEA01, t1.USU_ALTA_01 USUALTA01, t1.F_ALTA_01 FALTA01, t1.USU_MODIF_01 USUMODIF01, t1.F_MODIF_01 FMODIF01 FROM AE01B.CONCEPTOS_LIQ t1  WHERE t1.ID_LIQUIDACION_01 = ?   AND t1.ID_CONCEPTO_01 = ?  ";

		List<ConceptosLiq> conceptosliqList = this.jdbcTemplate.query(query, this.rwMap,
				conceptosliq.getLiquidaciones().getIdLiquidacion00(),
				conceptosliq.getConceptosIngreso().getIdConcepto31());
		return DataAccessUtils.uniqueResult(conceptosliqList);
	}

	/**
	 * Removes a single row in the ConceptosLiq table.
	 *
	 * @param conceptosliq ConceptosLiq
	 */
	public void remove(ConceptosLiq conceptosliq) {
		String query = "DELETE FROM AE01B.CONCEPTOS_LIQ WHERE ID_LIQUIDACION_01=? AND ID_CONCEPTO_01=?";
		this.jdbcTemplate.update(query, conceptosliq.getLiquidaciones().getIdLiquidacion00(),
				conceptosliq.getConceptosIngreso().getIdConcepto31());
	}

	public List<ConceptosLiq> getMultiple(ConceptosLiq filterConceptosLiq, TableRequestDto tableRequestDto,
			Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_LIQUIDACION_01 IDLIQUIDACION01, t1.ID_CONCEPTO_01 IDCONCEPTO01, t1.IMPORTE_01 IMPORTE01, t1.NUMLINEA_01 NUMLINEA01, t1.USU_ALTA_01 USUALTA01, t1.F_ALTA_01 FALTA01, t1.USU_MODIF_01 USUMODIF01, t1.F_MODIF_01 FMODIF01 ");
		// FROM
		query.append("FROM AE01B.CONCEPTOS_LIQ t1 ");
		// WHERE clause & Params
		Map<String, Object> mapaWhere = this.getWhereLikeMap(filterConceptosLiq, startsWith);
		StringBuilder where = new StringBuilder(" WHERE 1=1 ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		@SuppressWarnings("unchecked")
		List<Object> params = (List<Object>) mapaWhere.get("params");

		StringBuilder sbMultipleSQL = query.append(TableManager.getSelectMultipleQuery(tableRequestDto,
				ConceptosLiq.class, params, "id_liquidacion_01", "id_concepto_01"));

		return this.jdbcTemplate.query(sbMultipleSQL.toString(), this.rwMap, params.toArray());
	}

	/**
	 * Finds a list of rows in the ConceptosLiq table.
	 *
	 * @param conceptosliq    ConceptosLiq
	 * @param tableRequestDto TableRequestDto
	 *
	 * @return List<ConceptosLiq>
	 */
	@Transactional(readOnly = true)
	public List<ConceptosLiq> findAll(ConceptosLiq conceptosliq, TableRequestDto tableRequestDto) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT  t1.ID_LIQUIDACION_01 IDLIQUIDACION01,t1.ID_CONCEPTO_01 IDCONCEPTO01,t1.IMPORTE_01 IMPORTE01,t1.NUMLINEA_01 NUMLINEA01, t1.USU_ALTA_01 USUALTA01, t1.F_ALTA_01 FALTA01, t1.USU_MODIF_01 USUMODIF01, t1.F_MODIF_01 FMODIF01 ");

		// FROM
		query.append("FROM AE01B.CONCEPTOS_LIQ t1 ");

		// WHERE clause & Params
		Map<String, ?> mapaWhere = this.getWhereMap(conceptosliq);
		StringBuilder where = new StringBuilder(" WHERE 1=1 ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		if (tableRequestDto != null) {
			query = TableManager.getPaginationQuery(tableRequestDto, query, ConceptosLiqDaoImpl.ORDER_BY_WHITE_LIST);
		}

		return this.jdbcTemplate.query(query.toString(), this.rwMap, params.toArray());
	}

	/**
	 * Finds rows in the ConceptosLiq table using like.
	 *
	 * @param conceptosliq    ConceptosLiq
	 * @param tableRequestDto TableRequestDto
	 * @param startsWith      Boolean
	 *
	 * @return List<ConceptosLiq>
	 */
	@Transactional(readOnly = true)
	public List<ConceptosLiq> findAllLike(ConceptosLiq conceptosliq, TableRequestDto tableRequestDto,
			Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT  t1.ID_LIQUIDACION_01 IDLIQUIDACION01,t1.ID_CONCEPTO_01 IDCONCEPTO01,t1.IMPORTE_01 IMPORTE01,t1.NUMLINEA_01 NUMLINEA01, t1.USU_ALTA_01 USUALTA01, t1.F_ALTA_01 FALTA01, t1.USU_MODIF_01 USUMODIF01, t1.F_MODIF_01 FMODIF01 ");

		// FROM
		query.append("FROM AE01B.CONCEPTOS_LIQ t1 ");

		// WHERE clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(conceptosliq, startsWith);
		StringBuilder where = new StringBuilder(" WHERE 1=1 ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		if (tableRequestDto != null) {
			query = TableManager.getPaginationQuery(tableRequestDto, query, ConceptosLiqDaoImpl.ORDER_BY_WHITE_LIST);
		}

		return this.jdbcTemplate.query(query.toString(), this.rwMap, params.toArray());
	}

	/*
	 * OPERACIONES RUP_TABLE
	 */

	/**
	 * Counts rows in the ConceptosLiq table.
	 *
	 * @param conceptosliq ConceptosLiq
	 *
	 * @return Long
	 */
	@Transactional(readOnly = true)
	public Long findAllCount(ConceptosLiq conceptosliq) {
		// SELECT
		StringBuilder query = new StringBuilder("SELECT COUNT(1) FROM AE01B.CONCEPTOS_LIQ t1 ");

		// WHERE clause & Params
		Map<String, ?> mapaWhere = this.getWhereMap(conceptosliq);
		StringBuilder where = new StringBuilder(" WHERE 1=1 ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		return this.jdbcTemplate.queryForObject(query.toString(), params.toArray(), Long.class);
	}

	/**
	 * Counts rows in the ConceptosLiq table using like.
	 *
	 * @param conceptosliq ConceptosLiq
	 * @param startsWith   Boolean
	 *
	 * @return Long
	 */
	@Transactional(readOnly = true)
	public Long findAllLikeCount(ConceptosLiq conceptosliq, Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder("SELECT COUNT(1) FROM AE01B.CONCEPTOS_LIQ t1 ");

		// WHERE clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(conceptosliq, startsWith);
		StringBuilder where = new StringBuilder(" WHERE 1=1 ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		return this.jdbcTemplate.queryForObject(query.toString(), params.toArray(), Long.class);
	}

	/**
	 * Reorder the data list of ConceptosLiq selected for rup_table
	 *
	 * @param conceptosliq    ConceptosLiq
	 * @param tableRequestDto TableRequestDto
	 * @param startsWith      Boolean
	 *
	 * @return List<TableRowDto<ConceptosLiq>>
	 */
	@Override
	public List<TableRowDto<ConceptosLiq>> reorderSelection(ConceptosLiq conceptosliq, TableRequestDto tableRequestDto,
			Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_LIQUIDACION_01 IDLIQUIDACION01,t1.ID_CONCEPTO_01 IDCONCEPTO01,t1.IMPORTE_01 IMPORTE01,t1.NUMLINEA_01 NUMLINEA01, t1.USU_ALTA_01 USUALTA01, t1.F_ALTA_01 FALTA01, t1.USU_MODIF_01 USUMODIF01, t1.F_MODIF_01 FMODIF01 ");
		// FROM
		query.append("FROM AE01B.CONCEPTOS_LIQ t1 ");
		// FILTRADO
		// WHERE clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(conceptosliq, startsWith);
		StringBuilder where = new StringBuilder(" WHERE 1=1 ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		// Parámetros de filtrado
		@SuppressWarnings("unchecked")
		List<Object> filterParamList = (List<Object>) mapaWhere.get("params");

		// SQL para la reordenación
		StringBuilder sbReorderSelectionSQL = TableManager.getReorderQuery(query, tableRequestDto, ConceptosLiq.class,
				filterParamList, "idliquidacion01", "idconcepto01");

		return this.jdbcTemplate.query(sbReorderSelectionSQL.toString(),
				new RowNumResultSetExtractor<ConceptosLiq>(this.rwMapPK, tableRequestDto), filterParamList.toArray());
	}

	/**
	 * Search method for rup_table
	 *
	 * @param filterParams    ConceptosLiq
	 * @param searchParams    ConceptosLiq
	 * @param tableRequestDto TableRequestDto
	 * @param startsWith      Boolean
	 *
	 * @return List<TableRowDto<ConceptosLiq>>
	 */
	@Override
	public List<TableRowDto<ConceptosLiq>> search(ConceptosLiq filterParams, ConceptosLiq searchParams,
			TableRequestDto tableRequestDto, Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_LIQUIDACION_01 IDLIQUIDACION01,t1.ID_CONCEPTO_01 IDCONCEPTO01,t1.IMPORTE_01 IMPORTE01,t1.NUMLINEA_01 NUMLINEA01, t1.USU_ALTA_01 USUALTA01, t1.F_ALTA_01 FALTA01, t1.USU_MODIF_01 USUMODIF01, t1.F_MODIF_01 FMODIF01 ");
		// FROM
		query.append("FROM AE01B.CONCEPTOS_LIQ t1 ");
		// TABLAS_ALIAS
		List<String> from_alias = new ArrayList<String>();
		from_alias.add(" t1 ");

		// FILTRADO
		Map<String, ?> mapaWhereFilter = this.getWhereLikeMap(filterParams, startsWith);
		StringBuilder where = new StringBuilder(" WHERE 1=1 ");
		where.append(mapaWhereFilter.get("query"));
		query.append(where);
		// Filter params
		@SuppressWarnings("unchecked")
		List<Object> filterParamList = (List<Object>) mapaWhereFilter.get("params");

		// BUSQUEDA
		Map<String, Object> mapaWhereSearch = this.getWhereLikeMap(searchParams, startsWith);
		String searchSQL = ((StringBuilder) mapaWhereSearch.get("query")).toString();
		// Search params
		@SuppressWarnings("unchecked")
		List<Object> searchParamList = (List<Object>) mapaWhereSearch.get("params");

		// SQL
		StringBuilder sbReorderSelectionSQL = TableManager.getSearchQuery(query, tableRequestDto, ConceptosLiq.class,
				filterParamList, searchSQL, searchParamList, from_alias, "IDLIQUIDACION01,IDCONCEPTO01");

		return this.jdbcTemplate.query(sbReorderSelectionSQL.toString(),
				new RowNumResultSetExtractor<ConceptosLiq>(this.rwMapPK, tableRequestDto), filterParamList.toArray());
	}

	/*
	 * MÉTODOS PRIVADOS
	 */

	/**
	 * Returns a map with the needed value to create the conditions to filter by the
	 * ConceptosLiq entity
	 *
	 * @param conceptosliq ConceptosLiq Bean with the criteria values to filter by.
	 *
	 * @return Map created with two keys key query stores the sql query syntax key
	 *         params stores the parameter values to be used in the condition
	 *         sentence.
	 */
	private Map<String, ?> getWhereMap(ConceptosLiq conceptosliq) {
		StringBuilder where = new StringBuilder(ConceptosLiqDaoImpl.STRING_BUILDER_INIT);
		List<Object> params = new ArrayList<Object>();

		if (conceptosliq != null && conceptosliq.getLiquidaciones() != null
				&& conceptosliq.getLiquidaciones().getIdLiquidacion00() != null) {
			where.append(" AND t1.ID_LIQUIDACION_01 = ?");
			params.add(conceptosliq.getLiquidaciones().getIdLiquidacion00());
		}
		if (conceptosliq != null && conceptosliq.getConceptosIngreso() != null
				&& conceptosliq.getConceptosIngreso().getIdConcepto31() != null) {
			where.append(" AND t1.ID_CONCEPTO_01 = ?");
			params.add(conceptosliq.getConceptosIngreso().getIdConcepto31());
		}
		if (conceptosliq != null && conceptosliq.getImporte01() != null) {
			where.append(" AND t1.IMPORTE_01 = ?");
			params.add(conceptosliq.getImporte01());
		}
		if (conceptosliq != null && conceptosliq.getNumlinea01() != null) {
			where.append(" AND t1.NUMLINEA_01 = ?");
			params.add(conceptosliq.getNumlinea01());
		}
		if (conceptosliq != null && conceptosliq.getUsuAlta01() != null) {
			where.append(" AND t1.USU_ALTA_01 = ?");
			params.add(conceptosliq.getUsuAlta01());
		}
		if (conceptosliq != null && conceptosliq.getfAlta01() != null) {
			where.append(" AND t1.F_ALTA_01 = ?");
			params.add(conceptosliq.getfAlta01());
		}
		if (conceptosliq != null && conceptosliq.getUsuModif01() != null) {
			where.append(" AND t1.USU_MODIF_01 = ?");
			params.add(conceptosliq.getUsuModif01());
		}
		if (conceptosliq != null && conceptosliq.getfModif01() != null) {
			where.append(" AND t1.F_MODIF_01 = ?");
			params.add(conceptosliq.getfModif01());
		}

		Map<String, Object> mapWhere = new HashMap<String, Object>();
		mapWhere.put("query", where);
		mapWhere.put("params", params);

		return mapWhere;
	}

	/**
	 * Returns a map with the needed value to create the conditions to filter by the
	 * ConceptosLiq entity
	 *
	 * @param conceptosliq ConceptosLiq Bean with the criteria values to filter by.
	 * @param startsWith   Boolean
	 *
	 * @return Map created with two keys key query stores the sql query syntax key
	 *         params stores the parameter values to be used in the condition
	 *         sentence.
	 */
	private Map<String, Object> getWhereLikeMap(ConceptosLiq conceptosliq, Boolean startsWith) {
		StringBuilder where = new StringBuilder(ConceptosLiqDaoImpl.STRING_BUILDER_INIT);
		List<Object> params = new ArrayList<Object>();

		if (conceptosliq != null && conceptosliq.getLiquidaciones() != null
				&& conceptosliq.getLiquidaciones().getIdLiquidacion00() != null) {
			where.append(" AND t1.ID_LIQUIDACION_01 = ?");
			params.add(conceptosliq.getLiquidaciones().getIdLiquidacion00());
		}
		if (conceptosliq != null && conceptosliq.getConceptosIngreso() != null
				&& conceptosliq.getConceptosIngreso().getIdConcepto31() != null) {
			where.append(" AND t1.ID_CONCEPTO_01 = ?");
			params.add(conceptosliq.getConceptosIngreso().getIdConcepto31());
		}

		if (conceptosliq != null && conceptosliq.getImporte01() != null) {
			where.append(" AND t1.IMPORTE_01 = ?");
			params.add(conceptosliq.getImporte01());
		}
		if (conceptosliq != null && conceptosliq.getNumlinea01() != null) {
			where.append(" AND t1.NUMLINEA_01 = ?");
			params.add(conceptosliq.getNumlinea01());
		}
		if (conceptosliq != null && conceptosliq.getUsuAlta01() != null) {
			where.append(" AND UPPER(t1.USU_ALTA_01) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(conceptosliq.getUsuAlta01().toUpperCase() + "%");
			} else {
				params.add("%" + conceptosliq.getUsuAlta01().toUpperCase() + "%");
			}
			where.append(" AND t1.USU_ALTA_01 IS NOT NULL");
		}
		if (conceptosliq != null && conceptosliq.getfAlta01() != null) {
			where.append(" AND t1.F_ALTA_01 = ?");
			params.add(conceptosliq.getfAlta01());
		}
		if (conceptosliq != null && conceptosliq.getUsuModif01() != null) {
			where.append(" AND UPPER(t1.USU_MODIF_01) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(conceptosliq.getUsuModif01().toUpperCase() + "%");
			} else {
				params.add("%" + conceptosliq.getUsuModif01().toUpperCase() + "%");
			}
			where.append(" AND t1.USU_MODIF_01 IS NOT NULL");
		}
		if (conceptosliq != null && conceptosliq.getfModif01() != null) {
			where.append(" AND t1.F_MODIF_01 = ?");
			params.add(conceptosliq.getfModif01());
		}

		Map<String, Object> mapWhere = new HashMap<String, Object>();
		mapWhere.put("query", where);
		mapWhere.put("params", params);

		return mapWhere;
	}
}
