package cn.com.qmth.stmms.biz.mark.model;

import cn.com.qmth.stmms.biz.exam.model.Marker;

import java.io.Serializable;

/**
 * 阅卷轨迹交换类
 *
 * @author luoshi
 */
public class TrackDTO implements Serializable {

    private static final long serialVersionUID = 4336042741848228793L;

    private Integer mainNumber;

    private String subNumber;

    private int number;

    private double score;

    private double positionX;

    private double positionY;

    private int offsetIndex;

    private int offsetX;

    private int offsetY;

    private boolean unanswered;

    public TrackDTO() {

    }

    public TrackDTO(MarkTrack track) {
        String questionNumber = track.getQuestionNumber();
        String str[] = questionNumber.split("\\.");
        setMainNumber(Integer.parseInt(str[0]));
        setSubNumber(str[1]);
        setNumber(track.getNumber());
        setScore(track.getScore());
        setPositionX(track.getPositionX());
        setPositionY(track.getPositionY());
        setOffsetIndex(track.getOffsetIndex());
        setOffsetX(track.getOffsetX());
        setOffsetY(track.getOffsetY());
        setUnanswered(track.isUnanswered());
    }

    public TrackDTO(TrialTrack track) {
        String str[] = track.getQuestionNumber().split("\\.");
        setMainNumber(Integer.parseInt(str[0]));
        setSubNumber(str[1]);
        setNumber(track.getNumber());
        setScore(track.getScore());
        setPositionX(track.getPositionX());
        setPositionY(track.getPositionY());
        setOffsetIndex(track.getOffsetIndex());
        setOffsetX(track.getOffsetX());
        setOffsetY(track.getOffsetY());
        setUnanswered(track.isUnanswered());
    }

    public TrackDTO(HeaderTrack track) {
        String questionNumber = track.getQuestionNumber();
        String str[] = questionNumber.split("\\.");
        setMainNumber(Integer.parseInt(str[0]));
        setSubNumber(str[1]);
        setNumber(track.getNumber());
        setScore(track.getScore());
        setPositionX(track.getPositionX());
        setPositionY(track.getPositionY());
        setOffsetIndex(track.getOffsetIndex());
        setOffsetX(track.getOffsetX());
        setOffsetY(track.getOffsetY());
        setUnanswered(track.isUnanswered());
    }

    public MarkTrack transform(MarkLibrary library, Marker marker) {
        MarkTrack track = new MarkTrack();
        track.setLibraryId(library.getId());
        track.setQuestionNumber(getMainNumber() + "." + getSubNumber());
        track.setNumber(getNumber());
        track.setStudentId(library.getStudentId());
        track.setExamId(library.getExamId());
        track.setSubjectCode(library.getSubjectCode());
        track.setGroupNumber(library.getGroupNumber());
        track.setMarkerId(marker.getId());
        track.setScore(getScore());
        track.setPositionX(getPositionX());
        track.setPositionY(getPositionY());
        track.setOffsetIndex(getOffsetIndex());
        track.setOffsetX(getOffsetX());
        track.setOffsetY(getOffsetY());
        track.setUnanswered(isUnanswered());
        return track;
    }

    public TrialTrack transform(TrialLibrary library) {
        TrialTrack track = new TrialTrack();
        track.setLibraryId(library.getId());
        track.setMarkerId(library.getMarkerId());
        track.setQuestionNumber(getMainNumber() + "." + getSubNumber());
        track.setNumber(getNumber());
        track.setStudentId(library.getStudentId());
        track.setExamId(library.getExamId());
        track.setSubjectCode(library.getSubjectCode());
        track.setGroupNumber(library.getGroupNumber());
        track.setScore(getScore());
        track.setPositionX(getPositionX());
        track.setPositionY(getPositionY());
        track.setOffsetIndex(getOffsetIndex());
        track.setOffsetX(getOffsetX());
        track.setOffsetY(getOffsetY());
        track.setUnanswered(isUnanswered());
        return track;
    }

    public HeaderTrack transform(ArbitrateHistory library) {
        HeaderTrack track = new HeaderTrack();
        track.setQuestionNumber(getMainNumber() + "." + getSubNumber());
        track.setNumber(getNumber());
        track.setStudentId(library.getStudentId());
        track.setExamId(library.getExamId());
        track.setSubjectCode(library.getSubjectCode());
        track.setGroupNumber(library.getGroupNumber());
        track.setUserId(library.getUserId());
        track.setScore(getScore());
        track.setPositionX(getPositionX());
        track.setPositionY(getPositionY());
        track.setOffsetIndex(getOffsetIndex());
        track.setOffsetX(getOffsetX());
        track.setOffsetY(getOffsetY());
        track.setUnanswered(isUnanswered());
        return track;
    }

    public Integer getMainNumber() {
        return mainNumber;
    }

    public void setMainNumber(Integer mainNumber) {
        this.mainNumber = mainNumber;
    }

    public String getSubNumber() {
        return subNumber;
    }

    public void setSubNumber(String subNumber) {
        this.subNumber = subNumber;
    }

    public int getNumber() {
        return number;
    }

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

    public double getScore() {
        return score;
    }

    public void setScore(double score) {
        this.score = score;
    }

    public double getPositionX() {
        return positionX;
    }

    public void setPositionX(double positionX) {
        this.positionX = positionX;
    }

    public double getPositionY() {
        return positionY;
    }

    public void setPositionY(double positionY) {
        this.positionY = positionY;
    }

    public int getOffsetIndex() {
        return offsetIndex;
    }

    public void setOffsetIndex(int offsetIndex) {
        this.offsetIndex = offsetIndex;
    }

    public int getOffsetX() {
        return offsetX;
    }

    public void setOffsetX(int offsetX) {
        this.offsetX = offsetX;
    }

    public int getOffsetY() {
        return offsetY;
    }

    public void setOffsetY(int offsetY) {
        this.offsetY = offsetY;
    }

    public boolean isUnanswered() {
        return unanswered;
    }

    public void setUnanswered(boolean unanswered) {
        this.unanswered = unanswered;
    }

}
