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/siprp/medicina/presencas/PresencasDataProvider.java

134 lines
3.7 KiB

/*
* PresencasDataProvider.java
*
* Created on February 5, 2007, 5:51 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.medicina.presencas;
import com.evolute.utils.Singleton;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Update;
import siprp.medicina.MedicinaConstants;
import siprp.medicina.MedicinaDataProvider;
/**
*
* @author lflores
*/
public class PresencasDataProvider
implements MedicinaConstants
{
private static final Object LOCK = new Object();
private static PresencasDataProvider instance = null;
private MedicinaDataProvider medicinaProvider;
private Executer EXECUTER;
/** Creates a new instance of PresencasDataProvider */
public PresencasDataProvider()
throws Exception
{
DBManager dbm = ( DBManager ) Singleton.getInstance( Singleton.DEFAULT_DBMANAGER );
EXECUTER = dbm.getSharedExecuter( this );
medicinaProvider = ( MedicinaDataProvider ) MedicinaDataProvider.getProvider();
}
public static PresencasDataProvider getProvider()
throws Exception
{
synchronized( LOCK )
{
if( instance == null )
{
instance = new PresencasDataProvider();
}
}
return instance;
}
protected void apagarDetalhesRealizacao( Integer marcacaoID )
throws Exception
{
medicinaProvider.deleteDetalhesRealziadosForMarcacao( marcacaoID );
}
public void marcarFaltou( Integer id )
throws Exception
{
apagarDetalhesRealizacao( id );
Update update =
new Update( "marcacoes_trabalhador",
new Assignment[]{
new Assignment( new Field( "realizada" ), "n" ),
new Assignment( new Field( "estado" ), new Integer( ESTADO_FALTOU ) )
},
new Field( "id" ).isEqual( id ) );
EXECUTER.executeQuery( update );
}
public void marcarDesmarcadoSHST( Integer id )
throws Exception
{
apagarDetalhesRealizacao( id );
Update update =
new Update( "marcacoes_trabalhador",
new Assignment[]{
new Assignment( new Field( "realizada" ), "n" ),
new Assignment( new Field( "estado" ), new Integer( ESTADO_DESMARCADO_EMPRESA ) )
},
new Field( "id" ).isEqual( id ) );
EXECUTER.executeQuery( update );
}
public void marcarDesmarcadoTrabalhador( Integer id )
throws Exception
{
apagarDetalhesRealizacao( id );
Update update =
new Update( "marcacoes_trabalhador",
new Assignment[]{
new Assignment( new Field( "realizada" ), "n" ),
new Assignment( new Field( "estado" ), new Integer( ESTADO_DESMARCADO_TRABALHADOR ) )
},
new Field( "id" ).isEqual( id ) );
EXECUTER.executeQuery( update );
}
public void marcarRealizado( Integer id, Integer grupos[] )
throws Exception
{
apagarDetalhesRealizacao( id );
medicinaProvider.setDetalhesRealziadosForMarcacao( id, grupos );
Update update =
new Update( "marcacoes_trabalhador",
new Assignment[]{
new Assignment( new Field( "realizada" ), "y" ),
new Assignment( new Field( "estado" ), new Integer( ESTADO_REALIZADO ) )
},
new Field( "id" ).isEqual( id ) );
EXECUTER.executeQuery( update );
}
public void marcarParcialmenteRealizado( Integer id, Integer grupos[] )
throws Exception
{
apagarDetalhesRealizacao( id );
medicinaProvider.setDetalhesRealziadosForMarcacao( id, grupos );
Update update =
new Update( "marcacoes_trabalhador",
new Assignment[]{
new Assignment( new Field( "realizada" ), "n" ),
new Assignment( new Field( "estado" ), new Integer( ESTADO_PARCIALMENTE_REALIZADO ) )
},
new Field( "id" ).isEqual( id ) );
EXECUTER.executeQuery( update );
}
}