OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Compare Revisions

Regard whitespace Rev 141 → Rev 142

/trunk/OpenConcerto/src/org/openconcerto/erp/config/InstallationPanel.java
13,6 → 13,7
package org.openconcerto.erp.config;
 
import org.openconcerto.erp.config.update.Updater_1_5;
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeClient;
import org.openconcerto.erp.core.sales.quote.element.EtatDevisSQLElement;
import org.openconcerto.erp.modules.ModuleManager;
21,6 → 22,7
import org.openconcerto.sql.changer.convert.ChangeIDToInt;
import org.openconcerto.sql.changer.correct.CorrectOrder;
import org.openconcerto.sql.changer.correct.FixSerial;
import org.openconcerto.sql.element.GroupSQLComponent;
import org.openconcerto.sql.model.AliasedTable;
import org.openconcerto.sql.model.DBRoot;
import org.openconcerto.sql.model.DBSystemRoot;
47,6 → 49,8
import org.openconcerto.sql.sqlobject.SQLTextCombo;
import org.openconcerto.sql.utils.AlterTable;
import org.openconcerto.sql.utils.ChangeTable;
import org.openconcerto.sql.utils.ChangeTable.ClauseType;
import org.openconcerto.sql.utils.ChangeTable.DeferredClause;
import org.openconcerto.sql.utils.ReOrder;
import org.openconcerto.sql.utils.SQLCreateMoveableTable;
import org.openconcerto.sql.utils.SQLCreateTable;
90,7 → 94,7
public class InstallationPanel extends JPanel {
private static final boolean DEBUG_FK = false;
 
static private void insertUndef(final SQLCreateTable ct) throws SQLException {
static public void insertUndef(final SQLCreateTable ct) throws SQLException {
// check that we can use insertReturnFirstField()
if (ct.getPrimaryKey().size() != 1)
throw new IllegalStateException("Not one and only one field in the PK : " + ct.getPrimaryKey());
302,6 → 306,10
final DSNInstallationUtils dsnUtils = new DSNInstallationUtils();
dsnUtils.updateDSNCommonTable(conf.getRoot());
 
// ECo contribution
final EcoContributionInstallationUtils ecoUtils = new EcoContributionInstallationUtils();
ecoUtils.updateEcoCommonTable(conf.getRoot());
 
// we need to upgrade all roots
// ///////////////////////////
conf.getSystemRoot().mapAllRoots();
373,11 → 381,15
updateToV1Dot4(root);
// DSN
dsnUtils.updateDSN(root);
// Eco contribution
ecoUtils.updateEco(root);
updateStyle(root);
createBanque(root);
createAssocAnalytique(root, conf);
updateStock(root);
updateVille(root.getTable("ADRESSE"));
 
Updater_1_5.update(root);
return null;
}
 
1747,6 → 1759,65
}
}
 
SQLTable tableInfosSal = root.getTable("INFOS_SALARIE_PAYE");
if (!tableInfosSal.contains("ID_SALARIE")) {
// Ajout INFOS_SALARIE_PAYE.ID_SALARIE
AlterTable t = new AlterTable(tableInfosSal);
t.addForeignColumn("ID_SALARIE", root.getTable("SALARIE"));
 
try {
 
tableInfosSal.getBase().getDataSource().execute(t.asString());
tableInfosSal.getSchema().updateVersion();
tableInfosSal.fetchFields();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableInfosSal.getName(), ex);
}
 
// Ajout CONTRAT.DEBUT_CONTRAT
SQLTable tableContrat = root.getTable("CONTRAT_SALARIE");
AlterTable tContrat = new AlterTable(tableContrat);
tContrat.addDateAndTimeColumn("DATE_DEBUT");
tContrat.addDateAndTimeColumn("DATE_MODIFICATION");
// tContrat.addForeignColumn("ID_INFOS_SALARIE_PAYE_MODIFIE", tableInfosSal);
try {
tableContrat.getBase().getDataSource().execute(tContrat.asString());
tableContrat.getSchema().updateVersion();
tableContrat.fetchFields();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableContrat.getName(), ex);
}
 
