OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 156 Rev 174
Line 47... Line 47...
47
import org.openconcerto.sql.model.graph.SQLKey;
47
import org.openconcerto.sql.model.graph.SQLKey;
48
import org.openconcerto.sql.request.Inserter;
48
import org.openconcerto.sql.request.Inserter;
49
import org.openconcerto.sql.request.Inserter.Insertion;
49
import org.openconcerto.sql.request.Inserter.Insertion;
50
import org.openconcerto.sql.request.UpdateBuilder;
50
import org.openconcerto.sql.request.UpdateBuilder;
51
import org.openconcerto.sql.sqlobject.SQLTextCombo;
51
import org.openconcerto.sql.sqlobject.SQLTextCombo;
-
 
52
import org.openconcerto.sql.users.rights.TableAllRights;
52
import org.openconcerto.sql.utils.AlterTable;
53
import org.openconcerto.sql.utils.AlterTable;
53
import org.openconcerto.sql.utils.ChangeTable;
54
import org.openconcerto.sql.utils.ChangeTable;
54
import org.openconcerto.sql.utils.ChangeTable.ClauseType;
55
import org.openconcerto.sql.utils.ChangeTable.ClauseType;
55
import org.openconcerto.sql.utils.ChangeTable.DeferredClause;
56
import org.openconcerto.sql.utils.ChangeTable.DeferredClause;
56
import org.openconcerto.sql.utils.ReOrder;
57
import org.openconcerto.sql.utils.ReOrder;
Line 61... Line 62...
61
import org.openconcerto.ui.DefaultGridBagConstraints;
62
import org.openconcerto.ui.DefaultGridBagConstraints;
62
import org.openconcerto.ui.JLabelBold;
63
import org.openconcerto.ui.JLabelBold;
63
import org.openconcerto.utils.CollectionUtils;
64
import org.openconcerto.utils.CollectionUtils;
64
import org.openconcerto.utils.ExceptionHandler;
65
import org.openconcerto.utils.ExceptionHandler;
65
import org.openconcerto.utils.ProductInfo;
66
import org.openconcerto.utils.ProductInfo;
-
 
67
import org.openconcerto.utils.StringUtils;
66
import org.openconcerto.utils.cc.ITransformer;
68
import org.openconcerto.utils.cc.ITransformer;
67
 
69
 
68
import java.awt.GridBagConstraints;
70
import java.awt.GridBagConstraints;
69
import java.awt.GridBagLayout;
71
import java.awt.GridBagLayout;
70
import java.awt.Insets;
72
import java.awt.Insets;
Line 2385... Line 2387...
2385
            tableBonR.getSchema().updateVersion();
2387
            tableBonR.getSchema().updateVersion();
2386
            tableBonR.fetchFields();
2388
            tableBonR.fetchFields();
2387
        }
2389
        }
2388
        root.getTable("ARTICLE").getSchema().updateVersion();
2390
        root.getTable("ARTICLE").getSchema().updateVersion();
2389
        // Valeur par défaut des numérotations
2391
        // Valeur par défaut des numérotations
-
 
2392
        if (root.contains("NUMEROTATION_AUTO")) {
2390
        SQLRowValues rNumerotation = root.getTable("NUMEROTATION_AUTO").getRow(2).asRowValues();
2393
            SQLRow rowNumerotation = root.getTable("NUMEROTATION_AUTO").getRow(2);
-
 
2394
            if (rowNumerotation != null) {
-
 
2395
                SQLRowValues rNumerotation = rowNumerotation.asRowValues();
2391
        boolean numerotationFixed = false;
2396
                boolean numerotationFixed = false;
2392
        if (rNumerotation.getString("AVOIR_F_FORMAT").trim().isEmpty()) {
2397
                if (StringUtils.isEmpty(rNumerotation.getString("AVOIR_F_FORMAT"), true)) {
2393
            rNumerotation.put("AVOIR_F_FORMAT", "'AVOIR'yyMM-000");
2398
                    rNumerotation.put("AVOIR_F_FORMAT", "'AVOIR'yyMM-000");
-
 
2399
                    numerotationFixed = true;
2394
        }
2400
                }
2395
        if (rNumerotation.getString("CLIENT_FORMAT").trim().isEmpty()) {
2401
                if (StringUtils.isEmpty(rNumerotation.getString("CLIENT_FORMAT"), true)) {
2396
            rNumerotation.put("CLIENT_FORMAT", "'CLI'00000");
2402
                    rNumerotation.put("CLIENT_FORMAT", "'CLI'00000");
-
 
2403
                    numerotationFixed = true;
2397
        }
2404
                }
2398
        if (numerotationFixed) {
2405
                if (numerotationFixed) {
2399
            rNumerotation.commit();
2406
                    rNumerotation.commit();
2400
        }
2407
                }
-
 
2408
            }
2401
 
2409
        }
