package com.ejie.ad74a.dao;

import com.ejie.ad74a.model.MaestroTiposDoc;
import com.ejie.ad74a.model.MaestroTramites;
import com.ejie.ad74a.util.UtilSQL;
import com.ejie.x38.dao.RowNumResultSetExtractor;
import com.ejie.x38.dto.JerarquiaDto;
import com.ejie.x38.dto.TableManager;
import com.ejie.x38.dto.TableManagerJerarquia;
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.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.ejie.ad74a.model.MaestroTareas;

/**
 * MaestroTareasDaoImpl generated by UDA, 22-mar-2023 17:10:15.
 * 
 * @author UDA
 */

@Repository
@Transactional
public class MaestroTareasDaoImpl implements MaestroTareasDao {

	public static final String[] ORDER_BY_WHITE_LIST = new String[] { "IDTAREA38", "TIPOTAREA38", "DESCES38",
			"DESCEU38", "MTIPDOCIDTIPODOC36", "MTIPDOCDESCES36", "MTIPDOCDESCEU36", "MTIPDOCROLEID36",
			"MTIPDOCORIGEN36", "MTIPDOCFALTA36", "MTIPDOCUSUALTA36", "MTIPDOCFMODIF36", "MTIPDOCUSUMODIF36",
			"MATRAIDTRAMITE37", "MATRADESCES37", "MATRADESCEU37" };

	private JdbcTemplate jdbcTemplate;

	/*
	 * ROW_MAPPERS
	 */
	private RowMapper<MaestroTareas> rwMap = new RowMapper<MaestroTareas>() {
		public MaestroTareas mapRow(ResultSet resultSet, int rowNum) throws SQLException {
			return new MaestroTareas(UtilSQL.getLong(resultSet, "IDTAREA38"), resultSet.getString("TIPOTAREA38"),
					resultSet.getString("DESCES38"), resultSet.getString("DESCEU38"),
					new MaestroTiposDoc(UtilSQL.getLong(resultSet, "MTIPDOCIDTIPODOC36"),
							resultSet.getString("MTIPDOCDESCES36"), resultSet.getString("MTIPDOCDESCEU36"),
							resultSet.getString("MTIPDOCROLEID36"), resultSet.getString("MTIPDOCORIGEN36"),
							resultSet.getDate("MTIPDOCFALTA36"), resultSet.getString("MTIPDOCUSUALTA36"),
							resultSet.getDate("MTIPDOCFMODIF36"), resultSet.getString("MTIPDOCUSUMODIF36")),
					new MaestroTramites(UtilSQL.getLong(resultSet, "MATRAIDTRAMITE37"),
							resultSet.getString("MATRADESCES37"), resultSet.getString("MATRADESCEU37")));
		}
	};

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

	/**
	 * Rowmapper para Jerarquía
	 *
	 * @param dataSource DataSource
	 * @return
	 */
	private RowMapper<JerarquiaDto<MaestroTareas>> rwMapJerarquia = new RowMapper<JerarquiaDto<MaestroTareas>>() {
		public JerarquiaDto<MaestroTareas> mapRow(ResultSet resultSet, int rowNum) throws SQLException {

			MaestroTareas maestrotareas = new MaestroTareas(UtilSQL.getLong(resultSet, "IDTAREA38"),
					resultSet.getString("TIPOTAREA38"), resultSet.getString("DESCES38"),
					resultSet.getString("DESCEU38"),
					new MaestroTiposDoc(UtilSQL.getLong(resultSet, "MTIPDOCIDTIPODOC36"),
							resultSet.getString("MTIPDOCDESCES36"), resultSet.getString("MTIPDOCDESCEU36"),
							resultSet.getString("MTIPDOCROLEID36"), resultSet.getString("MTIPDOCORIGEN36"),
							resultSet.getDate("MTIPDOCFALTA36"), resultSet.getString("MTIPDOCUSUALTA36"),
							resultSet.getDate("MTIPDOCFMODIF36"), resultSet.getString("MTIPDOCUSUMODIF36")),
					new MaestroTramites(UtilSQL.getLong(resultSet, "MATRAIDTRAMITE37"),
							resultSet.getString("MATRADESCES37"), resultSet.getString("MATRADESCEU37")));

			JerarquiaDto<MaestroTareas> jerarquia = new JerarquiaDto<MaestroTareas>();
			jerarquia.setModel(maestrotareas);
			jerarquia.setLevel(resultSet.getBigDecimal("LEVEL").intValue());
			jerarquia.setParentNodes(resultSet.getString("PARENTNODES"));
			jerarquia.setIsLeaf(Boolean.parseBoolean(resultSet.getString("ISLEAF")));
			jerarquia.setFilter(Boolean.parseBoolean(resultSet.getString("FILTER")));
			return jerarquia;
		}
	};

	/**
	 * 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 MaestroTareas table.
	 *
	 * @param maestrotareas MaestroTareas
	 * @return MaestroTareas
	 */
	public MaestroTareas add(MaestroTareas maestrotareas) {
		String query = "INSERT INTO MAESTRO_TAREAS (ID_TAREA_38, ID_TIPO_DOC_38, ID_TRAMITE_38, TIPO_TAREA_38, DESC_ES_38, DESC_EU_38) VALUES (?,?,?,?,?,?)";
		Object getMaestroTiposDocIdTipoDoc36Aux = null;
		if (maestrotareas.getMaestroTiposDoc() != null && maestrotareas.getMaestroTiposDoc().getIdTipoDoc36() != null) {
			getMaestroTiposDocIdTipoDoc36Aux = maestrotareas.getMaestroTiposDoc().getIdTipoDoc36();
		}
		Object getMaestroTramitesIdTramite37Aux = null;
		if (maestrotareas.getMaestroTramites() != null && maestrotareas.getMaestroTramites().getIdTramite37() != null) {
			getMaestroTramitesIdTramite37Aux = maestrotareas.getMaestroTramites().getIdTramite37();
		}
		this.jdbcTemplate.update(query, maestrotareas.getIdTarea38(), getMaestroTiposDocIdTipoDoc36Aux,
				getMaestroTramitesIdTramite37Aux, maestrotareas.getTipoTarea38(), maestrotareas.getDescEs38(),
				maestrotareas.getDescEu38());
		return maestrotareas;
	}

	/**
	 * Updates a single row in the MaestroTareas table.
	 *
	 * @param maestrotareas MaestroTareas
	 * @return MaestroTareas
	 */
	public MaestroTareas update(MaestroTareas maestrotareas) {
		String query = "UPDATE MAESTRO_TAREAS SET ID_TIPO_DOC_38=?, ID_TRAMITE_38=?, TIPO_TAREA_38=?, DESC_ES_38=?, DESC_EU_38=? WHERE ID_TAREA_38=?";
		Object getMaestroTiposDocIdTipoDoc36Aux = null;
		if (maestrotareas.getMaestroTiposDoc() != null && maestrotareas.getMaestroTiposDoc().getIdTipoDoc36() != null) {
			getMaestroTiposDocIdTipoDoc36Aux = maestrotareas.getMaestroTiposDoc().getIdTipoDoc36();
		}
		Object getMaestroTramitesIdTramite37Aux = null;
		if (maestrotareas.getMaestroTramites() != null && maestrotareas.getMaestroTramites().getIdTramite37() != null) {
			getMaestroTramitesIdTramite37Aux = maestrotareas.getMaestroTramites().getIdTramite37();
		}
		this.jdbcTemplate.update(query, getMaestroTiposDocIdTipoDoc36Aux, getMaestroTramitesIdTramite37Aux,
				maestrotareas.getTipoTarea38(), maestrotareas.getDescEs38(), maestrotareas.getDescEu38(),
				maestrotareas.getIdTarea38());
		return maestrotareas;
	}

	/**
	 * Finds a single row in the MaestroTareas table.
	 *
	 * @param maestrotareas MaestroTareas
	 * @return MaestroTareas
	 */
	@Transactional(readOnly = true)
	public MaestroTareas find(MaestroTareas maestrotareas) {
		String query = "SELECT t1.ID_TAREA_38 IDTAREA38, t1.TIPO_TAREA_38 TIPOTAREA38, t1.DESC_ES_38 DESCES38, t1.DESC_EU_38 DESCEU38, t2.ID_TIPO_DOC_36 MTIPDOCIDTIPODOC36, t2.DESC_ES_36 MTIPDOCDESCES36, t2.DESC_EU_36 MTIPDOCDESCEU36, t2.ROLEID_36 MTIPDOCROLEID36, t2.ORIGEN_36 MTIPDOCORIGEN36, t2.F_ALTA_36 MTIPDOCFALTA36, t2.USU_ALTA_36 MTIPDOCUSUALTA36, t2.F_MODIF_36 MTIPDOCFMODIF36, t2.USU_MODIF_36 MTIPDOCUSUMODIF36, t3.ID_TRAMITE_37 MATRAIDTRAMITE37, t3.DESC_ES_37 MATRADESCES37, t3.DESC_EU_37 MATRADESCEU37 FROM MAESTRO_TAREAS t1 , MAESTRO_TIPOS_DOC t2 , MAESTRO_TRAMITES t3  WHERE t1.ID_TAREA_38 = ?   AND t1.ID_TIPO_DOC_38= t2.ID_TIPO_DOC_36(+) AND t1.ID_TRAMITE_38= t3.ID_TRAMITE_37(+)";

		List<MaestroTareas> maestrotareasList = this.jdbcTemplate.query(query, this.rwMap,
				maestrotareas.getIdTarea38());
		return (MaestroTareas) DataAccessUtils.uniqueResult(maestrotareasList);
	}

	/**
	 * Removes a single row in the MaestroTareas table.
	 *
	 * @param maestrotareas MaestroTareas
	 * @return
	 */
	public void remove(MaestroTareas maestrotareas) {
		String query = "DELETE FROM MAESTRO_TAREAS WHERE ID_TAREA_38=?";
		this.jdbcTemplate.update(query, maestrotareas.getIdTarea38());
	}

