package com.utopiaindustries.dao.ctp;

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

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

public class JobCardRowMapper implements RowMapper<JobCard> {
	public JobCard mapRow( ResultSet rs, int rowNum ) throws SQLException {
		JobCard jobCard = new JobCard();
		jobCard.setId( rs.getLong( "id" ) );
		jobCard.setCode( rs.getString("code" ));
		jobCard.setJobOrderId( rs.getLong( "job_order_id" ) );
		if ( rs.getTimestamp( "created_at" ) != null ) {
			jobCard.setCreatedAt( rs.getTimestamp( "created_at" ).toLocalDateTime() );
		}
		jobCard.setCreatedBy( rs.getString( "created_by" ) );
		jobCard.setStatus( rs.getString("status" ));
		jobCard.setInventoryStatus( rs.getString("inventory_status"));
		jobCard.setCustomer( rs.getString("customer") );
		jobCard.setLotNumber( rs.getString("lot_number") );
		jobCard.setPurchaseOrderId( rs.getString("purchase_order_id") );
		jobCard.setLocationSiteId( rs.getLong("location_site_id" ) );
		jobCard.setDescription( rs.getString("description" ) );
		jobCard.setPoQuantity( rs.getInt("poQuantity" ) );
		jobCard.setArticleName( rs.getString("articleName" ) );
		return jobCard;
	}
}