OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 102 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 102 Rev 181
Line 11... Line 11...
11
import org.openconcerto.sql.model.SQLRowAccessor;
11
import org.openconcerto.sql.model.SQLRowAccessor;
12
import org.openconcerto.sql.model.SQLRowValues;
12
import org.openconcerto.sql.model.SQLRowValues;
13
import org.openconcerto.ui.VFlowLayout;
13
import org.openconcerto.ui.VFlowLayout;
14
 
14
 
15
public class BooleanProcessor extends JPanel implements BatchProcessor {
15
public class BooleanProcessor extends JPanel implements BatchProcessor {
16
    private final SQLField field;
16
    private final BatchField field;
17
 
17
 
18
    private JRadioButton bTrue;
18
    private JRadioButton bTrue;
19
    private JRadioButton bFalse;
19
    private JRadioButton bFalse;
20
    private JRadioButton bInvert;
20
    private JRadioButton bInvert;
21
 
21
 
22
    public BooleanProcessor(SQLField field) {
22
    public BooleanProcessor(BatchField field) {
23
        this.field = field;
23
        this.field = field;
24
        this.setLayout(new VFlowLayout());
24
        this.setLayout(new VFlowLayout());
25
        bTrue = new JRadioButton("forcer à vrai");
25
        bTrue = new JRadioButton("forcer à vrai");
26
        bFalse = new JRadioButton("forcer à faux");
26
        bFalse = new JRadioButton("forcer à faux");
27
        bInvert = new JRadioButton("inverser");
27
        bInvert = new JRadioButton("inverser");
Line 39... Line 39...
39
    @Override
39
    @Override
40
    public void process(List<SQLRowValues> r) throws SQLException {
40
    public void process(List<SQLRowValues> r) throws SQLException {
41
        if (bTrue.isSelected()) {
41
        if (bTrue.isSelected()) {
42
            for (SQLRowAccessor sqlRowAccessor : r) {
42
            for (SQLRowAccessor sqlRowAccessor : r) {
43
                final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
43
                final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
44
                rowValues.put(field.getName(), Boolean.TRUE);
44
                rowValues.put(field.getField().getName(), Boolean.TRUE);
45
                processBeforeUpdate(sqlRowAccessor, rowValues);
45
                processBeforeUpdate(sqlRowAccessor, rowValues);
46
                rowValues.update();
46
                rowValues.update();
47
            }
47
            }
48
        } else if (bFalse.isSelected()) {
48
        } else if (bFalse.isSelected()) {
49
            for (SQLRowAccessor sqlRowAccessor : r) {
49
            for (SQLRowAccessor sqlRowAccessor : r) {
50
                final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
50
                final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
51
                rowValues.put(field.getName(), Boolean.FALSE);
51
                rowValues.put(field.getField().getName(), Boolean.FALSE);
52
                processBeforeUpdate(sqlRowAccessor, rowValues);
52
                processBeforeUpdate(sqlRowAccessor, rowValues);
53
                rowValues.update();
53
                rowValues.update();
54
            }
54
            }
55
        } else if (bInvert.isSelected()) {
55
        } else if (bInvert.isSelected()) {
56
            for (SQLRowAccessor sqlRowAccessor : r) {
56
            for (SQLRowAccessor sqlRowAccessor : r) {
57
                final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
57
                final SQLRowValues rowValues = sqlRowAccessor.createEmptyUpdateRow();
58
                final Boolean boolean1 = sqlRowAccessor.asRow().getBoolean(field.getName());
58
                final Boolean boolean1 = sqlRowAccessor.asRow().getBoolean(field.getField().getName());
59
                if (boolean1 != null) {
59
                if (boolean1 != null) {
60
                    rowValues.put(field.getName(), boolean1.equals(Boolean.FALSE));
60
                    rowValues.put(field.getField().getName(), boolean1.equals(Boolean.FALSE));
61
                    processBeforeUpdate(sqlRowAccessor, rowValues);
61
                    processBeforeUpdate(sqlRowAccessor, rowValues);
62
                    rowValues.update();
62
                    rowValues.update();
63
                }
63
                }
64
            }
64
            }
65
        }
65
        }