package model.gammeOperatoire;

import java.util.Arrays;
import java.util.Vector;

import model.article.Article;
import model.posteCharge.PosteCharge;



public class Operation extends Activite implements java.io.Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1473204781151943072L;
	protected Article cible;
	protected boolean assemblage;
	protected PosteCharge poste;
	protected int nbCible;
	protected static String[] strNom = {"Fabrication", "Assemblage"};
	static String[] str = {"Quantite", "Assemblage", "Produit", "Poste"}; 
	
	
	
	public Operation(int duree, Article cible, PosteCharge poste, int nbCible, boolean assemblage) {
		super(duree, strNom[assemblage? 1:0]+" ("+cible.getDesignation()+")", new Vector<String>(Arrays.asList(str)));

		this.cible=cible;
		this.poste=poste;
		this.nbCible=nbCible;
		this.assemblage=assemblage;
	}

	public Article getCible() {
		return cible;
	}

	public boolean isAssemblage() {
		return assemblage;
	}

	public PosteCharge getPoste() {
		return poste;
	}

	public int getNbCible() {
		return nbCible;
	}
	
	@Override
	public void set(Vector<Object> source){
		this.nom= (String)source.get(param.indexOf(baseStr[0]));
		this.duree=Integer.parseInt((String)(source.get(param.indexOf(baseStr[1]))));
		this.nbCible=Integer.parseInt((String)(source.get(param.indexOf(str[0]))));
		this.assemblage=(Boolean)(source.get(param.indexOf(str[1])));
		this.cible=(Article)(source.get(param.indexOf(str[2])));
		this.poste=(PosteCharge)(source.get(param.indexOf(str[3])));
	}
	
	@Override
	public Object get(int i){
		switch(i) {
		case 0 	: 	return nom;
		case 1 	:	return duree;
		case 2	: 	return nbCible;
		case 3	:	return assemblage;
		case 4	:	return cible;
		case 5	:	return poste;
		default	:	return null;
		}
	}
}