2402
        //
2410
        //
2403
 
2411
 
2404
        final SQLTable tableCalendarItem = root.getTable("CALENDAR_ITEM");
2412
        final SQLTable tableCalendarItem = root.getTable("CALENDAR_ITEM");
2405
        if (tableCalendarItem != null) {
2413
        if (tableCalendarItem != null) {
2406
            final AlterTable tVF = new AlterTable(tableCalendarItem);
2414
            final AlterTable tVF = new AlterTable(tableCalendarItem);
Line 3833... Line 3841...
3833
            rowValsUserRight.put("ID_RIGHT", row.getID());
3841
            rowValsUserRight.put("ID_RIGHT", row.getID());
3834
            rowValsUserRight.put("HAVE_RIGHT", Boolean.TRUE);
3842
            rowValsUserRight.put("HAVE_RIGHT", Boolean.TRUE);
3835
            rowValsUserRight.commit();
3843
            rowValsUserRight.commit();
3836
        }
3844
        }
3837
 
3845
 
-
 
3846
        if (!codes.contains(TableAllRights.USER_UI_LOCK_ROW)) {
-
 
3847
            SQLRowValues rowVals = new SQLRowValues(table);
-
 
3848
            rowVals.put("CODE", TableAllRights.USER_UI_LOCK_ROW);
-
 
3849
            rowVals.put("NOM", "Autoriser à verrouiller une ligne dans une liste.");
-
 
3850
            String desc = "Autorise un utilisateur à verrouiller une ou plusieurs dans les listes où cette fonctionnalité est active.";
-
 
3851
            rowVals.put("DESCRIPTION", desc);
-
 
3852
            SQLRow row = rowVals.commit();
-
 
3853
            SQLRowValues rowValsUserRight = new SQLRowValues(table.getTable("USER_RIGHT"));
-
 
3854
            rowValsUserRight.put("ID_RIGHT", row.getID());
-
 
3855
            rowValsUserRight.put("HAVE_RIGHT", Boolean.TRUE);
-
 
3856
            rowValsUserRight.commit();
-
 
3857
        }
-
 
3858
 
-
 
3859
        if (!codes.contains(TableAllRights.USER_UI_UNLOCK_ROW)) {
-
 
3860
            SQLRowValues rowVals = new SQLRowValues(table);
-
 
3861
            rowVals.put("CODE", TableAllRights.USER_UI_UNLOCK_ROW);
-
 
3862
            rowVals.put("NOM", "Autoriser à déverrouiller une ligne dans une liste.");
-
 
3863
            String desc = "Autorise un utilisateur à déverrouiller une ou plusieurs dans les listes où cette fonctionnalité est active.";
-
 
3864
            rowVals.put("DESCRIPTION", desc);
-
 
3865
            SQLRow row = rowVals.commit();
-
 
3866
            SQLRowValues rowValsUserRight = new SQLRowValues(table.getTable("USER_RIGHT"));
-
 
3867
            rowValsUserRight.put("ID_RIGHT", row.getID());
-
 
3868
            rowValsUserRight.put("HAVE_RIGHT", Boolean.TRUE);
-
 
3869
            rowValsUserRight.commit();
-
 
3870
        }