	/**
	 * Exporta Datos al clipBoard
	 *
	 */
	public List<MaestroTareas> getMultiple(MaestroTareas filterMaestroTareas, TableRequestDto tableRequestDto,
			Boolean startsWith) {

		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_TAREA_38 IDTAREA38, t1.TIPO_TAREA_38 TIPOTAREA38, t1.DESC_ES_38 DESCES38, t1.DESC_EU_38 DESCEU38, t2.ID_TIPO_DOC_36 MTIPDOCIDTIPODOC36, t2.DESC_ES_36 MTIPDOCDESCES36, t2.DESC_EU_36 MTIPDOCDESCEU36, t2.ROLEID_36 MTIPDOCROLEID36, t2.ORIGEN_36 MTIPDOCORIGEN36, t2.F_ALTA_36 MTIPDOCFALTA36, t2.USU_ALTA_36 MTIPDOCUSUALTA36, t2.F_MODIF_36 MTIPDOCFMODIF36, t2.USU_MODIF_36 MTIPDOCUSUMODIF36, t3.ID_TRAMITE_37 MATRAIDTRAMITE37, t3.DESC_ES_37 MATRADESCES37, t3.DESC_EU_37 MATRADESCEU37");
		query.append(" FROM MAESTRO_TAREAS t1 , MAESTRO_TIPOS_DOC t2 , MAESTRO_TRAMITES t3  ");
		// Where clause & Params
		Map<String, Object> mapaWhere = this.getWhereLikeMap(filterMaestroTareas, startsWith);
		StringBuilder where = new StringBuilder(query + " WHERE 1=1 ");
		where.append(mapaWhere.get("query"));

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

		StringBuilder sbMultipleSQL = TableManager.getSelectMultipleQuery(tableRequestDto, MaestroTareas.class, params,
				"ID_TAREA_38");
		where.append(sbMultipleSQL);

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

	/**
	 * Finds a list of rows in the MaestroTareas table.
	 *
	 * @param maestrotareas   MaestroTareas
	 * @param tableRequestDto TableRequestDto
	 * @return List<MaestroTareas>
	 */
	@Transactional(readOnly = true)
	public List<MaestroTareas> findAll(MaestroTareas maestrotareas, TableRequestDto tableRequestDto) {
		StringBuilder query = new StringBuilder(
				"SELECT  t1.ID_TAREA_38 IDTAREA38,t1.TIPO_TAREA_38 TIPOTAREA38,t1.DESC_ES_38 DESCES38,t1.DESC_EU_38 DESCEU38,t2.ID_TIPO_DOC_36 MTIPDOCIDTIPODOC36,t2.DESC_ES_36 MTIPDOCDESCES36,t2.DESC_EU_36 MTIPDOCDESCEU36,t2.ROLEID_36 MTIPDOCROLEID36,t2.ORIGEN_36 MTIPDOCORIGEN36,t2.F_ALTA_36 MTIPDOCFALTA36,t2.USU_ALTA_36 MTIPDOCUSUALTA36,t2.F_MODIF_36 MTIPDOCFMODIF36,t2.USU_MODIF_36 MTIPDOCUSUMODIF36,t3.ID_TRAMITE_37 MATRAIDTRAMITE37,t3.DESC_ES_37 MATRADESCES37,t3.DESC_EU_37 MATRADESCEU37 ");
		query.append("FROM MAESTRO_TAREAS t1 ,MAESTRO_TIPOS_DOC t2 ,MAESTRO_TRAMITES t3 ");

		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereMap(maestrotareas);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TIPO_DOC_38= t2.ID_TIPO_DOC_36(+) AND t1.ID_TRAMITE_38= t3.ID_TRAMITE_37(+) ");
		where.append(mapaWhere.get("query"));
		query.append(where);

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

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

		return (List<MaestroTareas>) this.jdbcTemplate.query(query.toString(), this.rwMap, params.toArray());
	}

	/**
	 * Finds rows in the MaestroTareas table using like.
	 *
	 * @param maestrotareas   MaestroTareas
	 * @param tableRequestDto TableRequestDto
	 * @param startsWith      Boolean
	 * @return List<MaestroTareas>
	 */
	@Transactional(readOnly = true)
	public List<MaestroTareas> findAllLike(MaestroTareas maestrotareas, TableRequestDto tableRequestDto,
			Boolean startsWith) {
		StringBuilder query = new StringBuilder(
				"SELECT  t1.ID_TAREA_38 IDTAREA38,t1.TIPO_TAREA_38 TIPOTAREA38,t1.DESC_ES_38 DESCES38,t1.DESC_EU_38 DESCEU38,t2.ID_TIPO_DOC_36 MTIPDOCIDTIPODOC36,t2.DESC_ES_36 MTIPDOCDESCES36,t2.DESC_EU_36 MTIPDOCDESCEU36,t2.ROLEID_36 MTIPDOCROLEID36,t2.ORIGEN_36 MTIPDOCORIGEN36,t2.F_ALTA_36 MTIPDOCFALTA36,t2.USU_ALTA_36 MTIPDOCUSUALTA36,t2.F_MODIF_36 MTIPDOCFMODIF36,t2.USU_MODIF_36 MTIPDOCUSUMODIF36,t3.ID_TRAMITE_37 MATRAIDTRAMITE37,t3.DESC_ES_37 MATRADESCES37,t3.DESC_EU_37 MATRADESCEU37 ");
		query.append("FROM MAESTRO_TAREAS t1 ,MAESTRO_TIPOS_DOC t2 ,MAESTRO_TRAMITES t3 ");

		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(maestrotareas, startsWith);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TIPO_DOC_38= t2.ID_TIPO_DOC_36(+) AND t1.ID_TRAMITE_38= t3.ID_TRAMITE_37(+) ");
		where.append(mapaWhere.get("query"));
		query.append(where);

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

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

		return (List<MaestroTareas>) this.jdbcTemplate.query(query.toString(), this.rwMap, params.toArray());
	}

	/*
	 * OPERACIONES RUP_TABLE
	 */

	/**
	 * Counts rows in the MaestroTareas table.
	 *
	 * @param maestrotareas MaestroTareas
	 * @return Long
	 */
	@Transactional(readOnly = true)
	public Long findAllCount(MaestroTareas maestrotareas) {
		StringBuilder query = new StringBuilder(
				"SELECT COUNT(1) FROM MAESTRO_TAREAS t1 , MAESTRO_TIPOS_DOC t2 , MAESTRO_TRAMITES t3 ");

		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereMap(maestrotareas);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TIPO_DOC_38= t2.ID_TIPO_DOC_36(+) AND t1.ID_TRAMITE_38= t3.ID_TRAMITE_37(+) ");
		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 MaestroTareas table using like.
	 *
	 * @param maestrotareas MaestroTareas
	 * @param startsWith    Boolean
	 * @return Long
	 */
	@Transactional(readOnly = true)
	public Long findAllLikeCount(MaestroTareas maestrotareas, Boolean startsWith) {
		StringBuilder query = new StringBuilder(
				"SELECT COUNT(1) FROM MAESTRO_TAREAS t1 ,MAESTRO_TIPOS_DOC t2 ,MAESTRO_TRAMITES t3 ");

		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(maestrotareas, startsWith);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TIPO_DOC_38= t2.ID_TIPO_DOC_36(+) AND t1.ID_TRAMITE_38= t3.ID_TRAMITE_37(+) ");
		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 MaestroTareas selected for rup_table
	 *
	 * @param maestrotareas   MaestroTareas
	 * @param tableRequestDto TableRequestDto
	 * @param startsWith      Boolean
	 * @return List<TableRowDto<MaestroTareas>>
	 */
	@Override
	public List<TableRowDto<MaestroTareas>> reorderSelection(MaestroTareas maestrotareas,
			TableRequestDto tableRequestDto, Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_TAREA_38 IDTAREA38,t1.TIPO_TAREA_38 TIPOTAREA38,t1.DESC_ES_38 DESCES38,t1.DESC_EU_38 DESCEU38,t2.ID_TIPO_DOC_36 MTIPDOCIDTIPODOC36,t2.DESC_ES_36 MTIPDOCDESCES36,t2.DESC_EU_36 MTIPDOCDESCEU36,t2.ROLEID_36 MTIPDOCROLEID36,t2.ORIGEN_36 MTIPDOCORIGEN36,t2.F_ALTA_36 MTIPDOCFALTA36,t2.USU_ALTA_36 MTIPDOCUSUALTA36,t2.F_MODIF_36 MTIPDOCFMODIF36,t2.USU_MODIF_36 MTIPDOCUSUMODIF36,t3.ID_TRAMITE_37 MATRAIDTRAMITE37,t3.DESC_ES_37 MATRADESCES37,t3.DESC_EU_37 MATRADESCEU37 ");
		// FROM
		query.append("FROM MAESTRO_TAREAS t1 ,MAESTRO_TIPOS_DOC t2 ,MAESTRO_TRAMITES t3 ");
		// FILTRADO
		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(maestrotareas, startsWith);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TIPO_DOC_38= t2.ID_TIPO_DOC_36(+) AND t1.ID_TRAMITE_38= t3.ID_TRAMITE_37(+) ");
		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, MaestroTareas.class,
				filterParamList, "IDTAREA38");

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

	/**
	 * Search method for rup_table
	 *
	 * @param filterParams    MaestroTareas
	 * @param searchParams    MaestroTareas
	 * @param tableRequestDto TableRequestDto
	 * @param startsWith      Boolean
	 * @return List<TableRowDto<MaestroTareas>>
	 */
	@Override
	public List<TableRowDto<MaestroTareas>> search(MaestroTareas filterParams, MaestroTareas searchParams,
			TableRequestDto tableRequestDto, Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_TAREA_38 IDTAREA38,t1.TIPO_TAREA_38 TIPOTAREA38,t1.DESC_ES_38 DESCES38,t1.DESC_EU_38 DESCEU38,t2.ID_TIPO_DOC_36 MTIPDOCIDTIPODOC36,t2.DESC_ES_36 MTIPDOCDESCES36,t2.DESC_EU_36 MTIPDOCDESCEU36,t2.ROLEID_36 MTIPDOCROLEID36,t2.ORIGEN_36 MTIPDOCORIGEN36,t2.F_ALTA_36 MTIPDOCFALTA36,t2.USU_ALTA_36 MTIPDOCUSUALTA36,t2.F_MODIF_36 MTIPDOCFMODIF36,t2.USU_MODIF_36 MTIPDOCUSUMODIF36,t3.ID_TRAMITE_37 MATRAIDTRAMITE37,t3.DESC_ES_37 MATRADESCES37,t3.DESC_EU_37 MATRADESCEU37 ");
		// FROM
		query.append("FROM MAESTRO_TAREAS t1 ,MAESTRO_TIPOS_DOC t2 ,MAESTRO_TRAMITES t3 ");
		// TABLAS_ALIAS
		List<String> from_alias = new ArrayList<String>();
		from_alias.add(" t1 ");
		from_alias.add(" t2 ");
		from_alias.add(" t3 ");

		// FILTRADO
		Map<String, ?> mapaWhereFilter = this.getWhereLikeMap(filterParams, startsWith);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TIPO_DOC_38= t2.ID_TIPO_DOC_36(+) AND t1.ID_TRAMITE_38= t3.ID_TRAMITE_37(+) ");
		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, MaestroTareas.class,
				filterParamList, searchSQL, searchParamList, from_alias, "IDTAREA38");

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

	/**
	 * Remove multiple method for rup_table
	 *
	 * @param tableRequestDto TableRequestDto
	 */
	@Override
	public void removeMultiple(TableRequestDto tableRequestDto) {
		StringBuilder sbRemoveMultipleSQL = TableManager.getRemoveMultipleQuery(tableRequestDto, MaestroTareas.class,
				"MAESTRO_TAREAS", new String[] { "IDTAREA38" });

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

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

	/**
	 * Filter in the hierarchical MaestroTareas table.
	 *
	 * @param filterMaestroTareas MaestroTareas
	 * @param tableRequestDto     TableRequestDto
	 * @return List<JerarquiaDto<MaestroTareas>>
	 */
	@Override
	public List<JerarquiaDto<MaestroTareas>> findAllLikeJerarquia(MaestroTareas filterMaestroTareas,
			TableRequestDto tableRequestDto) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_TAREA_38 IDTAREA38,t1.TIPO_TAREA_38 TIPOTAREA38,t1.DESC_ES_38 DESCES38,t1.DESC_EU_38 DESCEU38,t2.ID_TIPO_DOC_36 MTIPDOCIDTIPODOC36,t2.DESC_ES_36 MTIPDOCDESCES36,t2.DESC_EU_36 MTIPDOCDESCEU36,t2.ROLEID_36 MTIPDOCROLEID36,t2.ORIGEN_36 MTIPDOCORIGEN36,t2.F_ALTA_36 MTIPDOCFALTA36,t2.USU_ALTA_36 MTIPDOCUSUALTA36,t2.F_MODIF_36 MTIPDOCFMODIF36,t2.USU_MODIF_36 MTIPDOCUSUMODIF36,t3.ID_TRAMITE_37 MATRAIDTRAMITE37,t3.DESC_ES_37 MATRADESCES37,t3.DESC_EU_37 MATRADESCEU37 ");
		// FROM
		// StringBuilder from = new StringBuilder("FROM MAESTRO_TAREAS t1
		// ,MAESTRO_TIPOS_DOC t2 ,MAESTRO_TRAMITES t3 ");
		List<String> from = new ArrayList<String>();
		from.add("MAESTRO_TAREAS");
		from.add("MAESTRO_TIPOS_DOC");
		from.add("MAESTRO_TRAMITES");
		// TABLAS_ALIAS
		List<String> from_alias = new ArrayList<String>();
		from_alias.add(" t1 ");
		from_alias.add(" t2 ");
		from_alias.add(" t3 ");

		// JOINS TABLAS
		/*
		 * Ejemplo de como indicar joins entre las tablas de la query
		 */
		/*
		 * StringBuilder joins = new StringBuilder("");
		 * joins.append("AND T1.ID=T2.ID_T1");
		 */

		// CONDICIONES (negocio)
		/*
		 * Ejemplo de como incluir condiciones de negocio en la consulta de la jerarquía
		 */
		/*
		 * StringBuilder businessFilters = new StringBuilder(); List<Object>
		 * businessParams = new ArrayList<Object>();
		 * businessFilters.append("   AND t1.EJIE = ?  "); businessParams.add("1");
		 */

		// FILTRO
		Map<String, ?> mapaWhere = this.getWhereLikeMap(filterMaestroTareas, false);

		// JERARQUIA
		// Especificar la columna padre correspondiente en lugar de la generada por
		// defecto (ID_PADRE)
		query = TableManagerJerarquia.getQuery(tableRequestDto, query, mapaWhere, "IDTAREA38", "ID_PADRE", "NOMBRE",
				from, from_alias);

		/*
		 * Ejemplo de llamada en caso de indicar joins entre tablas y condiciones de
		 * negocio
		 */
//		query = TableManagerJerarquia.getQuery(tableRequestDto, query, mapaWhere, "ID", "ID_PADRE", "NOMBRE", from, from_alias, joins, businessFilters, businessParams);

		// PAGINACION
		if (tableRequestDto != null) {
			query = TableManagerJerarquia.getPaginationQuery(tableRequestDto, query,
					MaestroTareasDaoImpl.ORDER_BY_WHITE_LIST);
		}

		List<?> params = (List<?>) mapaWhere.get("params");
		return this.jdbcTemplate.query(query.toString(), this.rwMapJerarquia, params.toArray());
	}

	/**
	 * Count rows in hierarchy
	 *
	 * @param filterMaestroTareas MaestroTareas
	 * @param tableRequestDto     TableRequestDto
	 * @return Long
	 */
	@Override
	public Long findAllLikeCountJerarquia(MaestroTareas filterMaestroTareas, TableRequestDto tableRequestDto) {
		// FROM
		// StringBuilder from = new StringBuilder("FROM MAESTRO_TAREAS t1
		// ,MAESTRO_TIPOS_DOC t2 ,MAESTRO_TRAMITES t3 ");
		List<String> from = new ArrayList<String>();
		from.add("MAESTRO_TAREAS");
		from.add("MAESTRO_TIPOS_DOC");
		from.add("MAESTRO_TRAMITES");

		// TABLAS_ALIAS
		List<String> from_alias = new ArrayList<String>();
		from_alias.add(" t1 ");
		from_alias.add(" t2 ");
		from_alias.add(" t3 ");

		// JOINS TABLAS
		/*
		 * Ejemplo de como indicar joins entre las tablas de la query
		 */
		/*
		 * StringBuilder joins = new StringBuilder("");
		 * joins.append("AND T1.ID=T2.ID_T1");
		 */

		// CONDICIONES (negocio)
		/*
		 * Ejemplo de como incluir condiciones de negocio en la consulta de la jerarquía
		 */
		/*
		 * StringBuilder businessFilters = new StringBuilder(); List<Object>
		 * businessParams = new ArrayList<Object>();
		 * businessFilters.append("   AND t1.EJIE = ?  "); businessParams.add("1");
		 */

		// FILTRO
		Map<String, ?> mapaWhere = this.getWhereLikeMap(filterMaestroTareas, false);

		// JERARQUIA
		// Especificar la columna padre correspondiente en lugar de la generada por
		// defecto (ID_PADRE)
		StringBuilder query = TableManagerJerarquia.getQueryCount(tableRequestDto, mapaWhere, "IDTAREA38", "ID_PADRE",
				from, from_alias);

		/*
		 * Ejemplo de llamada en caso de indicar joins entre tablas y condiciones de
		 * negocio
		 */
//		StringBuilder query = TableManagerJerarquia.getQueryCount(tableRequestDto, mapaWhere, "ID", "ID_PADRE", from, from_alias, joins, businessFilters, businessParams);

		List<?> params = (List<?>) mapaWhere.get("params");
		return this.jdbcTemplate.queryForObject(query.toString(), params.toArray(), Long.class);
	}

	/**
	 * Find dependent hierarchical rows
	 *
	 * @param filterMaestroTareas MaestroTareas
	 * @param tableRequestDto     TableRequestDto
	 * @return List<TableRowDto<MaestroTareas>>
	 */
	@Override
	public List<TableRowDto<MaestroTareas>> findAllChild(MaestroTareas filterMaestroTareas,
			TableRequestDto tableRequestDto) {

		// FROM
		// StringBuilder from = new StringBuilder("FROM MAESTRO_TAREAS t1
		// ,MAESTRO_TIPOS_DOC t2 ,MAESTRO_TRAMITES t3 ");
		List<String> from = new ArrayList<String>();
		from.add("MAESTRO_TAREAS");
		from.add("MAESTRO_TIPOS_DOC");
		from.add("MAESTRO_TRAMITES");

		// TABLAS_ALIAS
		List<String> from_alias = new ArrayList<String>();
		from_alias.add(" t1 ");
		from_alias.add(" t2 ");
		from_alias.add(" t3 ");

		// JOINS TABLAS
		/*
		 * Ejemplo de como indicar joins entre las tablas de la query
		 */
		/*
		 * StringBuilder joins = new StringBuilder("");
		 * joins.append("AND T1.ID=T2.ID_T1");
		 */

		// CONDICIONES (negocio)
		/*
		 * Ejemplo de como incluir condiciones de negocio en la consulta de la jerarquía
		 */
		/*
		 * StringBuilder businessFilters = new StringBuilder(); List<Object>
		 * businessParams = new ArrayList<Object>();
		 * businessFilters.append("   AND t1.EJIE = ?  "); businessParams.add("1");
		 */

		// FILTRO
		Map<String, ?> mapaWhere = this.getWhereLikeMap(filterMaestroTareas, false);

		// MULTISELECCION
		// Especificar la columna padre correspondiente en lugar de la generada por
		// defecto (ID_PADRE)
		StringBuilder query = TableManagerJerarquia.getQueryChildren(tableRequestDto, mapaWhere, "IDTAREA38",
				"ID_PADRE", from, from_alias);

		/*
		 * Ejemplo de llamada en caso de indicar joins entre tablas y condiciones de
		 * negocio
		 */
//		StringBuilder query = TableManagerJerarquia.getQueryChildren(tableRequestDto, mapaWhere, "ID", "ID_PADRE", from, from_alias, joins, businessFilters, businessParams);

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

		return this.jdbcTemplate.query(query.toString(),
				new RowNumResultSetExtractor<MaestroTareas>(this.rwMapPK, "IDTAREA38"), params.toArray());
	}

	/*
	 * MÉTODOS PRIVADOS
	 */

	/**
	 * Returns a map with the needed value to create the conditions to filter by the
	 * MaestroTareas entity
	 *
	 * @param maestrotareas MaestroTareas 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.
	 */
	// CHECKSTYLE:OFF CyclomaticComplexity - Generación de código de UDA
	private Map<String, ?> getWhereMap(MaestroTareas maestrotareas) {

		StringBuilder where = new StringBuilder(MaestroTareasDaoImpl.STRING_BUILDER_INIT);
		List<Object> params = new ArrayList<Object>();

		if (maestrotareas != null && maestrotareas.getIdTarea38() != null) {
			where.append(" AND t1.ID_TAREA_38 = ?");
			params.add(maestrotareas.getIdTarea38());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getIdTipoDoc36() != null) {
			where.append(" AND t2.ID_TIPO_DOC_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getIdTipoDoc36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getDescEs36() != null) {
			where.append(" AND t2.DESC_ES_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getDescEs36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getDescEu36() != null) {
			where.append(" AND t2.DESC_EU_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getDescEu36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getRoleid36() != null) {
			where.append(" AND t2.ROLEID_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getRoleid36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getOrigen36() != null) {
			where.append(" AND t2.ORIGEN_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getOrigen36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getfAlta36() != null) {
			where.append(" AND t2.F_ALTA_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getfAlta36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getUsuAlta36() != null) {
			where.append(" AND t2.USU_ALTA_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getUsuAlta36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getfModif36() != null) {
			where.append(" AND t2.F_MODIF_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getfModif36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getUsuModif36() != null) {
			where.append(" AND t2.USU_MODIF_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getUsuModif36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTramites() != null
				&& maestrotareas.getMaestroTramites().getIdTramite37() != null) {
			where.append(" AND t3.ID_TRAMITE_37 = ?");
			params.add(maestrotareas.getMaestroTramites().getIdTramite37());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTramites() != null
				&& maestrotareas.getMaestroTramites().getDescEs37() != null) {
			where.append(" AND t3.DESC_ES_37 = ?");
			params.add(maestrotareas.getMaestroTramites().getDescEs37());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTramites() != null
				&& maestrotareas.getMaestroTramites().getDescEu37() != null) {
			where.append(" AND t3.DESC_EU_37 = ?");
			params.add(maestrotareas.getMaestroTramites().getDescEu37());
		}
		if (maestrotareas != null && maestrotareas.getTipoTarea38() != null) {
			where.append(" AND t1.TIPO_TAREA_38 = ?");
			params.add(maestrotareas.getTipoTarea38());
		}
		if (maestrotareas != null && maestrotareas.getDescEs38() != null) {
			where.append(" AND t1.DESC_ES_38 = ?");
			params.add(maestrotareas.getDescEs38());
		}
		if (maestrotareas != null && maestrotareas.getDescEu38() != null) {
			where.append(" AND t1.DESC_EU_38 = ?");
			params.add(maestrotareas.getDescEu38());
		}

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

		return mapWhere;
	}
	// CHECKSTYLE:ON CyclomaticComplexity - Generación de código de UDA

	/**
	 * Returns a map with the needed value to create the conditions to filter by the
	 * MaestroTareas entity
	 *
	 * @param maestrotareas MaestroTareas 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.
	 */
	// CHECKSTYLE:OFF CyclomaticComplexity - Generación de código de UDA
	private Map<String, Object> getWhereLikeMap(MaestroTareas maestrotareas, Boolean startsWith) {

		StringBuilder where = new StringBuilder(MaestroTareasDaoImpl.STRING_BUILDER_INIT);
		List<Object> params = new ArrayList<Object>();

		if (maestrotareas != null && maestrotareas.getIdTarea38() != null) {
			where.append(" AND t1.ID_TAREA_38 = ?");
			params.add(maestrotareas.getIdTarea38());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getIdTipoDoc36() != null) {
			where.append(" AND t2.ID_TIPO_DOC_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getIdTipoDoc36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getDescEs36() != null) {
			where.append(" AND UPPER(t2.DESC_ES_36) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(maestrotareas.getMaestroTiposDoc().getDescEs36().toUpperCase() + "%");
			} else {
				params.add("%" + maestrotareas.getMaestroTiposDoc().getDescEs36().toUpperCase() + "%");
			}
			where.append(" AND t2.DESC_ES_36 IS NOT NULL");
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getDescEu36() != null) {
			where.append(" AND UPPER(t2.DESC_EU_36) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(maestrotareas.getMaestroTiposDoc().getDescEu36().toUpperCase() + "%");
			} else {
				params.add("%" + maestrotareas.getMaestroTiposDoc().getDescEu36().toUpperCase() + "%");
			}
			where.append(" AND t2.DESC_EU_36 IS NOT NULL");
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getRoleid36() != null) {
			where.append(" AND UPPER(t2.ROLEID_36) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(maestrotareas.getMaestroTiposDoc().getRoleid36().toUpperCase() + "%");
			} else {
				params.add("%" + maestrotareas.getMaestroTiposDoc().getRoleid36().toUpperCase() + "%");
			}
			where.append(" AND t2.ROLEID_36 IS NOT NULL");
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getOrigen36() != null) {
			where.append(" AND UPPER(t2.ORIGEN_36) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(maestrotareas.getMaestroTiposDoc().getOrigen36().toUpperCase() + "%");
			} else {
				params.add("%" + maestrotareas.getMaestroTiposDoc().getOrigen36().toUpperCase() + "%");
			}
			where.append(" AND t2.ORIGEN_36 IS NOT NULL");
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getfAlta36() != null) {
			where.append(" AND t2.F_ALTA_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getfAlta36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getUsuAlta36() != null) {
			where.append(" AND UPPER(t2.USU_ALTA_36) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(maestrotareas.getMaestroTiposDoc().getUsuAlta36().toUpperCase() + "%");
			} else {
				params.add("%" + maestrotareas.getMaestroTiposDoc().getUsuAlta36().toUpperCase() + "%");
			}
			where.append(" AND t2.USU_ALTA_36 IS NOT NULL");
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getfModif36() != null) {
			where.append(" AND t2.F_MODIF_36 = ?");
			params.add(maestrotareas.getMaestroTiposDoc().getfModif36());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTiposDoc() != null
				&& maestrotareas.getMaestroTiposDoc().getUsuModif36() != null) {
			where.append(" AND UPPER(t2.USU_MODIF_36) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(maestrotareas.getMaestroTiposDoc().getUsuModif36().toUpperCase() + "%");
			} else {
				params.add("%" + maestrotareas.getMaestroTiposDoc().getUsuModif36().toUpperCase() + "%");
			}
			where.append(" AND t2.USU_MODIF_36 IS NOT NULL");
		}
		if (maestrotareas != null && maestrotareas.getMaestroTramites() != null
				&& maestrotareas.getMaestroTramites().getIdTramite37() != null) {
			where.append(" AND t3.ID_TRAMITE_37 = ?");
			params.add(maestrotareas.getMaestroTramites().getIdTramite37());
		}
		if (maestrotareas != null && maestrotareas.getMaestroTramites() != null
				&& maestrotareas.getMaestroTramites().getDescEs37() != null) {
			where.append(" AND UPPER(t3.DESC_ES_37) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(maestrotareas.getMaestroTramites().getDescEs37().toUpperCase() + "%");
			} else {
				params.add("%" + maestrotareas.getMaestroTramites().getDescEs37().toUpperCase() + "%");
			}
			where.append(" AND t3.DESC_ES_37 IS NOT NULL");
		}
		if (maestrotareas != null && maestrotareas.getMaestroTramites() != null
				&& maestrotareas.getMaestroTramites().getDescEu37() != null) {
			where.append(" AND UPPER(t3.DESC_EU_37) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(maestrotareas.getMaestroTramites().getDescEu37().toUpperCase() + "%");
			} else {
				params.add("%" + maestrotareas.getMaestroTramites().getDescEu37().toUpperCase() + "%");
			}
			where.append(" AND t3.DESC_EU_37 IS NOT NULL");
		}
		if (maestrotareas != null && maestrotareas.getTipoTarea38() != null) {
			where.append(" AND UPPER(t1.TIPO_TAREA_38) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(maestrotareas.getTipoTarea38().toUpperCase() + "%");
			} else {
				params.add("%" + maestrotareas.getTipoTarea38().toUpperCase() + "%");
			}
			where.append(" AND t1.TIPO_TAREA_38 IS NOT NULL");
		}
		if (maestrotareas != null && maestrotareas.getDescEs38() != null) {
			where.append(" AND UPPER(t1.DESC_ES_38) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(maestrotareas.getDescEs38().toUpperCase() + "%");
			} else {
				params.add("%" + maestrotareas.getDescEs38().toUpperCase() + "%");
			}
			where.append(" AND t1.DESC_ES_38 IS NOT NULL");
		}
		if (maestrotareas != null && maestrotareas.getDescEu38() != null) {
			where.append(" AND UPPER(t1.DESC_EU_38) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(maestrotareas.getDescEu38().toUpperCase() + "%");
			} else {
				params.add("%" + maestrotareas.getDescEu38().toUpperCase() + "%");
			}
			where.append(" AND t1.DESC_EU_38 IS NOT NULL");
		}

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

		return mapWhere;
	}
	// CHECKSTYLE:ON CyclomaticComplexity - Generación de código de UDA

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