/*
* HsPostoRiscoData.java
*
* Generated by com.evutils.codegen.EntityObjectGenerator
*
* Edit at will
*/
package siprp.data.outer;

import com.evolute.entity.evo.EvoDataException;

public final class HsPostoRiscoData extends siprp.data.inner.HsPostoRisco
{

	public HsPostoRiscoData()
	{
		super();
	}
	
	@Override
	public String toString()
	{
		return super.toRisco_id().getDescription();
	}
	
	@Override
	public void save() throws EvoDataException
	{
		HsPostoData posto = toPosto_id();
		if( posto != null )
		{
			Integer maxOrder = 0;
			for( HsPostoRiscoData rel : posto.fromHsPostoRisco_posto_id() )
			{
				Integer currentOrder = rel.getOrdem();
				if( currentOrder != null )
				{
					maxOrder = Math.max( currentOrder, maxOrder );
				}
			}
			this.setOrdem( maxOrder + 1 );
		}
		super.save();
	}
	
}
