/*******************************************************************************
 * This file is part of Educatio.
 *
 *     Educatio is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     Educatio is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with Educatio.  If not, see <http://www.gnu.org/licenses/>.
 *     
 *     Authors:
 *           Filipe Marinho de Brito - filipe.marinho.brito@gmail.com
 *           Rodrigo de Souza Ataides - rodrigoataides@gmail.com
 *******************************************************************************/
package br.com.core.jdbc.dao.publico;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.LinkedHashMap;
import java.util.Map;

import org.springframework.jdbc.core.RowMapper;

import com.blogspot.nurkiewicz.jdbcrepository.RowUnmapper;

/**
 * This class is generated by Spring Data Jdbc code generator.
 *
 * @author Spring Data Jdbc Code Generator
 */
public class NoticiaTableInfo
{

	private static String TABLE_NAME = "PUBLIC.NOTICIA";

	private static String TABLE_ALIAS = "not";

	public static String getTableName()
	{
		return TABLE_NAME;
	}

	public static String getTableAlias()
	{
		return TABLE_NAME + " as " + TABLE_ALIAS;
	}

	public enum COLUMNS
	{
		ID("id"),
		VERSION("version"),
		TIPO_NOTICIA("tipo_noticia"),
		TITULO("titulo"),
		NOTICIA("noticia"),
		DATA_POSTAGEM("data_postagem"),
		ARQUIVO("arquivo"),
		ATIVO("ativo"),
		;

		private String columnName;

		private COLUMNS (String columnName)
		{
			this.columnName = columnName;
		}

		public void setColumnName (String columnName)
		{
			this.columnName = columnName;
		}

		public String getColumnName ()
		{
			return this.columnName;
		}

		public String getColumnAlias ()
		{
			return TABLE_ALIAS + "." + this.columnName;
		}

		public String getColumnAliasAsName ()
		{
			return TABLE_ALIAS  + "." + this.columnName + " as " + TABLE_ALIAS + "_" + this.columnName;
		}

		public String getColumnAliasName ()
		{
			return TABLE_ALIAS + "_" + this.columnName;
		}

	}

	public NoticiaTableInfo ()
	{

	}

	public static final RowMapper<NoticiaTable> ROW_MAPPER = new NoticiaTableRowMapper ();
	public static final class  NoticiaTableRowMapper implements RowMapper<NoticiaTable>
	{
		public NoticiaTable mapRow(ResultSet rs, int rowNum) throws SQLException 
		{
			NoticiaTable obj = new NoticiaTable();
			obj.setId(rs.getLong(COLUMNS.ID.getColumnName()));
			if(rs.wasNull()){obj.setId(null);}
			obj.setVersion(rs.getInt(COLUMNS.VERSION.getColumnName()));
			if(rs.wasNull()){obj.setVersion(null);}
			obj.setTipoNoticia(rs.getString(COLUMNS.TIPO_NOTICIA.getColumnName()));
			if(rs.wasNull()){obj.setTipoNoticia(null);}
			obj.setTitulo(rs.getString(COLUMNS.TITULO.getColumnName()));
			if(rs.wasNull()){obj.setTitulo(null);}
			obj.setNoticia(rs.getString(COLUMNS.NOTICIA.getColumnName()));
			if(rs.wasNull()){obj.setNoticia(null);}
			obj.setDataPostagem(rs.getTimestamp(COLUMNS.DATA_POSTAGEM.getColumnName()));
			if(rs.wasNull()){obj.setDataPostagem(null);}
			obj.setArquivo(rs.getLong(COLUMNS.ARQUIVO.getColumnName()));
			if(rs.wasNull()){obj.setArquivo(null);}
			obj.setAtivo(rs.getBoolean(COLUMNS.ATIVO.getColumnName()));
			if(rs.wasNull()){obj.setAtivo(null);}
			return obj;
		}
	}

	public static final RowUnmapper<NoticiaTable> ROW_UNMAPPER = new NoticiaTableRowUnmapper ();
	public static final class NoticiaTableRowUnmapper implements RowUnmapper<NoticiaTable>
	{
		public Map<String, Object> mapColumns(NoticiaTable noticiatable)
		{
			Map<String, Object> mapping = new LinkedHashMap<String, Object>();
			mapping.put(COLUMNS.ID.getColumnName(), noticiatable.getId());
			mapping.put(COLUMNS.VERSION.getColumnName(), noticiatable.getVersion());
			mapping.put(COLUMNS.TIPO_NOTICIA.getColumnName(), noticiatable.getTipoNoticia());
			mapping.put(COLUMNS.TITULO.getColumnName(), noticiatable.getTitulo());
			mapping.put(COLUMNS.NOTICIA.getColumnName(), noticiatable.getNoticia());
			if (noticiatable.getDataPostagem() != null)
				mapping.put(COLUMNS.DATA_POSTAGEM.getColumnName(), new Timestamp (noticiatable.getDataPostagem().getTime()));
			else
				mapping.put(COLUMNS.DATA_POSTAGEM.getColumnName(), null);
			mapping.put(COLUMNS.ARQUIVO.getColumnName(), noticiatable.getArquivo());
			mapping.put(COLUMNS.ATIVO.getColumnName(), noticiatable.getAtivo());
			return mapping;
		}
	}

	public static final RowMapper<NoticiaTable> ALIAS_ROW_MAPPER = new NoticiaTableAliasRowMapper ();
	public static final class  NoticiaTableAliasRowMapper implements RowMapper<NoticiaTable>
	{
		public NoticiaTable mapRow(ResultSet rs, int rowNum) throws SQLException 
		{
			NoticiaTable obj = new NoticiaTable();
			obj.setId(rs.getLong(COLUMNS.ID.getColumnAliasName()));
			if(rs.wasNull()){obj.setId(null);}
			obj.setVersion(rs.getInt(COLUMNS.VERSION.getColumnAliasName()));
			if(rs.wasNull()){obj.setVersion(null);}
			obj.setTipoNoticia(rs.getString(COLUMNS.TIPO_NOTICIA.getColumnAliasName()));
			if(rs.wasNull()){obj.setTipoNoticia(null);}
			obj.setTitulo(rs.getString(COLUMNS.TITULO.getColumnAliasName()));
			if(rs.wasNull()){obj.setTitulo(null);}
			obj.setNoticia(rs.getString(COLUMNS.NOTICIA.getColumnAliasName()));
			if(rs.wasNull()){obj.setNoticia(null);}
			obj.setDataPostagem(rs.getTimestamp(COLUMNS.DATA_POSTAGEM.getColumnAliasName()));
			if(rs.wasNull()){obj.setDataPostagem(null);}
			obj.setArquivo(rs.getLong(COLUMNS.ARQUIVO.getColumnAliasName()));
			if(rs.wasNull()){obj.setArquivo(null);}
			obj.setAtivo(rs.getBoolean(COLUMNS.ATIVO.getColumnAliasName()));
			if(rs.wasNull()){obj.setAtivo(null);}
			return obj;
		}
	}

	public static StringBuffer getAllColumnAliases ()
	{
		StringBuffer strBuf = new StringBuffer ();
		int i = COLUMNS.values ().length;
		for (COLUMNS c : COLUMNS.values ())
		{
			strBuf.append (c.getColumnAliasAsName ());
			if (--i > 0)
				strBuf.append (", ");
		}
		return strBuf;
	}

	/* START Do not remove/edit this line. CodeGenerator will preserve any code between start and end tags.*/

	/* END Do not remove/edit this line. CodeGenerator will preserve any between start and end tags.*/

}
