Kenmegne
7 days ago 23a46b4be35277e06ec89f48730eeb694e686be8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.megatim.fdxconsultation.core.impl.dataproductionworker;
 
import com.megatim.fdxcommons.tools.database.connection.DBConnection;
import com.megatim.fdxcommons.tools.database.tables.FdxConsultationTable;
import com.megatim.fdxconsultation.core.impl.factory.FdxConsultationTableFactory;
import com.megatim.fdxconsultation.model.dataproduction.DataProduction;
import java.sql.Connection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.DataSource;
 
/**
 *
 * @author Gabuntu
 */
class DeleteDataProductionTask implements DataProductionTask {
 
    private final DataProduction dataProduction;
    private final DataSource dataSource;
 
    public DeleteDataProductionTask(DataProduction dataProduction, DataSource dataSource) {
        this.dataProduction = dataProduction;
        this.dataSource = dataSource;
    }
 
    @Override
    public void processProduction() {
 
        try ( Connection connection = new DBConnection(dataSource).connection()) {
 
            connection.setAutoCommit(false);
 
            FdxConsultationTable fdxConsTable = FdxConsultationTableFactory.createTable(dataProduction.getCodeTypeFichier(), dataProduction.getReferentielVersion(), connection);
            fdxConsTable.delete(null, dataProduction, connection);
            connection.commit();
 
        } catch (Exception ex) {
            Logger.getLogger(DeleteDataProductionTask.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
        }
 
    }
 
}