UnitMapper.java

package com.mycim.server.wip.dao.mapper;

import com.mycim.framework.jdbc.mapper.RowMapper;
import com.mycim.framework.utils.lang.StringUtils;
import com.mycim.valueobject.wip.Unit;

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

public class UnitMapper implements RowMapper<Unit> {

    private Unit unit;

    @Override
    public Unit mapRow(ResultSet rs, int rowNum) throws SQLException {
        unit = new Unit();

        unit.setUnitRrn(new Long(rs.getLong("UNIT_RRN")));
        unit.setFacilityRrn(new Long(rs.getLong("FACILITY_RRN")));
        unit.setUnitId(rs.getString("UNIT_ID"));
        unit.setStepSequence(new Long(rs.getLong("STEP_SEQUENCE")));
        unit.setLotRrn(new Long(rs.getLong("LOT_RRN")));
        unit.setLotId(rs.getString("LOT_ID"));
        unit.setLotStepSequence(new Long(rs.getLong("LOT_STEP_SEQUENCE")));
        unit.setCarrierRrn(new Long(rs.getLong("CARRIER_RRN")));
        unit.setPositionInCarrier(new Integer(rs.getInt("POSITION_IN_CARRIER")));
        unit.setUnitStatus(rs.getString("UNIT_STATUS"));
        unit.setProcessStatus(rs.getString("PROCESS_STATUS"));
        unit.setBeforeStatus(rs.getString("BEFORE_STATUS"));
        unit.setDummyFlag(rs.getString("DUMMY_FLAG"));
        unit.setDefectiveFlag(rs.getString("DEFECTIVE_FLAG"));
        unit.setBonusFlag(rs.getString("BONUS_FLAG"));
        unit.setQty(new Double(rs.getDouble("QTY")));
        unit.setProcessStartTime(rs.getDate("PROCESS_START_TIME"));
        unit.setProcessEndTime(rs.getDate("PROCESS_END_TIME"));
        unit.setUnitMapRrn(new Long(rs.getLong("UNIT_MAP_RRN")));
        unit.setRecipeId(rs.getString("RECIPE_ID"));
        unit.setUsageLimit(new Integer(rs.getInt("USAGE_LIMIT")));
        unit.setUsageCount(new Integer(rs.getInt("USAGE_COUNT")));
        unit.setUnitAlias1(rs.getString("unit_alias_1"));
        unit.setUnitAlias2(rs.getString("unit_alias_2"));
        unit.setT7code(rs.getString("T7CODE"));
        unit.setItemId(rs.getString("ITEM_ID"));
        unit.setMarkNumber(rs.getString("MARK_NUMBER"));
        unit.setMarkNumberComment(rs.getString("MARK_NUMBER_COMMENT"));
        unit.setIncomingType(rs.getString("incoming_type"));
        unit.setAutoMonitorUsedFlag(rs.getBoolean("AUTO_MONITOR_USED_FLAG"));
        unit.setCustomerT7Code(rs.getString("CUSTOMER_T7CODE"));
        String materialId = rs.getString("MATERIAL_ID");
        if (StringUtils.isNotBlank(materialId)) {
            unit.setMaterialId(rs.getString("MATERIAL_ID"));
        }
        return unit;

    }

}