-
 
3871
 
3838
    }
3872
    }
3839
 
3873
 
3840
    private void findBadForeignKey(DBRoot root) {
3874
    private void findBadForeignKey(DBRoot root) {
3841
        Set<SQLTable> tables = root.getTables();
3875
        Set<SQLTable> tables = root.getTables();
3842
        for (SQLTable table : tables) {
3876
        for (SQLTable table : tables) {
Line 3973... Line 4007...
3973
            Updater_1_5.exec(alter);
4007
            Updater_1_5.exec(alter);
3974
        }
4008
        }
3975
 
4009
 
3976
        // FK
4010
        // FK
3977
        new AddFK(root.getDBSystemRoot()).changeAll(root);
4011
        new AddFK(root.getDBSystemRoot()).changeAll(root);
-
 
4012
 
-
 
4013
        // Couleur
-
 
4014
        final SQLTable tableUser = root.getTable("USER_COMMON");
-
 
4015
        if (!tableUser.contains("COLOR")) {
-
 
4016
            final AlterTable alter = new AlterTable(tableUser);
-
 
4017
            alter.addIntegerColumn("COLOR", 0, false);
-
 
4018
            Updater_1_5.exec(alter);
-
 
4019
        }
-
 
4020
 
3978
    }
4021
    }
3979
 
4022
 
3980
    protected void fixCompletion(DBRoot root) throws SQLException {
4023
    protected void fixCompletion(DBRoot root) throws SQLException {
3981
        final SQLTable completionT = root.getTable(SQLTextCombo.getTableName());
4024
        final SQLTable completionT = root.getTable(SQLTextCombo.getTableName());
3982
        if (completionT != null && completionT.getPrimaryKeys().size() == 0) {
4025
        if (completionT != null && completionT.getPrimaryKeys().size() == 0) {
Line 4025... Line 4068...
4025
        if (!table.getFieldsName().contains("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT")) {
4068
        if (!table.getFieldsName().contains("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT")) {
4026
            t.addForeignColumn("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", root.getTable("COMPTE_PCE"));
4069
            t.addForeignColumn("ID_COMPTE_PCE_VALEUR_ENCAISSEMENT", root.getTable("COMPTE_PCE"));
4027
            alter = true;
4070
            alter = true;
4028
        }
4071
        }
4029
 
4072
 
-
 
4073
        if (!table.getFieldsName().contains("ID_JOURNAL_VALEUR_ENCAISSEMENT")) {
-
 
4074
            t.addForeignColumn("ID_JOURNAL_VALEUR_ENCAISSEMENT", root.getTable("JOURNAL"));
-
 
4075
            alter = true;
-
 
4076
        }
-
 
4077
 
4030
        if (!table.getFieldsName().contains("ID_COMPTE_PCE_PORT_NON_SOUMIS")) {
4078
        if (!table.getFieldsName().contains("ID_COMPTE_PCE_PORT_NON_SOUMIS")) {
4031
            t.addForeignColumn("ID_COMPTE_PCE_PORT_NON_SOUMIS", root.getTable("COMPTE_PCE"));
4079
            t.addForeignColumn("ID_COMPTE_PCE_PORT_NON_SOUMIS", root.getTable("COMPTE_PCE"));
4032
            alter = true;
4080
            alter = true;
4033
        }
4081
        }
4034
 
4082
 
Line 4623... Line 4671...
4623
 
4671
 
4624
                            }
4672
                            }
4625
 
4673
 
4626
                            // at the end to let Updater_1_5 change field types from varchar to text
4674
                            // at the end to let Updater_1_5 change field types from varchar to text
4627
                            fixUnboundedVarchar(root);
4675
                            fixUnboundedVarchar(root);
4628
 
-
 
4629
                            return null;
4676
                            return null;
4630
                        }
4677
                        }
4631
 
4678
 
4632
                    });
4679
                    });
4633
                }
4680
                }