# TimeLimitStatusRowMapper.java

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

    import com.mycim.framework.jdbc.mapper.RowMapper;
    import com.mycim.valueobject.wip.TimelimitStatus;

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

    public class TimeLimitStatusRowMapper implements RowMapper<TimelimitStatus> {

        private static String secsToTime(long secs) {
            StringBuffer time = new StringBuffer();
            long temp = 0;

            if (secs < 0) {
                time.append("-");
                secs = -secs;
            }
            time.append(secs / 3600);
            time.append(":");
            temp = secs % 3600 / 60;

            if (temp < 10) {
                time.append("0");
            }
            time.append(temp);
            time.append(":");
            temp = secs % 3600 % 60;

            if (temp < 10) {
                time.append("0");
            }
            time.append(secs % 3600 % 60);
            return time.toString();
        }

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

            timelimitStatus.setLotRrn(rs.getLong("LOT_RRN"));
            timelimitStatus.setStepSequence(rs.getLong("STEP_SEQUENCE"));

            timelimitStatus.setTimeLimitId(rs.getString("TIMELIMIT_ID"));
            timelimitStatus.setTimeLimitRrn(rs.getLong("TIMELIMIT_RRN"));
            timelimitStatus.setTimeLimitType(rs.getString("TIMELIMIT_TYPE"));

            timelimitStatus.setStartProductRrn(rs.getLong("START_PRODUCT_RRN"));
            timelimitStatus.setStartProcessRrn(rs.getLong("START_PROCESS_RRN"));
            timelimitStatus.setStartProcessVersion(rs.getInt("start_process_version"));
            timelimitStatus.setStartRouteRrn(rs.getLong("START_ROUTE_RRN"));
            timelimitStatus.setStartOperationRrn(rs.getLong("START_OPERATION_RRN"));

            timelimitStatus.setEndProductRrn(rs.getLong("END_PRODUCT_RRN"));
            timelimitStatus.setEndRouteRrn(rs.getLong("END_ROUTE_RRN"));
            timelimitStatus.setEndProcessRrn(rs.getLong("END_PROCESS_RRN"));
            timelimitStatus.setEndOperationRrn(rs.getLong("END_OPERATION_RRN"));

            timelimitStatus.setTimeLimit(secsToTime(rs.getLong("TIMELIMIT")));
            timelimitStatus.setTimeLimitSec(rs.getLong("TIMELIMIT"));

            timelimitStatus.setStartTime(rs.getTimestamp("START_TIME"));
            timelimitStatus.setStatus(rs.getString("STATUS"));
            timelimitStatus.setAdditionalTimeLimit(rs.getLong("ADDITIONAL_TIMELIMIT"));

            timelimitStatus.setTimeType(rs.getString("TIME_TYPE"));
            timelimitStatus.setLimitType(rs.getString("LIMIT_TYPE"));

            timelimitStatus.setStartRouteSeq(rs.getString("START_ROUTE_SEQ"));
            timelimitStatus.setStartOperationSeq(rs.getString("START_OPERATION_SEQ"));

            timelimitStatus.setEndRouteSeq(rs.getString("END_ROUTE_SEQ"));
            timelimitStatus.setEndOperationSeq(rs.getString("END_OPERATION_SEQ"));

            timelimitStatus.setModule(rs.getString("MODULE"));

            return timelimitStatus;
        }

    }