import java.io.File;
import java.time.LocalDateTime;
import javax.swing.DefaultListModel;

/**
 * Contain the result of the stamping of a job and all errors founds
 * @author 413
 *
 */
public class Result 
{
	static ServiceResult service = new ServiceResult();//to load and save results in XML files
	private String GeneralError;				//general job error (like PDF can't be opened)
	private Integer PageProcessCount;			//number of page processed
	private Integer PageErrorCount;				//Number of page errors detected
	private LocalDateTime StartJobDateTime;		//starting process date and time
	private LocalDateTime EndJobDateTime;		//ending process date and time
	private DefaultListModel<Error> errors;		//List of errors
	private File resultFile;					//Link to Result.xml file
	
	/**
	 * 
	 */
	public Result() 
	{
		GeneralError = "No Error";
		PageProcessCount = 0;
		PageErrorCount = 0;
		errors = new DefaultListModel<Error>();
	}

	/**
	 * return the general error of execution ("no error" if no error has closed the stamping)
	 * @return
	 */
	public String getGeneralError()
	{
		return GeneralError;
	}

	/**
	 * set the general error
	 * @param generalError
	 */
	public void setGeneralError(String generalError)
	{
		GeneralError = generalError;
	}

	/**
	 * return the number of pages processed
	 * @return
	 */
	public Integer getPageProcessCount()
	{
		return PageProcessCount;
	}

	/**
	 * set the number of pages processed
	 * @param pageProcessCount
	 */
	public void setPageProcessCount(Integer pageProcessCount)
	{
		PageProcessCount = pageProcessCount;
	}

	/**
	 * return the number of errors
	 * @return
	 */
	public Integer getPageErrorCount()
	{
		return PageErrorCount;
	}

	/**
	 * set the number of errors
	 * @param pageErrorCount
	 */
	public void setPageErrorCount(Integer pageErrorCount)
	{
		PageErrorCount = pageErrorCount;
	}

	/**
	 * get when the stamping began
	 * @return
	 */
	public LocalDateTime getStartJobDateTime()
	{
		return StartJobDateTime;
	}

	/**
	 * set when the stamping began
	 * @param startJobDateTime
	 */
	public void setStartJobDateTime(LocalDateTime startJobDateTime)
	{
		StartJobDateTime = startJobDateTime;
	}

	/**
	 * get when the stamping stopped
	 * @return
	 */
	public LocalDateTime getEndJobDateTime()
	{
		return EndJobDateTime;
	}

	/**
	 * set when the stamping stopped
	 * @param endJobDateTime
	 */
	public void setEndJobDateTime(LocalDateTime endJobDateTime)
	{
		EndJobDateTime = endJobDateTime;
	}
	
	/**
	 * add an error
	 * @param errorPageNumber the page of the error
	 * @param errorDescription the description of the error
	 * @param level the danger level of the error
	 */
	public void addError(Integer errorPageNumber, String errorDescription, Integer level)
	{
		errors.addElement(new Error(errorPageNumber, errorDescription, level));
	}
	
	/**
	 * add an error
	 * @param errorPageNumber the page of the error
	 * @param errorDescription the description of the error
	 * @param level the danger level of the error
	 */
	public void addError(Integer errorPageNumber, String errorDescription, Integer level, File screen)
	{
		errors.addElement(new Error(errorPageNumber, errorDescription, level, screen));
	}

	/**
	 * get the errors list
	 * @return
	 */
	public DefaultListModel<Error> getErrors()
	{
		return errors;
	}

	/**
	 * get the File containing the results
	 * @return
	 */
	public File getResultFile() 
	{
		return resultFile;
	}

	/**
	 * set the File containing the results
	 * @param resultFile
	 */
	public void setResultFile(File resultFile) 
	{
		this.resultFile = resultFile;
	}
}
