OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 132 Rev 156
Line 11... Line 11...
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.erp.config;
14
 package org.openconcerto.erp.config;
15
 
15
 
-
 
16
import org.openconcerto.sql.model.SQLRow;
16
import org.openconcerto.sql.model.SQLRowValues;
17
import org.openconcerto.sql.model.SQLRowValues;
-
 
18
import org.openconcerto.sql.model.SQLSelect;
17
import org.openconcerto.sql.model.SQLTable;
19
import org.openconcerto.sql.model.SQLTable;
-
 
20
import org.openconcerto.utils.Tuple2;
18
import org.openconcerto.utils.Tuple3;
21
import org.openconcerto.utils.Tuple3;
19
 
22
 
20
import java.sql.SQLException;
23
import java.sql.SQLException;
21
import java.util.ArrayList;
24
import java.util.ArrayList;
22
import java.util.List;
25
import java.util.List;
Line 116... Line 119...
116
            rowVals.put("TYPE", tuple3.get2());
119
            rowVals.put("TYPE", tuple3.get2());
117
            rowVals.insert();
120
            rowVals.insert();
118
        }
121
        }
119
    }
122
    }
120
 
123
 
-
 
124
    public void updateTable(List<Tuple3<String, String, String>> values, SQLTable table) throws SQLException {
-
 
125
        SQLSelect sel = new SQLSelect();
-
 
126
        sel.addSelect(table.getField("CODE"));
-
 
127
        sel.addSelect(table.getField("TYPE"));
-
 
128
        List<SQLRow> existingRows = new ArrayList<>();
-
 
129
        List<Tuple2<String, String>> existingCode = new ArrayList<>();
-
 
130
        for (SQLRow sqlRow : existingRows) {
-
 
131
            existingCode.add(Tuple2.create(sqlRow.getString("CODE"), sqlRow.getString("TYPE")));
-
 
132
        }
-
 
133
        for (Tuple3<String, String, String> tuple3 : values) {
-
 
134
            if (!existingCode.contains(Tuple2.create(tuple3.get0(), tuple3.get2()))) {
-
 
135
                SQLRowValues rowVals = new SQLRowValues(table);
-
 
136
                rowVals.put("CODE", tuple3.get0());
-
 
137
                rowVals.put("NOM", tuple3.get1());
-
 
138
                rowVals.put("TYPE", tuple3.get2());
-
 
139
                rowVals.insert();
-
 
140
            }
-
 
141
        }
-
 
142
    }
121
}
143
}