OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 61 → Rev 25

/trunk/OpenConcerto/src/org/openconcerto/erp/utils/ActionDB.java
27,9 → 27,9
import org.openconcerto.sql.model.SQLRowValues;
import org.openconcerto.sql.model.SQLSchema;
import org.openconcerto.sql.model.SQLSelect;
import org.openconcerto.sql.model.SQLSyntax;
import org.openconcerto.sql.model.SQLSystem;
import org.openconcerto.sql.model.SQLTable;
import org.openconcerto.sql.utils.ChangeTable.ConcatStep;
import org.openconcerto.sql.utils.SQLCreateRoot;
import org.openconcerto.utils.ExceptionHandler;
 
37,7 → 37,6
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
81,11 → 80,7
final SQLCreateRoot createRoot = baseSQLDefault.getDefinitionSQL(sysRoot.getServer().getSQLSystem());
final SQLDataSource ds = sysRoot.getDataSource();
// be safe don't add DROP SCHEMA
final List<String> sql = createRoot.asStringList(newBase, false, true, EnumSet.of(ConcatStep.ADD_FOREIGN));
// create root
ds.execute(sql.get(0));
// create tables (without constraints)
ds.execute(sql.get(1));
ds.execute(createRoot.asString(newBase, false, true));
sysRoot.getRootsToMap().add(newBase);
// TODO find a more functional way
final boolean origVal = Boolean.getBoolean(SQLSchema.NOAUTO_CREATE_METADATA);
98,6 → 93,10
 
final Set<SQLTable> newTables = baseSQLNew.getTables();
int i = 0;
final SQLSyntax syntax = sysRoot.getServer().getSQLSystem().getSyntax();
// MAYBE SQLCreateRoot can avoid creating foreign constraints, then we insert data,
// finally SQLCreateRoot adds just the constraints
ds.execute(syntax.disableFKChecks(baseSQLNew));
for (final SQLTable table : newTables) {
String tableName = table.getName();
 
107,11 → 106,9
log(l, "Table " + tableName + " " + (i + 1) + "/" + newTables.size() + " OK");
i++;
}
// create constraints
ds.execute(sql.get(2));
assert sql.size() == 3;
ds.execute(syntax.enableFKChecks(baseSQLNew));
 
if (sysRoot.getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
if (syntax.getSystem() == SQLSystem.POSTGRESQL) {
log(l, "Maj des séquences des tables");
new FixSerial(sysRoot).changeAll(baseSQLNew);
}