package com.utopiaindustries.dao.ctp;

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

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

public class InventoryTransactionRowMapper implements RowMapper<InventoryTransaction> {
	public InventoryTransaction mapRow( ResultSet rs, int rowNum ) throws SQLException {
		InventoryTransaction inventoryTransaction = new InventoryTransaction();
		inventoryTransaction.setId( rs.getLong( "id" ) );
		if ( rs.getTimestamp( "transaction_datetime" ) != null ) {
			inventoryTransaction.setTransactionDateTime( rs.getTimestamp( "transaction_datetime" ).toLocalDateTime() );
		}
		inventoryTransaction.setGeneratedBy( rs.getString( "generated_by" ) );
		inventoryTransaction.setNotes( rs.getString( "notes" ) );
		return inventoryTransaction;
	}
}