You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SIPRP/trunk/common/src/siprp/database/cayenne/objects/Estabelecimentos.java

88 lines
1.6 KiB

package siprp.database.cayenne.objects;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import siprp.database.cayenne.objects.auto._Estabelecimentos;
public class Estabelecimentos extends _Estabelecimentos implements Comparable<Estabelecimentos>
{
private static final long serialVersionUID = 1L;
private String name = null;
private String convertedName = null;
@Override
public String getNome()
{
String currentName = super.getNome();
if( name == null || !name.equals( currentName ) )
{
name = currentName;
convertedName = null;
}
return convertName();
}
@Override
public void setNome( String nome )
{
super.setNome( parseToUnicode( name ) );
getNome();
}
private String convertName()
{
if( name == null )
{
convertedName = null;
}
else
{
convertedName = parseFromUnicode( name );
}
return convertedName;
}
@Override
public String toString()
{
return getNome();
}
@Override
public List<Trabalhadores> getTrabalhadoresArray()
{
List<Trabalhadores> result = super.getTrabalhadoresArray();
for(int i = 0; i < result.size(); ++i)
{
Trabalhadores current = result.get(i);
if( current == null || "y".equals(current.getInactivo()))
{
result.remove( i );
--i;
}
}
Collections.sort( result );
return result;
}
@Override
public int compareTo( Estabelecimentos estabelecimento )
{
if( estabelecimento == null)
{
return 1;
}
if( this.getNomePlain() == null )
{
return (estabelecimento.getNomePlain() != null) ? -1 : 0;
}
return (-1) * estabelecimento.getNomePlain().compareTo( getNomePlain() );
}
}