package Model;

import java.awt.geom.Point2D;
import java.sql.SQLException;
import java.util.List;

import Controler.IO.DB;

public class Acquisition implements IAcquisition {

	private boolean isLog;
	private int acquisitionId;
	private ILog acquisitionLog;
	
	public Acquisition(boolean isLog) {
		this.isLog = isLog;
		this.acquisitionLog = null;
	}
	
	public Acquisition(int acquisitionId, boolean isLog) {
		this.acquisitionId = acquisitionId;
		this.isLog = isLog;
	}
	
	public int getAcquisitionId(){
		return acquisitionId;
	}
	
	public List<IPoint> getAcquisitionPoints() {
		return DB.getInstance().getAllAPoints(this);
	}

	public boolean isLog() {
		return isLog;
	}
	
	public IPoint addPoint(Point2D.Double point, int pressure, float time) throws SQLException {
		int id = DB.getInstance().addPoint(this, point, pressure, time);
		return new Point(id, point, pressure, time);
	}
	
	public void addPoints(List<IPoint> points) throws SQLException {
		DB.getInstance().addPoints(this, points);
	}

	public ILog addLog(boolean isSignatureValid, boolean isUserValid) throws SQLException {
		int id = DB.getInstance().addLog(getAcquisitionId(), isSignatureValid, isUserValid);
		acquisitionLog = new Log(id, isSignatureValid, isUserValid);
		return acquisitionLog;
	}

	@Override
	public ILog getAcquisitionLog() {
		return acquisitionLog;
	}
	
	
	
}