// Ajout FICHE_PAYE.INFOS_SALARIE_PAYE
SQLTable tableFichePaye = root.getTable("FICHE_PAYE");
AlterTable tFicheSal = new AlterTable(tableFichePaye);
tFicheSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", root.getTable("INFOS_SALARIE_PAYE"));
try {
 
tableFichePaye.getBase().getDataSource().execute(tFicheSal.asString());
tableFichePaye.getSchema().updateVersion();
tableFichePaye.fetchFields();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableFichePaye.getName(), ex);
}
 
{
// Mise à jour des dates de début de contrat
UpdateBuilder builderContrat = new UpdateBuilder(tableContrat);
builderContrat.addBackwardVirtualJoin(tableInfosSal, "ID_CONTRAT_SALARIE");
builderContrat.setFromVirtualJoinField("DATE_DEBUT", tableInfosSal.getAlias(), "DATE_ARRIVE");
tableInfosSal.getDBSystemRoot().getDataSource().execute(builderContrat.asString());
}
{
// Mise à jour des INFOS_SALARIE_PAYE dans les fiches
SQLTable tableSalarie = root.getTable("SALARIE");
UpdateBuilder builderFiche = new UpdateBuilder(tableFichePaye);
builderFiche.addForwardVirtualJoin(tableSalarie, "ID_SALARIE");
builderFiche.setFromVirtualJoinField("ID_INFOS_SALARIE_PAYE", tableSalarie.getAlias(), "ID_INFOS_SALARIE_PAYE");
tableInfosSal.getDBSystemRoot().getDataSource().execute(builderFiche.asString());
}
}
 
// Cumuls paye
SQLTable tableCumulsPaye = root.getTable("CUMULS_PAYE");
 
