package siprp.database.cayenne.objects; import java.util.Date; import java.util.HashMap; import siprp.database.cayenne.objects.auto._TrabalhadoresEcdsDatas; import siprp.medicina.MedicinaConstants; public class TrabalhadoresEcdsDatas extends _TrabalhadoresEcdsDatas implements MedicinaConstants{ private static final long serialVersionUID = 1L; public String getDataString() { return getData() == null ? "" : sdf.format( getData() ); } public String getEstadoString() { return getEstado() == null || getEstado() >= ESTADOS_EXAME_STR.length ? "" : ESTADOS_EXAME_STR[ getEstado() ]; } public HashMap getEstados() { HashMap result = new HashMap(); for( int i = 0; i < ESTADOS_EXAME_STR.length; ++i ) { if( ESTADOS_EXAME_STR[i] != null ) { result.put( new Integer( i ), ESTADOS_EXAME_STR[i] ); } } return result; } @Override public void setData( Date date ) { if( date != null && this.getToTrabalhadoresEcds() != null && this.getEstado() != null && new Integer(ESTADO_POR_REALIZAR).equals(this.getEstado())) { this.getToTrabalhadoresEcds().setData( date ); } super.setData( date ); } @Override public void setEstado( Integer estado ) { if( estado != null && this.getToTrabalhadoresEcds() != null && (new Integer(ESTADO_POR_REALIZAR).equals( this.getEstado() ) || new Integer(ESTADO_POR_REALIZAR).equals( estado ))) { this.getToTrabalhadoresEcds().setEstado( estado ); } super.setEstado( estado ); } @Override public String toString() { return getDataString() + ": " + getEstadoString(); } }