package siprp.higiene.relatorio.print;

import java.util.Vector;

import org.jdom.Element;

public class LegislacaoAplicavelToPrint
	implements PrintableInterface
{
	protected Vector<String> diplomasGerais;
	protected String[] nomesGruposEspecificos;
	protected Vector<String>[] diplomasEspecificos;
	
	public LegislacaoAplicavelToPrint( Vector<String> diplomasGerais,
			String[] nomesGruposEspecificos, Vector<String>[] diplomasEspecificos )
	{
		super();
		this.diplomasGerais = diplomasGerais;
		this.nomesGruposEspecificos = nomesGruposEspecificos;
		this.diplomasEspecificos = diplomasEspecificos;
	}
	
	@Override
	public Element toJdomElement() throws Exception
	{
		Element legislacaoAplicavelElement = new Element( "legislacao-aplicavel" );
		Element legislacaoGeralElement = new Element( "legislacao-geral" ); 
		for( String diploma : diplomasGerais )
		{
			Element diplomaElement = new Element( "diploma" );
			diplomaElement.setText( diploma );
			legislacaoGeralElement.addContent( diplomaElement );
		}
		legislacaoAplicavelElement.addContent( legislacaoGeralElement );
		
		for( int e = 0; e < nomesGruposEspecificos.length; e++ )
		{
			Element legislacaoEspecificaElement = new Element( "legislacao-especifica" );
			Element designacaoElement = new Element( "designacao" );
			designacaoElement.setText( nomesGruposEspecificos[ e ] );
			legislacaoEspecificaElement.addContent( designacaoElement );
			for( String diploma : diplomasEspecificos[ e ] )
			{
				Element diplomaElement = new Element( "diploma" );
				diplomaElement.setText( diploma );
				legislacaoEspecificaElement.addContent( diplomaElement );
			}
			legislacaoAplicavelElement.addContent( legislacaoEspecificaElement );
		}
		return legislacaoAplicavelElement;
	}

}