1757,11 → 1828,35
tCumuls.alterColumn("SAL_BRUT_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
tCumuls.alterColumn("NET_A_PAYER_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
tCumuls.alterColumn("CSG_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
if (!tableCumulsPaye.contains("HEURE_TRAV")) {
tCumuls.addDecimalColumn("HEURE_TRAV", 16, 2, BigDecimal.ZERO, false);
if (tableCumulsPaye.contains("HEURE_TRAV") && !tableCumulsPaye.contains("HEURE_TRAV_C")) {
 
AlterTable tColumnNameCumuls = new AlterTable(tableCumulsPaye);
 
tColumnNameCumuls.addClause(new DeferredClause() {
@Override
public String asString(ChangeTable<?> ct, SQLName tableName) {
return (root.getServer().getSQLSystem() == SQLSystem.POSTGRESQL ? "RENAME COLUMN \"HEURE_TRAV\" TO \"HEURE_TRAV_C\"" : "ALTER COLUMN \"HEURE_TRAV\" RENAME TO \"HEURE_TRAV_C\"");
}
 
@Override
public ClauseType getType() {
return ClauseType.OTHER;
}
});
try {
 
tableCumulsPaye.getBase().getDataSource().execute(tColumnNameCumuls.asString());
tableCumulsPaye.getSchema().updateVersion();
tableCumulsPaye.fetchFields();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la modification du champ de la table " + tableCumulsPaye.getName(), ex);
}
} else if (!tableCumulsPaye.contains("HEURE_TRAV_C")) {
tCumuls.addDecimalColumn("HEURE_TRAV_C", 16, 2, BigDecimal.ZERO, false);
}
 
try {
 
tableCumulsPaye.getBase().getDataSource().execute(tCumuls.asString());
tableCumulsPaye.getSchema().updateVersion();
tableCumulsPaye.fetchFields();
2265,7 → 2360,10
if (tableClient != null) {
AlterTable t = new AlterTable(tableClient);
boolean upClient = false;
 
if (!tableClient.contains("REMIND_DATE")) {
t.addDateAndTimeColumn("REMIND_DATE");
upClient = true;
}
if (!tableClient.contains("BLOQUE_LIVRAISON")) {
t.addBooleanColumn("BLOQUE_LIVRAISON", false, false);
upClient = true;
2361,6 → 2459,8
createTaskTable.addForeignColumn(createTaskGroupTable);
createTaskTable.addLongColumn("SOURCE_ID", null, true);
createTaskTable.addVarCharColumn("SOURCE_TABLE", 256);
createTaskTable.addVarCharColumn("UID", 1024);
createTaskTable.addVarCharColumn("LOCATION", 4096);
try {
root.getDBSystemRoot().getDataSource().execute(createTaskGroupTable.asString());
insertUndef(createTaskGroupTable);
2367,6 → 2467,9
root.getDBSystemRoot().getDataSource().execute(createTaskTable.asString());
insertUndef(createTaskTable);
tableDevis.getSchema().updateVersion();
root.refetchTable("CALENDAR_ITEM_GROUP");
root.refetchTable("CALENDAR_ITEM");
 
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de la création de la table TASK", ex);
}
2478,8 → 2581,34
if (numerotationFixed) {
rNumerotation.commit();
}
 
//
 
final SQLTable tableCalendarItem = root.getTable("CALENDAR_ITEM");
if (tableCalendarItem != null) {
final AlterTable tVF = new AlterTable(tableCalendarItem);
boolean needUpdate = false;
if (!tableCalendarItem.getFieldsName().contains("UID")) {
tVF.addVarCharColumn("UID", 1024);
needUpdate = true;
}
if (!tableCalendarItem.getFieldsName().contains("LOCATION")) {
tVF.addVarCharColumn("LOCATION", 4096);
needUpdate = true;
}
if (needUpdate) {
try {
tableCalendarItem.getBase().getDataSource().execute(tVF.asString());
tableCalendarItem.getSchema().updateVersion();
tableCalendarItem.fetchFields();
} catch (SQLException ex) {
throw new IllegalStateException("Erreur lors de l'ajout de UID sur la table CALENDAR_ITEM", ex);
}
}
}
 
}
 
private void updateStyle(final DBRoot root) throws SQLException {
SQLTable style = root.getTable("STYLE");
SQLRowValues rowVals = new SQLRowValues(style);
3622,7 → 3751,7
CorrectOrder orderCorrect = new CorrectOrder(sysRoot);
orderCorrect.change(tableCommercial);
 
new AddFK(sysRoot).changeAll(root);
// new AddFK(sysRoot).changeAll(root);
sysRoot.reload(Collections.singleton(root.getName()));
 
try {
3811,9 → 3940,9
rowValsUserRight.put("HAVE_RIGHT", Boolean.TRUE);
rowValsUserRight.commit();
}
if (!codes.contains("GROUP_ITEM_SHOW")) {
if (!codes.contains(GroupSQLComponent.ITEM_RIGHT_CODE)) {
SQLRowValues rowVals = new SQLRowValues(table);
rowVals.put("CODE", "GROUP_ITEM_SHOW");
rowVals.put("CODE", GroupSQLComponent.ITEM_RIGHT_CODE);
rowVals.put("NOM", "Autoriser à visualiser un champ");
String desc = "Autorise un utilisateur à visualiser le champ spécifié en objet dans une interface.";
rowVals.put("DESCRIPTION", desc);
4092,6 → 4221,16
alter = true;
}
 
if (!table.getFieldsName().contains("ID_COMPTE_PCE_AVANCE_CLIENT")) {
t.addForeignColumn("ID_COMPTE_PCE_AVANCE_CLIENT", root.getTable("COMPTE_PCE"));
alter = true;
}
 
if (!table.getFieldsName().contains("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT")) {
t.addForeignColumn("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", root.getTable("COMPTE_PCE"));
alter = true;
}
 
if (!table.getFieldsName().contains("ID_COMPTE_PCE_PORT_NON_SOUMIS")) {
t.addForeignColumn("ID_COMPTE_PCE_PORT_NON_SOUMIS", root.getTable("COMPTE_PCE"));
alter = true;
4128,8 → 4267,22
rowVals.commit();
}
 
if (!prefs.contains("AvanceClients")) {
SQLRowValues rowVals = new SQLRowValues(table);
rowVals.put("NOM", "AvanceClients");
rowVals.put("NUMERO_DEFAULT", "4191");
rowVals.commit();
}
 
if (!prefs.contains("ValeurEncaissement")) {
SQLRowValues rowVals = new SQLRowValues(table);
rowVals.put("NOM", "ValeurEncaissement");
rowVals.put("NUMERO_DEFAULT", "511");
rowVals.commit();
}
 
}
 
private void updateSocieteTable(DBRoot root) throws SQLException {
SQLTable table = root.findTable("SOCIETE_COMMON");
boolean alter = false;