package es.uv.saic.dto;

import java.io.Serializable;
import java.math.BigInteger;

import org.springframework.context.i18n.LocaleContextHolder;

import es.uv.saic.domain.Instancia;

public class TreeDTOInstancia implements Serializable {
	private static final long serialVersionUID = 1L;

	private BigInteger idInstancia;
	private BigInteger idInstanciaTasca;
	private Integer centre;
	private String estat;
	private Integer titulacio;
	private String tlugar;
	private Integer lugar;
	private String nomProces;
	private String descVal;
	private String descCas;
	private String ambit;
	private String text;

	public TreeDTOInstancia() {}
	
	public TreeDTOInstancia(Instancia i) {
		String locale = LocaleContextHolder.getLocale().getLanguage();
		this.idInstancia = i.getIdInstancia();
		this.centre = i.getCentre();
		this.estat = i.getEstat();
		this.titulacio = i.getTitulacio();
		this.lugar = i.getOrgan().getId().getLugar();
		this.tlugar = i.getOrgan().getId().getTlugar();
		this.nomProces = i.getProces().getNomProces();
		this.descVal = i.getProces().getTitolVal();
		this.descCas = i.getProces().getTitolCas();
		this.ambit = i.getProces().getAmbit(); 
		
		String icon = "<span class=\"btn gantt-legend-done\" style=\"border-width:5px;border-radius:50%;width:20px;height:20px;margin-top:-2px\"></span>";
		if(this.estat.equals("A")) {
			icon = "<span class=\"btn gantt-legend-active\" style=\"border-width:5px;border-radius:50%;width:20px;height:20px;margin-top:-2px\"></span>";
		}
		else if(this.estat.equals("C")) {
			icon = "<span class=\"btn gantt-legend-closed\" style=\"border-width:5px;border-radius:50%;width:20px;height:20px;margin-top:-2px\"></span>";
		}
		
		this.text = icon+" <a target=\"_blank\" href=\"/procedure/"+i.getIdInstancia().toString()+"\">"+i.getProces().getNomProces() + " - " + (locale.equals("es") ? i.getProces().getTitolCas() : i.getProces().getTitolVal()) +"</a>";
	}

	public BigInteger getIdInstancia() {
		return this.idInstancia;
	}

	public void setIdInstancia(BigInteger idInstancia) {
		this.idInstancia = idInstancia;
	}

	public Integer getCentre() {
		return this.centre;
	}

	public void setCentre(Integer centre) {
		this.centre = centre;
	}

	public String getEstat() {
		return this.estat;
	}

	public void setEstat(String estat) {
		this.estat = estat;
	}

	public Integer getTitulacio() {
		return this.titulacio;
	}

	public void setTitulacio(Integer titulacio) {
		this.titulacio = titulacio;
	}

	public String getTlugar() {
		return tlugar;
	}

	public void setTlugar(String tlugar) {
		this.tlugar = tlugar;
	}

	public Integer getLugar() {
		return lugar;
	}

	public void setLugar(Integer lugar) {
		this.lugar = lugar;
	}

	public String getNomProces() {
		return nomProces;
	}

	public void setNomProces(String nomProces) {
		this.nomProces = nomProces;
	}

	public String getDescVal() {
		return descVal;
	}

	public void setDescVal(String descVal) {
		this.descVal = descVal;
	}

	public String getDescCas() {
		return descCas;
	}

	public void setDescCas(String descCas) {
		this.descCas = descCas;
	}

	public String getAmbit() {
		return ambit;
	}

	public void setAmbit(String ambit) {
		this.ambit = ambit;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}
	
	public BigInteger getIdInstanciaTasca() {
		return idInstanciaTasca;
	}

	public void setIdInstanciaTasca(BigInteger idInstanciaTasca) {
		this.idInstanciaTasca = idInstanciaTasca;
	}
	
	


}