package siprp.data;

import java.text.DateFormat;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;

import siprp.database.cayenne.providers.MainDAO;

import com.evolute.entity.evo.EvoDataException;
import com.evolute.entity.evo.EvoDataObject;
import com.evolute.utils.strings.UnicodeChecker;

public abstract class BaseObject extends EvoDataObject
{

	static
	{
		UnicodeChecker.setUseDoubleSlash( true );
	}
	
	private static final long serialVersionUID = 1L;
	
	protected static MainDAO dao = new MainDAO();
	
	public static final DateFormat DATE_FORMAT = DateFormat.getDateInstance( DateFormat.SHORT, new Locale( "pt", "PT" ) );

	protected static final String isNewMessage = " ";
	
	@Override
	protected List fromReference(Class clazz, Integer id, String referingProperty, String... order) throws EvoDataException
	{
		List result = new LinkedList();
		for( Object o : super.fromReference(clazz, id, referingProperty, order) )
		{
			Object inactivoString = ((EvoDataObject)o).get("inactivo");
			Object deletedDateValue = ((EvoDataObject)o).get("deleted_date");
			if( deletedDateValue == null && !"y".equals( inactivoString ) )
			{
				result.add( o );
			}
		}
		return result;
	}
	
}
