/*
* 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.TiposIngreso;
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.jdbc.support.GeneratedKeyHolder;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

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

@Repository
@Transactional
public class ConceptosIngresoDaoImpl implements ConceptosIngresoDao {

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

	protected static final String[] ORDER_BY_WHITE_LIST = new String[] { "IDCONCEPTO31", "IDTIPOINGRESO31",
			"DESCRIPCIONES31", "DESCRIPCIONEU31", "CODSIPCA31", "TIPODEVENGO31", "USUALTA31", "FALTA31", "USUMODIF31",
			"FMODIF31" };

	private JdbcTemplate jdbcTemplate;

	public static final String SEQUENCE_CONCEPTOS_INGRESO = "SEQ_CONCEPTOS_INGRESO";

	/*
	 * ROW_MAPPERS
	 */
	private RowMapper<ConceptosIngreso> rwMap = new RowMapper<ConceptosIngreso>() {
		public ConceptosIngreso mapRow(ResultSet resultSet, int rowNum) throws SQLException {
			return new ConceptosIngreso(UtilSQL.getLong(resultSet, "IDCONCEPTO31"),
					new TiposIngreso(UtilSQL.getLong(resultSet, "IDTIPOINGRESO31")),
					resultSet.getString("DESCRIPCIONES31"), resultSet.getString("DESCRIPCIONEU31"),
					resultSet.getString("CODSIPCA31"), resultSet.getString("TIPODEVENGO31"),
					resultSet.getString("USUALTA31"), resultSet.getDate("FALTA31"), resultSet.getString("USUMODIF31"),
					resultSet.getDate("FMODIF31"));
		}
	};

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

	/**
	 * 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 ConceptosIngreso table.
	 *
	 * @param conceptosingreso ConceptosIngreso
	 *
	 * @return ConceptosIngreso
	 */
	public ConceptosIngreso add(ConceptosIngreso conceptosingreso) {

		GeneratedKeyHolder generatedKeyHolder = new GeneratedKeyHolder();

		String query = "INSERT INTO AE01B.CONCEPTOS_INGRESO (ID_CONCEPTO_31, ID_TIPO_INGRESO_31, DESCRIPCION_ES_31, DESCRIPCION_EU_31, COD_SIPCA_31, TIPO_DEVENGO_31, USU_ALTA_31, F_ALTA_31, USU_MODIF_31, F_MODIF_31) "
				+ "VALUES (" + SEQUENCE_CONCEPTOS_INGRESO
				+ ".NEXTVAL,:idTipoIngreso,:descripcionEs31,:descripcionEu31,:codSipca31,:tipoDevengo31,:usuAlta, :fAlta, :usuModif, :fModif)";

		Object getTipoIngresoIdTipoIngreso30Aux = null;
		if (conceptosingreso.getTiposIngreso() != null
				&& conceptosingreso.getTiposIngreso().getIdTipoIngreso30() != null) {
			getTipoIngresoIdTipoIngreso30Aux = conceptosingreso.getTiposIngreso().getIdTipoIngreso30();
		}

		MapSqlParameterSource parameters = new MapSqlParameterSource()
				.addValue("idTipoIngreso", getTipoIngresoIdTipoIngreso30Aux)
				.addValue("descripcionEs31", conceptosingreso.getDescripcionEs31())
				.addValue("descripcionEu31", conceptosingreso.getDescripcionEu31())
				.addValue("codSipca31", conceptosingreso.getCodSipca31())
				.addValue("tipoDevengo31", conceptosingreso.getTipoDevengo31())
				.addValue("usuAlta", conceptosingreso.getUsuAlta31()).addValue("fAlta", conceptosingreso.getfAlta31())
				.addValue("usuModif", conceptosingreso.getUsuModif31())
				.addValue("fModif", conceptosingreso.getfModif31());

		NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
		namedParameterJdbcTemplate.update(query, parameters, generatedKeyHolder, new String[] { "ID_CONCEPTO_31" });
		conceptosingreso.setIdConcepto31(generatedKeyHolder.getKey().longValue());

		return conceptosingreso;
	}

	/**
	 * Updates a single row in the ConceptosIngreso table.
	 *
	 * @param conceptosingreso ConceptosIngreso
	 *
	 * @return ConceptosIngreso
	 */
	public ConceptosIngreso update(ConceptosIngreso conceptosingreso) {
		String query = "UPDATE AE01B.CONCEPTOS_INGRESO SET ID_TIPO_INGRESO_31=?, DESCRIPCION_ES_31=?, DESCRIPCION_EU_31=?, COD_SIPCA_31=?, TIPO_DEVENGO_31=?, USU_MODIF_31=?, F_MODIF_31=? WHERE ID_CONCEPTO_31=?";

		Object getTipoIngresoIdTipoIngreso30Aux = null;
		if (conceptosingreso.getTiposIngreso() != null
				&& conceptosingreso.getTiposIngreso().getIdTipoIngreso30() != null) {
			getTipoIngresoIdTipoIngreso30Aux = conceptosingreso.getTiposIngreso().getIdTipoIngreso30();
		}

		this.jdbcTemplate.update(query, getTipoIngresoIdTipoIngreso30Aux, conceptosingreso.getDescripcionEs31(),
				conceptosingreso.getDescripcionEu31(), conceptosingreso.getCodSipca31(),
				conceptosingreso.getTipoDevengo31(), conceptosingreso.getUsuModif31(), conceptosingreso.getfModif31(),
				conceptosingreso.getIdConcepto31());
		return conceptosingreso;
	}

	/**
	 * Finds a single row in the ConceptosIngreso table.
	 *
	 * @param conceptosingreso ConceptosIngreso
	 *
	 * @return ConceptosIngreso
	 */
	@Transactional(readOnly = true)
	public ConceptosIngreso find(ConceptosIngreso conceptosingreso) {
		String query = "SELECT t1.ID_CONCEPTO_31 IDCONCEPTO31, t1.ID_TIPO_INGRESO_31 IDTIPOINGRESO31, t1.DESCRIPCION_ES_31 DESCRIPCIONES31, t1.DESCRIPCION_EU_31 DESCRIPCIONEU31, t1.COD_SIPCA_31 CODSIPCA31, t1.TIPO_DEVENGO_31 TIPODEVENGO31, t1.USU_ALTA_31 USUALTA31, t1.F_ALTA_31 FALTA31, t1.USU_MODIF_31 USUMODIF31, t1.F_MODIF_31 FMODIF31 FROM AE01B.CONCEPTOS_INGRESO t1  WHERE t1.ID_CONCEPTO_31 = ?  ";

		List<ConceptosIngreso> conceptosingresoList = this.jdbcTemplate.query(query, this.rwMap,
				conceptosingreso.getIdConcepto31());
		return DataAccessUtils.uniqueResult(conceptosingresoList);
	}

	/**
	 * Removes a single row in the ConceptosIngreso table.
	 *
	 * @param conceptosingreso ConceptosIngreso
	 */
	public void remove(ConceptosIngreso conceptosingreso) {
		String query = "DELETE FROM AE01B.CONCEPTOS_INGRESO WHERE ID_CONCEPTO_31=?";
		this.jdbcTemplate.update(query, conceptosingreso.getIdConcepto31());
	}

	public List<ConceptosIngreso> getMultiple(ConceptosIngreso filterConceptosIngreso, TableRequestDto tableRequestDto,
			Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_CONCEPTO_31 IDCONCEPTO31, t1.ID_TIPO_INGRESO_31 IDTIPOINGRESO31, t1.DESCRIPCION_ES_31 DESCRIPCIONES31, t1.DESCRIPCION_EU_31 DESCRIPCIONEU31, t1.COD_SIPCA_31 CODSIPCA31, t1.TIPO_DEVENGO_31 TIPODEVENGO31, t1.USU_ALTA_31 USUALTA31, t1.F_ALTA_31 FALTA31, t1.USU_MODIF_31 USUMODIF31, t1.F_MODIF_31 FMODIF31 ");
		// FROM
		query.append("FROM AE01B.CONCEPTOS_INGRESO t1 ");
		// WHERE clause & Params
		Map<String, Object> mapaWhere = this.getWhereLikeMap(filterConceptosIngreso, 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, ConceptosIngreso.class, params, "id_concepto_31"));

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

	/**
	 * Finds a list of rows in the ConceptosIngreso table.
	 *
	 * @param conceptosingreso ConceptosIngreso
	 * @param tableRequestDto  TableRequestDto
	 *
	 * @return List<ConceptosIngreso>
	 */
	@Transactional(readOnly = true)
	public List<ConceptosIngreso> findAll(ConceptosIngreso conceptosingreso, TableRequestDto tableRequestDto) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT  t1.ID_CONCEPTO_31 IDCONCEPTO31,t1.ID_TIPO_INGRESO_31 IDTIPOINGRESO31,t1.DESCRIPCION_ES_31 DESCRIPCIONES31,t1.DESCRIPCION_EU_31 DESCRIPCIONEU31,t1.COD_SIPCA_31 CODSIPCA31,t1.TIPO_DEVENGO_31 TIPODEVENGO31, t1.USU_ALTA_31 USUALTA31, t1.F_ALTA_31 FALTA31, t1.USU_MODIF_31 USUMODIF31, t1.F_MODIF_31 FMODIF31 ");

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

		// WHERE clause & Params
		Map<String, ?> mapaWhere = this.getWhereMap(conceptosingreso);
		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,
					ConceptosIngresoDaoImpl.ORDER_BY_WHITE_LIST);
		}

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

	/**
	 * Finds rows in the ConceptosIngreso table using like.
	 *
	 * @param conceptosingreso ConceptosIngreso
	 * @param tableRequestDto  TableRequestDto
	 * @param startsWith       Boolean
	 *
	 * @return List<ConceptosIngreso>
	 */
	@Transactional(readOnly = true)
	public List<ConceptosIngreso> findAllLike(ConceptosIngreso conceptosingreso, TableRequestDto tableRequestDto,
			Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT  t1.ID_CONCEPTO_31 IDCONCEPTO31,t1.ID_TIPO_INGRESO_31 IDTIPOINGRESO31,t1.DESCRIPCION_ES_31 DESCRIPCIONES31,t1.DESCRIPCION_EU_31 DESCRIPCIONEU31,t1.COD_SIPCA_31 CODSIPCA31,t1.TIPO_DEVENGO_31 TIPODEVENGO31, t1.USU_ALTA_31 USUALTA31, t1.F_ALTA_31 FALTA31, t1.USU_MODIF_31 USUMODIF31, t1.F_MODIF_31 FMODIF31 ");

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

		// WHERE clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(conceptosingreso, 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,
					ConceptosIngresoDaoImpl.ORDER_BY_WHITE_LIST);
		}

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

	/*
	 * OPERACIONES RUP_TABLE
	 */

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

		// WHERE clause & Params
		Map<String, ?> mapaWhere = this.getWhereMap(conceptosingreso);
		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 ConceptosIngreso table using like.
	 *
	 * @param conceptosingreso ConceptosIngreso
	 * @param startsWith       Boolean
	 *
	 * @return Long
	 */
	@Transactional(readOnly = true)
	public Long findAllLikeCount(ConceptosIngreso conceptosingreso, Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder("SELECT COUNT(1) FROM AE01B.CONCEPTOS_INGRESO t1 ");

		// WHERE clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(conceptosingreso, 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 ConceptosIngreso selected for rup_table
	 *
	 * @param conceptosingreso ConceptosIngreso
	 * @param tableRequestDto  TableRequestDto
	 * @param startsWith       Boolean
	 *
	 * @return List<TableRowDto<ConceptosIngreso>>
	 */
	@Override
	public List<TableRowDto<ConceptosIngreso>> reorderSelection(ConceptosIngreso conceptosingreso,
			TableRequestDto tableRequestDto, Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_CONCEPTO_31 IDCONCEPTO31,t1.ID_TIPO_INGRESO_31 IDTIPOINGRESO31,t1.DESCRIPCION_ES_31 DESCRIPCIONES31,t1.DESCRIPCION_EU_31 DESCRIPCIONEU31,t1.COD_SIPCA_31 CODSIPCA31,t1.TIPO_DEVENGO_31 TIPODEVENGO31, t1.USU_ALTA_31 USUALTA31, t1.F_ALTA_31 FALTA31, t1.USU_MODIF_31 USUMODIF31, t1.F_MODIF_31 FMODIF31 ");
		// FROM
		query.append("FROM AE01B.CONCEPTOS_INGRESO t1 ");
		// FILTRADO
		// WHERE clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(conceptosingreso, 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,
				ConceptosIngreso.class, filterParamList, "idconcepto31");

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

	/**
	 * Search method for rup_table
	 *
	 * @param filterParams    ConceptosIngreso
	 * @param searchParams    ConceptosIngreso
	 * @param tableRequestDto TableRequestDto
	 * @param startsWith      Boolean
	 *
	 * @return List<TableRowDto<ConceptosIngreso>>
	 */
	@Override
	public List<TableRowDto<ConceptosIngreso>> search(ConceptosIngreso filterParams, ConceptosIngreso searchParams,
			TableRequestDto tableRequestDto, Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_CONCEPTO_31 IDCONCEPTO31,t1.ID_TIPO_INGRESO_31 IDTIPOINGRESO31,t1.DESCRIPCION_ES_31 DESCRIPCIONES31,t1.DESCRIPCION_EU_31 DESCRIPCIONEU31,t1.COD_SIPCA_31 CODSIPCA31,t1.TIPO_DEVENGO_31 TIPODEVENGO31, t1.USU_ALTA_31 USUALTA31, t1.F_ALTA_31 FALTA31, t1.USU_MODIF_31 USUMODIF31, t1.F_MODIF_31 FMODIF31 ");
		// FROM
		query.append("FROM AE01B.CONCEPTOS_INGRESO 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,
				ConceptosIngreso.class, filterParamList, searchSQL, searchParamList, from_alias, "IDCONCEPTO31");

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

	/**
	 * Remove multiple method for rup_table
	 *
	 * @param tableRequestDto TableRequestDto
	 */
	@Override
	public void removeMultiple(TableRequestDto tableRequestDto) {
		StringBuilder sbRemoveMultipleSQL = TableManager.getRemoveMultipleQuery(null, tableRequestDto,
				ConceptosIngreso.class, "AE01B.CONCEPTOS_INGRESO", "t1", new String[] { "IDCONCEPTO31" });

		List<String> params = tableRequestDto.getMultiselection().getSelectedIds();

		this.jdbcTemplate.update(sbRemoveMultipleSQL.toString(), params.toArray());
	}

	/*
	 * MÃ‰TODOS PRIVADOS
	 */

	/**
	 * Returns a map with the needed value to create the conditions to filter by the
	 * ConceptosIngreso entity
	 *
	 * @param conceptosingreso ConceptosIngreso 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(ConceptosIngreso conceptosingreso) {
		StringBuilder where = new StringBuilder(ConceptosIngresoDaoImpl.STRING_BUILDER_INIT);
		List<Object> params = new ArrayList<Object>();

		if (conceptosingreso != null && conceptosingreso.getIdConcepto31() != null) {
			where.append(" AND t1.ID_CONCEPTO_31 = ?");
			params.add(conceptosingreso.getIdConcepto31());
		}
		if (conceptosingreso != null && conceptosingreso.getTiposIngreso() != null
				&& conceptosingreso.getTiposIngreso().getIdTipoIngreso30() != null) {
			where.append(" AND t1.ID_TIPO_INGRESO_31 = ?");
			params.add(conceptosingreso.getTiposIngreso().getIdTipoIngreso30());
		}
		if (conceptosingreso != null && conceptosingreso.getDescripcionEs31() != null) {
			where.append(" AND t1.DESCRIPCION_ES_31 = ?");
			params.add(conceptosingreso.getDescripcionEs31());
		}
		if (conceptosingreso != null && conceptosingreso.getDescripcionEu31() != null) {
			where.append(" AND t1.DESCRIPCION_EU_31 = ?");
			params.add(conceptosingreso.getDescripcionEu31());
		}
		if (conceptosingreso != null && conceptosingreso.getCodSipca31() != null) {
			where.append(" AND t1.COD_SIPCA_31 = ?");
			params.add(conceptosingreso.getCodSipca31());
		}
		if (conceptosingreso != null && conceptosingreso.getTipoDevengo31() != null) {
			where.append(" AND t1.TIPO_DEVENGO_31 = ?");
			params.add(conceptosingreso.getTipoDevengo31());
		}
		if (conceptosingreso != null && conceptosingreso.getUsuAlta31() != null) {
			where.append(" AND t1.USU_ALTA_31 = ?");
			params.add(conceptosingreso.getUsuAlta31());
		}
		if (conceptosingreso != null && conceptosingreso.getfAlta31() != null) {
			where.append(" AND t1.F_ALTA_31 = ?");
			params.add(conceptosingreso.getfAlta31());
		}
		if (conceptosingreso != null && conceptosingreso.getUsuModif31() != null) {
			where.append(" AND t1.USU_MODIF_31 = ?");
			params.add(conceptosingreso.getUsuModif31());
		}
		if (conceptosingreso != null && conceptosingreso.getfModif31() != null) {
			where.append(" AND t1.F_MODIF_31 = ?");
			params.add(conceptosingreso.getfModif31());
		}

		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
	 * ConceptosIngreso entity
	 *
	 * @param conceptosingreso ConceptosIngreso 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(ConceptosIngreso conceptosingreso, Boolean startsWith) {
		StringBuilder where = new StringBuilder(ConceptosIngresoDaoImpl.STRING_BUILDER_INIT);
		List<Object> params = new ArrayList<Object>();

		if (conceptosingreso != null && conceptosingreso.getIdConcepto31() != null) {
			where.append(" AND t1.ID_CONCEPTO_31 = ?");
			params.add(conceptosingreso.getIdConcepto31());
		}
		if (conceptosingreso != null && conceptosingreso.getTiposIngreso() != null
				&& conceptosingreso.getTiposIngreso().getIdTipoIngreso30() != null) {
			where.append(" AND t1.ID_TIPO_INGRESO_31 = ?");
			params.add(conceptosingreso.getTiposIngreso().getIdTipoIngreso30());
		}
		if (conceptosingreso != null && conceptosingreso.getDescripcionEs31() != null) {
			where.append(" AND UPPER(t1.DESCRIPCION_ES_31) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(conceptosingreso.getDescripcionEs31().toUpperCase() + "%");
			} else {
				params.add("%" + conceptosingreso.getDescripcionEs31().toUpperCase() + "%");
			}
			where.append(" AND t1.DESCRIPCION_ES_31 IS NOT NULL");
		}
		if (conceptosingreso != null && conceptosingreso.getDescripcionEu31() != null) {
			where.append(" AND UPPER(t1.DESCRIPCION_EU_31) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(conceptosingreso.getDescripcionEu31().toUpperCase() + "%");
			} else {
				params.add("%" + conceptosingreso.getDescripcionEu31().toUpperCase() + "%");
			}
			where.append(" AND t1.DESCRIPCION_EU_31 IS NOT NULL");
		}
		if (conceptosingreso != null && conceptosingreso.getCodSipca31() != null) {
			where.append(" AND UPPER(t1.COD_SIPCA_31) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(conceptosingreso.getCodSipca31().toUpperCase() + "%");
			} else {
				params.add("%" + conceptosingreso.getCodSipca31().toUpperCase() + "%");
			}
			where.append(" AND t1.COD_SIPCA_31 IS NOT NULL");
		}
		if (conceptosingreso != null && conceptosingreso.getTipoDevengo31() != null) {
			where.append(" AND UPPER(t1.TIPO_DEVENGO_31) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(conceptosingreso.getTipoDevengo31().toUpperCase() + "%");
			} else {
				params.add("%" + conceptosingreso.getTipoDevengo31().toUpperCase() + "%");
			}
			where.append(" AND t1.TIPO_DEVENGO_31 IS NOT NULL");
		}
		if (conceptosingreso != null && conceptosingreso.getUsuAlta31() != null) {
			where.append(" AND UPPER(t1.USU_ALTA_31) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(conceptosingreso.getUsuAlta31().toUpperCase() + "%");
			} else {
				params.add("%" + conceptosingreso.getUsuAlta31().toUpperCase() + "%");
			}
			where.append(" AND t1.USU_ALTA_31 IS NOT NULL");
		}
		if (conceptosingreso != null && conceptosingreso.getfAlta31() != null) {
			where.append(" AND t1.F_ALTA_31 = ?");
			params.add(conceptosingreso.getfAlta31());
		}
		if (conceptosingreso != null && conceptosingreso.getUsuModif31() != null) {
			where.append(" AND UPPER(t1.USU_MODIF_31) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(conceptosingreso.getUsuModif31().toUpperCase() + "%");
			} else {
				params.add("%" + conceptosingreso.getUsuModif31().toUpperCase() + "%");
			}
			where.append(" AND t1.USU_MODIF_31 IS NOT NULL");
		}
		if (conceptosingreso != null && conceptosingreso.getfModif31() != null) {
			where.append(" AND t1.F_MODIF_31 = ?");
			params.add(conceptosingreso.getfModif31());
		}

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

		return mapWhere;
	}
}
