package core.process;

import core.operation.UploadFile;
import error.GExcptInit;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class C_StudentUploadFinishedProduct extends C_UploadFile {

    File finishedProduct;
    String graduationDesignId;
    protected static String buttonName ="提交定稿";
    protected static String iconURL="../cssFile/images/upload.png";
    protected static String targetURL="/home/student-upload-finished-product";
    protected static String info = "";

    static String file_type = "finished_product";
    public void uploadOpeningReport() throws Exception{
        if(!check()) throw new GExcptInit("Upload FinishedProduct Attrs init error!");
        UploadFile uploadFile=new UploadFile();
        uploadFile.setOptions(new HashMap<>());
        uploadFile.addOptions("file",this.getFinishedProduct());
        uploadFile.addOptions("file_type",file_type);
        Map<String, String>limits = new HashMap<>();
        limits.put("id",this.getGraduationDesignId());
        uploadFile.addOptions("limits",limits);
        uploadFile.execute(null);
    }

    protected boolean check() {
        if(this.getFinishedProduct()==null||this.getGraduationDesignId()==null)
            return false;
        return true;
    }
    public File getFinishedProduct() {
        return finishedProduct;
    }

    public void setFinishedProduct(File finishedProduct) {
        this.finishedProduct = finishedProduct;
    }
    public String getGraduationDesignId() {
        return graduationDesignId;
    }

    public void setGraduationDesignId(String graduationDesignId) {
        this.graduationDesignId = graduationDesignId;
    }

    @Override
    public String getInfo() {
        return info;
    }

    @Override
    public String getTargetURL() {
        return targetURL;
    }

    @Override
    public String getIconURL() {
        return iconURL;
    }

    @Override
    public String getButtonName() {
        return buttonName;
    }
}
