package com.ejie.m62fb.dao.registroVPP;

import com.ejie.m62fb.dao.SQLGenericas;
import com.ejie.m62fb.utils.constants.BDConstantes;

public class ElementoAdDaoSql {

	public static final int STRING_BUILDER_INIT = 4096;

	public static final String TABLA = BDConstantes.ELEMENTO_AD;
	public static final String VISTA = BDConstantes.VIS_ELEMENTO_AD;

	public static final String ALIAS = " ELEM";

	public static final String ALIAS_DIR = "";

	private static final String SQL_SELECT = "SELECT" //
			+ ElementoAdDaoSql.ALIAS
			+ ".ID_ELEM_REG IDELEMREG, "
			+ ElementoAdDaoSql.ALIAS
			+ ".ID_ELEMENTO IDELEMENTO, "
			+ ElementoAdDaoSql.ALIAS
			+ ".COD_ELEMENTO CODELEMENTO, "
			+ ElementoAdDaoSql.ALIAS
			+ ".ID_EMPLAZAMIENTO IDEMPLAZAMIENTO, "
			+ ElementoAdDaoSql.ALIAS
			+ ".COD_VINCUL_ELEM CODVINCULELEM, "
			+ ElementoAdDaoSql.ALIAS
			+ ".NUM_EXPEDIENTE NUMEXPEDIENTE, "
			+ ElementoAdDaoSql.ALIAS
			+ ".ID_ALOJ_REG IDALOJREG, "
			+ ElementoAdDaoSql.ALIAS
			+ ".COD_TIPO_ELEM CODTIPOELEM, "
			+ ElementoAdDaoSql.ALIAS
			+ ".SUP_UTIL_ELEM SUPUTILELEM, "
			+ ElementoAdDaoSql.ALIAS
			+ ".NUM_FIJO_IBI_ELEM NUMFIJOIBIELEM, "
			+ ElementoAdDaoSql.ALIAS
			+ ".FEC_INI_GESTION FECINIGESTION, "
			+ ElementoAdDaoSql.ALIAS
			+ ".FEC_FIN_GESTION FECFINGESTION, "
			+ ElementoAdDaoSql.ALIAS
			+ ".NUM_ORGANO_GESTOR NUMORGANOGESTOR, "
			+ ElementoAdDaoSql.ALIAS + ".FEC_ENV_ORG_GESTOR FECENVORGGESTOR "
			// Direccion
			+ SQLGenericas.getSqlCamposDireccionCompleta(ALIAS, ALIAS_DIR)
			// AbstractM62FBModel
			+ SQLGenericas.getSqlCamposAbstractClass(ALIAS);

	private static final String SQL_FROM = " FROM " + VISTA + ALIAS;

	private static final String SQL_WHERE = " WHERE " + ALIAS
			+ ".ID_ELEM_REG = ?";

	public static final String SQL_FIND = SQL_SELECT + SQL_FROM + SQL_WHERE;

	private static final String SQL_WHERE_BY_ALOJ_AND_TIPO = " WHERE ID_ALOJ_REG = ?"
			+ " AND COD_TIPO_ELEM = ? ";

	public static final String SQL_FIND_BY_ALOJ_AND_TIPO = SQL_SELECT
			+ SQL_FROM + SQL_WHERE_BY_ALOJ_AND_TIPO;

	public static final String SQL_DESVINCULAR = "UPDATE " + TABLA
			+ " SET ID_ALOJ_REG = NULL "
			+ SQLGenericas.UPDATE_ABSTRACT_CLASS_SQL
			+ SQL_WHERE_BY_ALOJ_AND_TIPO;

	public static final String SQL_VINCULAR = "UPDATE " + TABLA
			+ " SET ID_ALOJ_REG = ? " + SQLGenericas.UPDATE_ABSTRACT_CLASS_SQL
			+ " WHERE ID_ELEM_REG = ?";

}