OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 17 Rev 182
Line 1... Line 1...
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011-2019 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
9
 * language governing permissions and limitations under the License.
Line 15... Line 15...
15
 
15
 
16
import org.openconcerto.sql.changer.Changer;
16
import org.openconcerto.sql.changer.Changer;
17
import org.openconcerto.sql.model.DBSystemRoot;
17
import org.openconcerto.sql.model.DBSystemRoot;
18
import org.openconcerto.sql.model.SQLBase;
18
import org.openconcerto.sql.model.SQLBase;
19
import org.openconcerto.sql.model.SQLField;
19
import org.openconcerto.sql.model.SQLField;
20
import org.openconcerto.sql.model.SQLSelect;
-
 
21
import org.openconcerto.sql.model.SQLSystem;
20
import org.openconcerto.sql.model.SQLSystem;
22
import org.openconcerto.sql.model.SQLTable;
21
import org.openconcerto.sql.model.SQLTable;
23
 
22
 
24
import java.sql.ResultSet;
23
import java.sql.ResultSet;
25
import java.sql.SQLException;
24
import java.sql.SQLException;
Line 47... Line 46...
47
    }
46
    }
48
 
47
 
49
    @SuppressWarnings("unchecked")
48
    @SuppressWarnings("unchecked")
50
    @Override
49
    @Override
51
    protected void changeImpl(SQLTable t) throws SQLException {
50
    protected void changeImpl(SQLTable t) throws SQLException {
52
        final String infoSchema = SQLSelect.quote("SELECT TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE from information_schema.COLUMNS where TABLE_SCHEMA=%s and TABLE_NAME=%s", t.getBase()
51
        final String infoSchema = t.getBase().quote("SELECT TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE from information_schema.COLUMNS where TABLE_SCHEMA=%s and TABLE_NAME=%s",
53
                .getName(), t.getName());
52
                t.getBase().getName(), t.getName());
54
        final Map<String, Object> defaults = (Map<String, Object>) this.getDS().execute(infoSchema, new ResultSetHandler() {
53
        final Map<String, Object> defaults = (Map<String, Object>) this.getDS().execute(infoSchema, new ResultSetHandler() {
55
            public Object handle(ResultSet rs) throws SQLException {
54
            public Object handle(ResultSet rs) throws SQLException {
56
                final Map<String, Object> res = new HashMap<String, Object>();
55
                final Map<String, Object> res = new HashMap<String, Object>();
57
                while (rs.next()) {
56
                while (rs.next()) {
58
                    res.put(rs.getString("COLUMN_NAME"), rs.getObject("COLUMN_DEFAULT"));
57
                    res.put(rs.getString("COLUMN_NAME"), rs.getObject("COLUMN_DEFAULT"));