package com.utopiaindustries.dao.ctp;

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

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

public class MasterBundleRowMapper implements RowMapper<MasterBundle> {
	public MasterBundle mapRow( ResultSet rs, int rowNum ) throws SQLException {
		MasterBundle masterBundle = new MasterBundle();
		masterBundle.setId( rs.getLong( "id" ) );
		masterBundle.setBarcode( rs.getString( "barcode" ) );
		masterBundle.setCreatedBy( rs.getString( "created_by" ) );
		masterBundle.setItemId( rs.getLong("item_id" ));
		masterBundle.setSku( rs.getString("sku" ) );
		if ( rs.getTimestamp( "created_at" ) != null ) {
			masterBundle.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
		}
		masterBundle.setJobCardId( rs.getLong( "job_card_id" ) );
		masterBundle.setIsReceived( rs.getBoolean("is_received" ));
		return masterBundle;
	}
}