OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 19 | Rev 25 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19 Rev 20
Line 17... Line 17...
17
import org.openconcerto.sql.model.SQLField.Properties;
17
import org.openconcerto.sql.model.SQLField.Properties;
18
import org.openconcerto.sql.model.SQLName;
18
import org.openconcerto.sql.model.SQLName;
19
import org.openconcerto.sql.model.SQLSyntax;
19
import org.openconcerto.sql.model.SQLSyntax;
20
import org.openconcerto.sql.model.SQLTable;
20
import org.openconcerto.sql.model.SQLTable;
21
import org.openconcerto.sql.utils.AlterTable;
21
import org.openconcerto.sql.utils.AlterTable;
-
 
22
import org.openconcerto.sql.utils.SQLCreateTableBase;
22
import org.openconcerto.utils.CollectionUtils;
23
import org.openconcerto.utils.CollectionUtils;
23
 
24
 
24
import java.util.HashSet;
25
import java.util.HashSet;
25
import java.util.List;
26
import java.util.List;
26
import java.util.Set;
27
import java.util.Set;
Line 95... Line 96...
95
    public final AlterTable addDateAndTimeColumn(String name) {
96
    public final AlterTable addDateAndTimeColumn(String name) {
96
        addCol(name);
97
        addCol(name);
97
        return this.alter.addDateAndTimeColumn(name);
98
        return this.alter.addDateAndTimeColumn(name);
98
    }
99
    }
99
 
100
 
-
 
101
    public final AlterTable addIntegerColumn(String name, int defaultVal) {
-
 
102
        addCol(name);
-
 
103
        return this.alter.addIntegerColumn(name, defaultVal);
-
 
104
    }
-
 
105
 
100
    public AlterTable addForeignColumn(String fk, String table) {
106
    public AlterTable addForeignColumn(String fk, String table) {
101
        return this.addForeignColumn(fk, new SQLName(table));
107
        return this.addForeignColumn(fk, new SQLName(table));
102
    }
108
    }
103
 
109
 
104
    public AlterTable addForeignColumn(String fk, SQLName tableName) {
110
    public AlterTable addForeignColumn(String fk, SQLName tableName) {
-
 
111
        SQLCreateTableBase<?> createTable;
105
        if (tableName.getItemCount() == 1 && this.ctxt.getAddedTables().contains(tableName.getFirst())) {
112
        if (tableName.getItemCount() == 1 && (createTable = this.ctxt.getCreateTables().get(tableName.getFirst())) != null) {
106
            addCol(fk);
113
            addCol(fk);
107
            // see DBContext.execute()
-
 
108
            return this.alter.addForeignColumn(fk, tableName, SQLSyntax.ID_NAME, "NULL");
114
            return this.alter.addForeignColumn(fk, createTable);
109
        } else {
115
        } else {
110
            return this.addForeignColumn(fk, this.table.getDesc(tableName, SQLTable.class));
116
            return this.addForeignColumn(fk, this.table.getDesc(tableName, SQLTable.class));
111
        }
117
        }
112
    }
118
    }
113
 
119