package model.gammeOperatoire;

import java.util.Vector;


public class GammeOperatoire implements java.io.Serializable{

	private static final long serialVersionUID = 5143222288334323441L;

	public static int compt=1;
	
	protected Vector<Activite> gamme;
	protected String nom;
	protected boolean isProduction;
	
	public boolean isProduction() {
		return isProduction;
	}

	public void setProduction(boolean isProduction) {
		this.isProduction = isProduction;
	}

	public String getNom() {
		return nom;
	}

	protected String reference;
	
	public GammeOperatoire(String nom, boolean isProduction) {
		this.gamme=new Vector<Activite>();
		this.nom=nom;
		this.reference=model.Reference.genererReference("GOP", compt);
		this.isProduction = isProduction;
		compt++;
	}
	
	public Vector<Activite> getGamme() {
		return this.gamme;
	}
	
	public void addActivite(Activite a) {
		gamme.add(a);
	}
	
	public void addActivite(Activite a, int p) {
		gamme.add(p, a);
	}
	
	public void addActivite(Vector<Activite> a) {
		gamme.addAll(a);
	}
	
	public void addActivite(Vector<Activite> a, int p) {
		gamme.addAll(p, a);
	}
	
	public int getOrdre(Activite a) {
		return gamme.indexOf(a);
	}
	
	public String getReference() {
		return reference;
	}
	
	public void swapArticle(Activite a1, Activite a2) {
		swapArticle(getOrdre(a1), getOrdre(a2));
	}
	
	
	public void swapArticle(int pos1, int pos2) {
		Activite temp = gamme.get(pos2);
		gamme.set(pos2, gamme.get(pos1));
		gamme.set(pos1, temp);
	}
	
	public void removeActivite(Activite a) {
		gamme.remove(a);
	}
	
	public void removeActivite(Vector<Activite> a) {
		gamme.removeAll(a);
	}
	
	public int getTotalTime() {
		int time=0;
		for(Activite a : gamme) time+=a.getDuree();
		return time;
	}

}
