package cn.com.qmth.stmms.admin.vo;

import java.util.LinkedList;
import java.util.List;

import cn.com.qmth.stmms.biz.exam.model.MarkLevel;
import cn.com.qmth.stmms.biz.exam.model.MarkStep;

public class MarkStepVO {

    private int number;

    private double totalScore;

    private double max;

    private double min;

    private double defaultScore;

    private double interval;

    private double[] scoreList;

    private MarkLevelVO[] levelList;

    public static MarkStepVO parse(MarkStep step) {
        MarkStepVO vo = new MarkStepVO();
        if (step != null) {
            vo.setNumber(step.getNumber());
            vo.setTotalScore(step.getTotalScore() != null ? step.getTotalScore() : 0);
            vo.setDefaultScore(step.getDefaultScore() != null ? step.getDefaultScore() : 0);
            vo.setMax(step.getMax() != null ? step.getMax() : 0);
            vo.setMin(step.getMin() != null ? step.getMin() : 0);
            vo.setInterval(step.getInterval() != null ? step.getInterval() : 0);
            vo.setScoreList(step.getScoreArray());
            if (step.getMarkLevelList() != null && step.getMarkLevelList().size() > 0) {
                List<MarkLevelVO> list = new LinkedList<MarkLevelVO>();
                for (MarkLevel level : step.getMarkLevelList()) {
                    list.add(MarkLevelVO.parse(level));
                }
                vo.setLevelList(new MarkLevelVO[list.size()]);
                list.toArray(vo.getLevelList());
            }
        }
        return vo;
    }

    public MarkStep transform() {
        MarkStep step = new MarkStep();
        step.setNumber(number);
        step.setTotalScore(totalScore);
        step.setDefaultScore(defaultScore);
        step.setMax(max);
        step.setMin(min);
        step.setInterval(interval);
        step.setScoreList(scoreList);
        List<MarkLevel> list = new LinkedList<MarkLevel>();
        if (levelList != null) {
            for (MarkLevelVO level : levelList) {
                list.add(level.transform());
            }
        }
        step.setMarkLevelList(list);
        return step;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public double getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(double totalScore) {
        this.totalScore = totalScore;
    }

    public double getMax() {
        return max;
    }

    public void setMax(double max) {
        this.max = max;
    }

    public double getMin() {
        return min;
    }

    public void setMin(double min) {
        this.min = min;
    }

    public double getDefaultScore() {
        return defaultScore;
    }

    public void setDefaultScore(double defaultScore) {
        this.defaultScore = defaultScore;
    }

    public double[] getScoreList() {
        return scoreList;
    }

    public void setScoreList(double[] scoreList) {
        this.scoreList = scoreList;
    }

    public MarkLevelVO[] getLevelList() {
        return levelList;
    }

    public void setLevelList(MarkLevelVO[] levelList) {
        this.levelList = levelList;
    }

    public double getInterval() {
        return interval;
    }

    public void setInterval(double interval) {
        this.interval = interval;
    }
}
