forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@1340 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
e5db6f8e53
commit
6f583a6ce5
Binary file not shown.
Binary file not shown.
@ -0,0 +1,39 @@
|
||||
package siprp;
|
||||
|
||||
import siprp.higiene.relatorio.MedidasRiscosDeleterController;
|
||||
|
||||
import com.evolute.threads.EvoShutdownHook;
|
||||
import com.evolute.utils.error.ErrorLogger;
|
||||
|
||||
public class SIPRPShutdownHook extends EvoShutdownHook
|
||||
{
|
||||
|
||||
public SIPRPShutdownHook()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void execute()
|
||||
{
|
||||
MedidasRiscosDeleterController controller = MedidasRiscosDeleterController.getInstance();
|
||||
System.out.println( "\nChecking " + controller.getThreads().size() + " threads ..." );
|
||||
for ( Thread deleter : controller.getThreads() )
|
||||
{
|
||||
System.out.println( "\nChecking " + deleter.getName() + " ... Running ? " + deleter.isAlive() );
|
||||
if ( deleter.isAlive() )
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println( "\nWaiting for <" + deleter + "> ... " );
|
||||
deleter.join();
|
||||
}
|
||||
catch ( InterruptedException e )
|
||||
{
|
||||
ErrorLogger.logException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package siprp.higiene.relatorio;
|
||||
|
||||
import com.evolute.utils.error.ErrorLogger;
|
||||
|
||||
import siprp.data.outer.HsRelatorioMedidaData;
|
||||
import siprp.data.outer.HsRelatorioPostoMedidaData;
|
||||
import siprp.data.outer.HsRelatorioRiscoData;
|
||||
|
||||
|
||||
public class MedidasRiscosDeleter implements Runnable
|
||||
{
|
||||
private HsRelatorioRiscoData riscoData;
|
||||
|
||||
private String name;
|
||||
|
||||
public MedidasRiscosDeleter( HsRelatorioRiscoData riscoData )
|
||||
{
|
||||
this.riscoData = riscoData;
|
||||
|
||||
setName( "Delete Medidas from Risco - " + riscoData );
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
for( HsRelatorioMedidaData medida : riscoData.fromHsRelatorioMedida_risco_id() )
|
||||
{
|
||||
for ( HsRelatorioPostoMedidaData relMedida : medida.fromHsRelatorioPostoMedida_medida_id() )
|
||||
{
|
||||
relMedida.delete();
|
||||
}
|
||||
medida.delete();
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
ErrorLogger.logException( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
package siprp.higiene.relatorio;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class MedidasRiscosDeleterController
|
||||
{
|
||||
private static MedidasRiscosDeleterController INSTANCE = null;
|
||||
|
||||
private List< Thread > threads = null;
|
||||
|
||||
private MedidasRiscosDeleterController()
|
||||
{
|
||||
threads = new LinkedList< Thread >();
|
||||
}
|
||||
|
||||
public static synchronized MedidasRiscosDeleterController getInstance()
|
||||
{
|
||||
if ( INSTANCE == null )
|
||||
{
|
||||
INSTANCE = new MedidasRiscosDeleterController();
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
public List< Thread > getThreads()
|
||||
{
|
||||
return threads;
|
||||
}
|
||||
|
||||
private void setThreads( List< Thread > threads )
|
||||
{
|
||||
this.threads = threads;
|
||||
}
|
||||
|
||||
public void delete( MedidasRiscosDeleter thread )
|
||||
{
|
||||
if ( getThreads() == null )
|
||||
{
|
||||
setThreads( new LinkedList< Thread >() );
|
||||
}
|
||||
|
||||
Thread t = new Thread( thread );
|
||||
t.setName( thread.getName() );
|
||||
t.setDaemon( false );
|
||||
t.start();
|
||||
getThreads().add( t );
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue