package com.utopiaindustries.dao.ctp;

import com.utopiaindustries.model.ctp.InventoryAccount;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

public class InventoryAccountRowMapper implements RowMapper<InventoryAccount> {
	public InventoryAccount mapRow( ResultSet rs, int rowNum ) throws SQLException {
		InventoryAccount inventoryAccount = new InventoryAccount();
		inventoryAccount.setId( rs.getLong( "id" ) );
		inventoryAccount.setTitle( rs.getString( "title" ) );
		inventoryAccount.setParentEntityType( rs.getString( "parent_entity_type" ) );
		inventoryAccount.setParentEntityId( rs.getLong( "parent_entity_id" ) );
		inventoryAccount.setActive( rs.getBoolean( "active" ) );
		inventoryAccount.setCreatedBy( rs.getString( "created_by" ) );
		if ( rs.getTimestamp( "created_at" ) != null ) {
			inventoryAccount.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
		}
		inventoryAccount.setLocationSiteId( rs.getInt( "location_site_id" ) );
		inventoryAccount.setNotes( rs.getString( "notes" ) );
		inventoryAccount.setArticleName( rs.getString( "article_name" ) );
		inventoryAccount.setShiftMinutes( rs.getLong( "shift_minutes" ) );
		inventoryAccount.setTotalMachines( rs.getLong( "total_machines" ) );
		inventoryAccount.setEfficiency( rs.getBigDecimal( "efficiency" ) );
		inventoryAccount.setSam( rs.getBigDecimal( "sam" ) );
		inventoryAccount.setIsPackaging( rs.getBoolean("is_packaging" ) );
		return inventoryAccount;
	}
}