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 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.
|
10 |
*
|
10 |
*
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
12 |
*/
|
12 |
*/
|
13 |
|
13 |
|
14 |
package org.openconcerto.erp.config;
|
14 |
package org.openconcerto.erp.config;
|
15 |
|
15 |
|
16 |
import org.openconcerto.erp.config.update.Updater_1_5;
|
16 |
import org.openconcerto.erp.config.update.Updater_1_5;
|
17 |
import org.openconcerto.erp.core.humanresources.payroll.report.LignePayeSimplifiee;
|
17 |
import org.openconcerto.erp.core.humanresources.payroll.report.LignePayeSimplifiee;
|
18 |
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeClient;
|
18 |
import org.openconcerto.erp.core.sales.order.ui.EtatCommandeClient;
|
19 |
import org.openconcerto.erp.core.sales.quote.element.EtatDevisSQLElement;
|
19 |
import org.openconcerto.erp.core.sales.quote.element.EtatDevisSQLElement;
|
20 |
import org.openconcerto.erp.modules.ModuleManager;
|
20 |
import org.openconcerto.erp.modules.ModuleManager;
|
21 |
import org.openconcerto.erp.modules.ModuleReference;
|
21 |
import org.openconcerto.erp.modules.ModuleReference;
|
- |
|
22 |
import org.openconcerto.sql.Configuration;
|
22 |
import org.openconcerto.sql.changer.convert.AddFK;
|
23 |
import org.openconcerto.sql.changer.convert.AddFK;
|
23 |
import org.openconcerto.sql.changer.convert.ChangeIDToInt;
|
24 |
import org.openconcerto.sql.changer.convert.ChangeIDToInt;
|
24 |
import org.openconcerto.sql.changer.correct.CorrectOrder;
|
25 |
import org.openconcerto.sql.changer.correct.CorrectOrder;
|
25 |
import org.openconcerto.sql.changer.correct.FixSerial;
|
26 |
import org.openconcerto.sql.changer.correct.FixSerial;
|
26 |
import org.openconcerto.sql.element.GroupSQLComponent;
|
27 |
import org.openconcerto.sql.element.GroupSQLComponent;
|
27 |
import org.openconcerto.sql.model.AliasedTable;
|
28 |
import org.openconcerto.sql.model.AliasedTable;
|
28 |
import org.openconcerto.sql.model.DBRoot;
|
29 |
import org.openconcerto.sql.model.DBRoot;
|
29 |
import org.openconcerto.sql.model.DBSystemRoot;
|
30 |
import org.openconcerto.sql.model.DBSystemRoot;
|
30 |
import org.openconcerto.sql.model.SQLBase;
|
31 |
import org.openconcerto.sql.model.SQLBase;
|
31 |
import org.openconcerto.sql.model.SQLDataSource;
|
32 |
import org.openconcerto.sql.model.SQLDataSource;
|
32 |
import org.openconcerto.sql.model.SQLField;
|
33 |
import org.openconcerto.sql.model.SQLField;
|
33 |
import org.openconcerto.sql.model.SQLField.Properties;
|
34 |
import org.openconcerto.sql.model.SQLField.Properties;
|
34 |
import org.openconcerto.sql.model.SQLInjector;
|
35 |
import org.openconcerto.sql.model.SQLInjector;
|
35 |
import org.openconcerto.sql.model.SQLName;
|
36 |
import org.openconcerto.sql.model.SQLName;
|
36 |
import org.openconcerto.sql.model.SQLRow;
|
37 |
import org.openconcerto.sql.model.SQLRow;
|
37 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
38 |
import org.openconcerto.sql.model.SQLRowListRSH;
|
38 |
import org.openconcerto.sql.model.SQLRowValues;
|
39 |
import org.openconcerto.sql.model.SQLRowValues;
|
39 |
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
|
40 |
import org.openconcerto.sql.model.SQLRowValuesListFetcher;
|
40 |
import org.openconcerto.sql.model.SQLSchema;
|
41 |
import org.openconcerto.sql.model.SQLSchema;
|
41 |
import org.openconcerto.sql.model.SQLSelect;
|
42 |
import org.openconcerto.sql.model.SQLSelect;
|
42 |
import org.openconcerto.sql.model.SQLSyntax;
|
43 |
import org.openconcerto.sql.model.SQLSyntax;
|
43 |
import org.openconcerto.sql.model.SQLSystem;
|
44 |
import org.openconcerto.sql.model.SQLSystem;
|
44 |
import org.openconcerto.sql.model.SQLTable;
|
45 |
import org.openconcerto.sql.model.SQLTable;
|
45 |
import org.openconcerto.sql.model.Where;
|
46 |
import org.openconcerto.sql.model.Where;
|
46 |
import org.openconcerto.sql.model.graph.SQLKey;
|
47 |
import org.openconcerto.sql.model.graph.SQLKey;
|
47 |
import org.openconcerto.sql.request.Inserter;
|
48 |
import org.openconcerto.sql.request.Inserter;
|
48 |
import org.openconcerto.sql.request.Inserter.Insertion;
|
49 |
import org.openconcerto.sql.request.Inserter.Insertion;
|
49 |
import org.openconcerto.sql.request.UpdateBuilder;
|
50 |
import org.openconcerto.sql.request.UpdateBuilder;
|
50 |
import org.openconcerto.sql.sqlobject.SQLTextCombo;
|
51 |
import org.openconcerto.sql.sqlobject.SQLTextCombo;
|
51 |
import org.openconcerto.sql.utils.AlterTable;
|
52 |
import org.openconcerto.sql.utils.AlterTable;
|
52 |
import org.openconcerto.sql.utils.ChangeTable;
|
53 |
import org.openconcerto.sql.utils.ChangeTable;
|
53 |
import org.openconcerto.sql.utils.ChangeTable.ClauseType;
|
54 |
import org.openconcerto.sql.utils.ChangeTable.ClauseType;
|
54 |
import org.openconcerto.sql.utils.ChangeTable.DeferredClause;
|
55 |
import org.openconcerto.sql.utils.ChangeTable.DeferredClause;
|
55 |
import org.openconcerto.sql.utils.ReOrder;
|
56 |
import org.openconcerto.sql.utils.ReOrder;
|
56 |
import org.openconcerto.sql.utils.SQLCreateMoveableTable;
|
57 |
import org.openconcerto.sql.utils.SQLCreateMoveableTable;
|
57 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
58 |
import org.openconcerto.sql.utils.SQLCreateTable;
|
58 |
import org.openconcerto.sql.utils.SQLUtils;
|
59 |
import org.openconcerto.sql.utils.SQLUtils;
|
59 |
import org.openconcerto.sql.utils.SQLUtils.SQLFactory;
|
60 |
import org.openconcerto.sql.utils.SQLUtils.SQLFactory;
|
60 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
61 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
61 |
import org.openconcerto.ui.JLabelBold;
|
62 |
import org.openconcerto.ui.JLabelBold;
|
62 |
import org.openconcerto.utils.CollectionUtils;
|
63 |
import org.openconcerto.utils.CollectionUtils;
|
63 |
import org.openconcerto.utils.ExceptionHandler;
|
64 |
import org.openconcerto.utils.ExceptionHandler;
|
64 |
import org.openconcerto.utils.ProductInfo;
|
65 |
import org.openconcerto.utils.ProductInfo;
|
65 |
import org.openconcerto.utils.cc.ITransformer;
|
66 |
import org.openconcerto.utils.cc.ITransformer;
|
66 |
|
67 |
|
67 |
import java.awt.GridBagConstraints;
|
68 |
import java.awt.GridBagConstraints;
|
68 |
import java.awt.GridBagLayout;
|
69 |
import java.awt.GridBagLayout;
|
69 |
import java.awt.Insets;
|
70 |
import java.awt.Insets;
|
70 |
import java.awt.event.ActionEvent;
|
71 |
import java.awt.event.ActionEvent;
|
71 |
import java.awt.event.ActionListener;
|
72 |
import java.awt.event.ActionListener;
|
72 |
import java.io.IOException;
|
73 |
import java.io.IOException;
|
73 |
import java.math.BigDecimal;
|
74 |
import java.math.BigDecimal;
|
74 |
import java.sql.SQLException;
|
75 |
import java.sql.SQLException;
|
75 |
import java.sql.Types;
|
76 |
import java.sql.Types;
|
76 |
import java.util.ArrayList;
|
77 |
import java.util.ArrayList;
|
77 |
import java.util.Arrays;
|
78 |
import java.util.Arrays;
|
78 |
import java.util.Collection;
|
79 |
import java.util.Collection;
|
79 |
import java.util.Collections;
|
80 |
import java.util.Collections;
|
80 |
import java.util.EnumSet;
|
81 |
import java.util.EnumSet;
|
81 |
import java.util.HashMap;
|
82 |
import java.util.HashMap;
|
82 |
import java.util.HashSet;
|
83 |
import java.util.HashSet;
|
83 |
import java.util.List;
|
84 |
import java.util.List;
|
84 |
import java.util.Map;
|
85 |
import java.util.Map;
|
85 |
import java.util.Set;
|
86 |
import java.util.Set;
|
86 |
|
87 |
|
87 |
import javax.swing.JButton;
|
88 |
import javax.swing.JButton;
|
88 |
import javax.swing.JLabel;
|
89 |
import javax.swing.JLabel;
|
89 |
import javax.swing.JOptionPane;
|
90 |
import javax.swing.JOptionPane;
|
90 |
import javax.swing.JPanel;
|
91 |
import javax.swing.JPanel;
|
91 |
import javax.swing.JProgressBar;
|
92 |
import javax.swing.JProgressBar;
|
92 |
import javax.swing.JTextField;
|
93 |
import javax.swing.JTextField;
|
93 |
import javax.swing.SwingUtilities;
|
94 |
import javax.swing.SwingUtilities;
|
94 |
|
95 |
|
95 |
public class InstallationPanel extends JPanel {
|
96 |
public class InstallationPanel extends JPanel {
|
96 |
private static final boolean DEBUG_FK = false;
|
97 |
private static final boolean DEBUG_FK = false;
|
97 |
|
98 |
|
98 |
public static void insertUndef(final SQLCreateTable ct) throws SQLException {
|
99 |
public static void insertUndef(final SQLCreateTable ct) throws SQLException {
|
99 |
// check that we can use insertReturnFirstField()
|
100 |
// check that we can use insertReturnFirstField()
|
100 |
if (ct.getPrimaryKey().size() != 1)
|
101 |
if (ct.getPrimaryKey().size() != 1)
|
101 |
throw new IllegalStateException("Not one and only one field in the PK : " + ct.getPrimaryKey());
|
102 |
throw new IllegalStateException("Not one and only one field in the PK : " + ct.getPrimaryKey());
|
102 |
final Insertion<?> insertion = new Inserter(ct).insertReturnFirstField("(" + SQLBase.quoteIdentifier(SQLSyntax.ORDER_NAME) + ") VALUES(" + ReOrder.MIN_ORDER + ")", false);
|
103 |
final Insertion<?> insertion = new Inserter(ct).insertReturnFirstField("(" + SQLBase.quoteIdentifier(SQLSyntax.ORDER_NAME) + ") VALUES(" + ReOrder.MIN_ORDER + ")", false);
|
103 |
assert insertion.getCount() == 1;
|
104 |
assert insertion.getCount() == 1;
|
104 |
if (insertion.getRows().size() != 1)
|
105 |
if (insertion.getRows().size() != 1)
|
105 |
throw new IllegalStateException("Missing ID " + insertion.getRows());
|
106 |
throw new IllegalStateException("Missing ID " + insertion.getRows());
|
106 |
SQLTable.setUndefID(ct.getRoot().getSchema(), ct.getName(), ((Number) insertion.getRows().get(0)).intValue());
|
107 |
SQLTable.setUndefID(ct.getRoot().getSchema(), ct.getName(), ((Number) insertion.getRows().get(0)).intValue());
|
107 |
}
|
108 |
}
|
108 |
|
109 |
|
109 |
private static SQLName getTableName(final SQLCreateTable ct) {
|
110 |
private static SQLName getTableName(final SQLCreateTable ct) {
|
110 |
return new SQLName(ct.getRoot().getName(), ct.getName());
|
111 |
return new SQLName(ct.getRoot().getName(), ct.getName());
|
111 |
}
|
112 |
}
|
112 |
|
113 |
|
113 |
JProgressBar bar = new JProgressBar();
|
114 |
JProgressBar bar = new JProgressBar();
|
114 |
boolean error;
|
115 |
boolean error;
|
115 |
|
116 |
|
116 |
public InstallationPanel(final ServerFinderPanel finderPanel) {
|
117 |
public InstallationPanel(final ServerFinderPanel finderPanel) {
|
117 |
super(new GridBagLayout());
|
118 |
super(new GridBagLayout());
|
118 |
setOpaque(false);
|
119 |
setOpaque(false);
|
119 |
GridBagConstraints c = new DefaultGridBagConstraints();
|
120 |
GridBagConstraints c = new DefaultGridBagConstraints();
|
120 |
JButton user = new JButton("Créer l'utilisateur");
|
121 |
JButton user = new JButton("Créer l'utilisateur");
|
121 |
user.setOpaque(false);
|
122 |
user.setOpaque(false);
|
122 |
// JButton bd = new JButton("Créer la base de données");
|
123 |
// JButton bd = new JButton("Créer la base de données");
|
123 |
final JButton up = new JButton("Mise à niveau de la base");
|
124 |
final JButton up = new JButton("Mise à niveau de la base");
|
124 |
up.setOpaque(false);
|
125 |
up.setOpaque(false);
|
125 |
up.addActionListener(new ActionListener() {
|
126 |
up.addActionListener(new ActionListener() {
|
126 |
|
127 |
|
127 |
@Override
|
128 |
@Override
|
128 |
public void actionPerformed(ActionEvent e) {
|
129 |
public void actionPerformed(ActionEvent e) {
|
129 |
if (finderPanel != null) {
|
130 |
if (finderPanel != null) {
|
130 |
finderPanel.saveConfigFile();
|
131 |
finderPanel.saveConfigFile();
|
131 |
}
|
132 |
}
|
132 |
bar.setIndeterminate(true);
|
133 |
bar.setIndeterminate(true);
|
133 |
up.setEnabled(false);
|
134 |
up.setEnabled(false);
|
134 |
new Thread(new Runnable() {
|
135 |
new Thread(new Runnable() {
|
135 |
|
136 |
|
136 |
@Override
|
137 |
@Override
|
137 |
public void run() {
|
138 |
public void run() {
|
138 |
System.setProperty(SQLSchema.NOAUTO_CREATE_METADATA, "false");
|
139 |
System.setProperty(SQLSchema.NOAUTO_CREATE_METADATA, "false");
|
139 |
final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create(true);
|
140 |
final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create(true);
|
140 |
|
141 |
|
- |
|
142 |
final DBSystemRoot systemRoot = conf.getSystemRoot();
|
- |
|
143 |
if (systemRoot.getChild(conf.getRootNameValue().getValue()) == null) {
|
- |
|
144 |
conf.destroy();
|
- |
|
145 |
SwingUtilities.invokeLater(new Runnable() {
|
- |
|
146 |
@Override
|
- |
|
147 |
public void run() {
|
- |
|
148 |
up.setEnabled(true);
|
- |
|
149 |
bar.setValue(bar.getMaximum());
|
- |
|
150 |
JOptionPane.showMessageDialog(InstallationPanel.this, "Votre base de données n'est pas initialisée");
|
- |
|
151 |
}
|
- |
|
152 |
});
|
- |
|
153 |
return;
|
- |
|
154 |
}
|
- |
|
155 |
|
141 |
updateDatabase(conf);
|
156 |
updateDatabase(conf);
|
142 |
|
157 |
|
143 |
conf.destroy();
|
158 |
conf.destroy();
|
144 |
SwingUtilities.invokeLater(new Runnable() {
|
159 |
SwingUtilities.invokeLater(new Runnable() {
|
145 |
|
160 |
|
146 |
@Override
|
161 |
@Override
|
147 |
public void run() {
|
162 |
public void run() {
|
148 |
up.setEnabled(true);
|
163 |
up.setEnabled(true);
|
149 |
bar.setValue(bar.getMaximum());
|
164 |
bar.setValue(bar.getMaximum());
|
150 |
if (!error) {
|
165 |
if (!error) {
|
151 |
JOptionPane.showMessageDialog(InstallationPanel.this, "Mise à niveau réussie");
|
166 |
JOptionPane.showMessageDialog(InstallationPanel.this, "Mise à niveau réussie");
|
152 |
}
|
167 |
}
|
153 |
}
|
168 |
}
|
154 |
});
|
169 |
});
|
155 |
System.setProperty(SQLSchema.NOAUTO_CREATE_METADATA, "true");
|
170 |
System.setProperty(SQLSchema.NOAUTO_CREATE_METADATA, "true");
|
156 |
}
|
171 |
}
|
157 |
}, "Database structure updater").start();
|
172 |
}, "Database structure updater").start();
|
158 |
|
173 |
|
159 |
}
|
174 |
}
|
160 |
|
175 |
|
161 |
});
|
176 |
});
|
162 |
if (finderPanel != null && finderPanel.getToken() == null) {
|
177 |
if (finderPanel != null && finderPanel.getToken() == null) {
|
163 |
c.weightx = 1;
|
178 |
c.weightx = 1;
|
164 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
179 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
165 |
this.add(new JLabelBold("Création de l'utilisateur openconcerto dans la base"), c);
|
180 |
this.add(new JLabelBold("Création de l'utilisateur openconcerto dans la base"), c);
|
166 |
c.gridy++;
|
181 |
c.gridy++;
|
167 |
c.weightx = 1;
|
182 |
c.weightx = 1;
|
168 |
this.add(new JLabel("Identifiant de connexion de votre base "), c);
|
183 |
this.add(new JLabel("Identifiant de connexion de votre base "), c);
|
169 |
c.gridy++;
|
184 |
c.gridy++;
|
170 |
c.gridwidth = 1;
|
185 |
c.gridwidth = 1;
|
171 |
c.weightx = 0;
|
186 |
c.weightx = 0;
|
172 |
this.add(new JLabel("Login"), c);
|
187 |
this.add(new JLabel("Login"), c);
|
173 |
c.gridx++;
|
188 |
c.gridx++;
|
174 |
|
189 |
|
175 |
final JTextField login = new JTextField();
|
190 |
final JTextField login = new JTextField();
|
176 |
c.weightx = 1;
|
191 |
c.weightx = 1;
|
177 |
this.add(login, c);
|
192 |
this.add(login, c);
|
178 |
|
193 |
|
179 |
c.gridx++;
|
194 |
c.gridx++;
|
180 |
c.weightx = 0;
|
195 |
c.weightx = 0;
|
181 |
this.add(new JLabel("Mot de passe"), c);
|
196 |
this.add(new JLabel("Mot de passe"), c);
|
182 |
c.gridx++;
|
197 |
c.gridx++;
|
183 |
final JTextField mdp = new JTextField();
|
198 |
final JTextField mdp = new JTextField();
|
184 |
c.weightx = 1;
|
199 |
c.weightx = 1;
|
185 |
this.add(mdp, c);
|
200 |
this.add(mdp, c);
|
186 |
|
201 |
|
187 |
c.gridx = 0;
|
202 |
c.gridx = 0;
|
188 |
c.gridy++;
|
203 |
c.gridy++;
|
189 |
c.weightx = 0;
|
204 |
c.weightx = 0;
|
190 |
c.anchor = GridBagConstraints.EAST;
|
205 |
c.anchor = GridBagConstraints.EAST;
|
191 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
206 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
192 |
c.fill = GridBagConstraints.NONE;
|
207 |
c.fill = GridBagConstraints.NONE;
|
193 |
this.add(user, c);
|
208 |
this.add(user, c);
|
194 |
c.anchor = GridBagConstraints.WEST;
|
209 |
c.anchor = GridBagConstraints.WEST;
|
195 |
c.fill = GridBagConstraints.HORIZONTAL;
|
210 |
c.fill = GridBagConstraints.HORIZONTAL;
|
196 |
c.gridwidth = 1;
|
211 |
c.gridwidth = 1;
|
197 |
user.addActionListener(new ActionListener() {
|
212 |
user.addActionListener(new ActionListener() {
|
198 |
|
213 |
|
199 |
@Override
|
214 |
@Override
|
200 |
public void actionPerformed(ActionEvent e) {
|
215 |
public void actionPerformed(ActionEvent e) {
|
201 |
// TODO Auto-generated method stub
|
- |
|
202 |
try {
|
216 |
try {
|
203 |
if (finderPanel.getServerConfig().createUserIfNeeded(login.getText(), mdp.getText())) {
|
217 |
if (finderPanel.getServerConfig().createUserIfNeeded(login.getText(), mdp.getText())) {
|
204 |
JOptionPane.showMessageDialog(InstallationPanel.this, "L'utilisateur openconcerto a été correctement ajouté.");
|
218 |
JOptionPane.showMessageDialog(InstallationPanel.this, "L'utilisateur openconcerto a été correctement ajouté.");
|
205 |
} else {
|
219 |
} else {
|
206 |
JOptionPane.showMessageDialog(InstallationPanel.this, "L'utilisateur openconcerto existe déjà dans la base.");
|
220 |
JOptionPane.showMessageDialog(InstallationPanel.this, "L'utilisateur openconcerto existe déjà dans la base.");
|
207 |
}
|
221 |
}
|
208 |
} catch (Exception e1) {
|
222 |
} catch (Exception e1) {
|
209 |
// TODO Auto-generated catch block
|
- |
|
210 |
e1.printStackTrace();
|
223 |
e1.printStackTrace();
|
211 |
JOptionPane.showMessageDialog(InstallationPanel.this, "Une erreur est survenue pendant la connexion au serveur, vérifiez vos paramètres de connexion.");
|
224 |
JOptionPane.showMessageDialog(InstallationPanel.this, "Une erreur est survenue pendant la connexion au serveur, vérifiez vos paramètres de connexion.");
|
212 |
}
|
225 |
}
|
213 |
}
|
226 |
}
|
214 |
});
|
227 |
});
|
215 |
|
228 |
|
216 |
c.gridy++;
|
229 |
c.gridy++;
|
217 |
c.weightx = 1;
|
230 |
c.weightx = 1;
|
218 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
231 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
219 |
c.insets = new Insets(10, 3, 2, 2);
|
232 |
c.insets = new Insets(10, 3, 2, 2);
|
220 |
this.add(new JLabelBold("Paramètrages de la base de données"), c);
|
233 |
this.add(new JLabelBold("Paramètrages de la base de données"), c);
|
221 |
c.gridy++;
|
234 |
c.gridy++;
|
222 |
c.insets = DefaultGridBagConstraints.getDefaultInsets();
|
235 |
c.insets = DefaultGridBagConstraints.getDefaultInsets();
|
223 |
this.add(new JLabel("Création des fonctions SQL nécessaires (plpgsql)."), c);
|
236 |
this.add(new JLabel("Création des fonctions SQL nécessaires (plpgsql)."), c);
|
224 |
c.gridy++;
|
237 |
c.gridy++;
|
225 |
c.weightx = 0;
|
238 |
c.weightx = 0;
|
226 |
c.anchor = GridBagConstraints.EAST;
|
239 |
c.anchor = GridBagConstraints.EAST;
|
227 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
240 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
228 |
c.fill = GridBagConstraints.NONE;
|
241 |
c.fill = GridBagConstraints.NONE;
|
229 |
|
242 |
|
230 |
JButton buttonPL = new JButton("Lancer");
|
243 |
JButton buttonPL = new JButton("Lancer");
|
231 |
buttonPL.setOpaque(false);
|
244 |
buttonPL.setOpaque(false);
|
232 |
buttonPL.addActionListener(new ActionListener() {
|
245 |
buttonPL.addActionListener(new ActionListener() {
|
233 |
|
246 |
|
234 |
@Override
|
247 |
@Override
|
235 |
public void actionPerformed(ActionEvent e) {
|
248 |
public void actionPerformed(ActionEvent e) {
|
236 |
if (!finderPanel.getServerConfig().getType().equals(ServerFinderConfig.POSTGRESQL)) {
|
249 |
if (!finderPanel.getServerConfig().getType().equals(ServerFinderConfig.POSTGRESQL)) {
|
237 |
|
250 |
|
238 |
} else {
|
251 |
} else {
|
239 |
final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create(true);
|
252 |
final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create(true);
|
240 |
try {
|
253 |
try {
|
241 |
final SQLDataSource ds = conf.getSystemRoot().getDataSource();
|
254 |
final SQLDataSource ds = conf.getSystemRoot().getDataSource();
|
242 |
// ds.execute("CREATE FUNCTION plpgsql_call_handler() RETURNS
|
255 |
// ds.execute("CREATE FUNCTION plpgsql_call_handler() RETURNS
|
243 |
// language_handler AS '$libdir/plpgsql' LANGUAGE C;"
|
256 |
// language_handler AS '$libdir/plpgsql' LANGUAGE C;"
|
244 |
// + "\n"
|
257 |
// + "\n"
|
245 |
// +
|
258 |
// +
|
246 |
// "CREATE FUNCTION plpgsql_validator(oid) RETURNS void AS
|
259 |
// "CREATE FUNCTION plpgsql_validator(oid) RETURNS void AS
|
247 |
// '$libdir/plpgsql' LANGUAGE C;"
|
260 |
// '$libdir/plpgsql' LANGUAGE C;"
|
248 |
// + "\n"
|
261 |
// + "\n"
|
249 |
// +
|
262 |
// +
|
250 |
// "CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql HANDLER
|
263 |
// "CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql HANDLER
|
251 |
// plpgsql_call_handler VALIDATOR plpgsql_validator;");
|
264 |
// plpgsql_call_handler VALIDATOR plpgsql_validator;");
|
252 |
ds.execute("CREATE LANGUAGE plpgsql;");
|
265 |
ds.execute("CREATE LANGUAGE plpgsql;");
|
253 |
|
266 |
|
254 |
} catch (Exception ex) {
|
267 |
} catch (Exception ex) {
|
255 |
System.err.println("Impossible d'ajouter le langage PLPGSQL. Peut etre est il déjà installé.");
|
268 |
System.err.println("Impossible d'ajouter le langage PLPGSQL. Peut etre est il déjà installé.");
|
256 |
}
|
269 |
}
|
257 |
}
|
270 |
}
|
258 |
JOptionPane.showMessageDialog(null, "Paramètrage terminé.");
|
271 |
JOptionPane.showMessageDialog(null, "Paramètrage terminé.");
|
259 |
}
|
272 |
}
|
260 |
});
|
273 |
});
|
261 |
this.add(buttonPL, c);
|
274 |
this.add(buttonPL, c);
|
262 |
}
|
275 |
}
|
263 |
c.gridy++;
|
276 |
c.gridy++;
|
264 |
c.gridx = 0;
|
277 |
c.gridx = 0;
|
265 |
c.weightx = 1;
|
278 |
c.weightx = 1;
|
266 |
c.fill = GridBagConstraints.HORIZONTAL;
|
279 |
c.fill = GridBagConstraints.HORIZONTAL;
|
267 |
c.anchor = GridBagConstraints.WEST;
|
280 |
c.anchor = GridBagConstraints.WEST;
|
268 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
281 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
269 |
c.insets = new Insets(10, 3, 2, 2);
|
282 |
c.insets = new Insets(10, 3, 2, 2);
|
270 |
this.add(new JLabelBold("Mise à niveau de la base OpenConcerto"), c);
|
283 |
this.add(new JLabelBold("Mise à niveau de la base OpenConcerto"), c);
|
271 |
c.gridy++;
|
284 |
c.gridy++;
|
272 |
c.insets = DefaultGridBagConstraints.getDefaultInsets();
|
285 |
c.insets = DefaultGridBagConstraints.getDefaultInsets();
|
273 |
this.add(new JLabel("Cette opération est nécessaire à chaque mise à jour du logiciel."), c);
|
286 |
this.add(new JLabel("Cette opération est nécessaire à chaque mise à jour du logiciel."), c);
|
274 |
c.gridy++;
|
287 |
c.gridy++;
|
275 |
this.add(new JLabel("La mise à niveau peut prendre plusieurs minutes."), c);
|
288 |
this.add(new JLabel("La mise à niveau peut prendre plusieurs minutes."), c);
|
276 |
c.gridy++;
|
289 |
c.gridy++;
|
277 |
this.add(this.bar, c);
|
290 |
this.add(this.bar, c);
|
278 |
c.gridy++;
|
291 |
c.gridy++;
|
279 |
c.weightx = 0;
|
292 |
c.weightx = 0;
|
280 |
c.anchor = GridBagConstraints.EAST;
|
293 |
c.anchor = GridBagConstraints.EAST;
|
281 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
294 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
282 |
c.fill = GridBagConstraints.NONE;
|
295 |
c.fill = GridBagConstraints.NONE;
|
283 |
|
296 |
|
284 |
this.add(up, c);
|
297 |
this.add(up, c);
|
285 |
|
298 |
|
286 |
c.anchor = GridBagConstraints.WEST;
|
299 |
c.anchor = GridBagConstraints.WEST;
|
287 |
c.fill = GridBagConstraints.HORIZONTAL;
|
300 |
c.fill = GridBagConstraints.HORIZONTAL;
|
288 |
|
301 |
|
289 |
c.weightx = 1;
|
302 |
c.weightx = 1;
|
290 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
303 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
291 |
c.weighty = 1;
|
304 |
c.weighty = 1;
|
292 |
c.gridy++;
|
305 |
c.gridy++;
|
293 |
final JPanel comp = new JPanel();
|
306 |
final JPanel comp = new JPanel();
|
294 |
comp.setOpaque(false);
|
307 |
comp.setOpaque(false);
|
295 |
this.add(comp, c);
|
308 |
this.add(comp, c);
|
296 |
}
|
309 |
}
|
297 |
|
310 |
|
298 |
|
311 |
|
299 |
private void addArticleFournisseur(DBRoot root) {
|
312 |
private void addArticleFournisseur(DBRoot root) {
|
300 |
if (!root.contains("ARTICLE_FOURNISSEUR")) {
|
313 |
if (!root.contains("ARTICLE_FOURNISSEUR")) {
|
301 |
|
314 |
|
302 |
SQLCreateTable createBaseFamille = new SQLCreateTable(root, "FAMILLE_ARTICLE_FOURNISSEUR");
|
315 |
SQLCreateTable createBaseFamille = new SQLCreateTable(root, "FAMILLE_ARTICLE_FOURNISSEUR");
|
303 |
createBaseFamille.addVarCharColumn("CODE", 45);
|
316 |
createBaseFamille.addVarCharColumn("CODE", 45);
|
304 |
createBaseFamille.addVarCharColumn("NOM", 2048);
|
317 |
createBaseFamille.addVarCharColumn("NOM", 2048);
|
305 |
createBaseFamille.addForeignColumn("ID_FAMILLE_ARTICLE_FOURNISSEUR_PERE", createBaseFamille);
|
318 |
createBaseFamille.addForeignColumn("ID_FAMILLE_ARTICLE_FOURNISSEUR_PERE", createBaseFamille);
|
306 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
319 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
307 |
|
320 |
|
308 |
try {
|
321 |
try {
|
309 |
ds.execute(createBaseFamille.asString());
|
322 |
ds.execute(createBaseFamille.asString());
|
310 |
|
323 |
|
311 |
insertUndef(createBaseFamille);
|
324 |
insertUndef(createBaseFamille);
|
312 |
root.refetchTable("FAMILLE_ARTICLE_FOURNISSEUR");
|
325 |
root.refetchTable("FAMILLE_ARTICLE_FOURNISSEUR");
|
313 |
root.getSchema().updateVersion();
|
326 |
root.getSchema().updateVersion();
|
314 |
} catch (SQLException ex) {
|
327 |
} catch (SQLException ex) {
|
315 |
throw new IllegalStateException("Erreur lors de la création de la table FAMILLE_ARTICLE_FOURNISSEUR", ex);
|
328 |
throw new IllegalStateException("Erreur lors de la création de la table FAMILLE_ARTICLE_FOURNISSEUR", ex);
|
316 |
}
|
329 |
}
|
317 |
|
330 |
|
318 |
SQLCreateTable createBase = new SQLCreateTable(root, "ARTICLE_FOURNISSEUR");
|
331 |
SQLCreateTable createBase = new SQLCreateTable(root, "ARTICLE_FOURNISSEUR");
|
319 |
createBase.addVarCharColumn("CODE", 45);
|
332 |
createBase.addVarCharColumn("CODE", 45);
|
320 |
createBase.addVarCharColumn("CODE_BARRE", 45);
|
333 |
createBase.addVarCharColumn("CODE_BARRE", 45);
|
321 |
createBase.addVarCharColumn("CODE_DOUANIER", 45);
|
334 |
createBase.addVarCharColumn("CODE_DOUANIER", 45);
|
322 |
createBase.addVarCharColumn("NOM", 2048);
|
335 |
createBase.addVarCharColumn("NOM", 2048);
|
323 |
createBase.addVarCharColumn("DESCRIPTIF", 2048);
|
336 |
createBase.addVarCharColumn("DESCRIPTIF", 2048);
|
324 |
createBase.addVarCharColumn("INFOS", 2048);
|
337 |
createBase.addVarCharColumn("INFOS", 2048);
|
325 |
|
338 |
|
326 |
createBase.addColumn("PRIX_METRIQUE_HA_1", "numeric (16,6) DEFAULT 0");
|
339 |
createBase.addColumn("PRIX_METRIQUE_HA_1", "numeric (16,6) DEFAULT 0");
|
327 |
createBase.addColumn("PRIX_METRIQUE_HA_2", "numeric (16,8) DEFAULT 0");
|
340 |
createBase.addColumn("PRIX_METRIQUE_HA_2", "numeric (16,8) DEFAULT 0");
|
328 |
createBase.addColumn("PRIX_METRIQUE_HA_3", "numeric (16,8) DEFAULT 0");
|
341 |
createBase.addColumn("PRIX_METRIQUE_HA_3", "numeric (16,8) DEFAULT 0");
|
329 |
|
342 |
|
330 |
createBase.addColumn("PRIX_METRIQUE_VT_1", "numeric (16,8) DEFAULT 0");
|
343 |
createBase.addColumn("PRIX_METRIQUE_VT_1", "numeric (16,8) DEFAULT 0");
|
331 |
createBase.addColumn("PRIX_METRIQUE_VT_2", "numeric (16,8) DEFAULT 0");
|
344 |
createBase.addColumn("PRIX_METRIQUE_VT_2", "numeric (16,8) DEFAULT 0");
|
332 |
createBase.addColumn("PRIX_METRIQUE_VT_3", "numeric (16,8) DEFAULT 0");
|
345 |
createBase.addColumn("PRIX_METRIQUE_VT_3", "numeric (16,8) DEFAULT 0");
|
333 |
|
346 |
|
334 |
createBase.addForeignColumn("ID_METRIQUE_1", root.findTable("METRIQUE", true));
|
347 |
createBase.addForeignColumn("ID_METRIQUE_1", root.findTable("METRIQUE", true));
|
335 |
createBase.addForeignColumn("ID_METRIQUE_2", root.findTable("METRIQUE", true));
|
348 |
createBase.addForeignColumn("ID_METRIQUE_2", root.findTable("METRIQUE", true));
|
336 |
createBase.addForeignColumn("ID_METRIQUE_3", root.findTable("METRIQUE", true));
|
349 |
createBase.addForeignColumn("ID_METRIQUE_3", root.findTable("METRIQUE", true));
|
337 |
|
350 |
|
338 |
createBase.addColumn("PA_DEVISE", "numeric (16,8) DEFAULT 0");
|
351 |
createBase.addColumn("PA_DEVISE", "numeric (16,8) DEFAULT 0");
|
339 |
createBase.addColumn("PV_U_DEVISE", "numeric (16,8) DEFAULT 0");
|
352 |
createBase.addColumn("PV_U_DEVISE", "numeric (16,8) DEFAULT 0");
|
340 |
createBase.addColumn("PA_HT", "numeric (16,8) DEFAULT 0");
|
353 |
createBase.addColumn("PA_HT", "numeric (16,8) DEFAULT 0");
|
341 |
createBase.addColumn("PV_HT", "numeric (16,8) DEFAULT 0");
|
354 |
createBase.addColumn("PV_HT", "numeric (16,8) DEFAULT 0");
|
342 |
createBase.addColumn("PV_TTC", "numeric (16,2) DEFAULT 0");
|
355 |
createBase.addColumn("PV_TTC", "numeric (16,2) DEFAULT 0");
|
343 |
|
356 |
|
344 |
createBase.addForeignColumn("ID_TAXE", root.findTable("TAXE", true));
|
357 |
createBase.addForeignColumn("ID_TAXE", root.findTable("TAXE", true));
|
345 |
createBase.addForeignColumn("ID_FAMILLE_ARTICLE_FOURNISSEUR", root.findTable("FAMILLE_ARTICLE_FOURNISSEUR", true));
|
358 |
createBase.addForeignColumn("ID_FAMILLE_ARTICLE_FOURNISSEUR", root.findTable("FAMILLE_ARTICLE_FOURNISSEUR", true));
|
346 |
createBase.addForeignColumn("ID_MODE_VENTE_ARTICLE", root.findTable("MODE_VENTE_ARTICLE", true));
|
359 |
createBase.addForeignColumn("ID_MODE_VENTE_ARTICLE", root.findTable("MODE_VENTE_ARTICLE", true));
|
347 |
createBase.addForeignColumn("ID_FOURNISSEUR", root.findTable("FOURNISSEUR", true));
|
360 |
createBase.addForeignColumn("ID_FOURNISSEUR", root.findTable("FOURNISSEUR", true));
|
348 |
createBase.addForeignColumn("ID_PAYS", root.findTable("PAYS", true));
|
361 |
createBase.addForeignColumn("ID_PAYS", root.findTable("PAYS", true));
|
349 |
createBase.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
362 |
createBase.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
350 |
createBase.addForeignColumn("ID_DEVISE_HA", root.findTable("DEVISE", true));
|
363 |
createBase.addForeignColumn("ID_DEVISE_HA", root.findTable("DEVISE", true));
|
351 |
createBase.addForeignColumn("ID_UNITE_VENTE", root.findTable("UNITE_VENTE", true));
|
364 |
createBase.addForeignColumn("ID_UNITE_VENTE", root.findTable("UNITE_VENTE", true));
|
352 |
createBase.addForeignColumn("ID_COMPTE_PCE", root.findTable("COMPTE_PCE", true));
|
365 |
createBase.addForeignColumn("ID_COMPTE_PCE", root.findTable("COMPTE_PCE", true));
|
353 |
createBase.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.findTable("COMPTE_PCE", true));
|
366 |
createBase.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.findTable("COMPTE_PCE", true));
|
354 |
createBase.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE", true));
|
367 |
createBase.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE", true));
|
355 |
|
368 |
|
356 |
createBase.addColumn("POIDS", "real DEFAULT 0");
|
369 |
createBase.addColumn("POIDS", "real DEFAULT 0");
|
357 |
createBase.addColumn("VALEUR_METRIQUE_1", "real DEFAULT 0");
|
370 |
createBase.addColumn("VALEUR_METRIQUE_1", "real DEFAULT 0");
|
358 |
createBase.addColumn("VALEUR_METRIQUE_2", "real DEFAULT 0");
|
371 |
createBase.addColumn("VALEUR_METRIQUE_2", "real DEFAULT 0");
|
359 |
createBase.addColumn("VALEUR_METRIQUE_3", "real DEFAULT 0");
|
372 |
createBase.addColumn("VALEUR_METRIQUE_3", "real DEFAULT 0");
|
360 |
createBase.addBooleanColumn("SERVICE", Boolean.FALSE, false);
|
373 |
createBase.addBooleanColumn("SERVICE", Boolean.FALSE, false);
|
361 |
createBase.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
374 |
createBase.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
362 |
createBase.addBooleanColumn("GESTION_STOCK", Boolean.FALSE, false);
|
375 |
createBase.addBooleanColumn("GESTION_STOCK", Boolean.FALSE, false);
|
363 |
createBase.addIntegerColumn("QTE_ACHAT", 1);
|
376 |
createBase.addIntegerColumn("QTE_ACHAT", 1);
|
364 |
createBase.addIntegerColumn("QTE_MIN", 1);
|
377 |
createBase.addIntegerColumn("QTE_MIN", 1);
|
365 |
|
378 |
|
366 |
try {
|
379 |
try {
|
367 |
ds.execute(createBase.asString());
|
380 |
ds.execute(createBase.asString());
|
368 |
|
381 |
|
369 |
insertUndef(createBase);
|
382 |
insertUndef(createBase);
|
370 |
root.refetchTable("ARTICLE_FOURNISSEUR");
|
383 |
root.refetchTable("ARTICLE_FOURNISSEUR");
|
371 |
root.getSchema().updateVersion();
|
384 |
root.getSchema().updateVersion();
|
372 |
} catch (SQLException ex) {
|
385 |
} catch (SQLException ex) {
|
373 |
throw new IllegalStateException("Erreur lors de la création de la table ARTICLE_FOURNISSEUR", ex);
|
386 |
throw new IllegalStateException("Erreur lors de la création de la table ARTICLE_FOURNISSEUR", ex);
|
374 |
}
|
387 |
}
|
375 |
}
|
388 |
}
|
376 |
}
|
389 |
}
|
377 |
|
390 |
|
378 |
private void addContact(DBRoot root) throws SQLException {
|
391 |
private void addContact(DBRoot root) throws SQLException {
|
379 |
|
392 |
|
380 |
List<String> tables = Arrays.asList("AVOIR_CLIENT", "DEVIS", "BON_DE_LIVRAISON", "COMMANDE_CLIENT", "SAISIE_VENTE_FACTURE");
|
393 |
List<String> tables = Arrays.asList("AVOIR_CLIENT", "DEVIS", "BON_DE_LIVRAISON", "COMMANDE_CLIENT", "SAISIE_VENTE_FACTURE");
|
381 |
final SQLTable tableContact = root.findTable("CONTACT");
|
394 |
final SQLTable tableContact = root.findTable("CONTACT");
|
382 |
final SQLTable tableDpt = root.findTable("CLIENT_DEPARTEMENT");
|
395 |
final SQLTable tableDpt = root.findTable("CLIENT_DEPARTEMENT");
|
383 |
final SQLDataSource dataSource = root.getDBSystemRoot().getDataSource();
|
396 |
final SQLDataSource dataSource = root.getDBSystemRoot().getDataSource();
|
384 |
for (String tableName : tables) {
|
397 |
for (String tableName : tables) {
|
385 |
boolean update = false;
|
398 |
boolean update = false;
|
386 |
final SQLTable table = root.getTable(tableName);
|
399 |
final SQLTable table = root.getTable(tableName);
|
387 |
final AlterTable alterEcheance = new AlterTable(table);
|
400 |
final AlterTable alterEcheance = new AlterTable(table);
|
388 |
|
401 |
|
389 |
if (!table.contains("ID_CONTACT")) {
|
402 |
if (!table.contains("ID_CONTACT")) {
|
390 |
alterEcheance.addForeignColumn("ID_CONTACT", tableContact);
|
403 |
alterEcheance.addForeignColumn("ID_CONTACT", tableContact);
|
391 |
update = true;
|
404 |
update = true;
|
392 |
}
|
405 |
}
|
393 |
|
406 |
|
394 |
if (!table.contains("ID_CLIENT_DEPARTEMENT")) {
|
407 |
if (!table.contains("ID_CLIENT_DEPARTEMENT")) {
|
395 |
alterEcheance.addForeignColumn("ID_CLIENT_DEPARTEMENT", tableDpt);
|
408 |
alterEcheance.addForeignColumn("ID_CLIENT_DEPARTEMENT", tableDpt);
|
396 |
update = true;
|
409 |
update = true;
|
397 |
}
|
410 |
}
|
398 |
if (update) {
|
411 |
if (update) {
|
399 |
dataSource.execute(alterEcheance.asString());
|
412 |
dataSource.execute(alterEcheance.asString());
|
400 |
table.getSchema().updateVersion();
|
413 |
table.getSchema().updateVersion();
|
401 |
}
|
414 |
}
|
402 |
|
415 |
|
403 |
}
|
416 |
}
|
404 |
}
|
417 |
}
|
405 |
|
418 |
|
406 |
private void addForeignKeyFactureOnEcheance(DBRoot root) {
|
419 |
private void addForeignKeyFactureOnEcheance(DBRoot root) {
|
407 |
|
420 |
|
408 |
final SQLTable tableEch = root.getTable("ECHEANCE_CLIENT");
|
421 |
final SQLTable tableEch = root.getTable("ECHEANCE_CLIENT");
|
409 |
if (!tableEch.contains("ID_SAISIE_VENTE_FACTURE")) {
|
422 |
if (!tableEch.contains("ID_SAISIE_VENTE_FACTURE")) {
|
410 |
final SQLTable tableFacture = root.getTable("SAISIE_VENTE_FACTURE");
|
423 |
final SQLTable tableFacture = root.getTable("SAISIE_VENTE_FACTURE");
|
411 |
final SQLTable tableMvt = root.getTable("MOUVEMENT");
|
424 |
final SQLTable tableMvt = root.getTable("MOUVEMENT");
|
412 |
String query = "no query";
|
425 |
String query = "no query";
|
413 |
try {
|
426 |
try {
|
414 |
final SQLDataSource dataSource = root.getDBSystemRoot().getDataSource();
|
427 |
final SQLDataSource dataSource = root.getDBSystemRoot().getDataSource();
|
415 |
final AlterTable alterEcheance = new AlterTable(tableEch);
|
428 |
final AlterTable alterEcheance = new AlterTable(tableEch);
|
416 |
alterEcheance.addForeignColumn("ID_SAISIE_VENTE_FACTURE", tableFacture);
|
429 |
alterEcheance.addForeignColumn("ID_SAISIE_VENTE_FACTURE", tableFacture);
|
417 |
dataSource.execute(alterEcheance.asString());
|
430 |
dataSource.execute(alterEcheance.asString());
|
418 |
tableEch.getSchema().updateVersion();
|
431 |
tableEch.getSchema().updateVersion();
|
419 |
tableEch.fetchFields();
|
432 |
tableEch.fetchFields();
|
420 |
|
433 |
|
421 |
// select MOUVEMENT whose parent has a source FACTURE
|
434 |
// select MOUVEMENT whose parent has a source FACTURE
|
422 |
final SQLSelect selMvt = new SQLSelect();
|
435 |
final SQLSelect selMvt = new SQLSelect();
|
423 |
final AliasedTable refChild = new AliasedTable(tableMvt, "m1");
|
436 |
final AliasedTable refChild = new AliasedTable(tableMvt, "m1");
|
424 |
final AliasedTable refParent = new AliasedTable(tableMvt, "m2");
|
437 |
final AliasedTable refParent = new AliasedTable(tableMvt, "m2");
|
425 |
selMvt.addSelect(refParent.getField("IDSOURCE"));
|
438 |
selMvt.addSelect(refParent.getField("IDSOURCE"));
|
426 |
selMvt.addBackwardJoin("INNER", refChild.getField("ID_MOUVEMENT_PERE"), refParent.getAlias());
|
439 |
selMvt.addBackwardJoin("INNER", refChild.getField("ID_MOUVEMENT_PERE"), refParent.getAlias());
|
427 |
selMvt.addSelect(refChild.getKey());
|
440 |
selMvt.addSelect(refChild.getKey());
|
428 |
selMvt.setWhere(new Where(refParent.getField("SOURCE"), "=", tableFacture.getName()));
|
441 |
selMvt.setWhere(new Where(refParent.getField("SOURCE"), "=", tableFacture.getName()));
|
429 |
|
442 |
|
430 |
final UpdateBuilder build = new UpdateBuilder(tableEch);
|
443 |
final UpdateBuilder build = new UpdateBuilder(tableEch);
|
431 |
build.addVirtualJoin("( " + selMvt.asString() + " )", "mvt", false, tableMvt.getKey().getName(), "ID_MOUVEMENT");
|
444 |
build.addVirtualJoin("( " + selMvt.asString() + " )", "mvt", false, tableMvt.getKey().getName(), "ID_MOUVEMENT");
|
432 |
build.setFromVirtualJoinField("ID_SAISIE_VENTE_FACTURE", "mvt", "IDSOURCE");
|
445 |
build.setFromVirtualJoinField("ID_SAISIE_VENTE_FACTURE", "mvt", "IDSOURCE");
|
433 |
query = build.asString();
|
446 |
query = build.asString();
|
434 |
dataSource.execute(query);
|
447 |
dataSource.execute(query);
|
435 |
} catch (SQLException ex) {
|
448 |
} catch (SQLException ex) {
|
436 |
Log.get().severe("Error on query :" + query);
|
449 |
Log.get().severe("Error on query :" + query);
|
437 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table ECHEANCE_CLIENT", ex);
|
450 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table ECHEANCE_CLIENT", ex);
|
438 |
}
|
451 |
}
|
439 |
}
|
452 |
}
|
440 |
}
|
453 |
}
|
441 |
|
454 |
|
442 |
private void addFieldForPartialInvoice(DBRoot root) throws SQLException {
|
455 |
private void addFieldForPartialInvoice(DBRoot root) throws SQLException {
|
443 |
final SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE");
|
456 |
final SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE");
|
444 |
AlterTable alter = new AlterTable(tableVF);
|
457 |
AlterTable alter = new AlterTable(tableVF);
|
445 |
boolean doAlter = false;
|
458 |
boolean doAlter = false;
|
446 |
if (!tableVF.contains("POURCENT_FACTURABLE")) {
|
459 |
if (!tableVF.contains("POURCENT_FACTURABLE")) {
|
447 |
alter.addColumn("POURCENT_FACTURABLE", "numeric (16,8)");
|
460 |
alter.addColumn("POURCENT_FACTURABLE", "numeric (16,8)");
|
448 |
doAlter = true;
|
461 |
doAlter = true;
|
449 |
}
|
462 |
}
|
450 |
if (!tableVF.contains("MONTANT_FACTURABLE")) {
|
463 |
if (!tableVF.contains("MONTANT_FACTURABLE")) {
|
451 |
alter.addColumn("MONTANT_FACTURABLE", "numeric (16,8)");
|
464 |
alter.addColumn("MONTANT_FACTURABLE", "numeric (16,8)");
|
452 |
doAlter = true;
|
465 |
doAlter = true;
|
453 |
}
|
466 |
}
|
454 |
|
467 |
|
455 |
if (!tableVF.contains("SOLDE")) {
|
468 |
if (!tableVF.contains("SOLDE")) {
|
456 |
alter.addColumn("SOLDE", "boolean DEFAULT false");
|
469 |
alter.addColumn("SOLDE", "boolean DEFAULT false");
|
457 |
doAlter = true;
|
470 |
doAlter = true;
|
458 |
}
|
471 |
}
|
459 |
|
472 |
|
460 |
if (!tableVF.contains("PARTIAL")) {
|
473 |
if (!tableVF.contains("PARTIAL")) {
|
461 |
alter.addColumn("PARTIAL", "boolean DEFAULT false");
|
474 |
alter.addColumn("PARTIAL", "boolean DEFAULT false");
|
462 |
doAlter = true;
|
475 |
doAlter = true;
|
463 |
}
|
476 |
}
|
464 |
|
477 |
|
465 |
if (doAlter) {
|
478 |
if (doAlter) {
|
466 |
root.getDBSystemRoot().getDataSource().execute(alter.asString());
|
479 |
root.getDBSystemRoot().getDataSource().execute(alter.asString());
|
467 |
root.refetchTable(tableVF.getName());
|
480 |
root.refetchTable(tableVF.getName());
|
468 |
}
|
481 |
}
|
469 |
|
482 |
|
470 |
// ELT
|
483 |
// ELT
|
471 |
final SQLTable tableVFElt = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
484 |
final SQLTable tableVFElt = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
472 |
AlterTable alterElt = new AlterTable(tableVFElt);
|
485 |
AlterTable alterElt = new AlterTable(tableVFElt);
|
473 |
boolean doAlterElt = false;
|
486 |
boolean doAlterElt = false;
|
474 |
if (!tableVFElt.contains("MONTANT_FACTURABLE")) {
|
487 |
if (!tableVFElt.contains("MONTANT_FACTURABLE")) {
|
475 |
alterElt.addColumn("MONTANT_FACTURABLE", "numeric (16,8)");
|
488 |
alterElt.addColumn("MONTANT_FACTURABLE", "numeric (16,8)");
|
476 |
doAlterElt = true;
|
489 |
doAlterElt = true;
|
477 |
}
|
490 |
}
|
478 |
|
491 |
|
479 |
if (!tableVFElt.contains("POURCENT_FACTURABLE")) {
|
492 |
if (!tableVFElt.contains("POURCENT_FACTURABLE")) {
|
480 |
alterElt.addColumn("POURCENT_FACTURABLE", "numeric (16,8)");
|
493 |
alterElt.addColumn("POURCENT_FACTURABLE", "numeric (16,8)");
|
481 |
doAlterElt = true;
|
494 |
doAlterElt = true;
|
482 |
}
|
495 |
}
|
483 |
|
496 |
|
484 |
if (doAlterElt) {
|
497 |
if (doAlterElt) {
|
485 |
root.getDBSystemRoot().getDataSource().execute(alterElt.asString());
|
498 |
root.getDBSystemRoot().getDataSource().execute(alterElt.asString());
|
486 |
root.refetchTable(tableVFElt.getName());
|
499 |
root.refetchTable(tableVFElt.getName());
|
487 |
}
|
500 |
}
|
488 |
|
501 |
|
489 |
}
|
502 |
}
|
490 |
|
503 |
|
491 |
private void createAssocAnalytique(DBRoot root, ComptaPropsConfiguration conf) {
|
504 |
private void createAssocAnalytique(DBRoot root, ComptaPropsConfiguration conf) {
|
492 |
|
505 |
|
493 |
if (!root.contains("ASSOCIATION_ANALYTIQUE")) {
|
506 |
if (!root.contains("ASSOCIATION_ANALYTIQUE")) {
|
494 |
|
507 |
|
495 |
SQLCreateTable createAssoc = new SQLCreateTable(root, "ASSOCIATION_ANALYTIQUE");
|
508 |
SQLCreateTable createAssoc = new SQLCreateTable(root, "ASSOCIATION_ANALYTIQUE");
|
496 |
createAssoc.addForeignColumn("ID_ECRITURE", root.findTable("ECRITURE", true));
|
509 |
createAssoc.addForeignColumn("ID_ECRITURE", root.findTable("ECRITURE", true));
|
497 |
createAssoc.addForeignColumn("ID_SAISIE_KM_ELEMENT", root.findTable("SAISIE_KM_ELEMENT", true));
|
510 |
createAssoc.addForeignColumn("ID_SAISIE_KM_ELEMENT", root.findTable("SAISIE_KM_ELEMENT", true));
|
498 |
createAssoc.addForeignColumn("ID_POSTE_ANALYTIQUE", root.findTable("POSTE_ANALYTIQUE", true));
|
511 |
createAssoc.addForeignColumn("ID_POSTE_ANALYTIQUE", root.findTable("POSTE_ANALYTIQUE", true));
|
499 |
createAssoc.addColumn("POURCENT", "numeric (16,8) DEFAULT 100");
|
512 |
createAssoc.addColumn("POURCENT", "numeric (16,8) DEFAULT 100");
|
500 |
createAssoc.addColumn("MONTANT", "bigInt DEFAULT 0");
|
513 |
createAssoc.addColumn("MONTANT", "bigInt DEFAULT 0");
|
501 |
createAssoc.addBooleanColumn("GESTION_AUTO", false, false);
|
514 |
createAssoc.addBooleanColumn("GESTION_AUTO", false, false);
|
502 |
|
515 |
|
503 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
516 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
504 |
|
517 |
|
505 |
try {
|
518 |
try {
|
506 |
ds.execute(createAssoc.asString());
|
519 |
ds.execute(createAssoc.asString());
|
507 |
|
520 |
|
508 |
insertUndef(createAssoc);
|
521 |
insertUndef(createAssoc);
|
509 |
root.refetchTable("ASSOCIATION_ANALYTIQUE");
|
522 |
root.refetchTable("ASSOCIATION_ANALYTIQUE");
|
510 |
root.getSchema().updateVersion();
|
523 |
root.getSchema().updateVersion();
|
511 |
} catch (SQLException ex) {
|
524 |
} catch (SQLException ex) {
|
512 |
throw new IllegalStateException("Erreur lors de la création de la table ASSOCIATION_ANALYTIQUE", ex);
|
525 |
throw new IllegalStateException("Erreur lors de la création de la table ASSOCIATION_ANALYTIQUE", ex);
|
513 |
}
|
526 |
}
|
514 |
|
527 |
|
515 |
}
|
528 |
}
|
516 |
SQLTable tablePoste = root.getTable("POSTE_ANALYTIQUE");
|
529 |
SQLTable tablePoste = root.getTable("POSTE_ANALYTIQUE");
|
517 |
if (!tablePoste.contains("DEFAULT")) {
|
530 |
if (!tablePoste.contains("DEFAULT")) {
|
518 |
AlterTable a = new AlterTable(tablePoste);
|
531 |
AlterTable a = new AlterTable(tablePoste);
|
519 |
a.addBooleanColumn("DEFAULT", Boolean.FALSE, false);
|
532 |
a.addBooleanColumn("DEFAULT", Boolean.FALSE, false);
|
520 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
533 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
521 |
try {
|
534 |
try {
|
522 |
ds.execute(a.asString());
|
535 |
ds.execute(a.asString());
|
523 |
root.refetchTable("POSTE_ANALYTIQUE");
|
536 |
root.refetchTable("POSTE_ANALYTIQUE");
|
524 |
root.getSchema().updateVersion();
|
537 |
root.getSchema().updateVersion();
|
525 |
} catch (SQLException ex) {
|
538 |
} catch (SQLException ex) {
|
526 |
throw new IllegalStateException("Erreur lors de la création du DEFAULT sur la table POSTE_ANALYTIQUE", ex);
|
539 |
throw new IllegalStateException("Erreur lors de la création du DEFAULT sur la table POSTE_ANALYTIQUE", ex);
|
527 |
}
|
540 |
}
|
528 |
}
|
541 |
}
|
529 |
}
|
542 |
}
|
530 |
|
543 |
|
531 |
private void updateStock(DBRoot root) throws SQLException {
|
544 |
private void updateStock(DBRoot root) throws SQLException {
|
532 |
|
545 |
|
533 |
final SQLTable tableStock = root.getTable("STOCK");
|
546 |
final SQLTable tableStock = root.getTable("STOCK");
|
534 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
547 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
535 |
if (!tableStock.contains("QTE_RECEPT_ATTENTE")) {
|
548 |
if (!tableStock.contains("QTE_RECEPT_ATTENTE")) {
|
536 |
|
549 |
|
537 |
try {
|
550 |
try {
|
538 |
|
551 |
|
539 |
AlterTable alterElt = new AlterTable(root.getTable("STOCK"));
|
552 |
AlterTable alterElt = new AlterTable(root.getTable("STOCK"));
|
540 |
alterElt.addColumn("QTE_RECEPT_ATTENTE", "real DEFAULT 0");
|
553 |
alterElt.addColumn("QTE_RECEPT_ATTENTE", "real DEFAULT 0");
|
541 |
alterElt.addColumn("QTE_LIV_ATTENTE", "real DEFAULT 0");
|
554 |
alterElt.addColumn("QTE_LIV_ATTENTE", "real DEFAULT 0");
|
542 |
ds.execute(alterElt.asString());
|
555 |
ds.execute(alterElt.asString());
|
543 |
|
556 |
|
544 |
AlterTable alterMvt = new AlterTable(root.getTable("MOUVEMENT_STOCK"));
|
557 |
AlterTable alterMvt = new AlterTable(root.getTable("MOUVEMENT_STOCK"));
|
545 |
alterMvt.addBooleanColumn("REEL", Boolean.TRUE, false);
|
558 |
alterMvt.addBooleanColumn("REEL", Boolean.TRUE, false);
|
546 |
|
559 |
|
547 |
ds.execute(alterMvt.asString());
|
560 |
ds.execute(alterMvt.asString());
|
548 |
|
561 |
|
549 |
root.getSchema().updateVersion();
|
562 |
root.getSchema().updateVersion();
|
550 |
|
563 |
|
551 |
} catch (SQLException ex) {
|
564 |
} catch (SQLException ex) {
|
552 |
throw new IllegalStateException("Erreur lors de la mise à jour des tables de stock", ex);
|
565 |
throw new IllegalStateException("Erreur lors de la mise à jour des tables de stock", ex);
|
553 |
}
|
566 |
}
|
554 |
|
567 |
|
555 |
}
|
568 |
}
|
556 |
// if (!root.contains("ARTICLE_ELEMENT")) {
|
569 |
// if (!root.contains("ARTICLE_ELEMENT")) {
|
557 |
// final SQLCreateTable createTable = new SQLCreateTable(root, "ARTICLE_ELEMENT");
|
570 |
// final SQLCreateTable createTable = new SQLCreateTable(root, "ARTICLE_ELEMENT");
|
558 |
// createTable.addForeignColumn("ARTICLE");
|
571 |
// createTable.addForeignColumn("ARTICLE");
|
559 |
// createTable.addForeignColumn("ID_ARTICLE_PARENT", root.getTable("ARTICLE"));
|
572 |
// createTable.addForeignColumn("ID_ARTICLE_PARENT", root.getTable("ARTICLE"));
|
560 |
// createTable.addIntegerColumn("QTE", 1);
|
573 |
// createTable.addIntegerColumn("QTE", 1);
|
561 |
// createTable.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.valueOf(1), false);
|
574 |
// createTable.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.valueOf(1), false);
|
562 |
// createTable.addForeignColumn("UNITE_VENTE");
|
575 |
// createTable.addForeignColumn("UNITE_VENTE");
|
563 |
// insertUndef(createTable);
|
576 |
// insertUndef(createTable);
|
564 |
// ds.execute(createTable.asString());
|
577 |
// ds.execute(createTable.asString());
|
565 |
//
|
578 |
//
|
566 |
// root.getSchema().updateVersion();
|
579 |
// root.getSchema().updateVersion();
|
567 |
// root.refetchTable("ARTICLE_ELEMENT");
|
580 |
// root.refetchTable("ARTICLE_ELEMENT");
|
568 |
//
|
581 |
//
|
569 |
// }
|
582 |
// }
|
570 |
//
|
583 |
//
|
571 |
// if (!root.getTable("ARTICLE").contains("COMPOSED")) {
|
584 |
// if (!root.getTable("ARTICLE").contains("COMPOSED")) {
|
572 |
// AlterTable alterMvt = new AlterTable(root.getTable("ARTICLE"));
|
585 |
// AlterTable alterMvt = new AlterTable(root.getTable("ARTICLE"));
|
573 |
// alterMvt.addBooleanColumn("COMPOSED", Boolean.FALSE, false);
|
586 |
// alterMvt.addBooleanColumn("COMPOSED", Boolean.FALSE, false);
|
574 |
//
|
587 |
//
|
575 |
// ds.execute(alterMvt.asString());
|
588 |
// ds.execute(alterMvt.asString());
|
576 |
//
|
589 |
//
|
577 |
// root.getSchema().updateVersion();
|
590 |
// root.getSchema().updateVersion();
|
578 |
// }
|
591 |
// }
|
579 |
|
592 |
|
580 |
}
|
593 |
}
|
581 |
|
594 |
|
582 |
private void createBanque(DBRoot root) throws SQLException {
|
595 |
private void createBanque(DBRoot root) throws SQLException {
|
583 |
|
596 |
|
584 |
// Création de la table
|
597 |
// Création de la table
|
585 |
if (!root.contains("BANQUE") && !root.contains("BANQUE_POLE_PRODUIT")) {
|
598 |
if (!root.contains("BANQUE") && !root.contains("BANQUE_POLE_PRODUIT")) {
|
586 |
|
599 |
|
587 |
SQLCreateTable createBanque = new SQLCreateTable(root, "BANQUE");
|
600 |
SQLCreateTable createBanque = new SQLCreateTable(root, "BANQUE");
|
588 |
createBanque.addForeignColumn("ID_JOURNAL", root.findTable("JOURNAL", true));
|
601 |
createBanque.addForeignColumn("ID_JOURNAL", root.findTable("JOURNAL", true));
|
589 |
createBanque.addVarCharColumn("INFOS", 2048);
|
602 |
createBanque.addVarCharColumn("INFOS", 2048);
|
590 |
createBanque.addVarCharColumn("NUMERO_RUE", 45);
|
603 |
createBanque.addVarCharColumn("NUMERO_RUE", 45);
|
591 |
createBanque.addVarCharColumn("RUE", 256);
|
604 |
createBanque.addVarCharColumn("RUE", 256);
|
592 |
createBanque.addVarCharColumn("IBAN", 256);
|
605 |
createBanque.addVarCharColumn("IBAN", 256);
|
593 |
createBanque.addVarCharColumn("BIC", 256);
|
606 |
createBanque.addVarCharColumn("BIC", 256);
|
594 |
createBanque.addVarCharColumn("VOIE", 256);
|
607 |
createBanque.addVarCharColumn("VOIE", 256);
|
595 |
createBanque.addVarCharColumn("VILLE", 256);
|
608 |
createBanque.addVarCharColumn("VILLE", 256);
|
596 |
createBanque.addVarCharColumn("NOM", 256);
|
609 |
createBanque.addVarCharColumn("NOM", 256);
|
597 |
createBanque.addVarCharColumn("DOMICILIATION", 256);
|
610 |
createBanque.addVarCharColumn("DOMICILIATION", 256);
|
598 |
createBanque.addVarCharColumn("CODE", 256);
|
611 |
createBanque.addVarCharColumn("CODE", 256);
|
599 |
createBanque.addBooleanColumn("AFFACTURAGE", Boolean.FALSE, false);
|
612 |
createBanque.addBooleanColumn("AFFACTURAGE", Boolean.FALSE, false);
|
600 |
createBanque.addForeignColumn("ID_COMPTE_PCE", root.findTable("COMPTE_PCE", true));
|
613 |
createBanque.addForeignColumn("ID_COMPTE_PCE", root.findTable("COMPTE_PCE", true));
|
601 |
|
614 |
|
602 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
615 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
603 |
|
616 |
|
604 |
try {
|
617 |
try {
|
605 |
ds.execute(createBanque.asString());
|
618 |
ds.execute(createBanque.asString());
|
606 |
|
619 |
|
607 |
insertUndef(createBanque);
|
620 |
insertUndef(createBanque);
|
608 |
root.refetchTable("BANQUE");
|
621 |
root.refetchTable("BANQUE");
|
609 |
root.getSchema().updateVersion();
|
622 |
root.getSchema().updateVersion();
|
610 |
|
623 |
|
611 |
} catch (SQLException ex) {
|
624 |
} catch (SQLException ex) {
|
612 |
throw new IllegalStateException("Erreur lors de la création de la table BANQUE", ex);
|
625 |
throw new IllegalStateException("Erreur lors de la création de la table BANQUE", ex);
|
613 |
}
|
626 |
}
|
614 |
}
|
627 |
}
|
615 |
|
628 |
|
616 |
// Création des foreignkeys
|
629 |
// Création des foreignkeys
|
617 |
{
|
630 |
{
|
618 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
631 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
619 |
List<String> tablesWithBanque = Arrays.asList("MODE_REGLEMENT", "CHEQUE_A_ENCAISSER", "CHEQUE_FOURNISSEUR");
|
632 |
List<String> tablesWithBanque = Arrays.asList("MODE_REGLEMENT", "CHEQUE_A_ENCAISSER", "CHEQUE_FOURNISSEUR");
|
620 |
|
633 |
|
621 |
for (String string : tablesWithBanque) {
|
634 |
for (String string : tablesWithBanque) {
|
622 |
|
635 |
|
623 |
final SQLTable table = root.getTable(string);
|
636 |
final SQLTable table = root.getTable(string);
|
624 |
if (!table.contains("ID_BANQUE") && !table.contains("ID_BANQUE_POLE_PRODUIT")) {
|
637 |
if (!table.contains("ID_BANQUE") && !table.contains("ID_BANQUE_POLE_PRODUIT")) {
|
625 |
String tableName = (table.contains("ID_BANQUE_PRODUIT")) ? "BANQUE_POLE_PRODUIT" : "BANQUE";
|
638 |
String tableName = (table.contains("ID_BANQUE_PRODUIT")) ? "BANQUE_POLE_PRODUIT" : "BANQUE";
|
626 |
AlterTable alterElt = new AlterTable(table);
|
639 |
AlterTable alterElt = new AlterTable(table);
|
627 |
alterElt.addForeignColumn("ID_" + tableName, root.getTable(tableName));
|
640 |
alterElt.addForeignColumn("ID_" + tableName, root.getTable(tableName));
|
628 |
ds.execute(alterElt.asString());
|
641 |
ds.execute(alterElt.asString());
|
629 |
root.refetchTable(string);
|
642 |
root.refetchTable(string);
|
630 |
root.getSchema().updateVersion();
|
643 |
root.getSchema().updateVersion();
|
631 |
}
|
644 |
}
|
632 |
}
|
645 |
}
|
633 |
}
|
646 |
}
|
634 |
|
647 |
|
635 |
}
|
648 |
}
|
636 |
|
649 |
|
637 |
private void createFactureFournisseur(DBRoot root) throws SQLException {
|
650 |
private void createFactureFournisseur(DBRoot root) throws SQLException {
|
638 |
boolean refetchRoot = false;
|
651 |
boolean refetchRoot = false;
|
639 |
if (!root.contains("FACTURE_FOURNISSEUR")) {
|
652 |
if (!root.contains("FACTURE_FOURNISSEUR")) {
|
640 |
|
653 |
|
641 |
SQLCreateTable createFactureF = new SQLCreateTable(root, "FACTURE_FOURNISSEUR");
|
654 |
SQLCreateTable createFactureF = new SQLCreateTable(root, "FACTURE_FOURNISSEUR");
|
642 |
createFactureF.addVarCharColumn("NOM", 256);
|
655 |
createFactureF.addVarCharColumn("NOM", 256);
|
643 |
createFactureF.addVarCharColumn("NUMERO", 45);
|
656 |
createFactureF.addVarCharColumn("NUMERO", 45);
|
644 |
createFactureF.addVarCharColumn("INFOS", 2048);
|
657 |
createFactureF.addVarCharColumn("INFOS", 2048);
|
645 |
createFactureF.addColumn("DATE", "date");
|
658 |
createFactureF.addColumn("DATE", "date");
|
646 |
createFactureF.addForeignColumn("FOURNISSEUR");
|
659 |
createFactureF.addForeignColumn("FOURNISSEUR");
|
647 |
createFactureF.addForeignColumn("AVOIR_FOURNISSEUR");
|
660 |
createFactureF.addForeignColumn("AVOIR_FOURNISSEUR");
|
648 |
createFactureF.addForeignColumn("COMPTE_PCE");
|
661 |
createFactureF.addForeignColumn("COMPTE_PCE");
|
649 |
createFactureF.addForeignColumn("COMMERCIAL");
|
662 |
createFactureF.addForeignColumn("COMMERCIAL");
|
650 |
createFactureF.addForeignColumn("MODE_REGLEMENT");
|
663 |
createFactureF.addForeignColumn("MODE_REGLEMENT");
|
651 |
createFactureF.addForeignColumn("MOUVEMENT");
|
664 |
createFactureF.addForeignColumn("MOUVEMENT");
|
652 |
createFactureF.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
665 |
createFactureF.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
653 |
createFactureF.addColumn("T_HT", "bigint DEFAULT 0");
|
666 |
createFactureF.addColumn("T_HT", "bigint DEFAULT 0");
|
654 |
createFactureF.addColumn("T_TVA", "bigint DEFAULT 0");
|
667 |
createFactureF.addColumn("T_TVA", "bigint DEFAULT 0");
|
655 |
createFactureF.addColumn("T_TTC", "bigint DEFAULT 0");
|
668 |
createFactureF.addColumn("T_TTC", "bigint DEFAULT 0");
|
656 |
createFactureF.addColumn("T_SERVICE", "bigint DEFAULT 0");
|
669 |
createFactureF.addColumn("T_SERVICE", "bigint DEFAULT 0");
|
657 |
createFactureF.addColumn("T_DEVISE", "bigint DEFAULT 0");
|
670 |
createFactureF.addColumn("T_DEVISE", "bigint DEFAULT 0");
|
658 |
createFactureF.addColumn("T_POIDS", "real DEFAULT 0");
|
671 |
createFactureF.addColumn("T_POIDS", "real DEFAULT 0");
|
659 |
|
672 |
|
660 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
673 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
661 |
|
674 |
|
662 |
try {
|
675 |
try {
|
663 |
ds.execute(createFactureF.asString());
|
676 |
ds.execute(createFactureF.asString());
|
664 |
insertUndef(createFactureF);
|
677 |
insertUndef(createFactureF);
|
665 |
root.getSchema().updateVersion();
|
678 |
root.getSchema().updateVersion();
|
666 |
root.refetchTable("FACTURE_FOURNISSEUR");
|
679 |
root.refetchTable("FACTURE_FOURNISSEUR");
|
667 |
refetchRoot = true;
|
680 |
refetchRoot = true;
|
668 |
} catch (SQLException ex) {
|
681 |
} catch (SQLException ex) {
|
669 |
throw new IllegalStateException("Erreur lors de la création de la table FACTURE_FOURNISSEUR", ex);
|
682 |
throw new IllegalStateException("Erreur lors de la création de la table FACTURE_FOURNISSEUR", ex);
|
670 |
}
|
683 |
}
|
671 |
|
684 |
|
672 |
}
|
685 |
}
|
673 |
|
686 |
|
674 |
if (!root.contains("FACTURE_FOURNISSEUR_ELEMENT")) {
|
687 |
if (!root.contains("FACTURE_FOURNISSEUR_ELEMENT")) {
|
675 |
|
688 |
|
676 |
SQLCreateTable createFactureF = new SQLCreateTable(root, "FACTURE_FOURNISSEUR_ELEMENT");
|
689 |
SQLCreateTable createFactureF = new SQLCreateTable(root, "FACTURE_FOURNISSEUR_ELEMENT");
|
677 |
|
690 |
|
678 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_HA_1", 16, 6, BigDecimal.ZERO, false);
|
691 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_HA_1", 16, 6, BigDecimal.ZERO, false);
|
679 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_HA_2", 16, 6, BigDecimal.ZERO, false);
|
692 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_HA_2", 16, 6, BigDecimal.ZERO, false);
|
680 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_HA_3", 16, 6, BigDecimal.ZERO, false);
|
693 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_HA_3", 16, 6, BigDecimal.ZERO, false);
|
681 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, BigDecimal.ZERO, false);
|
694 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, BigDecimal.ZERO, false);
|
682 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_VT_2", 16, 6, BigDecimal.ZERO, false);
|
695 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_VT_2", 16, 6, BigDecimal.ZERO, false);
|
683 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_VT_3", 16, 6, BigDecimal.ZERO, false);
|
696 |
createFactureF.addDecimalColumn("PRIX_METRIQUE_VT_3", 16, 6, BigDecimal.ZERO, false);
|
684 |
createFactureF.addDecimalColumn("T_PV_HT", 16, 6, BigDecimal.ZERO, false);
|
697 |
createFactureF.addDecimalColumn("T_PV_HT", 16, 6, BigDecimal.ZERO, false);
|
685 |
createFactureF.addDecimalColumn("T_PA_HT", 16, 6, BigDecimal.ZERO, false);
|
698 |
createFactureF.addDecimalColumn("T_PA_HT", 16, 6, BigDecimal.ZERO, false);
|
686 |
createFactureF.addDecimalColumn("PV_HT", 16, 6, BigDecimal.ZERO, false);
|
699 |
createFactureF.addDecimalColumn("PV_HT", 16, 6, BigDecimal.ZERO, false);
|
687 |
createFactureF.addDecimalColumn("PA_HT", 16, 6, BigDecimal.ZERO, false);
|
700 |
createFactureF.addDecimalColumn("PA_HT", 16, 6, BigDecimal.ZERO, false);
|
688 |
createFactureF.addDecimalColumn("T_PV_TTC", 16, 6, BigDecimal.ZERO, false);
|
701 |
createFactureF.addDecimalColumn("T_PV_TTC", 16, 6, BigDecimal.ZERO, false);
|
689 |
createFactureF.addDecimalColumn("T_PA_TTC", 16, 6, BigDecimal.ZERO, false);
|
702 |
createFactureF.addDecimalColumn("T_PA_TTC", 16, 6, BigDecimal.ZERO, false);
|
690 |
createFactureF.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ZERO, false);
|
703 |
createFactureF.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.ZERO, false);
|
691 |
createFactureF.addDecimalColumn("PA_DEVISE_T", 16, 6, BigDecimal.ZERO, false);
|
704 |
createFactureF.addDecimalColumn("PA_DEVISE_T", 16, 6, BigDecimal.ZERO, false);
|
692 |
createFactureF.addDecimalColumn("PA_DEVISE", 16, 6, BigDecimal.ZERO, false);
|
705 |
createFactureF.addDecimalColumn("PA_DEVISE", 16, 6, BigDecimal.ZERO, false);
|
693 |
createFactureF.addIntegerColumn("QTE", 1);
|
706 |
createFactureF.addIntegerColumn("QTE", 1);
|
694 |
createFactureF.addIntegerColumn("QTE_ACHAT", 1);
|
707 |
createFactureF.addIntegerColumn("QTE_ACHAT", 1);
|
695 |
|
708 |
|
696 |
createFactureF.addColumn("VALEUR_METRIQUE_1", "real DEFAULT 0");
|
709 |
createFactureF.addColumn("VALEUR_METRIQUE_1", "real DEFAULT 0");
|
697 |
createFactureF.addColumn("VALEUR_METRIQUE_2", "real DEFAULT 0");
|
710 |
createFactureF.addColumn("VALEUR_METRIQUE_2", "real DEFAULT 0");
|
698 |
createFactureF.addColumn("VALEUR_METRIQUE_3", "real DEFAULT 0");
|
711 |
createFactureF.addColumn("VALEUR_METRIQUE_3", "real DEFAULT 0");
|
699 |
createFactureF.addColumn("T_POIDS", "real DEFAULT 0");
|
712 |
createFactureF.addColumn("T_POIDS", "real DEFAULT 0");
|
700 |
createFactureF.addColumn("POIDS", "real DEFAULT 0");
|
713 |
createFactureF.addColumn("POIDS", "real DEFAULT 0");
|
701 |
createFactureF.addBooleanColumn("SERVICE", Boolean.FALSE, true);
|
714 |
createFactureF.addBooleanColumn("SERVICE", Boolean.FALSE, true);
|
702 |
createFactureF.addVarCharColumn("CODE", 45);
|
715 |
createFactureF.addVarCharColumn("CODE", 45);
|
703 |
createFactureF.addVarCharColumn("NOM", 256);
|
716 |
createFactureF.addVarCharColumn("NOM", 256);
|
704 |
createFactureF.addColumn("DATE", "date");
|
717 |
createFactureF.addColumn("DATE", "date");
|
705 |
createFactureF.addForeignColumn("STYLE");
|
718 |
createFactureF.addForeignColumn("STYLE");
|
706 |
createFactureF.addForeignColumn("METRIQUE", "3");
|
719 |
createFactureF.addForeignColumn("METRIQUE", "3");
|
707 |
createFactureF.addForeignColumn("METRIQUE", "2");
|
720 |
createFactureF.addForeignColumn("METRIQUE", "2");
|
708 |
createFactureF.addForeignColumn("METRIQUE", "1");
|
721 |
createFactureF.addForeignColumn("METRIQUE", "1");
|
709 |
createFactureF.addForeignColumn("FACTURE_FOURNISSEUR");
|
722 |
createFactureF.addForeignColumn("FACTURE_FOURNISSEUR");
|
710 |
createFactureF.addForeignColumn("TAXE");
|
723 |
createFactureF.addForeignColumn("TAXE");
|
711 |
createFactureF.addForeignColumn("ID_MODE_VENTE_ARTICLE", root.findTable("MODE_VENTE_ARTICLE").getSQLName(), "ID", "5");
|
724 |
createFactureF.addForeignColumn("ID_MODE_VENTE_ARTICLE", root.findTable("MODE_VENTE_ARTICLE").getSQLName(), "ID", "5");
|
712 |
createFactureF.addForeignColumn("UNITE_VENTE");
|
725 |
createFactureF.addForeignColumn("UNITE_VENTE");
|
713 |
createFactureF.addForeignColumn("ARTICLE");
|
726 |
createFactureF.addForeignColumn("ARTICLE");
|
714 |
createFactureF.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
727 |
createFactureF.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
715 |
createFactureF.addForeignColumn("CODE_FOURNISSEUR");
|
728 |
createFactureF.addForeignColumn("CODE_FOURNISSEUR");
|
716 |
|
729 |
|
717 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
730 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
718 |
|
731 |
|
719 |
try {
|
732 |
try {
|
720 |
ds.execute(createFactureF.asString());
|
733 |
ds.execute(createFactureF.asString());
|
721 |
insertUndef(createFactureF);
|
734 |
insertUndef(createFactureF);
|
722 |
root.getSchema().updateVersion();
|
735 |
root.getSchema().updateVersion();
|
723 |
refetchRoot = true;
|
736 |
refetchRoot = true;
|
724 |
} catch (SQLException ex) {
|
737 |
} catch (SQLException ex) {
|
725 |
throw new IllegalStateException("Erreur lors de la création de la table FACTURE_FOURNISSEUR_ELEMENT", ex);
|
738 |
throw new IllegalStateException("Erreur lors de la création de la table FACTURE_FOURNISSEUR_ELEMENT", ex);
|
726 |
}
|
739 |
}
|
727 |
|
740 |
|
728 |
}
|
741 |
}
|
729 |
|
742 |
|
730 |
if (root.contains("FACTURE_FOURNISSEUR_ELEMENT")) {
|
743 |
if (root.contains("FACTURE_FOURNISSEUR_ELEMENT")) {
|
731 |
addHAElementField(root.getTable("FACTURE_FOURNISSEUR_ELEMENT"), root);
|
744 |
addHAElementField(root.getTable("FACTURE_FOURNISSEUR_ELEMENT"), root);
|
732 |
}
|
745 |
}
|
733 |
|
746 |
|
734 |
if (!root.contains("REGLER_MONTANT_ELEMENT")) {
|
747 |
if (!root.contains("REGLER_MONTANT_ELEMENT")) {
|
735 |
|
748 |
|
736 |
SQLCreateTable createReglerElt = new SQLCreateTable(root, "REGLER_MONTANT_ELEMENT");
|
749 |
SQLCreateTable createReglerElt = new SQLCreateTable(root, "REGLER_MONTANT_ELEMENT");
|
737 |
|
750 |
|
738 |
createReglerElt.addForeignColumn("ECHEANCE_FOURNISSEUR");
|
751 |
createReglerElt.addForeignColumn("ECHEANCE_FOURNISSEUR");
|
739 |
createReglerElt.addForeignColumn("REGLER_MONTANT");
|
752 |
createReglerElt.addForeignColumn("REGLER_MONTANT");
|
740 |
createReglerElt.addForeignColumn("MOUVEMENT", "ECHEANCE");
|
753 |
createReglerElt.addForeignColumn("MOUVEMENT", "ECHEANCE");
|
741 |
createReglerElt.addColumn("DATE", "date");
|
754 |
createReglerElt.addColumn("DATE", "date");
|
742 |
createReglerElt.addColumn("MONTANT_REGLE", "bigint DEFAULT 0");
|
755 |
createReglerElt.addColumn("MONTANT_REGLE", "bigint DEFAULT 0");
|
743 |
createReglerElt.addColumn("MONTANT_A_REGLER", "bigint DEFAULT 0");
|
756 |
createReglerElt.addColumn("MONTANT_A_REGLER", "bigint DEFAULT 0");
|
744 |
|
757 |
|
745 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
758 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
746 |
|
759 |
|
747 |
try {
|
760 |
try {
|
748 |
ds.execute(createReglerElt.asString());
|
761 |
ds.execute(createReglerElt.asString());
|
749 |
insertUndef(createReglerElt);
|
762 |
insertUndef(createReglerElt);
|
750 |
root.getSchema().updateVersion();
|
763 |
root.getSchema().updateVersion();
|
751 |
root.refetchTable("REGLER_MONTANT_ELEMENT");
|
764 |
root.refetchTable("REGLER_MONTANT_ELEMENT");
|
752 |
refetchRoot = true;
|
765 |
refetchRoot = true;
|
753 |
} catch (SQLException ex) {
|
766 |
} catch (SQLException ex) {
|
754 |
throw new IllegalStateException("Erreur lors de la création de la table REGLER_MONTANT_ELEMENT", ex);
|
767 |
throw new IllegalStateException("Erreur lors de la création de la table REGLER_MONTANT_ELEMENT", ex);
|
755 |
}
|
768 |
}
|
756 |
|
769 |
|
757 |
}
|
770 |
}
|
758 |
|
771 |
|
759 |
final SQLTable tableReglerMontant = root.getTable("REGLER_MONTANT");
|
772 |
final SQLTable tableReglerMontant = root.getTable("REGLER_MONTANT");
|
760 |
|
773 |
|
761 |
boolean updateRegler = false;
|
774 |
boolean updateRegler = false;
|
762 |
|
775 |
|
763 |
AlterTable alterElt = new AlterTable(tableReglerMontant);
|
776 |
AlterTable alterElt = new AlterTable(tableReglerMontant);
|
764 |
if (!tableReglerMontant.contains("ID_FOURNISSEUR")) {
|
777 |
if (!tableReglerMontant.contains("ID_FOURNISSEUR")) {
|
765 |
alterElt.addForeignColumn("ID_FOURNISSEUR", root.getTable("FOURNISSEUR"));
|
778 |
alterElt.addForeignColumn("ID_FOURNISSEUR", root.getTable("FOURNISSEUR"));
|
766 |
updateRegler = true;
|
779 |
updateRegler = true;
|
767 |
}
|
780 |
}
|
768 |
|
781 |
|
769 |
if (!tableReglerMontant.contains("NOM")) {
|
782 |
if (!tableReglerMontant.contains("NOM")) {
|
770 |
alterElt.addVarCharColumn("NOM", 256);
|
783 |
alterElt.addVarCharColumn("NOM", 256);
|
771 |
updateRegler = true;
|
784 |
updateRegler = true;
|
772 |
}
|
785 |
}
|
773 |
|
786 |
|
774 |
if (updateRegler) {
|
787 |
if (updateRegler) {
|
775 |
root.getDBSystemRoot().getDataSource().execute(alterElt.asString());
|
788 |
root.getDBSystemRoot().getDataSource().execute(alterElt.asString());
|
776 |
root.refetchTable(tableReglerMontant.getName());
|
789 |
root.refetchTable(tableReglerMontant.getName());
|
777 |
}
|
790 |
}
|
778 |
|
791 |
|
779 |
if (refetchRoot) {
|
792 |
if (refetchRoot) {
|
780 |
root.refetch();
|
793 |
root.refetch();
|
781 |
}
|
794 |
}
|
782 |
}
|
795 |
}
|
783 |
|
796 |
|
784 |
private void fixUnboundedNumeric(DBRoot root) throws SQLException {
|
797 |
private void fixUnboundedNumeric(DBRoot root) throws SQLException {
|
785 |
|
798 |
|
786 |
final List<AlterTable> alters = new ArrayList<AlterTable>();
|
799 |
final List<AlterTable> alters = new ArrayList<AlterTable>();
|
787 |
final List<UpdateBuilder> builds = new ArrayList<UpdateBuilder>();
|
800 |
final List<UpdateBuilder> builds = new ArrayList<UpdateBuilder>();
|
788 |
{
|
801 |
{
|
789 |
SQLTable tableAvoir = root.getTable("AVOIR_CLIENT_ELEMENT");
|
802 |
SQLTable tableAvoir = root.getTable("AVOIR_CLIENT_ELEMENT");
|
790 |
final AlterTable alter = new AlterTable(tableAvoir);
|
803 |
final AlterTable alter = new AlterTable(tableAvoir);
|
791 |
if (tableAvoir.contains("POURCENT_ACOMPTE")) {
|
804 |
if (tableAvoir.contains("POURCENT_ACOMPTE")) {
|
792 |
SQLField fieldAcompteAvoir = tableAvoir.getField("POURCENT_ACOMPTE");
|
805 |
SQLField fieldAcompteAvoir = tableAvoir.getField("POURCENT_ACOMPTE");
|
793 |
if (fieldAcompteAvoir.getType().getSize() > 500) {
|
806 |
if (fieldAcompteAvoir.getType().getSize() > 500) {
|
794 |
final String fName = fieldAcompteAvoir.getName();
|
807 |
final String fName = fieldAcompteAvoir.getName();
|
795 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "numeric(6,2)", "100", false);
|
808 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "numeric(6,2)", "100", false);
|
796 |
|
809 |
|
797 |
UpdateBuilder build = new UpdateBuilder(tableAvoir);
|
810 |
UpdateBuilder build = new UpdateBuilder(tableAvoir);
|
798 |
build.set(fieldAcompteAvoir.getName(), "100");
|
811 |
build.set(fieldAcompteAvoir.getName(), "100");
|
799 |
build.setWhere(new Where(fieldAcompteAvoir, "=", (Object) null));
|
812 |
build.setWhere(new Where(fieldAcompteAvoir, "=", (Object) null));
|
800 |
builds.add(build);
|
813 |
builds.add(build);
|
801 |
}
|
814 |
}
|
802 |
}
|
815 |
}
|
803 |
if (tableAvoir.contains("POURCENT_REMISE")) {
|
816 |
if (tableAvoir.contains("POURCENT_REMISE")) {
|
804 |
SQLField fieldRemiseAvoir = tableAvoir.getField("POURCENT_REMISE");
|
817 |
SQLField fieldRemiseAvoir = tableAvoir.getField("POURCENT_REMISE");
|
805 |
if (fieldRemiseAvoir.getType().getSize() > 500) {
|
818 |
if (fieldRemiseAvoir.getType().getSize() > 500) {
|
806 |
final String fName = fieldRemiseAvoir.getName();
|
819 |
final String fName = fieldRemiseAvoir.getName();
|
807 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "numeric(6,2)", "0", false);
|
820 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "numeric(6,2)", "0", false);
|
808 |
|
821 |
|
809 |
UpdateBuilder build = new UpdateBuilder(tableAvoir);
|
822 |
UpdateBuilder build = new UpdateBuilder(tableAvoir);
|
810 |
build.set(fieldRemiseAvoir.getName(), "0");
|
823 |
build.set(fieldRemiseAvoir.getName(), "0");
|
811 |
build.setWhere(new Where(fieldRemiseAvoir, "=", (Object) null));
|
824 |
build.setWhere(new Where(fieldRemiseAvoir, "=", (Object) null));
|
812 |
builds.add(build);
|
825 |
builds.add(build);
|
813 |
}
|
826 |
}
|
814 |
}
|
827 |
}
|
815 |
if (!alter.isEmpty())
|
828 |
if (!alter.isEmpty())
|
816 |
alters.add(alter);
|
829 |
alters.add(alter);
|
817 |
}
|
830 |
}
|
818 |
|
831 |
|
819 |
{
|
832 |
{
|
820 |
SQLTable tableFacture = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
833 |
SQLTable tableFacture = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
821 |
final AlterTable alter = new AlterTable(tableFacture);
|
834 |
final AlterTable alter = new AlterTable(tableFacture);
|
822 |
if (tableFacture.contains("POURCENT_ACOMPTE")) {
|
835 |
if (tableFacture.contains("POURCENT_ACOMPTE")) {
|
823 |
SQLField fieldAcompteFacture = tableFacture.getField("POURCENT_ACOMPTE");
|
836 |
SQLField fieldAcompteFacture = tableFacture.getField("POURCENT_ACOMPTE");
|
824 |
if (fieldAcompteFacture.getType().getSize() > 500) {
|
837 |
if (fieldAcompteFacture.getType().getSize() > 500) {
|
825 |
final String fName = fieldAcompteFacture.getName();
|
838 |
final String fName = fieldAcompteFacture.getName();
|
826 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "numeric(6,2)", "100", false);
|
839 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "numeric(6,2)", "100", false);
|
827 |
|
840 |
|
828 |
UpdateBuilder build = new UpdateBuilder(tableFacture);
|
841 |
UpdateBuilder build = new UpdateBuilder(tableFacture);
|
829 |
build.set(fieldAcompteFacture.getName(), "100");
|
842 |
build.set(fieldAcompteFacture.getName(), "100");
|
830 |
build.setWhere(new Where(fieldAcompteFacture, "=", (Object) null));
|
843 |
build.setWhere(new Where(fieldAcompteFacture, "=", (Object) null));
|
831 |
builds.add(build);
|
844 |
builds.add(build);
|
832 |
}
|
845 |
}
|
833 |
}
|
846 |
}
|
834 |
|
847 |
|
835 |
if (tableFacture.contains("POURCENT_REMISE")) {
|
848 |
if (tableFacture.contains("POURCENT_REMISE")) {
|
836 |
SQLField fieldRemiseFacture = tableFacture.getField("POURCENT_REMISE");
|
849 |
SQLField fieldRemiseFacture = tableFacture.getField("POURCENT_REMISE");
|
837 |
if (fieldRemiseFacture.getType().getSize() > 500) {
|
850 |
if (fieldRemiseFacture.getType().getSize() > 500) {
|
838 |
final String fName = fieldRemiseFacture.getName();
|
851 |
final String fName = fieldRemiseFacture.getName();
|
839 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "numeric(6,2)", "0", false);
|
852 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "numeric(6,2)", "0", false);
|
840 |
|
853 |
|
841 |
UpdateBuilder build = new UpdateBuilder(tableFacture);
|
854 |
UpdateBuilder build = new UpdateBuilder(tableFacture);
|
842 |
build.set(fieldRemiseFacture.getName(), "0");
|
855 |
build.set(fieldRemiseFacture.getName(), "0");
|
843 |
build.setWhere(new Where(fieldRemiseFacture, "=", (Object) null));
|
856 |
build.setWhere(new Where(fieldRemiseFacture, "=", (Object) null));
|
844 |
builds.add(build);
|
857 |
builds.add(build);
|
845 |
}
|
858 |
}
|
846 |
}
|
859 |
}
|
847 |
if (tableFacture.getFieldsName().contains("REPARTITION_POURCENT")) {
|
860 |
if (tableFacture.getFieldsName().contains("REPARTITION_POURCENT")) {
|
848 |
SQLField fieldRepFacture = tableFacture.getField("REPARTITION_POURCENT");
|
861 |
SQLField fieldRepFacture = tableFacture.getField("REPARTITION_POURCENT");
|
849 |
if (fieldRepFacture.getType().getSize() > 500) {
|
862 |
if (fieldRepFacture.getType().getSize() > 500) {
|
850 |
final String fName = fieldRepFacture.getName();
|
863 |
final String fName = fieldRepFacture.getName();
|
851 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "numeric(6,2)", "0", false);
|
864 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "numeric(6,2)", "0", false);
|
852 |
|
865 |
|
853 |
UpdateBuilder build = new UpdateBuilder(tableFacture);
|
866 |
UpdateBuilder build = new UpdateBuilder(tableFacture);
|
854 |
build.set(fieldRepFacture.getName(), "0");
|
867 |
build.set(fieldRepFacture.getName(), "0");
|
855 |
build.setWhere(new Where(fieldRepFacture, "=", (Object) null));
|
868 |
build.setWhere(new Where(fieldRepFacture, "=", (Object) null));
|
856 |
builds.add(build);
|
869 |
builds.add(build);
|
857 |
}
|
870 |
}
|
858 |
}
|
871 |
}
|
859 |
|
872 |
|
860 |
if (!alter.isEmpty())
|
873 |
if (!alter.isEmpty())
|
861 |
alters.add(alter);
|
874 |
alters.add(alter);
|
862 |
|
875 |
|
863 |
}
|
876 |
}
|
864 |
if (alters.size() > 0) {
|
877 |
if (alters.size() > 0) {
|
865 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
878 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
866 |
|
879 |
|
867 |
for (UpdateBuilder updateBuilder : builds) {
|
880 |
for (UpdateBuilder updateBuilder : builds) {
|
868 |
ds.execute(updateBuilder.asString());
|
881 |
ds.execute(updateBuilder.asString());
|
869 |
}
|
882 |
}
|
870 |
|
883 |
|
871 |
for (final String sql : ChangeTable.cat(alters, root.getName())) {
|
884 |
for (final String sql : ChangeTable.cat(alters, root.getName())) {
|
872 |
ds.execute(sql);
|
885 |
ds.execute(sql);
|
873 |
}
|
886 |
}
|
874 |
root.refetch();
|
887 |
root.refetch();
|
875 |
}
|
888 |
}
|
876 |
}
|
889 |
}
|
877 |
|
890 |
|
878 |
private void fixUnboundedVarchar(DBRoot root) throws SQLException {
|
891 |
private void fixUnboundedVarchar(DBRoot root) throws SQLException {
|
879 |
final Set<String> namesSet = CollectionUtils.createSet("NOM", "PRENOM", "SURNOM", "LOGIN", "PASSWORD");
|
892 |
final Set<String> namesSet = CollectionUtils.createSet("NOM", "PRENOM", "SURNOM", "LOGIN", "PASSWORD");
|
880 |
final List<AlterTable> alters = new ArrayList<AlterTable>();
|
893 |
final List<AlterTable> alters = new ArrayList<AlterTable>();
|
881 |
final List<UpdateBuilder> builds = new ArrayList<UpdateBuilder>();
|
894 |
final List<UpdateBuilder> builds = new ArrayList<UpdateBuilder>();
|
882 |
for (final SQLTable t : root.getTables()) {
|
895 |
for (final SQLTable t : root.getTables()) {
|
883 |
final AlterTable alter = new AlterTable(t);
|
896 |
final AlterTable alter = new AlterTable(t);
|
884 |
for (final SQLField f : t.getFields()) {
|
897 |
for (final SQLField f : t.getFields()) {
|
- |
|
898 |
// on PG, CLOB are text and the JDBC driver returns Types.VARCHAR, not CLOB. So test
|
- |
|
899 |
// if the type name contains "char", since we only want unbounded varchar, not
|
- |
|
900 |
// text/clob.
|
885 |
if (f.getType().getType() == Types.VARCHAR && f.getType().getSize() == Integer.MAX_VALUE) {
|
901 |
if (f.getType().getType() == Types.VARCHAR && f.getType().getSize() == Integer.MAX_VALUE && f.getTypeDecl().contains("char")) {
|
886 |
|
902 |
|
887 |
UpdateBuilder build = new UpdateBuilder(t);
|
903 |
UpdateBuilder build = new UpdateBuilder(t);
|
888 |
build.set(f.getName(), "''");
|
904 |
build.setObject(f.getName(), "");
|
889 |
build.setWhere(new Where(f, "=", (Object) null));
|
905 |
build.setWhere(Where.isNull(f));
|
890 |
builds.add(build);
|
906 |
builds.add(build);
|
891 |
|
907 |
|
892 |
final String fName = f.getName();
|
908 |
final String fName = f.getName();
|
893 |
final int size;
|
909 |
final int size;
|
894 |
if (t.getName().contains("USER") && namesSet.contains(fName))
|
910 |
if (t.getName().contains("USER") && namesSet.contains(fName))
|
895 |
size = 128;
|
911 |
size = 128;
|
896 |
else if (fName.equals("TEL") || fName.startsWith("TEL_"))
|
912 |
else if (fName.equals("TEL") || fName.startsWith("TEL_"))
|
897 |
size = 32;
|
913 |
size = 32;
|
898 |
else if (fName.contains("INFO"))
|
914 |
else if (fName.contains("INFO"))
|
899 |
size = 4096;
|
915 |
size = 4096;
|
900 |
else if (fName.contains("FORMULE"))
|
916 |
else if (fName.contains("FORMULE"))
|
901 |
size = 1024;
|
917 |
size = 1024;
|
902 |
else if (fName.equals("CONTENU"))
|
918 |
else if (fName.equals("CONTENU"))
|
903 |
size = 2048;
|
919 |
size = 2048;
|
904 |
else
|
920 |
else
|
905 |
// e.g. IDCC.NOM > 350
|
921 |
// e.g. IDCC.NOM > 350
|
906 |
size = 512;
|
922 |
size = 512;
|
907 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "varchar(" + size + ")", "''", false);
|
923 |
alter.alterColumn(fName, EnumSet.allOf(Properties.class), "varchar(" + size + ")", "''", false);
|
908 |
}
|
924 |
}
|
909 |
}
|
925 |
}
|
910 |
if (!alter.isEmpty())
|
926 |
if (!alter.isEmpty())
|
911 |
alters.add(alter);
|
927 |
alters.add(alter);
|
912 |
}
|
928 |
}
|
913 |
if (alters.size() > 0) {
|
929 |
if (alters.size() > 0) {
|
914 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
930 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
915 |
|
931 |
|
916 |
for (UpdateBuilder build : builds) {
|
932 |
for (UpdateBuilder build : builds) {
|
917 |
ds.execute(build.asString());
|
933 |
ds.execute(build.asString());
|
918 |
}
|
934 |
}
|
919 |
|
935 |
|
920 |
for (final String sql : ChangeTable.cat(alters, root.getName())) {
|
936 |
for (final String sql : ChangeTable.cat(alters, root.getName())) {
|
921 |
ds.execute(sql);
|
937 |
ds.execute(sql);
|
922 |
}
|
938 |
}
|
923 |
root.refetch();
|
939 |
root.refetch();
|
924 |
}
|
940 |
}
|
925 |
|
941 |
|
926 |
}
|
942 |
}
|
927 |
|
943 |
|
928 |
private void updateToV1Dot3(final DBRoot root) throws SQLException {
|
944 |
private void updateToV1Dot3(final DBRoot root) throws SQLException {
|
929 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
945 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
930 |
|
946 |
|
931 |
addForeignKeyFactureOnEcheance(root);
|
947 |
addForeignKeyFactureOnEcheance(root);
|
932 |
addFieldForPartialInvoice(root);
|
948 |
addFieldForPartialInvoice(root);
|
933 |
|
949 |
|
934 |
// Numérotation client
|
950 |
// Numérotation client
|
935 |
{
|
951 |
{
|
936 |
SQLTable tableNum = root.getTable("NUMEROTATION_AUTO");
|
952 |
SQLTable tableNum = root.getTable("NUMEROTATION_AUTO");
|
937 |
boolean alterNum = false;
|
953 |
boolean alterNum = false;
|
938 |
AlterTable t = new AlterTable(tableNum);
|
954 |
AlterTable t = new AlterTable(tableNum);
|
939 |
if (!tableNum.getFieldsName().contains("CLIENT_START")) {
|
955 |
if (!tableNum.getFieldsName().contains("CLIENT_START")) {
|
940 |
t.addColumn("CLIENT_START", "integer DEFAULT 0");
|
956 |
t.addColumn("CLIENT_START", "integer DEFAULT 0");
|
941 |
alterNum = true;
|
957 |
alterNum = true;
|
942 |
}
|
958 |
}
|
943 |
if (!tableNum.getFieldsName().contains("CLIENT_FORMAT")) {
|
959 |
if (!tableNum.getFieldsName().contains("CLIENT_FORMAT")) {
|
944 |
t.addVarCharColumn("CLIENT_FORMAT", 48);
|
960 |
t.addVarCharColumn("CLIENT_FORMAT", 48);
|
945 |
alterNum = true;
|
961 |
alterNum = true;
|
946 |
}
|
962 |
}
|
947 |
|
963 |
|
948 |
if (alterNum) {
|
964 |
if (alterNum) {
|
949 |
try {
|
965 |
try {
|
950 |
ds.execute(t.asString());
|
966 |
ds.execute(t.asString());
|
951 |
tableNum.getSchema().updateVersion();
|
967 |
tableNum.getSchema().updateVersion();
|
952 |
tableNum.fetchFields();
|
968 |
tableNum.fetchFields();
|
953 |
} catch (SQLException ex) {
|
969 |
} catch (SQLException ex) {
|
954 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table NUMEROTATION_AUTO", ex);
|
970 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table NUMEROTATION_AUTO", ex);
|
955 |
}
|
971 |
}
|
956 |
}
|
972 |
}
|
957 |
}
|
973 |
}
|
958 |
|
974 |
|
959 |
// Eecheance founisseur
|
975 |
// Eecheance founisseur
|
960 |
{
|
976 |
{
|
961 |
SQLTable tableEchF = root.getTable("ECHEANCE_FOURNISSEUR");
|
977 |
SQLTable tableEchF = root.getTable("ECHEANCE_FOURNISSEUR");
|
962 |
AlterTable t = new AlterTable(tableEchF);
|
978 |
AlterTable t = new AlterTable(tableEchF);
|
963 |
if (!tableEchF.getFieldsName().contains("REG_COMPTA")) {
|
979 |
if (!tableEchF.getFieldsName().contains("REG_COMPTA")) {
|
964 |
t.addColumn("REG_COMPTA", "boolean DEFAULT false");
|
980 |
t.addColumn("REG_COMPTA", "boolean DEFAULT false");
|
965 |
try {
|
981 |
try {
|
966 |
ds.execute(t.asString());
|
982 |
ds.execute(t.asString());
|
967 |
tableEchF.getSchema().updateVersion();
|
983 |
tableEchF.getSchema().updateVersion();
|
968 |
tableEchF.fetchFields();
|
984 |
tableEchF.fetchFields();
|
969 |
} catch (SQLException ex) {
|
985 |
} catch (SQLException ex) {
|
970 |
throw new IllegalStateException("Erreur lors de l'ajout du champ REG_COMPTA sur la table ECHEANCE_FOUNISSEUR", ex);
|
986 |
throw new IllegalStateException("Erreur lors de l'ajout du champ REG_COMPTA sur la table ECHEANCE_FOUNISSEUR", ex);
|
971 |
}
|
987 |
}
|
972 |
}
|
988 |
}
|
973 |
}
|
989 |
}
|
974 |
|
990 |
|
975 |
SQLTable tableTaxe = root.getTable("TAXE");
|
991 |
SQLTable tableTaxe = root.getTable("TAXE");
|
976 |
boolean containsTaxeDefault = tableTaxe.contains("DEFAULT");
|
992 |
boolean containsTaxeDefault = tableTaxe.contains("DEFAULT");
|
977 |
if (!containsTaxeDefault) {
|
993 |
if (!containsTaxeDefault) {
|
978 |
AlterTable t = new AlterTable(tableTaxe);
|
994 |
AlterTable t = new AlterTable(tableTaxe);
|
979 |
t.addColumn("DEFAULT", "boolean DEFAULT false");
|
995 |
t.addColumn("DEFAULT", "boolean DEFAULT false");
|
980 |
|
996 |
|
981 |
try {
|
997 |
try {
|
982 |
ds.execute(t.asString());
|
998 |
ds.execute(t.asString());
|
983 |
tableTaxe.getSchema().updateVersion();
|
999 |
tableTaxe.getSchema().updateVersion();
|
984 |
tableTaxe.fetchFields();
|
1000 |
tableTaxe.fetchFields();
|
985 |
} catch (SQLException ex) {
|
1001 |
} catch (SQLException ex) {
|
986 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table TAXE", ex);
|
1002 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table TAXE", ex);
|
987 |
}
|
1003 |
}
|
988 |
|
1004 |
|
989 |
}
|
1005 |
}
|
990 |
|
1006 |
|
991 |
// Ajout de la TVA à 20
|
1007 |
// Ajout de la TVA à 20
|
992 |
SQLSelect selTVA = new SQLSelect();
|
1008 |
SQLSelect selTVA = new SQLSelect();
|
993 |
selTVA.addSelect(tableTaxe.getKey(), "COUNT");
|
1009 |
selTVA.addSelect(tableTaxe.getKey(), "COUNT");
|
994 |
selTVA.setWhere(new Where(tableTaxe.getField("TAUX"), "=", 20));
|
1010 |
selTVA.setWhere(new Where(tableTaxe.getField("TAUX"), "=", 20));
|
995 |
Object result = root.getBase().getDataSource().executeScalar(selTVA.asString());
|
1011 |
Object result = root.getBase().getDataSource().executeScalar(selTVA.asString());
|
996 |
if (result == null || ((Number) result).longValue() == 0) {
|
1012 |
if (result == null || ((Number) result).longValue() == 0) {
|
997 |
SQLRowValues rowVals = new SQLRowValues(tableTaxe);
|
1013 |
SQLRowValues rowVals = new SQLRowValues(tableTaxe);
|
998 |
rowVals.put("NOM", "TVA 20%");
|
1014 |
rowVals.put("NOM", "TVA 20%");
|
999 |
rowVals.put("TAUX", Float.valueOf(20));
|
1015 |
rowVals.put("TAUX", Float.valueOf(20));
|
1000 |
rowVals.put("DEFAULT", Boolean.TRUE);
|
1016 |
rowVals.put("DEFAULT", Boolean.TRUE);
|
1001 |
rowVals.commit();
|
1017 |
rowVals.commit();
|
1002 |
} else if (!containsTaxeDefault) {
|
1018 |
} else if (!containsTaxeDefault) {
|
1003 |
SQLSelect selTVA20 = new SQLSelect();
|
1019 |
SQLSelect selTVA20 = new SQLSelect();
|
1004 |
selTVA20.addSelectStar(tableTaxe);
|
1020 |
selTVA20.addSelectStar(tableTaxe);
|
1005 |
selTVA20.setWhere(new Where(tableTaxe.getField("TAUX"), "=", 20));
|
1021 |
selTVA20.setWhere(new Where(tableTaxe.getField("TAUX"), "=", 20));
|
1006 |
List<SQLRow> lTVA = SQLRowListRSH.execute(selTVA20);
|
1022 |
List<SQLRow> lTVA = SQLRowListRSH.execute(selTVA20);
|
1007 |
if (lTVA != null && lTVA.size() > 0) {
|
1023 |
if (lTVA != null && lTVA.size() > 0) {
|
1008 |
SQLRowValues rowVals = lTVA.get(0).asRowValues();
|
1024 |
SQLRowValues rowVals = lTVA.get(0).asRowValues();
|
1009 |
rowVals.put("DEFAULT", Boolean.TRUE);
|
1025 |
rowVals.put("DEFAULT", Boolean.TRUE);
|
1010 |
rowVals.update();
|
1026 |
rowVals.update();
|
1011 |
}
|
1027 |
}
|
1012 |
|
1028 |
|
1013 |
}
|
1029 |
}
|
1014 |
|
1030 |
|
1015 |
// Article
|
1031 |
// Article
|
1016 |
{
|
1032 |
{
|
1017 |
SQLTable tableProduct = root.getTable("ARTICLE");
|
1033 |
SQLTable tableProduct = root.getTable("ARTICLE");
|
1018 |
boolean alterTableProduct = false;
|
1034 |
boolean alterTableProduct = false;
|
1019 |
AlterTable t = new AlterTable(tableProduct);
|
1035 |
AlterTable t = new AlterTable(tableProduct);
|
1020 |
if (!tableProduct.getFieldsName().contains("ID_COMPTE_PCE")) {
|
1036 |
if (!tableProduct.getFieldsName().contains("ID_COMPTE_PCE")) {
|
1021 |
t.addForeignColumn("ID_COMPTE_PCE", root.getTable("COMPTE_PCE"));
|
1037 |
t.addForeignColumn("ID_COMPTE_PCE", root.getTable("COMPTE_PCE"));
|
1022 |
alterTableProduct = true;
|
1038 |
alterTableProduct = true;
|
1023 |
}
|
1039 |
}
|
1024 |
if (!tableProduct.getFieldsName().contains("ID_COMPTE_PCE_ACHAT")) {
|
1040 |
if (!tableProduct.getFieldsName().contains("ID_COMPTE_PCE_ACHAT")) {
|
1025 |
t.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.getTable("COMPTE_PCE"));
|
1041 |
t.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.getTable("COMPTE_PCE"));
|
1026 |
alterTableProduct = true;
|
1042 |
alterTableProduct = true;
|
1027 |
}
|
1043 |
}
|
1028 |
if (alterTableProduct) {
|
1044 |
if (alterTableProduct) {
|
1029 |
try {
|
1045 |
try {
|
1030 |
ds.execute(t.asString());
|
1046 |
ds.execute(t.asString());
|
1031 |
tableProduct.getSchema().updateVersion();
|
1047 |
tableProduct.getSchema().updateVersion();
|
1032 |
tableProduct.fetchFields();
|
1048 |
tableProduct.fetchFields();
|
1033 |
} catch (SQLException ex) {
|
1049 |
} catch (SQLException ex) {
|
1034 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table ARTICLE", ex);
|
1050 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table ARTICLE", ex);
|
1035 |
}
|
1051 |
}
|
1036 |
}
|
1052 |
}
|
1037 |
}
|
1053 |
}
|
1038 |
|
1054 |
|
1039 |
// Famille Article
|
1055 |
// Famille Article
|
1040 |
{
|
1056 |
{
|
1041 |
SQLTable tableArticleFamily = root.getTable("FAMILLE_ARTICLE");
|
1057 |
SQLTable tableArticleFamily = root.getTable("FAMILLE_ARTICLE");
|
1042 |
boolean alterArticleFamily = false;
|
1058 |
boolean alterArticleFamily = false;
|
1043 |
AlterTable t = new AlterTable(tableArticleFamily);
|
1059 |
AlterTable t = new AlterTable(tableArticleFamily);
|
1044 |
if (!tableArticleFamily.getFieldsName().contains("ID_COMPTE_PCE")) {
|
1060 |
if (!tableArticleFamily.getFieldsName().contains("ID_COMPTE_PCE")) {
|
1045 |
t.addForeignColumn("ID_COMPTE_PCE", root.getTable("COMPTE_PCE"));
|
1061 |
t.addForeignColumn("ID_COMPTE_PCE", root.getTable("COMPTE_PCE"));
|
1046 |
alterArticleFamily = true;
|
1062 |
alterArticleFamily = true;
|
1047 |
}
|
1063 |
}
|
1048 |
if (!tableArticleFamily.getFieldsName().contains("ID_COMPTE_PCE_ACHAT")) {
|
1064 |
if (!tableArticleFamily.getFieldsName().contains("ID_COMPTE_PCE_ACHAT")) {
|
1049 |
t.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.getTable("COMPTE_PCE"));
|
1065 |
t.addForeignColumn("ID_COMPTE_PCE_ACHAT", root.getTable("COMPTE_PCE"));
|
1050 |
alterArticleFamily = true;
|
1066 |
alterArticleFamily = true;
|
1051 |
}
|
1067 |
}
|
1052 |
if (alterArticleFamily) {
|
1068 |
if (alterArticleFamily) {
|
1053 |
try {
|
1069 |
try {
|
1054 |
ds.execute(t.asString());
|
1070 |
ds.execute(t.asString());
|
1055 |
tableArticleFamily.getSchema().updateVersion();
|
1071 |
tableArticleFamily.getSchema().updateVersion();
|
1056 |
tableArticleFamily.fetchFields();
|
1072 |
tableArticleFamily.fetchFields();
|
1057 |
} catch (SQLException ex) {
|
1073 |
} catch (SQLException ex) {
|
1058 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table FAMILLE_ARTICLE", ex);
|
1074 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table FAMILLE_ARTICLE", ex);
|
1059 |
}
|
1075 |
}
|
1060 |
}
|
1076 |
}
|
1061 |
}
|
1077 |
}
|
1062 |
|
1078 |
|
1063 |
// ECRITURE
|
1079 |
// ECRITURE
|
1064 |
{
|
1080 |
{
|
1065 |
SQLTable tableRecords = root.getTable("ECRITURE");
|
1081 |
SQLTable tableRecords = root.getTable("ECRITURE");
|
1066 |
boolean alterRecords = false;
|
1082 |
boolean alterRecords = false;
|
1067 |
AlterTable t = new AlterTable(tableRecords);
|
1083 |
AlterTable t = new AlterTable(tableRecords);
|
1068 |
if (!tableRecords.getFieldsName().contains("DATE_EXPORT")) {
|
1084 |
if (!tableRecords.getFieldsName().contains("DATE_EXPORT")) {
|
1069 |
t.addColumn("DATE_EXPORT", "date");
|
1085 |
t.addColumn("DATE_EXPORT", "date");
|
1070 |
alterRecords = true;
|
1086 |
alterRecords = true;
|
1071 |
}
|
1087 |
}
|
1072 |
|
1088 |
|
1073 |
if (!tableRecords.getFieldsName().contains("CODE_CLIENT")) {
|
1089 |
if (!tableRecords.getFieldsName().contains("CODE_CLIENT")) {
|
1074 |
t.addVarCharColumn("CODE_CLIENT", 256);
|
1090 |
t.addVarCharColumn("CODE_CLIENT", 256);
|
1075 |
alterRecords = true;
|
1091 |
alterRecords = true;
|
1076 |
}
|
1092 |
}
|
1077 |
if (alterRecords) {
|
1093 |
if (alterRecords) {
|
1078 |
try {
|
1094 |
try {
|
1079 |
ds.execute(t.asString());
|
1095 |
ds.execute(t.asString());
|
1080 |
tableRecords.getSchema().updateVersion();
|
1096 |
tableRecords.getSchema().updateVersion();
|
1081 |
tableRecords.fetchFields();
|
1097 |
tableRecords.fetchFields();
|
1082 |
} catch (SQLException ex) {
|
1098 |
} catch (SQLException ex) {
|
1083 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table ECRITURE", ex);
|
1099 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table ECRITURE", ex);
|
1084 |
}
|
1100 |
}
|
1085 |
}
|
1101 |
}
|
1086 |
}
|
1102 |
}
|
1087 |
addInfoField(root, ds, "AVOIR_FOURNISSEUR");
|
1103 |
addInfoField(root, ds, "AVOIR_FOURNISSEUR");
|
1088 |
addInfoField(root, ds, "AVOIR_CLIENT");
|
1104 |
addInfoField(root, ds, "AVOIR_CLIENT");
|
1089 |
|
1105 |
|
1090 |
boolean refetchRoot = false;
|
1106 |
boolean refetchRoot = false;
|
1091 |
if (!root.contains("CODE_FOURNISSEUR")) {
|
1107 |
if (!root.contains("CODE_FOURNISSEUR")) {
|
1092 |
|
1108 |
|
1093 |
SQLCreateTable createCode = new SQLCreateTable(root, "CODE_FOURNISSEUR");
|
1109 |
SQLCreateTable createCode = new SQLCreateTable(root, "CODE_FOURNISSEUR");
|
1094 |
createCode.addVarCharColumn("CODE", 256);
|
1110 |
createCode.addVarCharColumn("CODE", 256);
|
1095 |
createCode.addForeignColumn("FOURNISSEUR");
|
1111 |
createCode.addForeignColumn("FOURNISSEUR");
|
1096 |
createCode.addForeignColumn("ARTICLE");
|
1112 |
createCode.addForeignColumn("ARTICLE");
|
1097 |
try {
|
1113 |
try {
|
1098 |
ds.execute(createCode.asString());
|
1114 |
ds.execute(createCode.asString());
|
1099 |
insertUndef(createCode);
|
1115 |
insertUndef(createCode);
|
1100 |
root.getSchema().updateVersion();
|
1116 |
root.getSchema().updateVersion();
|
1101 |
refetchRoot = true;
|
1117 |
refetchRoot = true;
|
1102 |
} catch (SQLException ex) {
|
1118 |
} catch (SQLException ex) {
|
1103 |
throw new IllegalStateException("Erreur lors de la création de la table CODE_FOURNISSEUR", ex);
|
1119 |
throw new IllegalStateException("Erreur lors de la création de la table CODE_FOURNISSEUR", ex);
|
1104 |
}
|
1120 |
}
|
1105 |
|
1121 |
|
1106 |
}
|
1122 |
}
|
1107 |
|
1123 |
|
1108 |
// Chargement des tables fraichement créées
|
1124 |
// Chargement des tables fraichement créées
|
1109 |
if (refetchRoot)
|
1125 |
if (refetchRoot)
|
1110 |
root.refetch();
|
1126 |
root.refetch();
|
1111 |
|
1127 |
|
1112 |
createFactureFournisseur(root);
|
1128 |
createFactureFournisseur(root);
|
1113 |
|
1129 |
|
1114 |
addSupplierCode(root, ds, "BON_RECEPTION_ELEMENT");
|
1130 |
addSupplierCode(root, ds, "BON_RECEPTION_ELEMENT");
|
1115 |
addSupplierCode(root, ds, "COMMANDE_ELEMENT");
|
1131 |
addSupplierCode(root, ds, "COMMANDE_ELEMENT");
|
1116 |
|
1132 |
|
1117 |
// Undefined
|
1133 |
// Undefined
|
1118 |
SQLTable.setUndefID(root.getSchema(), "ARTICLE_DESIGNATION", 1);
|
1134 |
SQLTable.setUndefID(root.getSchema(), "ARTICLE_DESIGNATION", 1);
|
1119 |
SQLTable.setUndefID(root.getSchema(), "ARTICLE_TARIF", 1);
|
1135 |
SQLTable.setUndefID(root.getSchema(), "ARTICLE_TARIF", 1);
|
1120 |
SQLTable.setUndefID(root.getSchema(), "CODE_STATUT_CAT_CONV", 1);
|
1136 |
SQLTable.setUndefID(root.getSchema(), "CODE_STATUT_CAT_CONV", 1);
|
1121 |
SQLTable.setUndefID(root.getSchema(), "CONTACT_ADMINISTRATIF", 1);
|
1137 |
SQLTable.setUndefID(root.getSchema(), "CONTACT_ADMINISTRATIF", 1);
|
1122 |
SQLTable.setUndefID(root.getSchema(), "CONTACT_FOURNISSEUR", 1);
|
1138 |
SQLTable.setUndefID(root.getSchema(), "CONTACT_FOURNISSEUR", 1);
|
1123 |
|
1139 |
|
1124 |
SQLTable.setUndefID(root.getSchema(), "LANGUE", 1);
|
1140 |
SQLTable.setUndefID(root.getSchema(), "LANGUE", 1);
|
1125 |
SQLTable.setUndefID(root.getSchema(), "MODELE", 1);
|
1141 |
SQLTable.setUndefID(root.getSchema(), "MODELE", 1);
|
1126 |
SQLTable.setUndefID(root.getSchema(), "OBJECTIF_COMMERCIAL", 1);
|
1142 |
SQLTable.setUndefID(root.getSchema(), "OBJECTIF_COMMERCIAL", 1);
|
1127 |
SQLTable.setUndefID(root.getSchema(), "TARIF", 1);
|
1143 |
SQLTable.setUndefID(root.getSchema(), "TARIF", 1);
|
1128 |
|
1144 |
|
1129 |
SQLTable.setUndefID(root.getSchema(), "UNITE_VENTE", 1);
|
1145 |
SQLTable.setUndefID(root.getSchema(), "UNITE_VENTE", 1);
|
1130 |
|
1146 |
|
1131 |
// Create transfer tables
|
1147 |
// Create transfer tables
|
1132 |
ComptaPropsConfiguration.setSocieteSQLInjector(root);
|
1148 |
ComptaPropsConfiguration.setSocieteSQLInjector(root);
|
1133 |
SQLInjector.createTransferTables(root);
|
1149 |
SQLInjector.createTransferTables(root);
|
1134 |
// Move transfer info to SAISIE_VENTE_FACTURE
|
1150 |
// Move transfer info to SAISIE_VENTE_FACTURE
|
1135 |
convertTransfer(root, Arrays.asList("COMMANDE_CLIENT", "DEVIS", "BON_DE_LIVRAISON"), "SAISIE_VENTE_FACTURE");
|
1151 |
convertTransfer(root, Arrays.asList("COMMANDE_CLIENT", "DEVIS", "BON_DE_LIVRAISON"), "SAISIE_VENTE_FACTURE");
|
1136 |
// Fix keys
|
1152 |
// Fix keys
|
1137 |
if (root.getServer().getSQLSystem().equals(SQLSystem.H2)) {
|
1153 |
if (root.getServer().getSQLSystem().equals(SQLSystem.H2)) {
|
1138 |
final ChangeIDToInt c = new ChangeIDToInt(root.getDBSystemRoot());
|
1154 |
final ChangeIDToInt c = new ChangeIDToInt(root.getDBSystemRoot());
|
1139 |
c.changeAll(root);
|
1155 |
c.changeAll(root);
|
1140 |
root.getDBSystemRoot().reload(Collections.singleton(root.getName()));
|
1156 |
root.getDBSystemRoot().reload(Collections.singleton(root.getName()));
|
1141 |
}
|
1157 |
}
|
1142 |
}
|
1158 |
}
|
1143 |
|
1159 |
|
1144 |
private void convertTransfer(DBRoot root, List<String> tablesSrc, String tableDest) throws SQLException {
|
1160 |
private void convertTransfer(DBRoot root, List<String> tablesSrc, String tableDest) throws SQLException {
|
1145 |
final SQLTable tableDestination = root.getTable(tableDest);
|
1161 |
final SQLTable tableDestination = root.getTable(tableDest);
|
1146 |
if (tableDestination.contains("SOURCE") && tableDestination.contains("IDSOURCE")) {
|
1162 |
if (tableDestination.contains("SOURCE") && tableDestination.contains("IDSOURCE")) {
|
1147 |
for (String tableSrc : tablesSrc) {
|
1163 |
for (String tableSrc : tablesSrc) {
|
1148 |
convertTransfer(root.getTable(tableSrc), tableDestination);
|
1164 |
convertTransfer(root.getTable(tableSrc), tableDestination);
|
1149 |
}
|
1165 |
}
|
1150 |
final AlterTable alter = new AlterTable(tableDestination);
|
1166 |
final AlterTable alter = new AlterTable(tableDestination);
|
1151 |
alter.dropColumn("SOURCE");
|
1167 |
alter.dropColumn("SOURCE");
|
1152 |
alter.dropColumn("IDSOURCE");
|
1168 |
alter.dropColumn("IDSOURCE");
|
1153 |
final String req = alter.asString();
|
1169 |
final String req = alter.asString();
|
1154 |
root.getDBSystemRoot().getDataSource().execute(req);
|
1170 |
root.getDBSystemRoot().getDataSource().execute(req);
|
1155 |
root.refetchTable(tableDest);
|
1171 |
root.refetchTable(tableDest);
|
1156 |
}
|
1172 |
}
|
1157 |
}
|
1173 |
}
|
1158 |
|
1174 |
|
1159 |
private void convertTransfer(final SQLTable tableSource, final SQLTable tableDest) throws SQLException {
|
1175 |
private void convertTransfer(final SQLTable tableSource, final SQLTable tableDest) throws SQLException {
|
1160 |
SQLInjector inj = SQLInjector.getInjector(tableSource, tableDest);
|
1176 |
SQLInjector inj = SQLInjector.getInjector(tableSource, tableDest);
|
1161 |
final SQLRowValues vals = new SQLRowValues(tableDest);
|
1177 |
final SQLRowValues vals = new SQLRowValues(tableDest);
|
1162 |
vals.putNulls("SOURCE", "IDSOURCE");
|
1178 |
vals.putNulls("SOURCE", "IDSOURCE");
|
1163 |
final SQLRowValuesListFetcher fetcher = new SQLRowValuesListFetcher(vals);
|
1179 |
final SQLRowValuesListFetcher fetcher = new SQLRowValuesListFetcher(vals);
|
1164 |
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
1180 |
fetcher.setSelTransf(new ITransformer<SQLSelect, SQLSelect>() {
|
1165 |
|
1181 |
|
1166 |
@Override
|
1182 |
@Override
|
1167 |
public SQLSelect transformChecked(SQLSelect input) {
|
1183 |
public SQLSelect transformChecked(SQLSelect input) {
|
1168 |
Where w = new Where(tableDest.getField("SOURCE"), "=", tableSource.getName());
|
1184 |
Where w = new Where(tableDest.getField("SOURCE"), "=", tableSource.getName());
|
1169 |
w = w.and(new Where(tableDest.getField("IDSOURCE"), "!=", tableSource.getUndefinedIDNumber()));
|
1185 |
w = w.and(new Where(tableDest.getField("IDSOURCE"), "!=", tableSource.getUndefinedIDNumber()));
|
1170 |
// remove archive idsource
|
1186 |
// remove archive idsource
|
1171 |
w = w.and(new Where(tableDest.getField("IDSOURCE"), "=", tableSource.getKey()));
|
1187 |
w = w.and(new Where(tableDest.getField("IDSOURCE"), "=", tableSource.getKey()));
|
1172 |
input.setWhere(w);
|
1188 |
input.setWhere(w);
|
1173 |
return input;
|
1189 |
return input;
|
1174 |
}
|
1190 |
}
|
1175 |
});
|
1191 |
});
|
1176 |
List<SQLRowValues> rows = fetcher.fetch();
|
1192 |
List<SQLRowValues> rows = fetcher.fetch();
|
1177 |
for (SQLRowValues sqlRowValues : rows) {
|
1193 |
for (SQLRowValues sqlRowValues : rows) {
|
1178 |
inj.addTransfert(sqlRowValues.getInt("IDSOURCE"), sqlRowValues.getID());
|
1194 |
inj.addTransfert(sqlRowValues.getInt("IDSOURCE"), sqlRowValues.getID());
|
1179 |
}
|
1195 |
}
|
1180 |
}
|
1196 |
}
|
1181 |
|
1197 |
|
1182 |
private void addInfoField(final DBRoot root, final SQLDataSource ds, String tableName) {
|
1198 |
private void addInfoField(final DBRoot root, final SQLDataSource ds, String tableName) {
|
1183 |
SQLTable tableBL = root.getTable(tableName);
|
1199 |
SQLTable tableBL = root.getTable(tableName);
|
1184 |
boolean alterBL = false;
|
1200 |
boolean alterBL = false;
|
1185 |
AlterTable t = new AlterTable(tableBL);
|
1201 |
AlterTable t = new AlterTable(tableBL);
|
1186 |
if (!tableBL.getFieldsName().contains("INFOS")) {
|
1202 |
if (!tableBL.getFieldsName().contains("INFOS")) {
|
1187 |
t.addVarCharColumn("INFOS", 1024);
|
1203 |
t.addVarCharColumn("INFOS", 1024);
|
1188 |
alterBL = true;
|
1204 |
alterBL = true;
|
1189 |
}
|
1205 |
}
|
1190 |
if (alterBL) {
|
1206 |
if (alterBL) {
|
1191 |
try {
|
1207 |
try {
|
1192 |
ds.execute(t.asString());
|
1208 |
ds.execute(t.asString());
|
1193 |
tableBL.getSchema().updateVersion();
|
1209 |
tableBL.getSchema().updateVersion();
|
1194 |
tableBL.fetchFields();
|
1210 |
tableBL.fetchFields();
|
1195 |
} catch (SQLException ex) {
|
1211 |
} catch (SQLException ex) {
|
1196 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table AVOIR FOURNISSEUR", ex);
|
1212 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table AVOIR FOURNISSEUR", ex);
|
1197 |
}
|
1213 |
}
|
1198 |
}
|
1214 |
}
|
1199 |
}
|
1215 |
}
|
1200 |
|
1216 |
|
1201 |
private void addSupplierCode(final DBRoot root, final SQLDataSource ds, String tableName) {
|
1217 |
private void addSupplierCode(final DBRoot root, final SQLDataSource ds, String tableName) {
|
1202 |
SQLTable tableBL = root.getTable(tableName);
|
1218 |
SQLTable tableBL = root.getTable(tableName);
|
1203 |
boolean alterBL = false;
|
1219 |
boolean alterBL = false;
|
1204 |
AlterTable t = new AlterTable(tableBL);
|
1220 |
AlterTable t = new AlterTable(tableBL);
|
1205 |
if (!tableBL.contains("ID_CODE_FOURNISSEUR")) {
|
1221 |
if (!tableBL.contains("ID_CODE_FOURNISSEUR")) {
|
1206 |
t.addForeignColumn("ID_CODE_FOURNISSEUR", root.getTable("CODE_FOURNISSEUR"));
|
1222 |
t.addForeignColumn("ID_CODE_FOURNISSEUR", root.getTable("CODE_FOURNISSEUR"));
|
1207 |
alterBL = true;
|
1223 |
alterBL = true;
|
1208 |
}
|
1224 |
}
|
1209 |
if (alterBL) {
|
1225 |
if (alterBL) {
|
1210 |
try {
|
1226 |
try {
|
1211 |
ds.execute(t.asString());
|
1227 |
ds.execute(t.asString());
|
1212 |
tableBL.getSchema().updateVersion();
|
1228 |
tableBL.getSchema().updateVersion();
|
1213 |
tableBL.fetchFields();
|
1229 |
tableBL.fetchFields();
|
1214 |
} catch (SQLException ex) {
|
1230 |
} catch (SQLException ex) {
|
1215 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table " + tableName, ex);
|
1231 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table " + tableName, ex);
|
1216 |
}
|
1232 |
}
|
1217 |
}
|
1233 |
}
|
1218 |
}
|
1234 |
}
|
1219 |
|
1235 |
|
1220 |
private void checkDepartementExists(DBRoot root, String dpt, String chefLieu, String regionAdmin, String numero) throws SQLException {
|
1236 |
private void checkDepartementExists(DBRoot root, String dpt, String chefLieu, String regionAdmin, String numero) throws SQLException {
|
1221 |
SQLSelect sel = new SQLSelect();
|
1237 |
SQLSelect sel = new SQLSelect();
|
1222 |
final SQLTable tableDpt = root.getTable("DEPARTEMENT");
|
1238 |
final SQLTable tableDpt = root.getTable("DEPARTEMENT");
|
1223 |
sel.addSelect(tableDpt.getKey());
|
1239 |
sel.addSelect(tableDpt.getKey());
|
1224 |
sel.addSelect(tableDpt.getField("NOM"));
|
1240 |
sel.addSelect(tableDpt.getField("NOM"));
|
1225 |
Where w = new Where(tableDpt.getField("NOM"), "=", dpt);
|
1241 |
Where w = new Where(tableDpt.getField("NOM"), "=", dpt);
|
1226 |
sel.setWhere(w);
|
1242 |
sel.setWhere(w);
|
1227 |
int result = SQLRowListRSH.execute(sel).size();
|
1243 |
int result = SQLRowListRSH.execute(sel).size();
|
1228 |
if (result == 0) {
|
1244 |
if (result == 0) {
|
1229 |
SQLRowValues rowVals = new SQLRowValues(tableDpt);
|
1245 |
SQLRowValues rowVals = new SQLRowValues(tableDpt);
|
1230 |
rowVals.put("NOM", dpt);
|
1246 |
rowVals.put("NOM", dpt);
|
1231 |
rowVals.put("CHEF_LIEU", chefLieu);
|
1247 |
rowVals.put("CHEF_LIEU", chefLieu);
|
1232 |
rowVals.put("REGION_ADMIN", regionAdmin);
|
1248 |
rowVals.put("REGION_ADMIN", regionAdmin);
|
1233 |
rowVals.put("NUMERO", numero);
|
1249 |
rowVals.put("NUMERO", numero);
|
1234 |
rowVals.commit();
|
1250 |
rowVals.commit();
|
1235 |
}
|
1251 |
}
|
1236 |
}
|
1252 |
}
|
1237 |
|
1253 |
|
1238 |
private void updateToV1Dot4(final DBRoot root) throws SQLException {
|
1254 |
private void updateToV1Dot4(final DBRoot root) throws SQLException {
|
1239 |
|
1255 |
|
1240 |
checkPrefsComptable(root);
|
1256 |
checkPrefsComptable(root);
|
1241 |
checkDepartementExists(root, "Aisne", "Laon", "Picardie", "02");
|
1257 |
checkDepartementExists(root, "Aisne", "Laon", "Picardie", "02");
|
1242 |
|
1258 |
|
1243 |
if (root.contains("TARIF_AGENCE")) {
|
1259 |
if (root.contains("TARIF_AGENCE")) {
|
- |
|
1260 |
SQLTable tableCmdFA = root.getTable("COMMANDE");
|
- |
|
1261 |
if (!tableCmdFA.contains("INCOTERM")) {
|
- |
|
1262 |
AlterTable t = new AlterTable(tableCmdFA);
|
- |
|
1263 |
t.addVarCharColumn("INCOTERM", 256);
|
- |
|
1264 |
tableCmdFA.getBase().getDataSource().execute(t.asString());
|
- |
|
1265 |
tableCmdFA.getSchema().updateVersion();
|
- |
|
1266 |
tableCmdFA.fetchFields();
|
- |
|
1267 |
}
|
- |
|
1268 |
|
- |
|
1269 |
SQLTable tableArticleA = root.getTable("ARTICLE");
|
- |
|
1270 |
if (!tableArticleA.contains("CLOSED_KIT")) {
|
- |
|
1271 |
AlterTable t = new AlterTable(tableArticleA);
|
- |
|
1272 |
t.addBooleanColumn("CLOSED_KIT", Boolean.FALSE, true);
|
- |
|
1273 |
tableArticleA.getBase().getDataSource().execute(t.asString());
|
- |
|
1274 |
tableArticleA.getSchema().updateVersion();
|
- |
|
1275 |
tableArticleA.fetchFields();
|
- |
|
1276 |
}
|
- |
|
1277 |
|
- |
|
1278 |
if (!tableArticleA.contains("CLOSED_KIT_DESC")) {
|
- |
|
1279 |
AlterTable t = new AlterTable(tableArticleA);
|
- |
|
1280 |
t.addVarCharColumn("CLOSED_KIT_DESC", 4096);
|
- |
|
1281 |
tableArticleA.getBase().getDataSource().execute(t.asString());
|
- |
|
1282 |
tableArticleA.getSchema().updateVersion();
|
- |
|
1283 |
tableArticleA.fetchFields();
|
- |
|
1284 |
}
|
- |
|
1285 |
|
- |
|
1286 |
SQLTable tableCmdFEltA = root.getTable("COMMANDE_ELEMENT");
|
- |
|
1287 |
if (!tableCmdFEltA.contains("INCOTERM")) {
|
- |
|
1288 |
AlterTable t = new AlterTable(tableCmdFEltA);
|
- |
|
1289 |
t.addVarCharColumn("INCOTERM", 256);
|
- |
|
1290 |
tableCmdFEltA.getBase().getDataSource().execute(t.asString());
|
- |
|
1291 |
tableCmdFEltA.getSchema().updateVersion();
|
- |
|
1292 |
tableCmdFEltA.fetchFields();
|
- |
|
1293 |
}
|
- |
|
1294 |
|
- |
|
1295 |
if (root.getTable("VILLE") == null) {
|
- |
|
1296 |
|
- |
|
1297 |
// INSERT INTO "OpenConcerto49"."VILLE" ("CODE_POSTAL","NOM") SELECT
|
- |
|
1298 |
// "CODE_POSTAL",
|
- |
|
1299 |
// "VILLE" FROM "OpenConcerto49"."ADRESSE" a WHERE a."ARCHIVE"=0
|
- |
|
1300 |
final SQLCreateTable createTableVille = new SQLCreateTable(root, "VILLE");
|
- |
|
1301 |
createTableVille.addVarCharColumn("NOM", 2048);
|
- |
|
1302 |
createTableVille.addVarCharColumn("CODE_POSTAL", 2048);
|
- |
|
1303 |
createTableVille.addLongColumn("X_LAMBERT", 0L, true);
|
- |
|
1304 |
createTableVille.addLongColumn("Y_LAMBERT", 0L, true);
|
- |
|
1305 |
createTableVille.addLongColumn("POPULATION", 0L, true);
|
- |
|
1306 |
try {
|
- |
|
1307 |
root.getBase().getDataSource().execute(createTableVille.asString());
|
- |
|
1308 |
insertUndef(createTableVille);
|
- |
|
1309 |
root.refetchTable("VILLE");
|
- |
|
1310 |
root.getSchema().updateVersion();
|
- |
|
1311 |
} catch (SQLException ex2) {
|
- |
|
1312 |
throw new IllegalStateException("Erreur lors de la création de la table " + "VILLE", ex2);
|
- |
|
1313 |
}
|
- |
|
1314 |
}
|
- |
|
1315 |
|
- |
|
1316 |
if (root.getTable("ARTICLE_PRIX_MIN_VENTE") == null) {
|
- |
|
1317 |
final SQLCreateTable createTablePrixMin = new SQLCreateTable(root, "ARTICLE_PRIX_MIN_VENTE");
|
- |
|
1318 |
createTablePrixMin.addForeignColumn("ARTICLE");
|
- |
|
1319 |
createTablePrixMin.addIntegerColumn("QTE", 1);
|
- |
|
1320 |
createTablePrixMin.addDecimalColumn("PRIX", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1321 |
createTablePrixMin.addDateAndTimeColumn("DATE");
|
- |
|
1322 |
try {
|
- |
|
1323 |
root.getBase().getDataSource().execute(createTablePrixMin.asString());
|
- |
|
1324 |
insertUndef(createTablePrixMin);
|
- |
|
1325 |
root.refetchTable("ARTICLE_PRIX_MIN_VENTE");
|
- |
|
1326 |
root.getSchema().updateVersion();
|
- |
|
1327 |
} catch (SQLException ex2) {
|
- |
|
1328 |
throw new IllegalStateException("Erreur lors de la création de la table " + "ARTICLE_PRIX_MIN_VENTE", ex2);
|
- |
|
1329 |
}
|
- |
|
1330 |
}
|
- |
|
1331 |
|
- |
|
1332 |
{
|
- |
|
1333 |
final SQLTable tableTarifAgence = root.getTable("TARIF_AGENCE");
|
- |
|
1334 |
AlterTable tTarifAgence = new AlterTable(tableTarifAgence);
|
- |
|
1335 |
boolean updateTarifAgence = false;
|
- |
|
1336 |
|
- |
|
1337 |
if (!tableTarifAgence.contains("PRC_AGENCE")) {
|
- |
|
1338 |
updateTarifAgence = true;
|
- |
|
1339 |
tTarifAgence.addDecimalColumn("PRC_AGENCE", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1340 |
}
|
- |
|
1341 |
if (!tableTarifAgence.contains("CLOSED_KIT")) {
|
- |
|
1342 |
updateTarifAgence = true;
|
- |
|
1343 |
tTarifAgence.addBooleanColumn("CLOSED_KIT", false, true);
|
- |
|
1344 |
}
|
- |
|
1345 |
if (!tableTarifAgence.contains("PRIX_MIN_VENTE")) {
|
- |
|
1346 |
updateTarifAgence = true;
|
- |
|
1347 |
tTarifAgence.addDecimalColumn("PRIX_MIN_VENTE", 16, 8, BigDecimal.ZERO, true);
|
- |
|
1348 |
}
|
- |
|
1349 |
|
- |
|
1350 |
if (updateTarifAgence) {
|
- |
|
1351 |
tableTarifAgence.getBase().getDataSource().execute(tTarifAgence.asString());
|
- |
|
1352 |
tableTarifAgence.getSchema().updateVersion();
|
- |
|
1353 |
tableTarifAgence.fetchFields();
|
- |
|
1354 |
}
|
- |
|
1355 |
}
|
- |
|
1356 |
{
|
- |
|
1357 |
final SQLTable tableClient = root.getTable("CLIENT");
|
- |
|
1358 |
AlterTable tClient = new AlterTable(tableClient);
|
- |
|
1359 |
boolean updateClient = false;
|
- |
|
1360 |
|
- |
|
1361 |
if (!tableClient.contains("ALG_REGISTRE")) {
|
- |
|
1362 |
updateClient = true;
|
- |
|
1363 |
tClient.addVarCharColumn("ALG_REGISTRE", 512);
|
- |
|
1364 |
}
|
- |
|
1365 |
if (!tableClient.contains("ALG_MATRICULE")) {
|
- |
|
1366 |
updateClient = true;
|
- |
|
1367 |
tClient.addVarCharColumn("ALG_MATRICULE", 512);
|
- |
|
1368 |
}
|
- |
|
1369 |
if (!tableClient.contains("ALG_ARTICLE")) {
|
- |
|
1370 |
updateClient = true;
|
- |
|
1371 |
tClient.addVarCharColumn("ALG_ARTICLE", 512);
|
- |
|
1372 |
}
|
- |
|
1373 |
|
- |
|
1374 |
if (updateClient) {
|
- |
|
1375 |
tableClient.getBase().getDataSource().execute(tClient.asString());
|
- |
|
1376 |
tableClient.getSchema().updateVersion();
|
- |
|
1377 |
tableClient.fetchFields();
|
- |
|
1378 |
}
|
- |
|
1379 |
}
|
- |
|
1380 |
final SQLTable tableMvtStock = root.getTable("MOUVEMENT_STOCK");
|
- |
|
1381 |
|
- |
|
1382 |
if (!tableMvtStock.contains("PRICE")) {
|
- |
|
1383 |
AlterTable tMvt = new AlterTable(tableMvtStock);
|
- |
|
1384 |
tMvt.addDecimalColumn("PRICE", 16, 6, BigDecimal.ZERO, true);
|
- |
|
1385 |
tableMvtStock.getBase().getDataSource().execute(tMvt.asString());
|
- |
|
1386 |
tableMvtStock.getSchema().updateVersion();
|
- |
|
1387 |
tableMvtStock.fetchFields();
|
- |
|
1388 |
}
|
- |
|
1389 |
|
- |
|
1390 |
final SQLTable tableArticle = root.getTable("ARTICLE");
|
- |
|
1391 |
|
- |
|
1392 |
if (!tableArticle.contains("AUTO_PRIX_MIN_VENTE_NOMENCLATURE")) {
|
- |
|
1393 |
AlterTable tArt = new AlterTable(tableArticle);
|
- |
|
1394 |
tArt.addBooleanColumn("AUTO_PRIX_MIN_VENTE_NOMENCLATURE", false, true);
|
- |
|
1395 |
tableMvtStock.getBase().getDataSource().execute(tArt.asString());
|
- |
|
1396 |
tableMvtStock.getSchema().updateVersion();
|
- |
|
1397 |
tableMvtStock.fetchFields();
|
- |
|
1398 |
}
|
- |
|
1399 |
SQLTable tableContact = root.getTable("CONTACT");
|
- |
|
1400 |
if (!tableContact.contains("TYPE")) {
|
- |
|
1401 |
AlterTable t = new AlterTable(tableContact);
|
- |
|
1402 |
t.addVarCharColumn("TYPE", 256);
|
- |
|
1403 |
t.addVarCharColumn("SERVICE", 256);
|
- |
|
1404 |
t.addVarCharColumn("PAYS", 256);
|
- |
|
1405 |
t.addForeignColumn("ID_ADRESSE", root.getTable("ADRESSE"));
|
- |
|
1406 |
tableContact.getBase().getDataSource().execute(t.asString());
|
- |
|
1407 |
tableContact.getSchema().updateVersion();
|
- |
|
1408 |
tableContact.fetchFields();
|
- |
|
1409 |
}
|
- |
|
1410 |
|
- |
|
1411 |
if (!root.contains("PERSONNEL_AFHYMAT")) {
|
- |
|
1412 |
final SQLCreateTable createTablePers = new SQLCreateTable(root, "PERSONNEL_AFHYMAT");
|
- |
|
1413 |
createTablePers.addVarCharColumn("NOM", 256);
|
- |
|
1414 |
createTablePers.addVarCharColumn("PRENOM", 256);
|
- |
|
1415 |
createTablePers.addVarCharColumn("FONCTION", 256);
|
- |
|
1416 |
|
- |
|
1417 |
try {
|
- |
|
1418 |
root.getBase().getDataSource().execute(createTablePers.asString());
|
- |
|
1419 |
insertUndef(createTablePers);
|
- |
|
1420 |
root.refetchTable("PERSONNEL_AFHYMAT");
|
- |
|
1421 |
root.getSchema().updateVersion();
|
- |
|
1422 |
} catch (SQLException ex) {
|
- |
|
1423 |
throw new IllegalStateException("Erreur lors de la création de la table " + "PERSONNEL_AFHYMAT", ex);
|
- |
|
1424 |
}
|
- |
|
1425 |
|
- |
|
1426 |
final SQLCreateTable createTable = new SQLCreateTable(root, "PERSONNEL_AFHYMAT_COUT");
|
- |
|
1427 |
for (int i = 1; i <= 12; i++) {
|
- |
|
1428 |
createTable.addDecimalColumn("SAL_MONTH_" + i, 16, 2, BigDecimal.ZERO, false);
|
- |
|
1429 |
createTable.addDecimalColumn("COM_MONTH_" + i, 16, 2, BigDecimal.ZERO, false);
|
- |
|
1430 |
}
|
- |
|
1431 |
createTable.addIntegerColumn("ANNEE", 0);
|
- |
|
1432 |
createTable.addForeignColumn("ID_PERSONNEL_AFHYMAT", root.getTable("PERSONNEL_AFHYMAT"));
|
- |
|
1433 |
|
- |
|
1434 |
try {
|
- |
|
1435 |
root.getBase().getDataSource().execute(createTable.asString());
|
- |
|
1436 |
insertUndef(createTable);
|
- |
|
1437 |
root.refetchTable("PERSONNEL_AFHYMAT_COUT");
|
- |
|
1438 |
root.getSchema().updateVersion();
|
- |
|
1439 |
} catch (SQLException ex) {
|
- |
|
1440 |
throw new IllegalStateException("Erreur lors de la création de la table " + "PERSONNEL_AFHYMAT_COUT", ex);
|
- |
|
1441 |
}
|
- |
|
1442 |
}
|
1244 |
|
1443 |
|
1245 |
List<String> tablesUiLocked = Arrays.asList("BON_DE_LIVRAISON", "COMMANDE_CLIENT", "SAISIE_VENTE_FACTURE", "AVOIR_CLIENT", "COMMANDE", "BON_RECEPTION", "FACTURE_FOURNISSEUR");
|
1444 |
List<String> tablesUiLocked = Arrays.asList("BON_DE_LIVRAISON", "COMMANDE_CLIENT", "SAISIE_VENTE_FACTURE", "AVOIR_CLIENT", "COMMANDE", "BON_RECEPTION", "FACTURE_FOURNISSEUR");
|
1246 |
for (String tableName : tablesUiLocked) {
|
1445 |
for (String tableName : tablesUiLocked) {
|
1247 |
final SQLTable table = root.getTable(tableName);
|
1446 |
final SQLTable table = root.getTable(tableName);
|
1248 |
AlterTable t = new AlterTable(table);
|
1447 |
AlterTable t = new AlterTable(table);
|
1249 |
if (!table.contains("UI_LOCK")) {
|
1448 |
if (!table.contains("UI_LOCK")) {
|
1250 |
t.addVarCharColumn("UI_LOCK", 512);
|
1449 |
t.addVarCharColumn("UI_LOCK", 512);
|
1251 |
t.addForeignColumn("ID_USER_UI_LOCK", root.findTable("USER_COMMON"));
|
1450 |
t.addForeignColumn("ID_USER_UI_LOCK", root.findTable("USER_COMMON"));
|
1252 |
table.getBase().getDataSource().execute(t.asString());
|
1451 |
table.getBase().getDataSource().execute(t.asString());
|
1253 |
table.getSchema().updateVersion();
|
1452 |
table.getSchema().updateVersion();
|
1254 |
table.fetchFields();
|
1453 |
table.fetchFields();
|
1255 |
}
|
1454 |
}
|
1256 |
|
1455 |
|
1257 |
}
|
1456 |
}
|
1258 |
|
1457 |
|
1259 |
if (!root.contains("RELIQUAT_BL")) {
|
1458 |
if (!root.contains("RELIQUAT_BL")) {
|
1260 |
final SQLCreateTable createTable = new SQLCreateTable(root, "RELIQUAT_BL");
|
1459 |
final SQLCreateTable createTable = new SQLCreateTable(root, "RELIQUAT_BL");
|
1261 |
createTable.addForeignColumn("ARTICLE");
|
1460 |
createTable.addForeignColumn("ARTICLE");
|
1262 |
createTable.addForeignColumn("ID_BON_DE_LIVRAISON_ORIGINE", root.getTable("BON_DE_LIVRAISON"));
|
1461 |
createTable.addForeignColumn("ID_BON_DE_LIVRAISON_ORIGINE", root.getTable("BON_DE_LIVRAISON"));
|
1263 |
createTable.addForeignColumn("ID_BON_DE_LIVRAISON", root.getTable("BON_DE_LIVRAISON"));
|
1462 |
createTable.addForeignColumn("ID_BON_DE_LIVRAISON", root.getTable("BON_DE_LIVRAISON"));
|
1264 |
createTable.addForeignColumn("ID_BON_DE_LIVRAISON_ELEMENT", root.getTable("BON_DE_LIVRAISON_ELEMENT"));
|
1463 |
createTable.addForeignColumn("ID_BON_DE_LIVRAISON_ELEMENT", root.getTable("BON_DE_LIVRAISON_ELEMENT"));
|
1265 |
createTable.addIntegerColumn("QTE", 1);
|
1464 |
createTable.addIntegerColumn("QTE", 1);
|
1266 |
createTable.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.valueOf(1), false);
|
1465 |
createTable.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.valueOf(1), false);
|
1267 |
createTable.addForeignColumn("UNITE_VENTE");
|
1466 |
createTable.addForeignColumn("UNITE_VENTE");
|
1268 |
|
1467 |
|
1269 |
try {
|
1468 |
try {
|
1270 |
root.getBase().getDataSource().execute(createTable.asString());
|
1469 |
root.getBase().getDataSource().execute(createTable.asString());
|
1271 |
insertUndef(createTable);
|
1470 |
insertUndef(createTable);
|
1272 |
root.refetchTable("RELIQUAT_BL");
|
1471 |
root.refetchTable("RELIQUAT_BL");
|
1273 |
root.getSchema().updateVersion();
|
1472 |
root.getSchema().updateVersion();
|
1274 |
} catch (SQLException ex) {
|
1473 |
} catch (SQLException ex) {
|
1275 |
throw new IllegalStateException("Erreur lors de la création de la table " + "RELIQUAT_BL", ex);
|
1474 |
throw new IllegalStateException("Erreur lors de la création de la table " + "RELIQUAT_BL", ex);
|
1276 |
}
|
1475 |
}
|
1277 |
}
|
1476 |
}
|
1278 |
|
1477 |
|
1279 |
if (!root.getTable("ARTICLE").contains("TRANSPORT")) {
|
1478 |
if (!root.getTable("ARTICLE").contains("TRANSPORT")) {
|
1280 |
final SQLTable tableArticle = root.getTable("ARTICLE");
|
- |
|
1281 |
AlterTable alterArticle = new AlterTable(tableArticle);
|
1479 |
AlterTable alterArticle = new AlterTable(tableArticle);
|
1282 |
alterArticle.addBooleanColumn("TRANSPORT", false, false);
|
1480 |
alterArticle.addBooleanColumn("TRANSPORT", false, false);
|
1283 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
1481 |
tableArticle.getBase().getDataSource().execute(alterArticle.asString());
|
1284 |
tableArticle.getSchema().updateVersion();
|
1482 |
tableArticle.getSchema().updateVersion();
|
1285 |
tableArticle.fetchFields();
|
1483 |
tableArticle.fetchFields();
|
1286 |
}
|
1484 |
}
|
1287 |
|
1485 |
|
1288 |
if (!root.contains("RELIQUAT_BR")) {
|
1486 |
if (!root.contains("RELIQUAT_BR")) {
|
1289 |
final SQLCreateTable createTable = new SQLCreateTable(root, "RELIQUAT_BR");
|
1487 |
final SQLCreateTable createTable = new SQLCreateTable(root, "RELIQUAT_BR");
|
1290 |
createTable.addForeignColumn("ARTICLE");
|
1488 |
createTable.addForeignColumn("ARTICLE");
|
1291 |
createTable.addForeignColumn("ID_BON_RECEPTION_ORIGINE", root.getTable("BON_RECEPTION"));
|
1489 |
createTable.addForeignColumn("ID_BON_RECEPTION_ORIGINE", root.getTable("BON_RECEPTION"));
|
1292 |
createTable.addForeignColumn("ID_BON_RECEPTION", root.getTable("BON_RECEPTION"));
|
1490 |
createTable.addForeignColumn("ID_BON_RECEPTION", root.getTable("BON_RECEPTION"));
|
1293 |
createTable.addForeignColumn("ID_BON_RECEPTION_ELEMENT", root.getTable("BON_RECEPTION_ELEMENT"));
|
1491 |
createTable.addForeignColumn("ID_BON_RECEPTION_ELEMENT", root.getTable("BON_RECEPTION_ELEMENT"));
|
1294 |
createTable.addIntegerColumn("QTE", 1);
|
1492 |
createTable.addIntegerColumn("QTE", 1);
|
1295 |
createTable.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.valueOf(1), false);
|
1493 |
createTable.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.valueOf(1), false);
|
1296 |
createTable.addForeignColumn("UNITE_VENTE");
|
1494 |
createTable.addForeignColumn("UNITE_VENTE");
|
1297 |
|
1495 |
|
1298 |
try {
|
1496 |
try {
|
1299 |
root.getBase().getDataSource().execute(createTable.asString());
|
1497 |
root.getBase().getDataSource().execute(createTable.asString());
|
1300 |
insertUndef(createTable);
|
1498 |
insertUndef(createTable);
|
1301 |
root.refetchTable("RELIQUAT_BL");
|
1499 |
root.refetchTable("RELIQUAT_BL");
|
1302 |
root.getSchema().updateVersion();
|
1500 |
root.getSchema().updateVersion();
|
1303 |
} catch (SQLException ex) {
|
1501 |
} catch (SQLException ex) {
|
1304 |
throw new IllegalStateException("Erreur lors de la création de la table " + "RELIQUAT_BR", ex);
|
1502 |
throw new IllegalStateException("Erreur lors de la création de la table " + "RELIQUAT_BR", ex);
|
1305 |
}
|
1503 |
}
|
1306 |
}
|
1504 |
}
|
1307 |
|
1505 |
|
1308 |
{
|
1506 |
{
|
1309 |
if (root.getName().endsWith("54")) {
|
1507 |
if (root.getName().endsWith("54")) {
|
1310 |
final SQLTable tableArticle = root.getTable("ARTICLE");
|
- |
|
1311 |
AlterTable tArt = new AlterTable(tableArticle);
|
1508 |
AlterTable tArt = new AlterTable(tableArticle);
|
1312 |
if (!tableArticle.contains("LABEL_DOUANE")) {
|
1509 |
if (!tableArticle.contains("LABEL_DOUANE")) {
|
1313 |
tArt.addVarCharColumn("LABEL_DOUANE", 512);
|
1510 |
tArt.addVarCharColumn("LABEL_DOUANE", 512);
|
1314 |
tableArticle.getBase().getDataSource().execute(tArt.asString());
|
1511 |
tableArticle.getBase().getDataSource().execute(tArt.asString());
|
1315 |
tableArticle.getSchema().updateVersion();
|
1512 |
tableArticle.getSchema().updateVersion();
|
1316 |
tableArticle.fetchFields();
|
1513 |
tableArticle.fetchFields();
|
1317 |
}
|
1514 |
}
|
1318 |
}
|
1515 |
}
|
1319 |
}
|
1516 |
}
|
1320 |
|
1517 |
|
1321 |
{
|
1518 |
{
|
1322 |
final SQLTable tableFour = root.getTable("FOURNISSEUR");
|
1519 |
final SQLTable tableFour = root.getTable("FOURNISSEUR");
|
1323 |
AlterTable tFour = new AlterTable(tableFour);
|
1520 |
AlterTable tFour = new AlterTable(tableFour);
|
1324 |
boolean updateFour = false;
|
1521 |
boolean updateFour = false;
|
1325 |
|
1522 |
|
1326 |
if (!tableFour.contains("ALG_REGISTRE")) {
|
1523 |
if (!tableFour.contains("ALG_REGISTRE")) {
|
1327 |
updateFour = true;
|
1524 |
updateFour = true;
|
1328 |
tFour.addVarCharColumn("ALG_REGISTRE", 512);
|
1525 |
tFour.addVarCharColumn("ALG_REGISTRE", 512);
|
1329 |
}
|
1526 |
}
|
1330 |
if (!tableFour.contains("ALG_MATRICULE")) {
|
1527 |
if (!tableFour.contains("ALG_MATRICULE")) {
|
1331 |
updateFour = true;
|
1528 |
updateFour = true;
|
1332 |
tFour.addVarCharColumn("ALG_MATRICULE", 512);
|
1529 |
tFour.addVarCharColumn("ALG_MATRICULE", 512);
|
1333 |
}
|
1530 |
}
|
1334 |
if (!tableFour.contains("ALG_ARTICLE")) {
|
1531 |
if (!tableFour.contains("ALG_ARTICLE")) {
|
1335 |
updateFour = true;
|
1532 |
updateFour = true;
|
1336 |
tFour.addVarCharColumn("ALG_ARTICLE", 512);
|
1533 |
tFour.addVarCharColumn("ALG_ARTICLE", 512);
|
1337 |
}
|
1534 |
}
|
1338 |
|
1535 |
|
1339 |
if (updateFour) {
|
1536 |
if (updateFour) {
|
1340 |
tableFour.getBase().getDataSource().execute(tFour.asString());
|
1537 |
tableFour.getBase().getDataSource().execute(tFour.asString());
|
1341 |
tableFour.getSchema().updateVersion();
|
1538 |
tableFour.getSchema().updateVersion();
|
1342 |
tableFour.fetchFields();
|
1539 |
tableFour.fetchFields();
|
1343 |
}
|
1540 |
}
|
1344 |
}
|
1541 |
}
|
1345 |
|
1542 |
|
1346 |
}
|
1543 |
}
|
1347 |
|
1544 |
|
1348 |
if (root.getTable("COEFF_PRIME") == null) {
|
1545 |
if (root.getTable("COEFF_PRIME") == null) {
|
1349 |
final SQLCreateTable createTable = new SQLCreateTable(root, "COEFF_PRIME");
|
1546 |
final SQLCreateTable createTable = new SQLCreateTable(root, "COEFF_PRIME");
|
1350 |
// TODO numeric to real
|
1547 |
// TODO numeric to real
|
1351 |
createTable.addColumn("PRIME_PERSO", "real DEFAULT 0");
|
1548 |
createTable.addColumn("PRIME_PERSO", "real DEFAULT 0");
|
1352 |
createTable.addColumn("PRIME_RECONSTRUCTION", "real DEFAULT 0");
|
1549 |
createTable.addColumn("PRIME_RECONSTRUCTION", "real DEFAULT 0");
|
1353 |
createTable.addColumn("PRIME_ANCIENNETE", "real DEFAULT 0");
|
1550 |
createTable.addColumn("PRIME_ANCIENNETE", "real DEFAULT 0");
|
1354 |
createTable.addColumn("PRIME_DEROULEMENT", "real DEFAULT 0");
|
1551 |
createTable.addColumn("PRIME_DEROULEMENT", "real DEFAULT 0");
|
1355 |
|
1552 |
|
1356 |
try {
|
1553 |
try {
|
1357 |
root.getDBSystemRoot().getDataSource().execute(createTable.asString());
|
1554 |
root.getDBSystemRoot().getDataSource().execute(createTable.asString());
|
1358 |
insertUndef(createTable);
|
1555 |
insertUndef(createTable);
|
1359 |
root.refetchTable("COEFF_PRIME");
|
1556 |
root.refetchTable("COEFF_PRIME");
|
1360 |
root.getSchema().updateVersion();
|
1557 |
root.getSchema().updateVersion();
|
1361 |
} catch (SQLException ex) {
|
1558 |
} catch (SQLException ex) {
|
1362 |
throw new IllegalStateException("Erreur lors de la création de la table " + "COEFF_PRIME", ex);
|
1559 |
throw new IllegalStateException("Erreur lors de la création de la table " + "COEFF_PRIME", ex);
|
1363 |
}
|
1560 |
}
|
1364 |
|
1561 |
|
1365 |
SQLTable tableInfosSal = root.getTable("INFOS_SALARIE_PAYE");
|
1562 |
SQLTable tableInfosSal = root.getTable("INFOS_SALARIE_PAYE");
|
1366 |
if (!tableInfosSal.contains("ID_COEFF_PRIME")) {
|
1563 |
if (!tableInfosSal.contains("ID_COEFF_PRIME")) {
|
1367 |
AlterTable t = new AlterTable(tableInfosSal);
|
1564 |
AlterTable t = new AlterTable(tableInfosSal);
|
1368 |
t.addForeignColumn("ID_COEFF_PRIME", root.getTable("COEFF_PRIME"));
|
1565 |
t.addForeignColumn("ID_COEFF_PRIME", root.getTable("COEFF_PRIME"));
|
1369 |
|
1566 |
|
1370 |
try {
|
1567 |
try {
|
1371 |
|
1568 |
|
1372 |
tableInfosSal.getBase().getDataSource().execute(t.asString());
|
1569 |
tableInfosSal.getBase().getDataSource().execute(t.asString());
|
1373 |
tableInfosSal.getSchema().updateVersion();
|
1570 |
tableInfosSal.getSchema().updateVersion();
|
1374 |
tableInfosSal.fetchFields();
|
1571 |
tableInfosSal.fetchFields();
|
1375 |
} catch (SQLException ex) {
|
1572 |
} catch (SQLException ex) {
|
1376 |
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableInfosSal.getName(), ex);
|
1573 |
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableInfosSal.getName(), ex);
|
1377 |
}
|
1574 |
}
|
1378 |
}
|
1575 |
}
|
1379 |
}
|
1576 |
}
|
1380 |
|
1577 |
|
1381 |
SQLTable tableInfosSal = root.getTable("INFOS_SALARIE_PAYE");
|
1578 |
SQLTable tableInfosSal = root.getTable("INFOS_SALARIE_PAYE");
|
1382 |
if (!tableInfosSal.contains("ID_SALARIE")) {
|
1579 |
if (!tableInfosSal.contains("ID_SALARIE")) {
|
1383 |
// Ajout INFOS_SALARIE_PAYE.ID_SALARIE
|
1580 |
// Ajout INFOS_SALARIE_PAYE.ID_SALARIE
|
1384 |
AlterTable t = new AlterTable(tableInfosSal);
|
1581 |
AlterTable t = new AlterTable(tableInfosSal);
|
1385 |
t.addForeignColumn("ID_SALARIE", root.getTable("SALARIE"));
|
1582 |
t.addForeignColumn("ID_SALARIE", root.getTable("SALARIE"));
|
1386 |
|
1583 |
|
1387 |
try {
|
1584 |
try {
|
1388 |
|
1585 |
|
1389 |
tableInfosSal.getBase().getDataSource().execute(t.asString());
|
1586 |
tableInfosSal.getBase().getDataSource().execute(t.asString());
|
1390 |
tableInfosSal.getSchema().updateVersion();
|
1587 |
tableInfosSal.getSchema().updateVersion();
|
1391 |
tableInfosSal.fetchFields();
|
1588 |
tableInfosSal.fetchFields();
|
1392 |
} catch (SQLException ex) {
|
1589 |
} catch (SQLException ex) {
|
1393 |
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableInfosSal.getName(), ex);
|
1590 |
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableInfosSal.getName(), ex);
|
1394 |
}
|
1591 |
}
|
1395 |
|
1592 |
|
1396 |
// Ajout CONTRAT.DEBUT_CONTRAT
|
1593 |
// Ajout CONTRAT.DEBUT_CONTRAT
|
1397 |
SQLTable tableContrat = root.getTable("CONTRAT_SALARIE");
|
1594 |
SQLTable tableContrat = root.getTable("CONTRAT_SALARIE");
|
1398 |
AlterTable tContrat = new AlterTable(tableContrat);
|
1595 |
AlterTable tContrat = new AlterTable(tableContrat);
|
1399 |
tContrat.addDateAndTimeColumn("DATE_DEBUT");
|
1596 |
tContrat.addDateAndTimeColumn("DATE_DEBUT");
|
1400 |
tContrat.addDateAndTimeColumn("DATE_MODIFICATION");
|
1597 |
tContrat.addDateAndTimeColumn("DATE_MODIFICATION");
|
1401 |
// tContrat.addForeignColumn("ID_INFOS_SALARIE_PAYE_MODIFIE", tableInfosSal);
|
1598 |
// tContrat.addForeignColumn("ID_INFOS_SALARIE_PAYE_MODIFIE", tableInfosSal);
|
1402 |
try {
|
1599 |
try {
|
1403 |
tableContrat.getBase().getDataSource().execute(tContrat.asString());
|
1600 |
tableContrat.getBase().getDataSource().execute(tContrat.asString());
|
1404 |
tableContrat.getSchema().updateVersion();
|
1601 |
tableContrat.getSchema().updateVersion();
|
1405 |
tableContrat.fetchFields();
|
1602 |
tableContrat.fetchFields();
|
1406 |
} catch (SQLException ex) {
|
1603 |
} catch (SQLException ex) {
|
1407 |
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableContrat.getName(), ex);
|
1604 |
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableContrat.getName(), ex);
|
1408 |
}
|
1605 |
}
|
1409 |
|
1606 |
|
1410 |
// Ajout FICHE_PAYE.INFOS_SALARIE_PAYE
|
1607 |
// Ajout FICHE_PAYE.INFOS_SALARIE_PAYE
|
1411 |
SQLTable tableFichePaye = root.getTable("FICHE_PAYE");
|
1608 |
SQLTable tableFichePaye = root.getTable("FICHE_PAYE");
|
1412 |
AlterTable tFicheSal = new AlterTable(tableFichePaye);
|
1609 |
AlterTable tFicheSal = new AlterTable(tableFichePaye);
|
1413 |
tFicheSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", root.getTable("INFOS_SALARIE_PAYE"));
|
1610 |
tFicheSal.addForeignColumn("ID_INFOS_SALARIE_PAYE", root.getTable("INFOS_SALARIE_PAYE"));
|
1414 |
try {
|
1611 |
try {
|
1415 |
|
1612 |
|
1416 |
tableFichePaye.getBase().getDataSource().execute(tFicheSal.asString());
|
1613 |
tableFichePaye.getBase().getDataSource().execute(tFicheSal.asString());
|
1417 |
tableFichePaye.getSchema().updateVersion();
|
1614 |
tableFichePaye.getSchema().updateVersion();
|
1418 |
tableFichePaye.fetchFields();
|
1615 |
tableFichePaye.fetchFields();
|
1419 |
} catch (SQLException ex) {
|
1616 |
} catch (SQLException ex) {
|
1420 |
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableFichePaye.getName(), ex);
|
1617 |
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + tableFichePaye.getName(), ex);
|
1421 |
}
|
1618 |
}
|
1422 |
|
1619 |
|
1423 |
{
|
1620 |
{
|
1424 |
// Mise à jour des dates de début de contrat
|
1621 |
// Mise à jour des dates de début de contrat
|
1425 |
UpdateBuilder builderContrat = new UpdateBuilder(tableContrat);
|
1622 |
UpdateBuilder builderContrat = new UpdateBuilder(tableContrat);
|
1426 |
builderContrat.addBackwardVirtualJoin(tableInfosSal, "ID_CONTRAT_SALARIE");
|
1623 |
builderContrat.addBackwardVirtualJoin(tableInfosSal, "ID_CONTRAT_SALARIE");
|
1427 |
builderContrat.setFromVirtualJoinField("DATE_DEBUT", tableInfosSal.getAlias(), "DATE_ARRIVE");
|
1624 |
builderContrat.setFromVirtualJoinField("DATE_DEBUT", tableInfosSal.getAlias(), "DATE_ARRIVE");
|
1428 |
tableInfosSal.getDBSystemRoot().getDataSource().execute(builderContrat.asString());
|
1625 |
tableInfosSal.getDBSystemRoot().getDataSource().execute(builderContrat.asString());
|
1429 |
}
|
1626 |
}
|
1430 |
{
|
1627 |
{
|
1431 |
// Mise à jour des INFOS_SALARIE_PAYE dans les fiches
|
1628 |
// Mise à jour des INFOS_SALARIE_PAYE dans les fiches
|
1432 |
SQLTable tableSalarie = root.getTable("SALARIE");
|
1629 |
SQLTable tableSalarie = root.getTable("SALARIE");
|
1433 |
UpdateBuilder builderFiche = new UpdateBuilder(tableFichePaye);
|
1630 |
UpdateBuilder builderFiche = new UpdateBuilder(tableFichePaye);
|
1434 |
builderFiche.addForwardVirtualJoin(tableSalarie, "ID_SALARIE");
|
1631 |
builderFiche.addForwardVirtualJoin(tableSalarie, "ID_SALARIE");
|
1435 |
builderFiche.setFromVirtualJoinField("ID_INFOS_SALARIE_PAYE", tableSalarie.getAlias(), "ID_INFOS_SALARIE_PAYE");
|
1632 |
builderFiche.setFromVirtualJoinField("ID_INFOS_SALARIE_PAYE", tableSalarie.getAlias(), "ID_INFOS_SALARIE_PAYE");
|
1436 |
tableInfosSal.getDBSystemRoot().getDataSource().execute(builderFiche.asString());
|
1633 |
tableInfosSal.getDBSystemRoot().getDataSource().execute(builderFiche.asString());
|
1437 |
}
|
1634 |
}
|
1438 |
}
|
1635 |
}
|
1439 |
|
1636 |
|
1440 |
// Cumuls paye
|
1637 |
// Cumuls paye
|
1441 |
SQLTable tableCumulsPaye = root.getTable("CUMULS_PAYE");
|
1638 |
SQLTable tableCumulsPaye = root.getTable("CUMULS_PAYE");
|
1442 |
|
1639 |
|
1443 |
AlterTable tCumuls = new AlterTable(tableCumulsPaye);
|
1640 |
AlterTable tCumuls = new AlterTable(tableCumulsPaye);
|
1444 |
tCumuls.alterColumn("NET_IMP_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1641 |
tCumuls.alterColumn("NET_IMP_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1445 |
tCumuls.alterColumn("COT_PAT_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1642 |
tCumuls.alterColumn("COT_PAT_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1446 |
tCumuls.alterColumn("COT_SAL_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1643 |
tCumuls.alterColumn("COT_SAL_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1447 |
tCumuls.alterColumn("SAL_BRUT_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1644 |
tCumuls.alterColumn("SAL_BRUT_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1448 |
tCumuls.alterColumn("NET_A_PAYER_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1645 |
tCumuls.alterColumn("NET_A_PAYER_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1449 |
tCumuls.alterColumn("CSG_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1646 |
tCumuls.alterColumn("CSG_C", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1450 |
if (tableCumulsPaye.contains("HEURE_TRAV") && !tableCumulsPaye.contains("HEURE_TRAV_C")) {
|
1647 |
if (tableCumulsPaye.contains("HEURE_TRAV") && !tableCumulsPaye.contains("HEURE_TRAV_C")) {
|
1451 |
|
1648 |
|
1452 |
AlterTable tColumnNameCumuls = new AlterTable(tableCumulsPaye);
|
1649 |
AlterTable tColumnNameCumuls = new AlterTable(tableCumulsPaye);
|
1453 |
|
1650 |
|
1454 |
tColumnNameCumuls.addClause(new DeferredClause() {
|
1651 |
tColumnNameCumuls.addClause(new DeferredClause() {
|
1455 |
@Override
|
1652 |
@Override
|
1456 |
public String asString(ChangeTable<?> ct, SQLName tableName) {
|
1653 |
public String asString(ChangeTable<?> ct, SQLName tableName) {
|
1457 |
return (root.getServer().getSQLSystem() == SQLSystem.POSTGRESQL ? "RENAME COLUMN \"HEURE_TRAV\" TO \"HEURE_TRAV_C\"" : "ALTER COLUMN \"HEURE_TRAV\" RENAME TO \"HEURE_TRAV_C\"");
|
1654 |
return (root.getServer().getSQLSystem() == SQLSystem.POSTGRESQL ? "RENAME COLUMN \"HEURE_TRAV\" TO \"HEURE_TRAV_C\"" : "ALTER COLUMN \"HEURE_TRAV\" RENAME TO \"HEURE_TRAV_C\"");
|
1458 |
}
|
1655 |
}
|
1459 |
|
1656 |
|
1460 |
@Override
|
1657 |
@Override
|
1461 |
public ClauseType getType() {
|
1658 |
public ClauseType getType() {
|
1462 |
return ClauseType.OTHER;
|
1659 |
return ClauseType.OTHER;
|
1463 |
}
|
1660 |
}
|
1464 |
});
|
1661 |
});
|
1465 |
try {
|
1662 |
try {
|
1466 |
|
1663 |
|
1467 |
tableCumulsPaye.getBase().getDataSource().execute(tColumnNameCumuls.asString());
|
1664 |
tableCumulsPaye.getBase().getDataSource().execute(tColumnNameCumuls.asString());
|
1468 |
tableCumulsPaye.getSchema().updateVersion();
|
1665 |
tableCumulsPaye.getSchema().updateVersion();
|
1469 |
tableCumulsPaye.fetchFields();
|
1666 |
tableCumulsPaye.fetchFields();
|
1470 |
} catch (SQLException ex) {
|
1667 |
} catch (SQLException ex) {
|
1471 |
throw new IllegalStateException("Erreur lors de la modification du champ de la table " + tableCumulsPaye.getName(), ex);
|
1668 |
throw new IllegalStateException("Erreur lors de la modification du champ de la table " + tableCumulsPaye.getName(), ex);
|
1472 |
}
|
1669 |
}
|
1473 |
} else if (!tableCumulsPaye.contains("HEURE_TRAV_C")) {
|
1670 |
} else if (!tableCumulsPaye.contains("HEURE_TRAV_C")) {
|
1474 |
tCumuls.addDecimalColumn("HEURE_TRAV_C", 16, 2, BigDecimal.ZERO, false);
|
1671 |
tCumuls.addDecimalColumn("HEURE_TRAV_C", 16, 2, BigDecimal.ZERO, false);
|
1475 |
}
|
1672 |
}
|
1476 |
|
1673 |
|
1477 |
try {
|
1674 |
try {
|
1478 |
|
1675 |
|
1479 |
tableCumulsPaye.getBase().getDataSource().execute(tCumuls.asString());
|
1676 |
tableCumulsPaye.getBase().getDataSource().execute(tCumuls.asString());
|
1480 |
tableCumulsPaye.getSchema().updateVersion();
|
1677 |
tableCumulsPaye.getSchema().updateVersion();
|
1481 |
tableCumulsPaye.fetchFields();
|
1678 |
tableCumulsPaye.fetchFields();
|
1482 |
} catch (SQLException ex) {
|
1679 |
} catch (SQLException ex) {
|
1483 |
throw new IllegalStateException("Erreur lors de la modification des champs de la table " + tableCumulsPaye.getName(), ex);
|
1680 |
throw new IllegalStateException("Erreur lors de la modification des champs de la table " + tableCumulsPaye.getName(), ex);
|
1484 |
}
|
1681 |
}
|
1485 |
|
1682 |
|
1486 |
// element paye
|
1683 |
// element paye
|
1487 |
SQLTable tableElementPaye = root.getTable("FICHE_PAYE_ELEMENT");
|
1684 |
SQLTable tableElementPaye = root.getTable("FICHE_PAYE_ELEMENT");
|
1488 |
|
1685 |
|
1489 |
AlterTable tEltPaye = new AlterTable(tableElementPaye);
|
1686 |
AlterTable tEltPaye = new AlterTable(tableElementPaye);
|
1490 |
tEltPaye.alterColumn("TAUX_PAT", EnumSet.allOf(Properties.class), "numeric(16,6)", "0", true);
|
1687 |
tEltPaye.alterColumn("TAUX_PAT", EnumSet.allOf(Properties.class), "numeric(16,6)", "0", true);
|
1491 |
tEltPaye.alterColumn("MONTANT_SAL_AJ", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1688 |
tEltPaye.alterColumn("MONTANT_SAL_AJ", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1492 |
tEltPaye.alterColumn("TAUX_SAL", EnumSet.allOf(Properties.class), "numeric(16,6)", "0", true);
|
1689 |
tEltPaye.alterColumn("TAUX_SAL", EnumSet.allOf(Properties.class), "numeric(16,6)", "0", true);
|
1493 |
tEltPaye.alterColumn("MONTANT_SAL_DED", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1690 |
tEltPaye.alterColumn("MONTANT_SAL_DED", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1494 |
tEltPaye.alterColumn("MONTANT_PAT", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1691 |
tEltPaye.alterColumn("MONTANT_PAT", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1495 |
tEltPaye.alterColumn("NB_BASE", EnumSet.allOf(Properties.class), "numeric(16,6)", "0", true);
|
1692 |
tEltPaye.alterColumn("NB_BASE", EnumSet.allOf(Properties.class), "numeric(16,6)", "0", true);
|
1496 |
|
1693 |
|
1497 |
try {
|
1694 |
try {
|
1498 |
|
1695 |
|
1499 |
tableElementPaye.getBase().getDataSource().execute(tEltPaye.asString());
|
1696 |
tableElementPaye.getBase().getDataSource().execute(tEltPaye.asString());
|
1500 |
tableElementPaye.getSchema().updateVersion();
|
1697 |
tableElementPaye.getSchema().updateVersion();
|
1501 |
tableElementPaye.fetchFields();
|
1698 |
tableElementPaye.fetchFields();
|
1502 |
} catch (SQLException ex) {
|
1699 |
} catch (SQLException ex) {
|
1503 |
throw new IllegalStateException("Erreur lors de la modification des champs de la table " + tableElementPaye.getName(), ex);
|
1700 |
throw new IllegalStateException("Erreur lors de la modification des champs de la table " + tableElementPaye.getName(), ex);
|
1504 |
}
|
1701 |
}
|
1505 |
|
1702 |
|
1506 |
// paye
|
1703 |
// paye
|
1507 |
SQLTable tablePaye = root.getTable("FICHE_PAYE");
|
1704 |
SQLTable tablePaye = root.getTable("FICHE_PAYE");
|
1508 |
|
1705 |
|
1509 |
AlterTable tPaye = new AlterTable(tablePaye);
|
1706 |
AlterTable tPaye = new AlterTable(tablePaye);
|
1510 |
tPaye.alterColumn("ACOMPTE", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1707 |
tPaye.alterColumn("ACOMPTE", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1511 |
tPaye.alterColumn("NET_IMP", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1708 |
tPaye.alterColumn("NET_IMP", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1512 |
tPaye.alterColumn("COT_PAT", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1709 |
tPaye.alterColumn("COT_PAT", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1513 |
tPaye.alterColumn("NET_A_PAYER", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1710 |
tPaye.alterColumn("NET_A_PAYER", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1514 |
tPaye.alterColumn("SAL_BRUT", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1711 |
tPaye.alterColumn("SAL_BRUT", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1515 |
tPaye.alterColumn("CSG", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1712 |
tPaye.alterColumn("CSG", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1516 |
tPaye.alterColumn("COT_SAL", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1713 |
tPaye.alterColumn("COT_SAL", EnumSet.allOf(Properties.class), "numeric(16,2)", "0", true);
|
1517 |
|
1714 |
|
1518 |
try {
|
1715 |
try {
|
1519 |
tablePaye.getBase().getDataSource().execute(tPaye.asString());
|
1716 |
tablePaye.getBase().getDataSource().execute(tPaye.asString());
|
1520 |
tablePaye.getSchema().updateVersion();
|
1717 |
tablePaye.getSchema().updateVersion();
|
1521 |
tablePaye.fetchFields();
|
1718 |
tablePaye.fetchFields();
|
1522 |
} catch (SQLException ex) {
|
1719 |
} catch (SQLException ex) {
|
1523 |
throw new IllegalStateException("Erreur lors de la modification des champs de la table " + tablePaye.getName(), ex);
|
1720 |
throw new IllegalStateException("Erreur lors de la modification des champs de la table " + tablePaye.getName(), ex);
|
1524 |
}
|
1721 |
}
|
1525 |
|
1722 |
|
1526 |
if (root.getTable("ARTICLE_ELEMENT") == null) {
|
1723 |
if (root.getTable("ARTICLE_ELEMENT") == null) {
|
1527 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ARTICLE_ELEMENT");
|
1724 |
final SQLCreateTable createTable = new SQLCreateTable(root, "ARTICLE_ELEMENT");
|
1528 |
createTable.addForeignColumn("ARTICLE");
|
1725 |
createTable.addForeignColumn("ARTICLE");
|
1529 |
createTable.addForeignColumn("ID_ARTICLE_PARENT", root.getTable("ARTICLE"));
|
1726 |
createTable.addForeignColumn("ID_ARTICLE_PARENT", root.getTable("ARTICLE"));
|
1530 |
createTable.addIntegerColumn("QTE", 1);
|
1727 |
createTable.addIntegerColumn("QTE", 1);
|
1531 |
createTable.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.valueOf(1), false);
|
1728 |
createTable.addDecimalColumn("QTE_UNITAIRE", 16, 6, BigDecimal.valueOf(1), false);
|
1532 |
createTable.addForeignColumn("UNITE_VENTE");
|
1729 |
createTable.addForeignColumn("UNITE_VENTE");
|
1533 |
try {
|
1730 |
try {
|
1534 |
root.getBase().getDataSource().execute(createTable.asString());
|
1731 |
root.getBase().getDataSource().execute(createTable.asString());
|
1535 |
insertUndef(createTable);
|
1732 |
insertUndef(createTable);
|
1536 |
root.refetchTable("ARTICLE_ELEMENT");
|
1733 |
root.refetchTable("ARTICLE_ELEMENT");
|
1537 |
root.getSchema().updateVersion();
|
1734 |
root.getSchema().updateVersion();
|
1538 |
} catch (SQLException ex) {
|
1735 |
} catch (SQLException ex) {
|
1539 |
throw new IllegalStateException("Erreur lors de la création de la table " + "ARTICLE_ELEMENT", ex);
|
1736 |
throw new IllegalStateException("Erreur lors de la création de la table " + "ARTICLE_ELEMENT", ex);
|
1540 |
}
|
1737 |
}
|
1541 |
}
|
1738 |
}
|
1542 |
|
1739 |
|
1543 |
if (root.getTable("VILLE") == null) {
|
1740 |
if (root.getTable("VILLE") == null) {
|
1544 |
final SQLCreateTable createTable = new SQLCreateTable(root, "VILLE");
|
1741 |
final SQLCreateTable createTable = new SQLCreateTable(root, "VILLE");
|
1545 |
createTable.addLongColumn("X_LAMBERT", 0L, true);
|
1742 |
createTable.addLongColumn("X_LAMBERT", 0L, true);
|
1546 |
createTable.addLongColumn("Y_LAMBERT", 0L, true);
|
1743 |
createTable.addLongColumn("Y_LAMBERT", 0L, true);
|
1547 |
createTable.addLongColumn("POPULATION", 0L, true);
|
1744 |
createTable.addLongColumn("POPULATION", 0L, true);
|
1548 |
createTable.addVarCharColumn("NOM", 512);
|
1745 |
createTable.addVarCharColumn("NOM", 512);
|
1549 |
createTable.addVarCharColumn("CODE_POSTAL", 256);
|
1746 |
createTable.addVarCharColumn("CODE_POSTAL", 256);
|
1550 |
try {
|
1747 |
try {
|
1551 |
root.getBase().getDataSource().execute(createTable.asString());
|
1748 |
root.getBase().getDataSource().execute(createTable.asString());
|
1552 |
insertUndef(createTable);
|
1749 |
insertUndef(createTable);
|
1553 |
root.refetchTable("VILLE");
|
1750 |
root.refetchTable("VILLE");
|
1554 |
root.getSchema().updateVersion();
|
1751 |
root.getSchema().updateVersion();
|
1555 |
} catch (SQLException ex) {
|
1752 |
} catch (SQLException ex) {
|
1556 |
throw new IllegalStateException("Erreur lors de la création de la table " + "VILLE", ex);
|
1753 |
throw new IllegalStateException("Erreur lors de la création de la table " + "VILLE", ex);
|
1557 |
}
|
1754 |
}
|
1558 |
}
|
1755 |
}
|
1559 |
|
1756 |
|
1560 |
// Gestion des différentes numérotation
|
1757 |
// Gestion des différentes numérotation
|
1561 |
if (!root.getTable("NUMEROTATION_AUTO").contains("NOM")) {
|
1758 |
if (!root.getTable("NUMEROTATION_AUTO").contains("NOM")) {
|
1562 |
final SQLTable tableNum = root.getTable("NUMEROTATION_AUTO");
|
1759 |
final SQLTable tableNum = root.getTable("NUMEROTATION_AUTO");
|
1563 |
AlterTable tNum = new AlterTable(tableNum);
|
1760 |
AlterTable tNum = new AlterTable(tableNum);
|
1564 |
tNum.addColumn("NOM", "varchar (256)", "'Standard'", true);
|
1761 |
tNum.addColumn("NOM", "varchar (256)", "'Standard'", true);
|
1565 |
|
1762 |
|
1566 |
root.getBase().getDataSource().execute(tNum.asString());
|
1763 |
root.getBase().getDataSource().execute(tNum.asString());
|
1567 |
tableNum.fetchFields();
|
1764 |
tableNum.fetchFields();
|
1568 |
root.getSchema().updateVersion();
|
1765 |
root.getSchema().updateVersion();
|
1569 |
|
1766 |
|
1570 |
}
|
1767 |
}
|
1571 |
|
1768 |
|
1572 |
// Gestion du timbre fiscal
|
1769 |
// Gestion du timbre fiscal
|
1573 |
if (!root.getTable("CLIENT").contains("TIMBRE_FISCAL")) {
|
1770 |
if (!root.getTable("CLIENT").contains("TIMBRE_FISCAL")) {
|
1574 |
AlterTable tClient = new AlterTable(root.getTable("CLIENT"));
|
1771 |
AlterTable tClient = new AlterTable(root.getTable("CLIENT"));
|
1575 |
tClient.addBooleanColumn("TIMBRE_FISCAL", Boolean.FALSE, false);
|
1772 |
tClient.addBooleanColumn("TIMBRE_FISCAL", Boolean.FALSE, false);
|
1576 |
root.getBase().getDataSource().execute(tClient.asString());
|
1773 |
root.getBase().getDataSource().execute(tClient.asString());
|
1577 |
root.getSchema().updateVersion();
|
1774 |
root.getSchema().updateVersion();
|
1578 |
}
|
1775 |
}
|
1579 |
// Obsolete
|
1776 |
// Obsolete
|
1580 |
if (!root.getTable("CLIENT").contains("OBSOLETE")) {
|
1777 |
if (!root.getTable("CLIENT").contains("OBSOLETE")) {
|
1581 |
AlterTable tClient = new AlterTable(root.getTable("CLIENT"));
|
1778 |
AlterTable tClient = new AlterTable(root.getTable("CLIENT"));
|
1582 |
tClient.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
1779 |
tClient.addBooleanColumn("OBSOLETE", Boolean.FALSE, false);
|
1583 |
root.getBase().getDataSource().execute(tClient.asString());
|
1780 |
root.getBase().getDataSource().execute(tClient.asString());
|
1584 |
root.getSchema().updateVersion();
|
1781 |
root.getSchema().updateVersion();
|
1585 |
}
|
1782 |
}
|
1586 |
|
1783 |
|
1587 |
// Relance
|
1784 |
// Relance
|
1588 |
if (!root.getTable("RELANCE").contains("ID_ECHEANCE_CLIENT")) {
|
1785 |
if (!root.getTable("RELANCE").contains("ID_ECHEANCE_CLIENT")) {
|
1589 |
AlterTable tRelance = new AlterTable(root.getTable("RELANCE"));
|
1786 |
AlterTable tRelance = new AlterTable(root.getTable("RELANCE"));
|
1590 |
tRelance.addForeignColumn("ID_ECHEANCE_CLIENT", root.getTable("ECHEANCE_CLIENT"));
|
1787 |
tRelance.addForeignColumn("ID_ECHEANCE_CLIENT", root.getTable("ECHEANCE_CLIENT"));
|
1591 |
root.getBase().getDataSource().execute(tRelance.asString());
|
1788 |
root.getBase().getDataSource().execute(tRelance.asString());
|
1592 |
root.getSchema().updateVersion();
|
1789 |
root.getSchema().updateVersion();
|
1593 |
}
|
1790 |
}
|
1594 |
|
1791 |
|
1595 |
if (!root.getTable("AVOIR_CLIENT_ELEMENT").contains("RETOUR_STOCK")) {
|
1792 |
if (!root.getTable("AVOIR_CLIENT_ELEMENT").contains("RETOUR_STOCK")) {
|
1596 |
final SQLTable tableAvoirElt = root.getTable("AVOIR_CLIENT_ELEMENT");
|
1793 |
final SQLTable tableAvoirElt = root.getTable("AVOIR_CLIENT_ELEMENT");
|
1597 |
AlterTable tAvoir = new AlterTable(tableAvoirElt);
|
1794 |
AlterTable tAvoir = new AlterTable(tableAvoirElt);
|
1598 |
tAvoir.addBooleanColumn("RETOUR_STOCK", Boolean.FALSE, false);
|
1795 |
tAvoir.addBooleanColumn("RETOUR_STOCK", Boolean.FALSE, false);
|
1599 |
root.getBase().getDataSource().execute(tAvoir.asString());
|
1796 |
root.getBase().getDataSource().execute(tAvoir.asString());
|
1600 |
root.getSchema().updateVersion();
|
1797 |
root.getSchema().updateVersion();
|
1601 |
tableAvoirElt.fetchFields();
|
1798 |
tableAvoirElt.fetchFields();
|
1602 |
}
|
1799 |
}
|
1603 |
|
1800 |
|
1604 |
final SQLTable tableVenteFacture = root.getTable("SAISIE_VENTE_FACTURE");
|
1801 |
final SQLTable tableVenteFacture = root.getTable("SAISIE_VENTE_FACTURE");
|
1605 |
AlterTable tFacture = new AlterTable(tableVenteFacture);
|
1802 |
AlterTable tFacture = new AlterTable(tableVenteFacture);
|
1606 |
boolean alterFacture = false;
|
1803 |
boolean alterFacture = false;
|
1607 |
boolean upNET = false;
|
1804 |
boolean upNET = false;
|
1608 |
if (!tableVenteFacture.contains("SOUMIS_TIMBRE_FISCAL")) {
|
1805 |
if (!tableVenteFacture.contains("SOUMIS_TIMBRE_FISCAL")) {
|
1609 |
tFacture.addBooleanColumn("SOUMIS_TIMBRE_FISCAL", Boolean.FALSE, true);
|
1806 |
tFacture.addBooleanColumn("SOUMIS_TIMBRE_FISCAL", Boolean.FALSE, true);
|
1610 |
alterFacture = true;
|
1807 |
alterFacture = true;
|
1611 |
}
|
1808 |
}
|
1612 |
if (!tableVenteFacture.contains("TAUX_TIMBRE_FISCAL")) {
|
1809 |
if (!tableVenteFacture.contains("TAUX_TIMBRE_FISCAL")) {
|
1613 |
tFacture.addDecimalColumn("TAUX_TIMBRE_FISCAL", 16, 4, BigDecimal.ONE, true);
|
1810 |
tFacture.addDecimalColumn("TAUX_TIMBRE_FISCAL", 16, 4, BigDecimal.ONE, true);
|
1614 |
alterFacture = true;
|
1811 |
alterFacture = true;
|
1615 |
}
|
1812 |
}
|
1616 |
if (!tableVenteFacture.contains("TOTAL_TIMBRE_FISCAL")) {
|
1813 |
if (!tableVenteFacture.contains("TOTAL_TIMBRE_FISCAL")) {
|
1617 |
tFacture.addLongColumn("TOTAL_TIMBRE_FISCAL", 0L, true);
|
1814 |
tFacture.addLongColumn("TOTAL_TIMBRE_FISCAL", 0L, true);
|
1618 |
alterFacture = true;
|
1815 |
alterFacture = true;
|
1619 |
}
|
1816 |
}
|
1620 |
if (!tableVenteFacture.contains("NET_A_PAYER")) {
|
1817 |
if (!tableVenteFacture.contains("NET_A_PAYER")) {
|
1621 |
tFacture.addLongColumn("NET_A_PAYER", 0L, true);
|
1818 |
tFacture.addLongColumn("NET_A_PAYER", 0L, true);
|
1622 |
alterFacture = true;
|
1819 |
alterFacture = true;
|
1623 |
upNET = true;
|
1820 |
upNET = true;
|
1624 |
}
|
1821 |
}
|
1625 |
if (alterFacture) {
|
1822 |
if (alterFacture) {
|
1626 |
root.getBase().getDataSource().execute(tFacture.asString());
|
1823 |
root.getBase().getDataSource().execute(tFacture.asString());
|
1627 |
root.getSchema().updateVersion();
|
1824 |
root.getSchema().updateVersion();
|
1628 |
tableVenteFacture.fetchFields();
|
1825 |
tableVenteFacture.fetchFields();
|
1629 |
if (upNET) {
|
1826 |
if (upNET) {
|
1630 |
String req = "UPDATE " + tableVenteFacture.getSQLName().quote() + " SET \"NET_A_PAYER\"=(\"T_TTC\"-\"T_AVOIR_TTC\")";
|
1827 |
String req = "UPDATE " + tableVenteFacture.getSQLName().quote() + " SET \"NET_A_PAYER\"=(\"T_TTC\"-\"T_AVOIR_TTC\")";
|
1631 |
root.getBase().getDataSource().execute(req);
|
1828 |
root.getBase().getDataSource().execute(req);
|
1632 |
}
|
1829 |
}
|
1633 |
}
|
1830 |
}
|
1634 |
|
1831 |
|
1635 |
SQLTable tableTaxe = root.getTable("TAXE");
|
1832 |
SQLTable tableTaxe = root.getTable("TAXE");
|
1636 |
boolean updateTaxe = false;
|
1833 |
boolean updateTaxe = false;
|
1637 |
AlterTable tTaxe = new AlterTable(tableTaxe);
|
1834 |
AlterTable tTaxe = new AlterTable(tableTaxe);
|
1638 |
if (!tableTaxe.contains("ID_COMPTE_PCE_VENTE")) {
|
1835 |
if (!tableTaxe.contains("ID_COMPTE_PCE_VENTE")) {
|
1639 |
tTaxe.addForeignColumn("ID_COMPTE_PCE_VENTE", root.getTable("COMPTE_PCE"));
|
1836 |
tTaxe.addForeignColumn("ID_COMPTE_PCE_VENTE", root.getTable("COMPTE_PCE"));
|
1640 |
updateTaxe = true;
|
1837 |
updateTaxe = true;
|
1641 |
}
|
1838 |
}
|
1642 |
if (!tableTaxe.contains("ID_COMPTE_PCE_VENTE_SERVICE")) {
|
1839 |
if (!tableTaxe.contains("ID_COMPTE_PCE_VENTE_SERVICE")) {
|
1643 |
tTaxe.addForeignColumn("ID_COMPTE_PCE_VENTE_SERVICE", root.getTable("COMPTE_PCE"));
|
1840 |
tTaxe.addForeignColumn("ID_COMPTE_PCE_VENTE_SERVICE", root.getTable("COMPTE_PCE"));
|
1644 |
updateTaxe = true;
|
1841 |
updateTaxe = true;
|
1645 |
}
|
1842 |
}
|
1646 |
|
1843 |
|
1647 |
if (updateTaxe) {
|
1844 |
if (updateTaxe) {
|
1648 |
try {
|
1845 |
try {
|
1649 |
tableTaxe.getBase().getDataSource().execute(tTaxe.asString());
|
1846 |
tableTaxe.getBase().getDataSource().execute(tTaxe.asString());
|
1650 |
tableTaxe.getSchema().updateVersion();
|
1847 |
tableTaxe.getSchema().updateVersion();
|
1651 |
tableTaxe.fetchFields();
|
1848 |
tableTaxe.fetchFields();
|
1652 |
} catch (SQLException ex) {
|
1849 |
} catch (SQLException ex) {
|
1653 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table TAXE", ex);
|
1850 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table TAXE", ex);
|
1654 |
}
|
1851 |
}
|
1655 |
|
1852 |
|
1656 |
}
|
1853 |
}
|
1657 |
|
1854 |
|
1658 |
// Tarification par quantite
|
1855 |
// Tarification par quantite
|
1659 |
if (root.getTable("TARIF_QUANTITE") == null) {
|
1856 |
if (root.getTable("TARIF_QUANTITE") == null) {
|
1660 |
final SQLCreateTable createTableQtyTarif = new SQLCreateTable(root, "TARIF_QUANTITE");
|
1857 |
final SQLCreateTable createTableQtyTarif = new SQLCreateTable(root, "TARIF_QUANTITE");
|
1661 |
createTableQtyTarif.addForeignColumn("ID_ARTICLE", root.getTable("ARTICLE"));
|
1858 |
createTableQtyTarif.addForeignColumn("ID_ARTICLE", root.getTable("ARTICLE"));
|
1662 |
createTableQtyTarif.addDecimalColumn("QUANTITE", 16, 3, BigDecimal.ONE, false);
|
1859 |
createTableQtyTarif.addDecimalColumn("QUANTITE", 16, 3, BigDecimal.ONE, false);
|
1663 |
createTableQtyTarif.addDecimalColumn("POURCENT_REMISE", 16, 3, null, true);
|
1860 |
createTableQtyTarif.addDecimalColumn("POURCENT_REMISE", 16, 3, null, true);
|
1664 |
createTableQtyTarif.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, null, true);
|
1861 |
createTableQtyTarif.addDecimalColumn("PRIX_METRIQUE_VT_1", 16, 6, null, true);
|
1665 |
try {
|
1862 |
try {
|
1666 |
root.getBase().getDataSource().execute(createTableQtyTarif.asString());
|
1863 |
root.getBase().getDataSource().execute(createTableQtyTarif.asString());
|
1667 |
insertUndef(createTableQtyTarif);
|
1864 |
insertUndef(createTableQtyTarif);
|
1668 |
root.refetchTable("TARIF_QUANTITE");
|
1865 |
root.refetchTable("TARIF_QUANTITE");
|
1669 |
root.getSchema().updateVersion();
|
1866 |
root.getSchema().updateVersion();
|
1670 |
} catch (SQLException ex) {
|
1867 |
} catch (SQLException ex) {
|
1671 |
throw new IllegalStateException("Erreur lors de la création de la table " + "TARIF_QUANTITE", ex);
|
1868 |
throw new IllegalStateException("Erreur lors de la création de la table " + "TARIF_QUANTITE", ex);
|
1672 |
}
|
1869 |
}
|
1673 |
}
|
1870 |
}
|
1674 |
// Articles fournisseurs
|
1871 |
// Articles fournisseurs
|
1675 |
addArticleFournisseur(root);
|
1872 |
addArticleFournisseur(root);
|
1676 |
|
1873 |
|
1677 |
SQLTable tableCmdF = root.getTable("COMMANDE");
|
1874 |
SQLTable tableCmdF = root.getTable("COMMANDE");
|
1678 |
if (!tableCmdF.contains("ID_MODELE")) {
|
1875 |
if (!tableCmdF.contains("ID_MODELE")) {
|
1679 |
AlterTable t = new AlterTable(tableCmdF);
|
1876 |
AlterTable t = new AlterTable(tableCmdF);
|
1680 |
t.addForeignColumn("ID_MODELE", root.getTable("MODELE"));
|
1877 |
t.addForeignColumn("ID_MODELE", root.getTable("MODELE"));
|
1681 |
tableCmdF.getBase().getDataSource().execute(t.asString());
|
1878 |
tableCmdF.getBase().getDataSource().execute(t.asString());
|
1682 |
tableCmdF.getSchema().updateVersion();
|
1879 |
tableCmdF.getSchema().updateVersion();
|
1683 |
tableCmdF.fetchFields();
|
1880 |
tableCmdF.fetchFields();
|
1684 |
}
|
1881 |
}
|
1685 |
|
1882 |
|
1686 |
SQLTable tableArtF = root.getTable("ARTICLE_FOURNISSEUR");
|
1883 |
SQLTable tableArtF = root.getTable("ARTICLE_FOURNISSEUR");
|
1687 |
if (!tableArtF.contains("ID_FAMILLE_ARTICLE")) {
|
1884 |
if (!tableArtF.contains("ID_FAMILLE_ARTICLE")) {
|
1688 |
AlterTable t = new AlterTable(tableArtF);
|
1885 |
AlterTable t = new AlterTable(tableArtF);
|
1689 |
t.addForeignColumn("ID_FAMILLE_ARTICLE", root.getTable("FAMILLE_ARTICLE"));
|
1886 |
t.addForeignColumn("ID_FAMILLE_ARTICLE", root.getTable("FAMILLE_ARTICLE"));
|
1690 |
tableArtF.getBase().getDataSource().execute(t.asString());
|
1887 |
tableArtF.getBase().getDataSource().execute(t.asString());
|
1691 |
tableArtF.getSchema().updateVersion();
|
1888 |
tableArtF.getSchema().updateVersion();
|
1692 |
tableArtF.fetchFields();
|
1889 |
tableArtF.fetchFields();
|
1693 |
}
|
1890 |
}
|
1694 |
|
1891 |
|
1695 |
if (!tableCmdF.contains("DATE_RECEPTION_DEMANDEE")) {
|
1892 |
if (!tableCmdF.contains("DATE_RECEPTION_DEMANDEE")) {
|
1696 |
AlterTable t = new AlterTable(tableCmdF);
|
1893 |
AlterTable t = new AlterTable(tableCmdF);
|
1697 |
t.addColumn("DATE_RECEPTION_DEMANDEE", "date");
|
1894 |
t.addColumn("DATE_RECEPTION_DEMANDEE", "date");
|
1698 |
t.addColumn("DATE_RECEPTION_CONFIRMEE", "date");
|
1895 |
t.addColumn("DATE_RECEPTION_CONFIRMEE", "date");
|
1699 |
tableCmdF.getBase().getDataSource().execute(t.asString());
|
1896 |
tableCmdF.getBase().getDataSource().execute(t.asString());
|
1700 |
tableCmdF.getSchema().updateVersion();
|
1897 |
tableCmdF.getSchema().updateVersion();
|
1701 |
tableCmdF.fetchFields();
|
1898 |
tableCmdF.fetchFields();
|
1702 |
}
|
1899 |
}
|
1703 |
|
1900 |
|
1704 |
SQLTable tableEcr = root.getTable("ECRITURE");
|
1901 |
SQLTable tableEcr = root.getTable("ECRITURE");
|
1705 |
if (!tableEcr.contains("NOM_PIECE")) {
|
1902 |
if (!tableEcr.contains("NOM_PIECE")) {
|
1706 |
AlterTable t = new AlterTable(tableEcr);
|
1903 |
AlterTable t = new AlterTable(tableEcr);
|
1707 |
t.addVarCharColumn("NOM_PIECE", 1024);
|
1904 |
t.addVarCharColumn("NOM_PIECE", 1024);
|
1708 |
tableEcr.getBase().getDataSource().execute(t.asString());
|
1905 |
tableEcr.getBase().getDataSource().execute(t.asString());
|
1709 |
tableEcr.getSchema().updateVersion();
|
1906 |
tableEcr.getSchema().updateVersion();
|
1710 |
tableEcr.fetchFields();
|
1907 |
tableEcr.fetchFields();
|
1711 |
}
|
1908 |
}
|
1712 |
|
1909 |
|
1713 |
SQLTable tableKm = root.getTable("SAISIE_KM_ELEMENT");
|
1910 |
SQLTable tableKm = root.getTable("SAISIE_KM_ELEMENT");
|
1714 |
if (!tableKm.contains("NOM_PIECE")) {
|
1911 |
if (!tableKm.contains("NOM_PIECE")) {
|
1715 |
AlterTable t = new AlterTable(tableKm);
|
1912 |
AlterTable t = new AlterTable(tableKm);
|
1716 |
t.addVarCharColumn("NOM_PIECE", 1024);
|
1913 |
t.addVarCharColumn("NOM_PIECE", 1024);
|
1717 |
|
1914 |
|
1718 |
tableKm.getBase().getDataSource().execute(t.asString());
|
1915 |
tableKm.getBase().getDataSource().execute(t.asString());
|
1719 |
tableKm.getSchema().updateVersion();
|
1916 |
tableKm.getSchema().updateVersion();
|
1720 |
tableKm.fetchFields();
|
1917 |
tableKm.fetchFields();
|
1721 |
}
|
1918 |
}
|
1722 |
|
1919 |
|
1723 |
{
|
1920 |
{
|
1724 |
SQLSelect sel = new SQLSelect();
|
1921 |
SQLSelect sel = new SQLSelect();
|
1725 |
final SQLTable tableStyle = root.getTable("STYLE");
|
1922 |
final SQLTable tableStyle = root.getTable("STYLE");
|
1726 |
sel.addSelect(tableStyle.getKey());
|
1923 |
sel.addSelect(tableStyle.getKey());
|
1727 |
sel.setWhere(new Where(tableStyle.getField("NOM"), "=", "Composant"));
|
1924 |
sel.setWhere(new Where(tableStyle.getField("NOM"), "=", "Composant"));
|
1728 |
String req = sel.asString();
|
1925 |
String req = sel.asString();
|
1729 |
List<Map<String, Object>> l = root.getDBSystemRoot().getDataSource().execute(req);
|
1926 |
List<Map<String, Object>> l = root.getDBSystemRoot().getDataSource().execute(req);
|
1730 |
|
1927 |
|
1731 |
if (l.size() == 0) {
|
1928 |
if (l.size() == 0) {
|
1732 |
SQLRowValues rowValsStyle = new SQLRowValues(tableStyle);
|
1929 |
SQLRowValues rowValsStyle = new SQLRowValues(tableStyle);
|
1733 |
rowValsStyle.put("NOM", "Composant");
|
1930 |
rowValsStyle.put("NOM", "Composant");
|
1734 |
rowValsStyle.put("CODE", "COMP");
|
1931 |
rowValsStyle.put("CODE", "COMP");
|
1735 |
rowValsStyle.insert();
|
1932 |
rowValsStyle.insert();
|
1736 |
}
|
1933 |
}
|
1737 |
}
|
1934 |
}
|
1738 |
|
1935 |
|
1739 |
{
|
1936 |
{
|
1740 |
// Fix qté et style
|
1937 |
// Fix qté et style
|
1741 |
List<String> tableElt = Arrays.asList("AVOIR_CLIENT_ELEMENT", "BON_DE_LIVRAISON_ELEMENT", "BON_RECEPTION_ELEMENT", "COMMANDE_CLIENT_ELEMENT", "COMMANDE_ELEMENT", "DEVIS_ELEMENT",
|
1938 |
List<String> tableElt = Arrays.asList("AVOIR_CLIENT_ELEMENT", "BON_DE_LIVRAISON_ELEMENT", "BON_RECEPTION_ELEMENT", "COMMANDE_CLIENT_ELEMENT", "COMMANDE_ELEMENT", "DEVIS_ELEMENT",
|
1742 |
"SAISIE_VENTE_FACTURE_ELEMENT");
|
1939 |
"SAISIE_VENTE_FACTURE_ELEMENT");
|
1743 |
for (String string : tableElt) {
|
1940 |
for (String string : tableElt) {
|
1744 |
final SQLTable table = root.getTable(string);
|
1941 |
final SQLTable table = root.getTable(string);
|
1745 |
Number undefined = table.getUndefinedIDNumber();
|
1942 |
Number undefined = table.getUndefinedIDNumber();
|
1746 |
if (undefined != null && undefined.intValue() > 0) {
|
1943 |
if (undefined != null && undefined.intValue() > 0) {
|
1747 |
UpdateBuilder build = new UpdateBuilder(table);
|
1944 |
UpdateBuilder build = new UpdateBuilder(table);
|
1748 |
build.setObject("ID_STYLE", 2);
|
1945 |
build.setObject("ID_STYLE", 2);
|
1749 |
build.setObject("QTE", 1);
|
1946 |
build.setObject("QTE", 1);
|
1750 |
build.setWhere(new Where(table.getKey(), "=", undefined.intValue()));
|
1947 |
build.setWhere(new Where(table.getKey(), "=", undefined.intValue()));
|
1751 |
table.getDBSystemRoot().getDataSource().execute(build.asString());
|
1948 |
table.getDBSystemRoot().getDataSource().execute(build.asString());
|
1752 |
}
|
1949 |
}
|
1753 |
}
|
1950 |
}
|
1754 |
}
|
1951 |
}
|
1755 |
|
1952 |
|
1756 |
// ADresse de livraison et remise
|
1953 |
// ADresse de livraison et remise
|
1757 |
{
|
1954 |
{
|
1758 |
SQLTable tableDevis = root.getTable("DEVIS");
|
1955 |
SQLTable tableDevis = root.getTable("DEVIS");
|
1759 |
addAdresseField(tableDevis, root);
|
1956 |
addAdresseField(tableDevis, root);
|
1760 |
addRemiseField(tableDevis, root);
|
1957 |
addRemiseField(tableDevis, root);
|
1761 |
|
1958 |
|
1762 |
SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE");
|
1959 |
SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE");
|
1763 |
addAdresseField(tableVF, root);
|
1960 |
addAdresseField(tableVF, root);
|
1764 |
addRemiseField(tableVF, root);
|
1961 |
addRemiseField(tableVF, root);
|
1765 |
|
1962 |
|
1766 |
SQLTable tableCmd = root.getTable("COMMANDE_CLIENT");
|
1963 |
SQLTable tableCmd = root.getTable("COMMANDE_CLIENT");
|
1767 |
addAdresseField(tableCmd, root);
|
1964 |
addAdresseField(tableCmd, root);
|
1768 |
addRemiseField(tableCmd, root);
|
1965 |
addRemiseField(tableCmd, root);
|
1769 |
|
1966 |
|
1770 |
SQLTable tableBon = root.getTable("BON_DE_LIVRAISON");
|
1967 |
SQLTable tableBon = root.getTable("BON_DE_LIVRAISON");
|
1771 |
addAdresseField(tableBon, root);
|
1968 |
addAdresseField(tableBon, root);
|
1772 |
addRemiseField(tableBon, root);
|
1969 |
addRemiseField(tableBon, root);
|
1773 |
|
1970 |
|
1774 |
SQLTable tableAvoir = root.getTable("AVOIR_CLIENT");
|
1971 |
SQLTable tableAvoir = root.getTable("AVOIR_CLIENT");
|
1775 |
addAdresseField(tableAvoir, root);
|
1972 |
addAdresseField(tableAvoir, root);
|
1776 |
addRemiseField(tableAvoir, root);
|
1973 |
addRemiseField(tableAvoir, root);
|
1777 |
}
|
1974 |
}
|
1778 |
// Service client
|
1975 |
// Service client
|
1779 |
if (root.getTable("CLIENT_DEPARTEMENT") == null) {
|
1976 |
if (root.getTable("CLIENT_DEPARTEMENT") == null) {
|
1780 |
final SQLCreateTable createTableDpt = new SQLCreateTable(root, "CLIENT_DEPARTEMENT");
|
1977 |
final SQLCreateTable createTableDpt = new SQLCreateTable(root, "CLIENT_DEPARTEMENT");
|
1781 |
createTableDpt.addForeignColumn("CLIENT");
|
1978 |
createTableDpt.addForeignColumn("CLIENT");
|
1782 |
if (root.contains("ADRESSE")) {
|
1979 |
if (root.contains("ADRESSE")) {
|
1783 |
createTableDpt.addForeignColumn("ADRESSE");
|
1980 |
createTableDpt.addForeignColumn("ADRESSE");
|
1784 |
} else {
|
1981 |
} else {
|
1785 |
createTableDpt.addForeignColumn("ID_ADRESSE", root.findTable("ADRESSE"));
|
1982 |
createTableDpt.addForeignColumn("ID_ADRESSE", root.findTable("ADRESSE"));
|
1786 |
}
|
1983 |
}
|
1787 |
createTableDpt.addVarCharColumn("INFOS", 2048);
|
1984 |
createTableDpt.addVarCharColumn("INFOS", 2048);
|
1788 |
createTableDpt.addVarCharColumn("NOM", 256);
|
1985 |
createTableDpt.addVarCharColumn("NOM", 256);
|
1789 |
try {
|
1986 |
try {
|
1790 |
root.getBase().getDataSource().execute(createTableDpt.asString());
|
1987 |
root.getBase().getDataSource().execute(createTableDpt.asString());
|
1791 |
insertUndef(createTableDpt);
|
1988 |
insertUndef(createTableDpt);
|
1792 |
root.refetchTable("CLIENT_DEPARTEMENT");
|
1989 |
root.refetchTable("CLIENT_DEPARTEMENT");
|
1793 |
root.getSchema().updateVersion();
|
1990 |
root.getSchema().updateVersion();
|
1794 |
} catch (SQLException ex2) {
|
1991 |
} catch (SQLException ex2) {
|
1795 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CLIENT_DEPARTEMENT", ex2);
|
1992 |
throw new IllegalStateException("Erreur lors de la création de la table " + "CLIENT_DEPARTEMENT", ex2);
|
1796 |
}
|
1993 |
}
|
1797 |
}
|
1994 |
}
|
1798 |
|
1995 |
|
1799 |
SQLTable tableVFElt = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
1996 |
SQLTable tableVFElt = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
1800 |
patchFieldElt1Dot4(tableVFElt, root);
|
1997 |
patchFieldElt1Dot4(tableVFElt, root);
|
1801 |
|
1998 |
|
1802 |
SQLTable tableDevisElt = root.getTable("DEVIS_ELEMENT");
|
1999 |
SQLTable tableDevisElt = root.getTable("DEVIS_ELEMENT");
|
1803 |
patchFieldElt1Dot4(tableDevisElt, root);
|
2000 |
patchFieldElt1Dot4(tableDevisElt, root);
|
1804 |
|
2001 |
|
1805 |
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
|
2002 |
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
|
1806 |
|
2003 |
|
1807 |
patchFieldElt1Dot4(tableCmdElt, root);
|
2004 |
patchFieldElt1Dot4(tableCmdElt, root);
|
1808 |
|
2005 |
|
1809 |
SQLTable tableBonElt = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
2006 |
SQLTable tableBonElt = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
1810 |
patchFieldElt1Dot4(tableBonElt, root);
|
2007 |
patchFieldElt1Dot4(tableBonElt, root);
|
1811 |
|
2008 |
|
1812 |
SQLTable tableAvoirElt = root.getTable("AVOIR_CLIENT_ELEMENT");
|
2009 |
SQLTable tableAvoirElt = root.getTable("AVOIR_CLIENT_ELEMENT");
|
1813 |
patchFieldElt1Dot4(tableAvoirElt, root);
|
2010 |
patchFieldElt1Dot4(tableAvoirElt, root);
|
1814 |
|
2011 |
|
1815 |
addNiveauElementField(root.getTable("COMMANDE_ELEMENT"));
|
2012 |
addNiveauElementField(root.getTable("COMMANDE_ELEMENT"));
|
1816 |
addNiveauElementField(root.getTable("BON_RECEPTION_ELEMENT"));
|
2013 |
addNiveauElementField(root.getTable("BON_RECEPTION_ELEMENT"));
|
1817 |
addNiveauElementField(root.getTable("FACTURE_FOURNISSEUR_ELEMENT"));
|
2014 |
addNiveauElementField(root.getTable("FACTURE_FOURNISSEUR_ELEMENT"));
|
1818 |
|
2015 |
|
1819 |
addContact(root);
|
2016 |
addContact(root);
|
1820 |
|
2017 |
|
1821 |
{
|
2018 |
{
|
1822 |
// Gestion des préparations de commandes
|
2019 |
// Gestion des préparations de commandes
|
1823 |
final SQLTable tableCommandeClient = root.getTable("COMMANDE_CLIENT");
|
2020 |
final SQLTable tableCommandeClient = root.getTable("COMMANDE_CLIENT");
|
1824 |
AlterTable tCommandeClient = new AlterTable(tableCommandeClient);
|
2021 |
AlterTable tCommandeClient = new AlterTable(tableCommandeClient);
|
1825 |
boolean updateCmdCli = false;
|
2022 |
boolean updateCmdCli = false;
|
1826 |
|
2023 |
|
1827 |
if (!tableCommandeClient.contains("ETAT_COMMANDE")) {
|
2024 |
if (!tableCommandeClient.contains("ETAT_COMMANDE")) {
|
1828 |
updateCmdCli = true;
|
2025 |
updateCmdCli = true;
|
1829 |
tCommandeClient.addIntegerColumn("ETAT_COMMANDE", EtatCommandeClient.A_PREPARER.getId());
|
2026 |
tCommandeClient.addIntegerColumn("ETAT_COMMANDE", EtatCommandeClient.A_PREPARER.getId());
|
1830 |
}
|
2027 |
}
|
1831 |
if (!tableCommandeClient.contains("EMBALLAGE")) {
|
2028 |
if (!tableCommandeClient.contains("EMBALLAGE")) {
|
1832 |
updateCmdCli = true;
|
2029 |
updateCmdCli = true;
|
1833 |
tCommandeClient.addVarCharColumn("EMBALLAGE", 256);
|
2030 |
tCommandeClient.addVarCharColumn("EMBALLAGE", 256);
|
1834 |
}
|
2031 |
}
|
1835 |
if (!tableCommandeClient.contains("NUMERO_EXPEDITION")) {
|
2032 |
if (!tableCommandeClient.contains("NUMERO_EXPEDITION")) {
|
1836 |
updateCmdCli = true;
|
2033 |
updateCmdCli = true;
|
1837 |
tCommandeClient.addVarCharColumn("NUMERO_EXPEDITION", 256);
|
2034 |
tCommandeClient.addVarCharColumn("NUMERO_EXPEDITION", 256);
|
1838 |
}
|
2035 |
}
|
1839 |
|
2036 |
|
1840 |
if (!tableCommandeClient.contains("ID_TAXE_PORT")) {
|
2037 |
if (!tableCommandeClient.contains("ID_TAXE_PORT")) {
|
1841 |
updateCmdCli = true;
|
2038 |
updateCmdCli = true;
|
1842 |
tCommandeClient.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
2039 |
tCommandeClient.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
1843 |
}
|
2040 |
}
|
1844 |
|
2041 |
|
1845 |
if (!tableCommandeClient.contains("PORT_HT")) {
|
2042 |
if (!tableCommandeClient.contains("PORT_HT")) {
|
1846 |
updateCmdCli = true;
|
2043 |
updateCmdCli = true;
|
1847 |
tCommandeClient.addLongColumn("PORT_HT", Long.valueOf(0), false);
|
2044 |
tCommandeClient.addLongColumn("PORT_HT", Long.valueOf(0), false);
|
1848 |
}
|
2045 |
}
|
1849 |
|
2046 |
|
1850 |
if (!tableCommandeClient.contains("REMISE_HT")) {
|
2047 |
if (!tableCommandeClient.contains("REMISE_HT")) {
|
1851 |
updateCmdCli = true;
|
2048 |
updateCmdCli = true;
|
1852 |
tCommandeClient.addLongColumn("REMISE_HT", Long.valueOf(0), false);
|
2049 |
tCommandeClient.addLongColumn("REMISE_HT", Long.valueOf(0), false);
|
1853 |
}
|
2050 |
}
|
1854 |
|
2051 |
|
1855 |
if (updateCmdCli) {
|
2052 |
if (updateCmdCli) {
|
1856 |
tableCommandeClient.getBase().getDataSource().execute(tCommandeClient.asString());
|
2053 |
tableCommandeClient.getBase().getDataSource().execute(tCommandeClient.asString());
|
1857 |
tableCommandeClient.getSchema().updateVersion();
|
2054 |
tableCommandeClient.getSchema().updateVersion();
|
1858 |
tableCommandeClient.fetchFields();
|
2055 |
tableCommandeClient.fetchFields();
|
1859 |
}
|
2056 |
}
|
1860 |
}
|
2057 |
}
|
1861 |
|
2058 |
|
1862 |
{
|
2059 |
{
|
1863 |
// Gestion des préparations de commandes
|
2060 |
// Gestion des préparations de commandes
|
1864 |
final SQLTable tableBonL = root.getTable("BON_DE_LIVRAISON");
|
2061 |
final SQLTable tableBonL = root.getTable("BON_DE_LIVRAISON");
|
1865 |
AlterTable tBonL = new AlterTable(tableBonL);
|
2062 |
AlterTable tBonL = new AlterTable(tableBonL);
|
1866 |
boolean updateBonL = false;
|
2063 |
boolean updateBonL = false;
|
1867 |
|
2064 |
|
1868 |
if (!tableBonL.contains("TOTAL_DEVISE")) {
|
2065 |
if (!tableBonL.contains("TOTAL_DEVISE")) {
|
1869 |
updateBonL = true;
|
2066 |
updateBonL = true;
|
1870 |
tBonL.addLongColumn("TOTAL_DEVISE", Long.valueOf(0), false);
|
2067 |
tBonL.addLongColumn("TOTAL_DEVISE", Long.valueOf(0), false);
|
1871 |
}
|
2068 |
}
|
1872 |
|
2069 |
|
1873 |
if (!tableBonL.contains("TOTAL_SERVICE")) {
|
2070 |
if (!tableBonL.contains("TOTAL_SERVICE")) {
|
1874 |
updateBonL = true;
|
2071 |
updateBonL = true;
|
1875 |
tBonL.addLongColumn("TOTAL_SERVICE", Long.valueOf(0), false);
|
2072 |
tBonL.addLongColumn("TOTAL_SERVICE", Long.valueOf(0), false);
|
1876 |
}
|
2073 |
}
|
1877 |
|
2074 |
|
1878 |
if (!tableBonL.contains("ID_TAXE_PORT")) {
|
2075 |
if (!tableBonL.contains("ID_TAXE_PORT")) {
|
1879 |
updateBonL = true;
|
2076 |
updateBonL = true;
|
1880 |
tBonL.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
2077 |
tBonL.addForeignColumn("ID_TAXE_PORT", root.getTable("TAXE"));
|
1881 |
}
|
2078 |
}
|
1882 |
|
2079 |
|
1883 |
if (!tableBonL.contains("PORT_HT")) {
|
2080 |
if (!tableBonL.contains("PORT_HT")) {
|
1884 |
updateBonL = true;
|
2081 |
updateBonL = true;
|
1885 |
tBonL.addLongColumn("PORT_HT", Long.valueOf(0), false);
|
2082 |
tBonL.addLongColumn("PORT_HT", Long.valueOf(0), false);
|
1886 |
}
|
2083 |
}
|
1887 |
|
2084 |
|
1888 |
if (!tableBonL.contains("REMISE_HT")) {
|
2085 |
if (!tableBonL.contains("REMISE_HT")) {
|
1889 |
updateBonL = true;
|
2086 |
updateBonL = true;
|
1890 |
tBonL.addLongColumn("REMISE_HT", Long.valueOf(0), false);
|
2087 |
tBonL.addLongColumn("REMISE_HT", Long.valueOf(0), false);
|
1891 |
}
|
2088 |
}
|
1892 |
|
2089 |
|
1893 |
if (updateBonL) {
|
2090 |
if (updateBonL) {
|
1894 |
tableBonL.getBase().getDataSource().execute(tBonL.asString());
|
2091 |
tableBonL.getBase().getDataSource().execute(tBonL.asString());
|
1895 |
tableBonL.getSchema().updateVersion();
|
2092 |
tableBonL.getSchema().updateVersion();
|
1896 |
tableBonL.fetchFields();
|
2093 |
tableBonL.fetchFields();
|
1897 |
}
|
2094 |
}
|
1898 |
}
|
2095 |
}
|
1899 |
|
2096 |
|
1900 |
final List<String> asList = Arrays.asList("SAISIE_VENTE_FACTURE", "BON_RECEPTION", "BON_DE_LIVRAISON");
|
2097 |
final List<String> asList = Arrays.asList("SAISIE_VENTE_FACTURE", "BON_RECEPTION", "BON_DE_LIVRAISON");
|
1901 |
for (String tableVirtualStockName : asList) {
|
2098 |
for (String tableVirtualStockName : asList) {
|
1902 |
SQLTable tableVirtualStock = root.getTable(tableVirtualStockName);
|
2099 |
SQLTable tableVirtualStock = root.getTable(tableVirtualStockName);
|
1903 |
if (!tableVirtualStock.contains("CREATE_VIRTUAL_STOCK")) {
|
2100 |
if (!tableVirtualStock.contains("CREATE_VIRTUAL_STOCK")) {
|
1904 |
AlterTable t = new AlterTable(tableVirtualStock);
|
2101 |
AlterTable t = new AlterTable(tableVirtualStock);
|
1905 |
t.addBooleanColumn("CREATE_VIRTUAL_STOCK", Boolean.TRUE, false);
|
2102 |
t.addBooleanColumn("CREATE_VIRTUAL_STOCK", Boolean.TRUE, false);
|
1906 |
tableVirtualStock.getBase().getDataSource().execute(t.asString());
|
2103 |
tableVirtualStock.getBase().getDataSource().execute(t.asString());
|
1907 |
tableVirtualStock.getSchema().updateVersion();
|
2104 |
tableVirtualStock.getSchema().updateVersion();
|
1908 |
tableVirtualStock.fetchFields();
|
2105 |
tableVirtualStock.fetchFields();
|
1909 |
}
|
2106 |
}
|
1910 |
}
|
2107 |
}
|
1911 |
|
2108 |
|
1912 |
// Remise dans les devis
|
2109 |
// Remise dans les devis
|
1913 |
final SQLTable tableDevis = root.getTable("DEVIS");
|
2110 |
final SQLTable tableDevis = root.getTable("DEVIS");
|
1914 |
AlterTable tDevis = new AlterTable(tableDevis);
|
2111 |
AlterTable tDevis = new AlterTable(tableDevis);
|
1915 |
boolean updateDevis = false;
|
2112 |
boolean updateDevis = false;
|
1916 |
|
2113 |
|
1917 |
if (!tableDevis.contains("POURCENT_REMISE")) {
|
2114 |
if (!tableDevis.contains("POURCENT_REMISE")) {
|
1918 |
updateDevis = true;
|
2115 |
updateDevis = true;
|
1919 |
tDevis.addColumn("POURCENT_REMISE", "numeric (12,8)");
|
2116 |
tDevis.addColumn("POURCENT_REMISE", "numeric (12,8)");
|
1920 |
}
|
2117 |
}
|
1921 |
if (!tableDevis.contains("MONTANT_REMISE")) {
|
2118 |
if (!tableDevis.contains("MONTANT_REMISE")) {
|
1922 |
updateDevis = true;
|
2119 |
updateDevis = true;
|
1923 |
tDevis.addColumn("MONTANT_REMISE", "numeric (16,8)");
|
2120 |
tDevis.addColumn("MONTANT_REMISE", "numeric (16,8)");
|
1924 |
}
|
2121 |
}
|
1925 |
if (!tableDevis.contains("T_HA")) {
|
2122 |
if (!tableDevis.contains("T_HA")) {
|
1926 |
updateDevis = true;
|
2123 |
updateDevis = true;
|
1927 |
tDevis.addColumn("T_HA", "bigint", "0", false);
|
2124 |
tDevis.addColumn("T_HA", "bigint", "0", false);
|
1928 |
}
|
2125 |
}
|
1929 |
|
2126 |
|
1930 |
if (!tableDevis.contains("DUNNING_DATE")) {
|
2127 |
if (!tableDevis.contains("DUNNING_DATE")) {
|
1931 |
updateDevis = true;
|
2128 |
updateDevis = true;
|
1932 |
tDevis.addColumn("DUNNING_DATE", "date");
|
2129 |
tDevis.addColumn("DUNNING_DATE", "date");
|
1933 |
}
|
2130 |
}
|
1934 |
|
2131 |
|
1935 |
if (updateDevis) {
|
2132 |
if (updateDevis) {
|
1936 |
tableDevis.getBase().getDataSource().execute(tDevis.asString());
|
2133 |
tableDevis.getBase().getDataSource().execute(tDevis.asString());
|
1937 |
tableDevis.getSchema().updateVersion();
|
2134 |
tableDevis.getSchema().updateVersion();
|
1938 |
tableDevis.fetchFields();
|
2135 |
tableDevis.fetchFields();
|
1939 |
}
|
2136 |
}
|
1940 |
|
2137 |
|
1941 |
final SQLTable tableKmElt = root.getTable("SAISIE_KM_ELEMENT");
|
2138 |
final SQLTable tableKmElt = root.getTable("SAISIE_KM_ELEMENT");
|
1942 |
if (!tableKmElt.contains("ANALYTIQUE")) {
|
2139 |
if (!tableKmElt.contains("ANALYTIQUE")) {
|
1943 |
AlterTable t = new AlterTable(tableKmElt);
|
2140 |
AlterTable t = new AlterTable(tableKmElt);
|
1944 |
t.addVarCharColumn("ANALYTIQUE", 256);
|
2141 |
t.addVarCharColumn("ANALYTIQUE", 256);
|
1945 |
tableKmElt.getBase().getDataSource().execute(t.asString());
|
2142 |
tableKmElt.getBase().getDataSource().execute(t.asString());
|
1946 |
tableKmElt.getSchema().updateVersion();
|
2143 |
tableKmElt.getSchema().updateVersion();
|
1947 |
tableKmElt.fetchFields();
|
2144 |
tableKmElt.fetchFields();
|
1948 |
|
2145 |
|
1949 |
}
|
2146 |
}
|
1950 |
|
2147 |
|
1951 |
final SQLTable tableClient = root.getTable("CLIENT");
|
2148 |
final SQLTable tableClient = root.getTable("CLIENT");
|
1952 |
final SQLTable tableAdresse = tableClient.getForeignTable("ID_ADRESSE");
|
2149 |
final SQLTable tableAdresse = tableClient.getForeignTable("ID_ADRESSE");
|
1953 |
if (tableAdresse != null) {
|
2150 |
if (tableAdresse != null) {
|
1954 |
AlterTable t = new AlterTable(tableAdresse);
|
2151 |
AlterTable t = new AlterTable(tableAdresse);
|
1955 |
boolean updateADr = false;
|
2152 |
boolean updateADr = false;
|
1956 |
if (!tableAdresse.contains("PROVINCE")) {
|
2153 |
if (!tableAdresse.contains("PROVINCE")) {
|
1957 |
t.addVarCharColumn("PROVINCE", 256);
|
2154 |
t.addVarCharColumn("PROVINCE", 256);
|
1958 |
updateADr = true;
|
2155 |
updateADr = true;
|
1959 |
}
|
2156 |
}
|
1960 |
if (!tableAdresse.contains("LIBELLE")) {
|
2157 |
if (!tableAdresse.contains("LIBELLE")) {
|
1961 |
t.addVarCharColumn("LIBELLE", 256);
|
2158 |
t.addVarCharColumn("LIBELLE", 256);
|
1962 |
updateADr = true;
|
2159 |
updateADr = true;
|
1963 |
}
|
2160 |
}
|
1964 |
if (!tableAdresse.contains("TYPE")) {
|
2161 |
if (!tableAdresse.contains("TYPE")) {
|
1965 |
t.addVarCharColumn("TYPE", 256);
|
2162 |
t.addVarCharColumn("TYPE", 256);
|
1966 |
updateADr = true;
|
2163 |
updateADr = true;
|
1967 |
}
|
2164 |
}
|
1968 |
if (!tableAdresse.contains("EMAIL_CONTACT")) {
|
2165 |
if (!tableAdresse.contains("EMAIL_CONTACT")) {
|
1969 |
t.addVarCharColumn("EMAIL_CONTACT", 256);
|
2166 |
t.addVarCharColumn("EMAIL_CONTACT", 256);
|
1970 |
updateADr = true;
|
2167 |
updateADr = true;
|
1971 |
}
|
2168 |
}
|
1972 |
if (updateADr) {
|
2169 |
if (updateADr) {
|
1973 |
tableAdresse.getBase().getDataSource().execute(t.asString());
|
2170 |
tableAdresse.getBase().getDataSource().execute(t.asString());
|
1974 |
tableAdresse.getSchema().updateVersion();
|
2171 |
tableAdresse.getSchema().updateVersion();
|
1975 |
tableAdresse.fetchFields();
|
2172 |
tableAdresse.fetchFields();
|
1976 |
}
|
2173 |
}
|
1977 |
}
|
2174 |
}
|
1978 |
|
2175 |
|
1979 |
if (tableClient != null) {
|
2176 |
if (tableClient != null) {
|
1980 |
AlterTable t = new AlterTable(tableClient);
|
2177 |
AlterTable t = new AlterTable(tableClient);
|
1981 |
boolean upClient = false;
|
2178 |
boolean upClient = false;
|
1982 |
if (!tableClient.contains("REMIND_DATE")) {
|
2179 |
if (!tableClient.contains("REMIND_DATE")) {
|
1983 |
t.addDateAndTimeColumn("REMIND_DATE");
|
2180 |
t.addDateAndTimeColumn("REMIND_DATE");
|
1984 |
upClient = true;
|
2181 |
upClient = true;
|
1985 |
}
|
2182 |
}
|
1986 |
if (!tableClient.contains("BLOQUE_LIVRAISON")) {
|
2183 |
if (!tableClient.contains("BLOQUE_LIVRAISON")) {
|
1987 |
t.addBooleanColumn("BLOQUE_LIVRAISON", false, false);
|
2184 |
t.addBooleanColumn("BLOQUE_LIVRAISON", false, false);
|
1988 |
upClient = true;
|
2185 |
upClient = true;
|
1989 |
}
|
2186 |
}
|
1990 |
if (!tableClient.contains("BLOQUE")) {
|
2187 |
if (!tableClient.contains("BLOQUE")) {
|
1991 |
upClient = true;
|
2188 |
upClient = true;
|
1992 |
t.addBooleanColumn("BLOQUE", false, false);
|
2189 |
t.addBooleanColumn("BLOQUE", false, false);
|
1993 |
}
|
2190 |
}
|
1994 |
if (!tableClient.contains("ID_COMPTE_PCE_SERVICE")) {
|
2191 |
if (!tableClient.contains("ID_COMPTE_PCE_SERVICE")) {
|
1995 |
upClient = true;
|
2192 |
upClient = true;
|
1996 |
t.addForeignColumn("ID_COMPTE_PCE_SERVICE", tableClient.getTable("COMPTE_PCE"));
|
2193 |
t.addForeignColumn("ID_COMPTE_PCE_SERVICE", tableClient.getTable("COMPTE_PCE"));
|
1997 |
}
|
2194 |
}
|
1998 |
|
2195 |
|
1999 |
if (!tableClient.contains("ID_COMPTE_PCE_PRODUIT")) {
|
2196 |
if (!tableClient.contains("ID_COMPTE_PCE_PRODUIT")) {
|
2000 |
upClient = true;
|
2197 |
upClient = true;
|
2001 |
t.addForeignColumn("ID_COMPTE_PCE_PRODUIT", tableClient.getTable("COMPTE_PCE"));
|
2198 |
t.addForeignColumn("ID_COMPTE_PCE_PRODUIT", tableClient.getTable("COMPTE_PCE"));
|
2002 |
}
|
2199 |
}
|
2003 |
|
2200 |
|
2004 |
if (!tableClient.contains("ENCOURS_MAX")) {
|
2201 |
if (!tableClient.contains("ENCOURS_MAX")) {
|
2005 |
upClient = true;
|
2202 |
upClient = true;
|
2006 |
t.addDecimalColumn("ENCOURS_MAX", 16, 2, BigDecimal.valueOf(0), false);
|
2203 |
t.addDecimalColumn("ENCOURS_MAX", 16, 2, BigDecimal.valueOf(0), false);
|
2007 |
}
|
2204 |
}
|
2008 |
if (!tableClient.contains("CATEGORIES")) {
|
2205 |
if (!tableClient.contains("CATEGORIES")) {
|
2009 |
upClient = true;
|
2206 |
upClient = true;
|
2010 |
t.addVarCharColumn("CATEGORIES", 2048);
|
2207 |
t.addVarCharColumn("CATEGORIES", 2048);
|
2011 |
}
|
2208 |
}
|
2012 |
if (!tableClient.contains("NOTE_FINANCIERE")) {
|
2209 |
if (!tableClient.contains("NOTE_FINANCIERE")) {
|
2013 |
upClient = true;
|
2210 |
upClient = true;
|
2014 |
t.addVarCharColumn("NOTE_FINANCIERE", 1024);
|
2211 |
t.addVarCharColumn("NOTE_FINANCIERE", 1024);
|
2015 |
}
|
2212 |
}
|
2016 |
if (!tableClient.contains("CENTRE_GESTION")) {
|
2213 |
if (!tableClient.contains("CENTRE_GESTION")) {
|
2017 |
upClient = true;
|
2214 |
upClient = true;
|
2018 |
t.addVarCharColumn("CENTRE_GESTION", 1024);
|
2215 |
t.addVarCharColumn("CENTRE_GESTION", 1024);
|
2019 |
}
|
2216 |
}
|
2020 |
if (!tableClient.contains("METHODE_RELANCE")) {
|
2217 |
if (!tableClient.contains("METHODE_RELANCE")) {
|
2021 |
upClient = true;
|
2218 |
upClient = true;
|
2022 |
t.addVarCharColumn("METHODE_RELANCE", 1024);
|
2219 |
t.addVarCharColumn("METHODE_RELANCE", 1024);
|
2023 |
}
|
2220 |
}
|
2024 |
if (!tableClient.contains("SITE_INTERNET")) {
|
2221 |
if (!tableClient.contains("SITE_INTERNET")) {
|
2025 |
upClient = true;
|
2222 |
upClient = true;
|
2026 |
t.addVarCharColumn("SITE_INTERNET", 2048);
|
2223 |
t.addVarCharColumn("SITE_INTERNET", 2048);
|
2027 |
}
|
2224 |
}
|
2028 |
if (!tableClient.contains("GROUPE")) {
|
2225 |
if (!tableClient.contains("GROUPE")) {
|
2029 |
upClient = true;
|
2226 |
upClient = true;
|
2030 |
t.addVarCharColumn("GROUPE", 1024);
|
2227 |
t.addVarCharColumn("GROUPE", 1024);
|
2031 |
}
|
2228 |
}
|
2032 |
if (!tableClient.contains("ID_COMMERCIAL")) {
|
2229 |
if (!tableClient.contains("ID_COMMERCIAL")) {
|
2033 |
upClient = true;
|
2230 |
upClient = true;
|
2034 |
t.addForeignColumn("ID_COMMERCIAL", tableClient.getTable("COMMERCIAL"));
|
2231 |
t.addForeignColumn("ID_COMMERCIAL", tableClient.getTable("COMMERCIAL"));
|
2035 |
}
|
2232 |
}
|
2036 |
|
2233 |
|
2037 |
if (upClient) {
|
2234 |
if (upClient) {
|
2038 |
tableClient.getBase().getDataSource().execute(t.asString());
|
2235 |
tableClient.getBase().getDataSource().execute(t.asString());
|
2039 |
tableClient.getSchema().updateVersion();
|
2236 |
tableClient.getSchema().updateVersion();
|
2040 |
tableClient.fetchFields();
|
2237 |
tableClient.fetchFields();
|
2041 |
}
|
2238 |
}
|
2042 |
}
|
2239 |
}
|
2043 |
if (!root.contains("CATEGORIE_CLIENT")) {
|
2240 |
if (!root.contains("CATEGORIE_CLIENT")) {
|
2044 |
final SQLCreateTable createCategorieClientTable = new SQLCreateTable(root, "CATEGORIE_CLIENT");
|
2241 |
final SQLCreateTable createCategorieClientTable = new SQLCreateTable(root, "CATEGORIE_CLIENT");
|
2045 |
createCategorieClientTable.addVarCharColumn("NOM", 1024);
|
2242 |
createCategorieClientTable.addVarCharColumn("NOM", 1024);
|
2046 |
|
2243 |
|
2047 |
try {
|
2244 |
try {
|
2048 |
root.getDBSystemRoot().getDataSource().execute(createCategorieClientTable.asString());
|
2245 |
root.getDBSystemRoot().getDataSource().execute(createCategorieClientTable.asString());
|
2049 |
insertUndef(createCategorieClientTable);
|
2246 |
insertUndef(createCategorieClientTable);
|
2050 |
tableDevis.getSchema().updateVersion();
|
2247 |
tableDevis.getSchema().updateVersion();
|
2051 |
} catch (SQLException ex) {
|
2248 |
} catch (SQLException ex) {
|
2052 |
throw new IllegalStateException("Erreur lors de la création de la table CATEGORIE_CLIENT", ex);
|
2249 |
throw new IllegalStateException("Erreur lors de la création de la table CATEGORIE_CLIENT", ex);
|
2053 |
}
|
2250 |
}
|
2054 |
|
2251 |
|
2055 |
}
|
2252 |
}
|
2056 |
|
2253 |
|
2057 |
final SQLTable tableAssoc = root.getTable("ASSOCIATION_ANALYTIQUE");
|
2254 |
final SQLTable tableAssoc = root.getTable("ASSOCIATION_ANALYTIQUE");
|
2058 |
if (tableAssoc != null && !tableAssoc.contains("GESTION_AUTO")) {
|
2255 |
if (tableAssoc != null && !tableAssoc.contains("GESTION_AUTO")) {
|
2059 |
AlterTable t = new AlterTable(tableAssoc);
|
2256 |
AlterTable t = new AlterTable(tableAssoc);
|
2060 |
t.addBooleanColumn("GESTION_AUTO", false, false);
|
2257 |
t.addBooleanColumn("GESTION_AUTO", false, false);
|
2061 |
tableAssoc.getBase().getDataSource().execute(t.asString());
|
2258 |
tableAssoc.getBase().getDataSource().execute(t.asString());
|
2062 |
tableAssoc.getSchema().updateVersion();
|
2259 |
tableAssoc.getSchema().updateVersion();
|
2063 |
tableAssoc.fetchFields();
|
2260 |
tableAssoc.fetchFields();
|
2064 |
}
|
2261 |
}
|
2065 |
if (!root.contains("CALENDAR_ITEM")) {
|
2262 |
if (!root.contains("CALENDAR_ITEM")) {
|
2066 |
final SQLCreateTable createTaskGroupTable = new SQLCreateTable(root, "CALENDAR_ITEM_GROUP");
|
2263 |
final SQLCreateTable createTaskGroupTable = new SQLCreateTable(root, "CALENDAR_ITEM_GROUP");
|
2067 |
createTaskGroupTable.addVarCharColumn("NAME", 1024);
|
2264 |
createTaskGroupTable.addVarCharColumn("NAME", 1024);
|
2068 |
createTaskGroupTable.addVarCharColumn("DESCRIPTION", 1024 * 8);
|
2265 |
createTaskGroupTable.addVarCharColumn("DESCRIPTION", 1024 * 8);
|
2069 |
|
2266 |
|
2070 |
final SQLCreateTable createTaskTable = new SQLCreateTable(root, "CALENDAR_ITEM");
|
2267 |
final SQLCreateTable createTaskTable = new SQLCreateTable(root, "CALENDAR_ITEM");
|
2071 |
createTaskTable.addDateAndTimeColumn("START");
|
2268 |
createTaskTable.addDateAndTimeColumn("START");
|
2072 |
createTaskTable.addDateAndTimeColumn("END");
|
2269 |
createTaskTable.addDateAndTimeColumn("END");
|
2073 |
createTaskTable.addLongColumn("DURATION_S", 0L, false);
|
2270 |
createTaskTable.addLongColumn("DURATION_S", 0L, false);
|
2074 |
createTaskTable.addVarCharColumn("SUMMARY", 1024);
|
2271 |
createTaskTable.addVarCharColumn("SUMMARY", 1024);
|
2075 |
createTaskTable.addVarCharColumn("DESCRIPTION", 1024 * 8);
|
2272 |
createTaskTable.addVarCharColumn("DESCRIPTION", 1024 * 8);
|
2076 |
createTaskTable.addVarCharColumn("FLAGS", 1024);
|
2273 |
createTaskTable.addVarCharColumn("FLAGS", 1024);
|
2077 |
createTaskTable.addVarCharColumn("STATUS", 128);
|
2274 |
createTaskTable.addVarCharColumn("STATUS", 128);
|
2078 |
createTaskTable.addForeignColumn(createTaskGroupTable);
|
2275 |
createTaskTable.addForeignColumn(createTaskGroupTable);
|
2079 |
createTaskTable.addLongColumn("SOURCE_ID", null, true);
|
2276 |
createTaskTable.addLongColumn("SOURCE_ID", null, true);
|
2080 |
createTaskTable.addVarCharColumn("SOURCE_TABLE", 256);
|
2277 |
createTaskTable.addVarCharColumn("SOURCE_TABLE", 256);
|
2081 |
createTaskTable.addVarCharColumn("UID", 1024);
|
2278 |
createTaskTable.addVarCharColumn("UID", 1024);
|
2082 |
createTaskTable.addVarCharColumn("LOCATION", 4096);
|
2279 |
createTaskTable.addVarCharColumn("LOCATION", 4096);
|
2083 |
try {
|
2280 |
try {
|
2084 |
root.getDBSystemRoot().getDataSource().execute(createTaskGroupTable.asString());
|
2281 |
root.getDBSystemRoot().getDataSource().execute(createTaskGroupTable.asString());
|
2085 |
insertUndef(createTaskGroupTable);
|
2282 |
insertUndef(createTaskGroupTable);
|
2086 |
root.getDBSystemRoot().getDataSource().execute(createTaskTable.asString());
|
2283 |
root.getDBSystemRoot().getDataSource().execute(createTaskTable.asString());
|
2087 |
insertUndef(createTaskTable);
|
2284 |
insertUndef(createTaskTable);
|
2088 |
tableDevis.getSchema().updateVersion();
|
2285 |
tableDevis.getSchema().updateVersion();
|
2089 |
root.refetchTable("CALENDAR_ITEM_GROUP");
|
2286 |
root.refetchTable("CALENDAR_ITEM_GROUP");
|
2090 |
root.refetchTable("CALENDAR_ITEM");
|
2287 |
root.refetchTable("CALENDAR_ITEM");
|
2091 |
|
2288 |
|
2092 |
} catch (SQLException ex) {
|
2289 |
} catch (SQLException ex) {
|
2093 |
throw new IllegalStateException("Erreur lors de la création de la table TASK", ex);
|
2290 |
throw new IllegalStateException("Erreur lors de la création de la table TASK", ex);
|
2094 |
}
|
2291 |
}
|
2095 |
|
2292 |
|
2096 |
}
|
2293 |
}
|
2097 |
|
2294 |
|
2098 |
// Remise sur tarif client
|
2295 |
// Remise sur tarif client
|
2099 |
if (root.contains("ARTICLE_TARIF")) {
|
2296 |
if (root.contains("ARTICLE_TARIF")) {
|
2100 |
|
2297 |
|
2101 |
AlterTable t = new AlterTable(root.getTable("ARTICLE_TARIF"));
|
2298 |
AlterTable t = new AlterTable(root.getTable("ARTICLE_TARIF"));
|
2102 |
boolean alterTarif = false;
|
2299 |
boolean alterTarif = false;
|
2103 |
if (!root.getTable("ARTICLE_TARIF").contains("POURCENT_REMISE")) {
|
2300 |
if (!root.getTable("ARTICLE_TARIF").contains("POURCENT_REMISE")) {
|
2104 |
t.addDecimalColumn("POURCENT_REMISE", 16, 6, BigDecimal.valueOf(0), false);
|
2301 |
t.addDecimalColumn("POURCENT_REMISE", 16, 6, BigDecimal.valueOf(0), false);
|
2105 |
alterTarif = true;
|
2302 |
alterTarif = true;
|
2106 |
}
|
2303 |
}
|
2107 |
|
2304 |
|
2108 |
if (!root.getTable("ARTICLE_TARIF").contains("QTE")) {
|
2305 |
if (!root.getTable("ARTICLE_TARIF").contains("QTE")) {
|
2109 |
t.addIntegerColumn("QTE", 1);
|
2306 |
t.addIntegerColumn("QTE", 1);
|
2110 |
alterTarif = true;
|
2307 |
alterTarif = true;
|
2111 |
}
|
2308 |
}
|
2112 |
if (alterTarif) {
|
2309 |
if (alterTarif) {
|
2113 |
root.getTable("ARTICLE_TARIF").getBase().getDataSource().execute(t.asString());
|
2310 |
root.getTable("ARTICLE_TARIF").getBase().getDataSource().execute(t.asString());
|
2114 |
root.getTable("ARTICLE_TARIF").fetchFields();
|
2311 |
root.getTable("ARTICLE_TARIF").fetchFields();
|
2115 |
root.getTable("ARTICLE").getSchema().updateVersion();
|
2312 |
root.getTable("ARTICLE").getSchema().updateVersion();
|
2116 |
}
|
2313 |
}
|
2117 |
}
|
2314 |
}
|
2118 |
// SKU et Type d'expedition
|
2315 |
// SKU et Type d'expedition
|
2119 |
final SQLTable articleTable = root.getTable("ARTICLE");
|
2316 |
final SQLTable articleTable = root.getTable("ARTICLE");
|
2120 |
if (!articleTable.contains("SKU")) {
|
2317 |
if (!articleTable.contains("SKU")) {
|
2121 |
AlterTable a = new AlterTable(articleTable);
|
2318 |
AlterTable a = new AlterTable(articleTable);
|
2122 |
a.addVarCharColumn("SKU", 256);
|
2319 |
a.addVarCharColumn("SKU", 256);
|
2123 |
try {
|
2320 |
try {
|
2124 |
articleTable.getBase().getDataSource().execute(a.asString());
|
2321 |
articleTable.getBase().getDataSource().execute(a.asString());
|
2125 |
articleTable.getSchema().updateVersion();
|
2322 |
articleTable.getSchema().updateVersion();
|
2126 |
articleTable.fetchFields();
|
2323 |
articleTable.fetchFields();
|
2127 |
} catch (SQLException ex2) {
|
2324 |
} catch (SQLException ex2) {
|
2128 |
throw new IllegalStateException("Erreur lors de l'ajout du champs SKU sur la table ARTICLE", ex2);
|
2325 |
throw new IllegalStateException("Erreur lors de l'ajout du champs SKU sur la table ARTICLE", ex2);
|
2129 |
}
|
2326 |
}
|
2130 |
}
|
2327 |
}
|
2131 |
|
2328 |
|
2132 |
try {
|
2329 |
try {
|
2133 |
final SQLTable cmdClientTable = root.getTable("COMMANDE_CLIENT");
|
2330 |
final SQLTable cmdClientTable = root.getTable("COMMANDE_CLIENT");
|
2134 |
if (!cmdClientTable.contains("TYPE_EXPEDITION")) {
|
2331 |
if (!cmdClientTable.contains("TYPE_EXPEDITION")) {
|
2135 |
final AlterTable a = new AlterTable(cmdClientTable);
|
2332 |
final AlterTable a = new AlterTable(cmdClientTable);
|
2136 |
a.addVarCharColumn("TYPE_EXPEDITION", 256);
|
2333 |
a.addVarCharColumn("TYPE_EXPEDITION", 256);
|
2137 |
cmdClientTable.getBase().getDataSource().execute(a.asString());
|
2334 |
cmdClientTable.getBase().getDataSource().execute(a.asString());
|
2138 |
cmdClientTable.getSchema().updateVersion();
|
2335 |
cmdClientTable.getSchema().updateVersion();
|
2139 |
cmdClientTable.fetchFields();
|
2336 |
cmdClientTable.fetchFields();
|
2140 |
}
|
2337 |
}
|
2141 |
} catch (SQLException ex2) {
|
2338 |
} catch (SQLException ex2) {
|
2142 |
throw new IllegalStateException("Erreur lors de l'ajout du champs TYPE_EXPEDITION sur la table COMMANDE_CLIENT", ex2);
|
2339 |
throw new IllegalStateException("Erreur lors de l'ajout du champs TYPE_EXPEDITION sur la table COMMANDE_CLIENT", ex2);
|
2143 |
}
|
2340 |
}
|
2144 |
try {
|
2341 |
try {
|
2145 |
final SQLTable axeTable = root.getTable("AXE_ANALYTIQUE");
|
2342 |
final SQLTable axeTable = root.getTable("AXE_ANALYTIQUE");
|
2146 |
if (!axeTable.contains("TYPE")) {
|
2343 |
if (!axeTable.contains("TYPE")) {
|
2147 |
final AlterTable a = new AlterTable(axeTable);
|
2344 |
final AlterTable a = new AlterTable(axeTable);
|
2148 |
a.addVarCharColumn("TYPE", 256);
|
2345 |
a.addVarCharColumn("TYPE", 256);
|
2149 |
axeTable.getBase().getDataSource().execute(a.asString());
|
2346 |
axeTable.getBase().getDataSource().execute(a.asString());
|
2150 |
axeTable.getSchema().updateVersion();
|
2347 |
axeTable.getSchema().updateVersion();
|
2151 |
axeTable.fetchFields();
|
2348 |
axeTable.fetchFields();
|
2152 |
}
|
2349 |
}
|
2153 |
} catch (SQLException ex2) {
|
2350 |
} catch (SQLException ex2) {
|
2154 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table AXE_ANALYTIQUE", ex2);
|
2351 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table AXE_ANALYTIQUE", ex2);
|
2155 |
}
|
2352 |
}
|
2156 |
// Historique des taux
|
2353 |
// Historique des taux
|
2157 |
if (!root.contains("DEVISE_HISTORIQUE")) {
|
2354 |
if (!root.contains("DEVISE_HISTORIQUE")) {
|
2158 |
final SQLCreateTable createTable = new SQLCreateTable(root, "DEVISE_HISTORIQUE");
|
2355 |
final SQLCreateTable createTable = new SQLCreateTable(root, "DEVISE_HISTORIQUE");
|
2159 |
createTable.addDateAndTimeColumn("DATE");
|
2356 |
createTable.addDateAndTimeColumn("DATE");
|
2160 |
createTable.addVarCharColumn("SRC", 8);
|
2357 |
createTable.addVarCharColumn("SRC", 8);
|
2161 |
createTable.addVarCharColumn("DST", 8);
|
2358 |
createTable.addVarCharColumn("DST", 8);
|
2162 |
createTable.addDecimalColumn("TAUX", 12, 6, new BigDecimal(1), false);
|
2359 |
createTable.addDecimalColumn("TAUX", 12, 6, new BigDecimal(1), false);
|
2163 |
createTable.addDecimalColumn("TAUX_COMMERCIAL", 12, 6, new BigDecimal(1), false);
|
2360 |
createTable.addDecimalColumn("TAUX_COMMERCIAL", 12, 6, new BigDecimal(1), false);
|
2164 |
try {
|
2361 |
try {
|
2165 |
root.getDBSystemRoot().getDataSource().execute(createTable.asString());
|
2362 |
root.getDBSystemRoot().getDataSource().execute(createTable.asString());
|
2166 |
insertUndef(createTable);
|
2363 |
insertUndef(createTable);
|
2167 |
tableDevis.getSchema().updateVersion();
|
2364 |
tableDevis.getSchema().updateVersion();
|
- |
|
2365 |
root.refetchTable("DEVISE_HISTORIQUE");
|
2168 |
} catch (SQLException ex) {
|
2366 |
} catch (SQLException ex) {
|
2169 |
throw new IllegalStateException("Erreur lors de la création de la table TASK", ex);
|
2367 |
throw new IllegalStateException("Erreur lors de la création de la table TASK", ex);
|
2170 |
}
|
2368 |
}
|
2171 |
}
|
2369 |
}
|
2172 |
|
2370 |
|
2173 |
final SQLTable tableContact = root.getTable("CONTACT");
|
2371 |
final SQLTable tableContact = root.getTable("CONTACT");
|
2174 |
if (tableContact != null && !tableContact.contains("NO_MAILING")) {
|
2372 |
if (tableContact != null && !tableContact.contains("NO_MAILING")) {
|
2175 |
AlterTable t = new AlterTable(tableContact);
|
2373 |
AlterTable t = new AlterTable(tableContact);
|
2176 |
t.addBooleanColumn("NO_MAILING", false, false);
|
2374 |
t.addBooleanColumn("NO_MAILING", false, false);
|
2177 |
tableContact.getBase().getDataSource().execute(t.asString());
|
2375 |
tableContact.getBase().getDataSource().execute(t.asString());
|
2178 |
tableContact.getSchema().updateVersion();
|
2376 |
tableContact.getSchema().updateVersion();
|
2179 |
tableContact.fetchFields();
|
2377 |
tableContact.fetchFields();
|
2180 |
}
|
2378 |
}
|
2181 |
|
2379 |
|
2182 |
SQLTable tableBonR = root.getTable("FACTURE_FOURNISSEUR");
|
2380 |
SQLTable tableBonR = root.getTable("FACTURE_FOURNISSEUR");
|
2183 |
if (!tableBonR.contains("TAUX_APPLIQUE")) {
|
2381 |
if (!tableBonR.contains("TAUX_APPLIQUE")) {
|
2184 |
AlterTable t = new AlterTable(tableBonR);
|
2382 |
AlterTable t = new AlterTable(tableBonR);
|
2185 |
t.addDecimalColumn("TAUX_APPLIQUE", 12, 6, BigDecimal.ONE, true);
|
2383 |
t.addDecimalColumn("TAUX_APPLIQUE", 12, 6, BigDecimal.ONE, true);
|
2186 |
tableBonR.getBase().getDataSource().execute(t.asString());
|
2384 |
tableBonR.getBase().getDataSource().execute(t.asString());
|
2187 |
tableBonR.getSchema().updateVersion();
|
2385 |
tableBonR.getSchema().updateVersion();
|
2188 |
tableBonR.fetchFields();
|
2386 |
tableBonR.fetchFields();
|
2189 |
}
|
2387 |
}
|
2190 |
root.getTable("ARTICLE").getSchema().updateVersion();
|
2388 |
root.getTable("ARTICLE").getSchema().updateVersion();
|
2191 |
// Valeur par défaut des numérotations
|
2389 |
// Valeur par défaut des numérotations
|
2192 |
SQLRowValues rNumerotation = root.getTable("NUMEROTATION_AUTO").getRow(2).asRowValues();
|
2390 |
SQLRowValues rNumerotation = root.getTable("NUMEROTATION_AUTO").getRow(2).asRowValues();
|
2193 |
boolean numerotationFixed = false;
|
2391 |
boolean numerotationFixed = false;
|
2194 |
if (rNumerotation.getString("AVOIR_F_FORMAT").trim().isEmpty()) {
|
2392 |
if (rNumerotation.getString("AVOIR_F_FORMAT").trim().isEmpty()) {
|
2195 |
rNumerotation.put("AVOIR_F_FORMAT", "'AVOIR'yyMM-000");
|
2393 |
rNumerotation.put("AVOIR_F_FORMAT", "'AVOIR'yyMM-000");
|
2196 |
}
|
2394 |
}
|
2197 |
if (rNumerotation.getString("CLIENT_FORMAT").trim().isEmpty()) {
|
2395 |
if (rNumerotation.getString("CLIENT_FORMAT").trim().isEmpty()) {
|
2198 |
rNumerotation.put("CLIENT_FORMAT", "'CLI'00000");
|
2396 |
rNumerotation.put("CLIENT_FORMAT", "'CLI'00000");
|
2199 |
}
|
2397 |
}
|
2200 |
if (numerotationFixed) {
|
2398 |
if (numerotationFixed) {
|
2201 |
rNumerotation.commit();
|
2399 |
rNumerotation.commit();
|
2202 |
}
|
2400 |
}
|
2203 |
|
2401 |
|
2204 |
//
|
2402 |
//
|
2205 |
|
2403 |
|
2206 |
final SQLTable tableCalendarItem = root.getTable("CALENDAR_ITEM");
|
2404 |
final SQLTable tableCalendarItem = root.getTable("CALENDAR_ITEM");
|
2207 |
if (tableCalendarItem != null) {
|
2405 |
if (tableCalendarItem != null) {
|
2208 |
final AlterTable tVF = new AlterTable(tableCalendarItem);
|
2406 |
final AlterTable tVF = new AlterTable(tableCalendarItem);
|
2209 |
boolean needUpdate = false;
|
2407 |
boolean needUpdate = false;
|
2210 |
if (!tableCalendarItem.getFieldsName().contains("UID")) {
|
2408 |
if (!tableCalendarItem.getFieldsName().contains("UID")) {
|
2211 |
tVF.addVarCharColumn("UID", 1024);
|
2409 |
tVF.addVarCharColumn("UID", 1024);
|
2212 |
needUpdate = true;
|
2410 |
needUpdate = true;
|
2213 |
}
|
2411 |
}
|
2214 |
if (!tableCalendarItem.getFieldsName().contains("LOCATION")) {
|
2412 |
if (!tableCalendarItem.getFieldsName().contains("LOCATION")) {
|
2215 |
tVF.addVarCharColumn("LOCATION", 4096);
|
2413 |
tVF.addVarCharColumn("LOCATION", 4096);
|
2216 |
needUpdate = true;
|
2414 |
needUpdate = true;
|
2217 |
}
|
2415 |
}
|
2218 |
if (needUpdate) {
|
2416 |
if (needUpdate) {
|
2219 |
try {
|
2417 |
try {
|
2220 |
tableCalendarItem.getBase().getDataSource().execute(tVF.asString());
|
2418 |
tableCalendarItem.getBase().getDataSource().execute(tVF.asString());
|
2221 |
tableCalendarItem.getSchema().updateVersion();
|
2419 |
tableCalendarItem.getSchema().updateVersion();
|
2222 |
tableCalendarItem.fetchFields();
|
2420 |
tableCalendarItem.fetchFields();
|
2223 |
} catch (SQLException ex) {
|
2421 |
} catch (SQLException ex) {
|
2224 |
throw new IllegalStateException("Erreur lors de l'ajout de UID sur la table CALENDAR_ITEM", ex);
|
2422 |
throw new IllegalStateException("Erreur lors de l'ajout de UID sur la table CALENDAR_ITEM", ex);
|
2225 |
}
|
2423 |
}
|
2226 |
}
|
2424 |
}
|
2227 |
}
|
2425 |
}
|
2228 |
|
2426 |
|
2229 |
}
|
2427 |
}
|
2230 |
|
2428 |
|
2231 |
private void updateStyle(final DBRoot root) throws SQLException {
|
2429 |
private void updateStyle(final DBRoot root) throws SQLException {
|
2232 |
SQLTable style = root.getTable("STYLE");
|
2430 |
SQLTable style = root.getTable("STYLE");
|
2233 |
SQLRowValues rowVals = new SQLRowValues(style);
|
2431 |
SQLRowValues rowVals = new SQLRowValues(style);
|
2234 |
rowVals.put("NOM", null);
|
2432 |
rowVals.put("NOM", null);
|
2235 |
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowVals);
|
2433 |
SQLRowValuesListFetcher fetcher = SQLRowValuesListFetcher.create(rowVals);
|
2236 |
List<SQLRowValues> list = fetcher.fetch();
|
2434 |
List<SQLRowValues> list = fetcher.fetch();
|
2237 |
boolean containsInvisible = false;
|
2435 |
boolean containsInvisible = false;
|
2238 |
for (SQLRowValues sqlRowValues : list) {
|
2436 |
for (SQLRowValues sqlRowValues : list) {
|
2239 |
if (sqlRowValues.getString("NOM").equals("Invisible")) {
|
2437 |
if (sqlRowValues.getString("NOM").equals("Invisible")) {
|
2240 |
containsInvisible = true;
|
2438 |
containsInvisible = true;
|
2241 |
}
|
2439 |
}
|
2242 |
}
|
2440 |
}
|
2243 |
if (!containsInvisible) {
|
2441 |
if (!containsInvisible) {
|
2244 |
SQLRowValues rowValsStyle = new SQLRowValues(style);
|
2442 |
SQLRowValues rowValsStyle = new SQLRowValues(style);
|
2245 |
rowValsStyle.put("NOM", "Invisible");
|
2443 |
rowValsStyle.put("NOM", "Invisible");
|
2246 |
rowValsStyle.put("CODE", "INV");
|
2444 |
rowValsStyle.put("CODE", "INV");
|
2247 |
rowValsStyle.insert();
|
2445 |
rowValsStyle.insert();
|
2248 |
}
|
2446 |
}
|
2249 |
|
2447 |
|
2250 |
}
|
2448 |
}
|
2251 |
|
2449 |
|
2252 |
private void updateToV1Dot2(final DBRoot root) throws SQLException {
|
2450 |
private void updateToV1Dot2(final DBRoot root) throws SQLException {
|
2253 |
// bigint -> int ID_METRIQUE BON_DE_LIVRAISON_ELEMENT
|
2451 |
// bigint -> int ID_METRIQUE BON_DE_LIVRAISON_ELEMENT
|
2254 |
final SQLTable tableLivraisonElement = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
2452 |
final SQLTable tableLivraisonElement = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
2255 |
AlterTable alter = new AlterTable(tableLivraisonElement);
|
2453 |
AlterTable alter = new AlterTable(tableLivraisonElement);
|
2256 |
alter.alterColumn("ID_METRIQUE_2", EnumSet.of(Properties.TYPE), "integer", null, null);
|
2454 |
alter.alterColumn("ID_METRIQUE_2", EnumSet.of(Properties.TYPE), "integer", null, null);
|
2257 |
String req3 = alter.asString();
|
2455 |
String req3 = alter.asString();
|
2258 |
root.getDBSystemRoot().getDataSource().execute(req3);
|
2456 |
root.getDBSystemRoot().getDataSource().execute(req3);
|
2259 |
|
2457 |
|
2260 |
final SQLTable tableDevis = root.getTable("DEVIS");
|
2458 |
final SQLTable tableDevis = root.getTable("DEVIS");
|
2261 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
2459 |
final SQLDataSource ds = root.getDBSystemRoot().getDataSource();
|
2262 |
if (!tableDevis.getFieldsName().contains("DATE_VALIDITE")) {
|
2460 |
if (!tableDevis.getFieldsName().contains("DATE_VALIDITE")) {
|
2263 |
AlterTable t = new AlterTable(tableDevis);
|
2461 |
AlterTable t = new AlterTable(tableDevis);
|
2264 |
t.addColumn("DATE_VALIDITE", "date");
|
2462 |
t.addColumn("DATE_VALIDITE", "date");
|
2265 |
try {
|
2463 |
try {
|
2266 |
ds.execute(t.asString());
|
2464 |
ds.execute(t.asString());
|
2267 |
tableDevis.getSchema().updateVersion();
|
2465 |
tableDevis.getSchema().updateVersion();
|
2268 |
} catch (SQLException ex) {
|
2466 |
} catch (SQLException ex) {
|
2269 |
throw new IllegalStateException("Erreur lors de l'ajout du champ DATE_VALIDITE à la table DEVIS", ex);
|
2467 |
throw new IllegalStateException("Erreur lors de l'ajout du champ DATE_VALIDITE à la table DEVIS", ex);
|
2270 |
}
|
2468 |
}
|
2271 |
} else {
|
2469 |
} else {
|
2272 |
AlterTable t = new AlterTable(tableDevis);
|
2470 |
AlterTable t = new AlterTable(tableDevis);
|
2273 |
t.alterColumn("DATE_VALIDITE", EnumSet.allOf(Properties.class), "date", null, true);
|
2471 |
t.alterColumn("DATE_VALIDITE", EnumSet.allOf(Properties.class), "date", null, true);
|
2274 |
try {
|
2472 |
try {
|
2275 |
ds.execute(t.asString());
|
2473 |
ds.execute(t.asString());
|
2276 |
tableDevis.getSchema().updateVersion();
|
2474 |
tableDevis.getSchema().updateVersion();
|
2277 |
} catch (SQLException ex) {
|
2475 |
} catch (SQLException ex) {
|
2278 |
throw new IllegalStateException("Erreur lors de l'ajout du champ DATE_VALIDITE à la table DEVIS", ex);
|
2476 |
throw new IllegalStateException("Erreur lors de l'ajout du champ DATE_VALIDITE à la table DEVIS", ex);
|
2279 |
}
|
2477 |
}
|
2280 |
}
|
2478 |
}
|
2281 |
|
2479 |
|
2282 |
final SQLTable tableEtatDevis = root.getTable("ETAT_DEVIS");
|
2480 |
final SQLTable tableEtatDevis = root.getTable("ETAT_DEVIS");
|
2283 |
if (tableEtatDevis.getRow(5) == null && tableEtatDevis.getRowCount() <= 4) {
|
2481 |
if (tableEtatDevis.getRow(5) == null && tableEtatDevis.getRowCount() <= 4) {
|
2284 |
SQLRowValues rowVals = new SQLRowValues(tableEtatDevis);
|
2482 |
SQLRowValues rowVals = new SQLRowValues(tableEtatDevis);
|
2285 |
rowVals.put("NOM", "En cours de rédaction");
|
2483 |
rowVals.put("NOM", "En cours de rédaction");
|
2286 |
rowVals.commit();
|
2484 |
rowVals.commit();
|
2287 |
|
2485 |
|
2288 |
}
|
2486 |
}
|
2289 |
|
2487 |
|
2290 |
SQLRowValues rowValsOrdre = new SQLRowValues(tableEtatDevis);
|
2488 |
SQLRowValues rowValsOrdre = new SQLRowValues(tableEtatDevis);
|
2291 |
rowValsOrdre.put("ORDRE", new BigDecimal("1.505"));
|
2489 |
rowValsOrdre.put("ORDRE", new BigDecimal("1.505"));
|
2292 |
rowValsOrdre.update(EtatDevisSQLElement.EN_ATTENTE);
|
2490 |
rowValsOrdre.update(EtatDevisSQLElement.EN_ATTENTE);
|
2293 |
|
2491 |
|
2294 |
rowValsOrdre.put("ORDRE", new BigDecimal("2.505"));
|
2492 |
rowValsOrdre.put("ORDRE", new BigDecimal("2.505"));
|
2295 |
rowValsOrdre.update(EtatDevisSQLElement.ACCEPTE);
|
2493 |
rowValsOrdre.update(EtatDevisSQLElement.ACCEPTE);
|
2296 |
|
2494 |
|
2297 |
rowValsOrdre.put("ORDRE", new BigDecimal("3.505"));
|
2495 |
rowValsOrdre.put("ORDRE", new BigDecimal("3.505"));
|
2298 |
rowValsOrdre.update(EtatDevisSQLElement.REFUSE);
|
2496 |
rowValsOrdre.update(EtatDevisSQLElement.REFUSE);
|
2299 |
|
2497 |
|
2300 |
rowValsOrdre.put("ORDRE", new BigDecimal("4.505"));
|
2498 |
rowValsOrdre.put("ORDRE", new BigDecimal("4.505"));
|
2301 |
rowValsOrdre.update(EtatDevisSQLElement.EN_COURS);
|
2499 |
rowValsOrdre.update(EtatDevisSQLElement.EN_COURS);
|
2302 |
|
2500 |
|
2303 |
// Ajout de la TVA à 0
|
2501 |
// Ajout de la TVA à 0
|
2304 |
SQLSelect selTVA = new SQLSelect();
|
2502 |
SQLSelect selTVA = new SQLSelect();
|
2305 |
SQLTable tableTaxe = root.getTable("TAXE");
|
2503 |
SQLTable tableTaxe = root.getTable("TAXE");
|
2306 |
selTVA.addSelect(tableTaxe.getKey(), "COUNT");
|
2504 |
selTVA.addSelect(tableTaxe.getKey(), "COUNT");
|
2307 |
selTVA.setWhere(new Where(tableTaxe.getField("TAUX"), "=", 0));
|
2505 |
selTVA.setWhere(new Where(tableTaxe.getField("TAUX"), "=", 0));
|
2308 |
Object result = root.getBase().getDataSource().executeScalar(selTVA.asString());
|
2506 |
Object result = root.getBase().getDataSource().executeScalar(selTVA.asString());
|
2309 |
if (result == null || ((Number) result).longValue() == 0) {
|
2507 |
if (result == null || ((Number) result).longValue() == 0) {
|
2310 |
SQLRowValues rowVals = new SQLRowValues(tableTaxe);
|
2508 |
SQLRowValues rowVals = new SQLRowValues(tableTaxe);
|
2311 |
rowVals.put("NOM", "Non applicable");
|
2509 |
rowVals.put("NOM", "Non applicable");
|
2312 |
rowVals.put("TAUX", Float.valueOf(0));
|
2510 |
rowVals.put("TAUX", Float.valueOf(0));
|
2313 |
rowVals.commit();
|
2511 |
rowVals.commit();
|
2314 |
}
|
2512 |
}
|
2315 |
|
2513 |
|
2316 |
// Bon de livraison
|
2514 |
// Bon de livraison
|
2317 |
{
|
2515 |
{
|
2318 |
SQLTable tableBL = root.getTable("BON_DE_LIVRAISON");
|
2516 |
SQLTable tableBL = root.getTable("BON_DE_LIVRAISON");
|
2319 |
boolean alterBL = false;
|
2517 |
boolean alterBL = false;
|
2320 |
AlterTable t = new AlterTable(tableBL);
|
2518 |
AlterTable t = new AlterTable(tableBL);
|
2321 |
if (!tableBL.getFieldsName().contains("SOURCE")) {
|
2519 |
if (!tableBL.getFieldsName().contains("SOURCE")) {
|
2322 |
t.addVarCharColumn("SOURCE", 512);
|
2520 |
t.addVarCharColumn("SOURCE", 512);
|
2323 |
alterBL = true;
|
2521 |
alterBL = true;
|
2324 |
}
|
2522 |
}
|
2325 |
if (!tableBL.getFieldsName().contains("IDSOURCE")) {
|
2523 |
if (!tableBL.getFieldsName().contains("IDSOURCE")) {
|
2326 |
t.addColumn("IDSOURCE", "integer DEFAULT 1");
|
2524 |
t.addColumn("IDSOURCE", "integer DEFAULT 1");
|
2327 |
alterBL = true;
|
2525 |
alterBL = true;
|
2328 |
}
|
2526 |
}
|
2329 |
|
2527 |
|
2330 |
if (!tableBL.getFieldsName().contains("DATE_LIVRAISON")) {
|
2528 |
if (!tableBL.getFieldsName().contains("DATE_LIVRAISON")) {
|
2331 |
t.addColumn("DATE_LIVRAISON", "date");
|
2529 |
t.addColumn("DATE_LIVRAISON", "date");
|
2332 |
alterBL = true;
|
2530 |
alterBL = true;
|
2333 |
}
|
2531 |
}
|
2334 |
if (alterBL) {
|
2532 |
if (alterBL) {
|
2335 |
try {
|
2533 |
try {
|
2336 |
ds.execute(t.asString());
|
2534 |
ds.execute(t.asString());
|
2337 |
tableBL.getSchema().updateVersion();
|
2535 |
tableBL.getSchema().updateVersion();
|
2338 |
tableBL.fetchFields();
|
2536 |
tableBL.fetchFields();
|
2339 |
} catch (SQLException ex) {
|
2537 |
} catch (SQLException ex) {
|
2340 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table BON_DE_LIVRAISON", ex);
|
2538 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table BON_DE_LIVRAISON", ex);
|
2341 |
}
|
2539 |
}
|
2342 |
}
|
2540 |
}
|
2343 |
}
|
2541 |
}
|
2344 |
|
2542 |
|
2345 |
// Fournisseur
|
2543 |
// Fournisseur
|
2346 |
{
|
2544 |
{
|
2347 |
SQLTable tableBL = root.getTable("FOURNISSEUR");
|
2545 |
SQLTable tableBL = root.getTable("FOURNISSEUR");
|
2348 |
boolean alterBL = false;
|
2546 |
boolean alterBL = false;
|
2349 |
AlterTable t = new AlterTable(tableBL);
|
2547 |
AlterTable t = new AlterTable(tableBL);
|
2350 |
if (!tableBL.getFieldsName().contains("ID_COMPTE_PCE_CHARGE")) {
|
2548 |
if (!tableBL.getFieldsName().contains("ID_COMPTE_PCE_CHARGE")) {
|
2351 |
t.addForeignColumn("ID_COMPTE_PCE_CHARGE", root.getTable("COMPTE_PCE"));
|
2549 |
t.addForeignColumn("ID_COMPTE_PCE_CHARGE", root.getTable("COMPTE_PCE"));
|
2352 |
alterBL = true;
|
2550 |
alterBL = true;
|
2353 |
}
|
2551 |
}
|
2354 |
if (alterBL) {
|
2552 |
if (alterBL) {
|
2355 |
try {
|
2553 |
try {
|
2356 |
ds.execute(t.asString());
|
2554 |
ds.execute(t.asString());
|
2357 |
tableBL.getSchema().updateVersion();
|
2555 |
tableBL.getSchema().updateVersion();
|
2358 |
tableBL.fetchFields();
|
2556 |
tableBL.fetchFields();
|
2359 |
} catch (SQLException ex) {
|
2557 |
} catch (SQLException ex) {
|
2360 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table FOURNISSEUR", ex);
|
2558 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table FOURNISSEUR", ex);
|
2361 |
}
|
2559 |
}
|
2362 |
}
|
2560 |
}
|
2363 |
}
|
2561 |
}
|
2364 |
|
2562 |
|
2365 |
// Numérotation
|
2563 |
// Numérotation
|
2366 |
{
|
2564 |
{
|
2367 |
SQLTable tableNum = root.getTable("NUMEROTATION_AUTO");
|
2565 |
SQLTable tableNum = root.getTable("NUMEROTATION_AUTO");
|
2368 |
boolean alterNum = false;
|
2566 |
boolean alterNum = false;
|
2369 |
AlterTable t = new AlterTable(tableNum);
|
2567 |
AlterTable t = new AlterTable(tableNum);
|
2370 |
if (!tableNum.getFieldsName().contains("AVOIR_F_START")) {
|
2568 |
if (!tableNum.getFieldsName().contains("AVOIR_F_START")) {
|
2371 |
t.addColumn("AVOIR_F_START", "integer DEFAULT 0");
|
2569 |
t.addColumn("AVOIR_F_START", "integer DEFAULT 0");
|
2372 |
alterNum = true;
|
2570 |
alterNum = true;
|
2373 |
}
|
2571 |
}
|
2374 |
if (!tableNum.getFieldsName().contains("AVOIR_F_FORMAT")) {
|
2572 |
if (!tableNum.getFieldsName().contains("AVOIR_F_FORMAT")) {
|
2375 |
t.addVarCharColumn("AVOIR_F_FORMAT", 48);
|
2573 |
t.addVarCharColumn("AVOIR_F_FORMAT", 48);
|
2376 |
alterNum = true;
|
2574 |
alterNum = true;
|
2377 |
}
|
2575 |
}
|
2378 |
|
2576 |
|
2379 |
if (alterNum) {
|
2577 |
if (alterNum) {
|
2380 |
try {
|
2578 |
try {
|
2381 |
ds.execute(t.asString());
|
2579 |
ds.execute(t.asString());
|
2382 |
tableNum.getSchema().updateVersion();
|
2580 |
tableNum.getSchema().updateVersion();
|
2383 |
tableNum.fetchFields();
|
2581 |
tableNum.fetchFields();
|
2384 |
} catch (SQLException ex) {
|
2582 |
} catch (SQLException ex) {
|
2385 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table NUMEROTATION_AUTO", ex);
|
2583 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table NUMEROTATION_AUTO", ex);
|
2386 |
}
|
2584 |
}
|
2387 |
}
|
2585 |
}
|
2388 |
}
|
2586 |
}
|
2389 |
|
2587 |
|
2390 |
SQLTable tableArticle = root.getTable("ARTICLE");
|
2588 |
SQLTable tableArticle = root.getTable("ARTICLE");
|
2391 |
|
2589 |
|
2392 |
AlterTable t = new AlterTable(tableArticle);
|
2590 |
AlterTable t = new AlterTable(tableArticle);
|
2393 |
boolean alterArticle = false;
|
2591 |
boolean alterArticle = false;
|
2394 |
if (!tableArticle.getFieldsName().contains("QTE_ACHAT")) {
|
2592 |
if (!tableArticle.getFieldsName().contains("QTE_ACHAT")) {
|
2395 |
t.addColumn("QTE_ACHAT", "integer DEFAULT 1");
|
2593 |
t.addColumn("QTE_ACHAT", "integer DEFAULT 1");
|
2396 |
alterArticle = true;
|
2594 |
alterArticle = true;
|
2397 |
}
|
2595 |
}
|
2398 |
if (!tableArticle.getFieldsName().contains("DESCRIPTIF")) {
|
2596 |
if (!tableArticle.getFieldsName().contains("DESCRIPTIF")) {
|
2399 |
t.addVarCharColumn("DESCRIPTIF", 2048);
|
2597 |
t.addVarCharColumn("DESCRIPTIF", 2048);
|
2400 |
alterArticle = true;
|
2598 |
alterArticle = true;
|
2401 |
}
|
2599 |
}
|
2402 |
if (!tableArticle.getFieldsName().contains("CODE_BARRE")) {
|
2600 |
if (!tableArticle.getFieldsName().contains("CODE_BARRE")) {
|
2403 |
t.addVarCharColumn("CODE_BARRE", 256);
|
2601 |
t.addVarCharColumn("CODE_BARRE", 256);
|
2404 |
alterArticle = true;
|
2602 |
alterArticle = true;
|
2405 |
}
|
2603 |
}
|
2406 |
if (!tableArticle.getFieldsName().contains("GESTION_STOCK")) {
|
2604 |
if (!tableArticle.getFieldsName().contains("GESTION_STOCK")) {
|
2407 |
t.addColumn("GESTION_STOCK", "boolean DEFAULT true");
|
2605 |
t.addColumn("GESTION_STOCK", "boolean DEFAULT true");
|
2408 |
alterArticle = true;
|
2606 |
alterArticle = true;
|
2409 |
}
|
2607 |
}
|
2410 |
if (!tableArticle.getFieldsName().contains("CODE_DOUANIER")) {
|
2608 |
if (!tableArticle.getFieldsName().contains("CODE_DOUANIER")) {
|
2411 |
t.addVarCharColumn("CODE_DOUANIER", 256);
|
2609 |
t.addVarCharColumn("CODE_DOUANIER", 256);
|
2412 |
alterArticle = true;
|
2610 |
alterArticle = true;
|
2413 |
}
|
2611 |
}
|
2414 |
if (!tableArticle.getFieldsName().contains("QTE_MIN")) {
|
2612 |
if (!tableArticle.getFieldsName().contains("QTE_MIN")) {
|
2415 |
t.addColumn("QTE_MIN", "integer DEFAULT 1");
|
2613 |
t.addColumn("QTE_MIN", "integer DEFAULT 1");
|
2416 |
alterArticle = true;
|
2614 |
alterArticle = true;
|
2417 |
}
|
2615 |
}
|
2418 |
if (!tableArticle.getFieldsName().contains("ID_DEVISE")) {
|
2616 |
if (!tableArticle.getFieldsName().contains("ID_DEVISE")) {
|
2419 |
t.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
2617 |
t.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
2420 |
alterArticle = true;
|
2618 |
alterArticle = true;
|
2421 |
}
|
2619 |
}
|
2422 |
if (!tableArticle.getFieldsName().contains("ID_FOURNISSEUR")) {
|
2620 |
if (!tableArticle.getFieldsName().contains("ID_FOURNISSEUR")) {
|
2423 |
t.addForeignColumn("ID_FOURNISSEUR", root.findTable("FOURNISSEUR", true));
|
2621 |
t.addForeignColumn("ID_FOURNISSEUR", root.findTable("FOURNISSEUR", true));
|
2424 |
alterArticle = true;
|
2622 |
alterArticle = true;
|
2425 |
}
|
2623 |
}
|
2426 |
if (!tableArticle.getFieldsName().contains("PV_U_DEVISE")) {
|
2624 |
if (!tableArticle.getFieldsName().contains("PV_U_DEVISE")) {
|
2427 |
t.addColumn("PV_U_DEVISE", "bigint default 0");
|
2625 |
t.addColumn("PV_U_DEVISE", "bigint default 0");
|
2428 |
alterArticle = true;
|
2626 |
alterArticle = true;
|
2429 |
}
|
2627 |
}
|
2430 |
if (!tableArticle.getFieldsName().contains("ID_DEVISE_HA")) {
|
2628 |
if (!tableArticle.getFieldsName().contains("ID_DEVISE_HA")) {
|
2431 |
t.addForeignColumn("ID_DEVISE_HA", root.findTable("DEVISE", true));
|
2629 |
t.addForeignColumn("ID_DEVISE_HA", root.findTable("DEVISE", true));
|
2432 |
alterArticle = true;
|
2630 |
alterArticle = true;
|
2433 |
}
|
2631 |
}
|
2434 |
if (!tableArticle.getFieldsName().contains("PA_DEVISE")) {
|
2632 |
if (!tableArticle.getFieldsName().contains("PA_DEVISE")) {
|
2435 |
t.addColumn("PA_DEVISE", "bigint default 0");
|
2633 |
t.addColumn("PA_DEVISE", "bigint default 0");
|
2436 |
alterArticle = true;
|
2634 |
alterArticle = true;
|
2437 |
}
|
2635 |
}
|
2438 |
if (!tableArticle.getFieldsName().contains("ID_PAYS")) {
|
2636 |
if (!tableArticle.getFieldsName().contains("ID_PAYS")) {
|
2439 |
t.addForeignColumn("ID_PAYS", root.findTable("PAYS", true));
|
2637 |
t.addForeignColumn("ID_PAYS", root.findTable("PAYS", true));
|
2440 |
alterArticle = true;
|
2638 |
alterArticle = true;
|
2441 |
}
|
2639 |
}
|
2442 |
if (alterArticle) {
|
2640 |
if (alterArticle) {
|
2443 |
try {
|
2641 |
try {
|
2444 |
ds.execute(t.asString());
|
2642 |
ds.execute(t.asString());
|
2445 |
tableArticle.getSchema().updateVersion();
|
2643 |
tableArticle.getSchema().updateVersion();
|
2446 |
tableArticle.fetchFields();
|
2644 |
tableArticle.fetchFields();
|
2447 |
} catch (SQLException ex) {
|
2645 |
} catch (SQLException ex) {
|
2448 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table ARTICLE", ex);
|
2646 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table ARTICLE", ex);
|
2449 |
}
|
2647 |
}
|
2450 |
}
|
2648 |
}
|
2451 |
|
2649 |
|
2452 |
// Création de la table Langue
|
2650 |
// Création de la table Langue
|
2453 |
boolean refetchRoot = false;
|
2651 |
boolean refetchRoot = false;
|
2454 |
if (!root.contains("OBJECTIF_COMMERCIAL")) {
|
2652 |
if (!root.contains("OBJECTIF_COMMERCIAL")) {
|
2455 |
|
2653 |
|
2456 |
SQLCreateTable createObjectif = new SQLCreateTable(root, "OBJECTIF_COMMERCIAL");
|
2654 |
SQLCreateTable createObjectif = new SQLCreateTable(root, "OBJECTIF_COMMERCIAL");
|
2457 |
createObjectif.addVarCharColumn("MOIS", 32);
|
2655 |
createObjectif.addVarCharColumn("MOIS", 32);
|
2458 |
createObjectif.addColumn("ANNEE", "integer");
|
2656 |
createObjectif.addColumn("ANNEE", "integer");
|
2459 |
createObjectif.addColumn("MARGE_HT", "bigint DEFAULT 0");
|
2657 |
createObjectif.addColumn("MARGE_HT", "bigint DEFAULT 0");
|
2460 |
createObjectif.addColumn("POURCENT_MARGE", "numeric (16,8)");
|
2658 |
createObjectif.addColumn("POURCENT_MARGE", "numeric (16,8)");
|
2461 |
createObjectif.addColumn("CHIFFRE_AFFAIRE", "bigint DeFAULT 0");
|
2659 |
createObjectif.addColumn("CHIFFRE_AFFAIRE", "bigint DeFAULT 0");
|
2462 |
createObjectif.addForeignColumn("COMMERCIAL");
|
2660 |
createObjectif.addForeignColumn("COMMERCIAL");
|
2463 |
try {
|
2661 |
try {
|
2464 |
ds.execute(createObjectif.asString());
|
2662 |
ds.execute(createObjectif.asString());
|
2465 |
insertUndef(createObjectif);
|
2663 |
insertUndef(createObjectif);
|
2466 |
tableDevis.getSchema().updateVersion();
|
2664 |
tableDevis.getSchema().updateVersion();
|
2467 |
refetchRoot = true;
|
2665 |
refetchRoot = true;
|
2468 |
} catch (SQLException ex) {
|
2666 |
} catch (SQLException ex) {
|
2469 |
throw new IllegalStateException("Erreur lors de la création de la table OBJECTIF_COMMERCIAL", ex);
|
2667 |
throw new IllegalStateException("Erreur lors de la création de la table OBJECTIF_COMMERCIAL", ex);
|
2470 |
}
|
2668 |
}
|
2471 |
|
2669 |
|
2472 |
}
|
2670 |
}
|
2473 |
|
2671 |
|
2474 |
if (!root.contains("LANGUE")) {
|
2672 |
if (!root.contains("LANGUE")) {
|
2475 |
|
2673 |
|
2476 |
SQLCreateTable createLangue = new SQLCreateTable(root, "LANGUE");
|
2674 |
SQLCreateTable createLangue = new SQLCreateTable(root, "LANGUE");
|
2477 |
createLangue.addVarCharColumn("CODE", 256);
|
2675 |
createLangue.addVarCharColumn("CODE", 256);
|
2478 |
createLangue.addVarCharColumn("NOM", 256);
|
2676 |
createLangue.addVarCharColumn("NOM", 256);
|
2479 |
createLangue.addVarCharColumn("CHEMIN", 256);
|
2677 |
createLangue.addVarCharColumn("CHEMIN", 256);
|
2480 |
try {
|
2678 |
try {
|
2481 |
ds.execute(createLangue.asString());
|
2679 |
ds.execute(createLangue.asString());
|
2482 |
insertUndef(createLangue);
|
2680 |
insertUndef(createLangue);
|
2483 |
tableDevis.getSchema().updateVersion();
|
2681 |
tableDevis.getSchema().updateVersion();
|
2484 |
root.refetchTable(createLangue.getName());
|
2682 |
root.refetchTable(createLangue.getName());
|
2485 |
} catch (SQLException ex) {
|
2683 |
} catch (SQLException ex) {
|
2486 |
throw new IllegalStateException("Erreur lors de la création de la table LANGUE", ex);
|
2684 |
throw new IllegalStateException("Erreur lors de la création de la table LANGUE", ex);
|
2487 |
}
|
2685 |
}
|
2488 |
|
2686 |
|
2489 |
final String[] langs = new String[] { "FR", "Français", "EN", "Anglais", "SP", "Espagnol", "DE", "Allemand", "NL", "Néerlandais", "IT", "Italien" };
|
2687 |
final String[] langs = new String[] { "FR", "Français", "EN", "Anglais", "SP", "Espagnol", "DE", "Allemand", "NL", "Néerlandais", "IT", "Italien" };
|
2490 |
// ('FR', 'Français', 1.000), ('EN', 'Anglais', 2.000)
|
2688 |
// ('FR', 'Français', 1.000), ('EN', 'Anglais', 2.000)
|
2491 |
final List<String> values = new ArrayList<String>();
|
2689 |
final List<String> values = new ArrayList<String>();
|
2492 |
final SQLBase base = root.getBase();
|
2690 |
final SQLBase base = root.getBase();
|
2493 |
for (int i = 0; i < langs.length; i += 2) {
|
2691 |
for (int i = 0; i < langs.length; i += 2) {
|
2494 |
final int order = values.size() + 1;
|
2692 |
final int order = values.size() + 1;
|
2495 |
values.add("(" + base.quoteString(langs[i]) + ", " + base.quoteString(langs[i + 1]) + ", " + order + ")");
|
2693 |
values.add("(" + base.quoteString(langs[i]) + ", " + base.quoteString(langs[i + 1]) + ", " + order + ")");
|
2496 |
}
|
2694 |
}
|
2497 |
final String valuesStr = CollectionUtils.join(values, ", ");
|
2695 |
final String valuesStr = CollectionUtils.join(values, ", ");
|
2498 |
final String insertVals = "INSERT INTO " + getTableName(createLangue).quote() + "(" + SQLBase.quoteIdentifier("CODE") + ", " + SQLBase.quoteIdentifier("NOM") + ", "
|
2696 |
final String insertVals = "INSERT INTO " + getTableName(createLangue).quote() + "(" + SQLBase.quoteIdentifier("CODE") + ", " + SQLBase.quoteIdentifier("NOM") + ", "
|
2499 |
+ SQLBase.quoteIdentifier(SQLSyntax.ORDER_NAME) + ") VALUES" + valuesStr;
|
2697 |
+ SQLBase.quoteIdentifier(SQLSyntax.ORDER_NAME) + ") VALUES" + valuesStr;
|
2500 |
ds.execute(insertVals);
|
2698 |
ds.execute(insertVals);
|
2501 |
}
|
2699 |
}
|
2502 |
|
2700 |
|
2503 |
// Création de la table Modéle
|
2701 |
// Création de la table Modéle
|
2504 |
if (!root.contains("MODELE")) {
|
2702 |
if (!root.contains("MODELE")) {
|
2505 |
|
2703 |
|
2506 |
SQLCreateTable createModele = new SQLCreateTable(root, "MODELE");
|
2704 |
SQLCreateTable createModele = new SQLCreateTable(root, "MODELE");
|
2507 |
createModele.addVarCharColumn("NOM", 256);
|
2705 |
createModele.addVarCharColumn("NOM", 256);
|
2508 |
createModele.addForeignColumn("ID_TYPE_MODELE", root.findTable("TYPE_MODELE", true));
|
2706 |
createModele.addForeignColumn("ID_TYPE_MODELE", root.findTable("TYPE_MODELE", true));
|
2509 |
try {
|
2707 |
try {
|
2510 |
ds.execute(createModele.asString());
|
2708 |
ds.execute(createModele.asString());
|
2511 |
insertUndef(createModele);
|
2709 |
insertUndef(createModele);
|
2512 |
tableDevis.getSchema().updateVersion();
|
2710 |
tableDevis.getSchema().updateVersion();
|
2513 |
refetchRoot = true;
|
2711 |
refetchRoot = true;
|
2514 |
} catch (SQLException ex) {
|
2712 |
} catch (SQLException ex) {
|
2515 |
throw new IllegalStateException("Erreur lors de la création de la table MODELE", ex);
|
2713 |
throw new IllegalStateException("Erreur lors de la création de la table MODELE", ex);
|
2516 |
}
|
2714 |
}
|
2517 |
}
|
2715 |
}
|
2518 |
|
2716 |
|
2519 |
// Création de la table Modéle
|
2717 |
// Création de la table Modéle
|
2520 |
if (!root.contains("CONTACT_FOURNISSEUR")) {
|
2718 |
if (!root.contains("CONTACT_FOURNISSEUR")) {
|
2521 |
|
2719 |
|
2522 |
SQLCreateTable createModele = new SQLCreateTable(root, "CONTACT_FOURNISSEUR");
|
2720 |
SQLCreateTable createModele = new SQLCreateTable(root, "CONTACT_FOURNISSEUR");
|
2523 |
createModele.addVarCharColumn("NOM", 256);
|
2721 |
createModele.addVarCharColumn("NOM", 256);
|
2524 |
createModele.addVarCharColumn("PRENOM", 256);
|
2722 |
createModele.addVarCharColumn("PRENOM", 256);
|
2525 |
createModele.addVarCharColumn("TEL_DIRECT", 256);
|
2723 |
createModele.addVarCharColumn("TEL_DIRECT", 256);
|
2526 |
createModele.addVarCharColumn("TEL_MOBILE", 256);
|
2724 |
createModele.addVarCharColumn("TEL_MOBILE", 256);
|
2527 |
createModele.addVarCharColumn("EMAIL", 256);
|
2725 |
createModele.addVarCharColumn("EMAIL", 256);
|
2528 |
createModele.addVarCharColumn("FAX", 256);
|
2726 |
createModele.addVarCharColumn("FAX", 256);
|
2529 |
createModele.addVarCharColumn("FONCTION", 256);
|
2727 |
createModele.addVarCharColumn("FONCTION", 256);
|
2530 |
createModele.addVarCharColumn("TEL_PERSONEL", 256);
|
2728 |
createModele.addVarCharColumn("TEL_PERSONEL", 256);
|
2531 |
createModele.addVarCharColumn("TEL_STANDARD", 256);
|
2729 |
createModele.addVarCharColumn("TEL_STANDARD", 256);
|
2532 |
createModele.addForeignColumn("ID_TITRE_PERSONNEL", root.findTable("TITRE_PERSONNEL"));
|
2730 |
createModele.addForeignColumn("ID_TITRE_PERSONNEL", root.findTable("TITRE_PERSONNEL"));
|
2533 |
createModele.addForeignColumn("ID_FOURNISSEUR", root.findTable("FOURNISSEUR"));
|
2731 |
createModele.addForeignColumn("ID_FOURNISSEUR", root.findTable("FOURNISSEUR"));
|
2534 |
|
2732 |
|
2535 |
try {
|
2733 |
try {
|
2536 |
ds.execute(createModele.asString());
|
2734 |
ds.execute(createModele.asString());
|
2537 |
insertUndef(createModele);
|
2735 |
insertUndef(createModele);
|
2538 |
tableDevis.getSchema().updateVersion();
|
2736 |
tableDevis.getSchema().updateVersion();
|
2539 |
refetchRoot = true;
|
2737 |
refetchRoot = true;
|
2540 |
} catch (SQLException ex) {
|
2738 |
} catch (SQLException ex) {
|
2541 |
throw new IllegalStateException("Erreur lors de la création de la table MODELE", ex);
|
2739 |
throw new IllegalStateException("Erreur lors de la création de la table MODELE", ex);
|
2542 |
}
|
2740 |
}
|
2543 |
}
|
2741 |
}
|
2544 |
|
2742 |
|
2545 |
// Création de la table Tarif
|
2743 |
// Création de la table Tarif
|
2546 |
if (!root.contains("TARIF")) {
|
2744 |
if (!root.contains("TARIF")) {
|
2547 |
|
2745 |
|
2548 |
SQLCreateTable createTarif = new SQLCreateTable(root, "TARIF");
|
2746 |
SQLCreateTable createTarif = new SQLCreateTable(root, "TARIF");
|
2549 |
createTarif.addVarCharColumn("NOM", 256);
|
2747 |
createTarif.addVarCharColumn("NOM", 256);
|
2550 |
createTarif.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
2748 |
createTarif.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
2551 |
createTarif.addForeignColumn("ID_TAXE", root.findTable("TAXE", true));
|
2749 |
createTarif.addForeignColumn("ID_TAXE", root.findTable("TAXE", true));
|
2552 |
createTarif.asString();
|
2750 |
createTarif.asString();
|
2553 |
try {
|
2751 |
try {
|
2554 |
ds.execute(createTarif.asString());
|
2752 |
ds.execute(createTarif.asString());
|
2555 |
insertUndef(createTarif);
|
2753 |
insertUndef(createTarif);
|
2556 |
tableDevis.getSchema().updateVersion();
|
2754 |
tableDevis.getSchema().updateVersion();
|
2557 |
root.refetchTable(createTarif.getName());
|
2755 |
root.refetchTable(createTarif.getName());
|
2558 |
} catch (SQLException ex) {
|
2756 |
} catch (SQLException ex) {
|
2559 |
throw new IllegalStateException("Erreur lors de la création de la table TARIF", ex);
|
2757 |
throw new IllegalStateException("Erreur lors de la création de la table TARIF", ex);
|
2560 |
}
|
2758 |
}
|
2561 |
}
|
2759 |
}
|
2562 |
|
2760 |
|
2563 |
// Création de la table article Tarif
|
2761 |
// Création de la table article Tarif
|
2564 |
if (!root.contains("ARTICLE_TARIF")) {
|
2762 |
if (!root.contains("ARTICLE_TARIF")) {
|
2565 |
|
2763 |
|
2566 |
SQLCreateTable createTarif = new SQLCreateTable(root, "ARTICLE_TARIF");
|
2764 |
SQLCreateTable createTarif = new SQLCreateTable(root, "ARTICLE_TARIF");
|
2567 |
createTarif.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
2765 |
createTarif.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
2568 |
createTarif.addForeignColumn("ID_TAXE", root.findTable("TAXE", true));
|
2766 |
createTarif.addForeignColumn("ID_TAXE", root.findTable("TAXE", true));
|
2569 |
createTarif.addForeignColumn("ID_TARIF", root.findTable("TARIF", true));
|
2767 |
createTarif.addForeignColumn("ID_TARIF", root.findTable("TARIF", true));
|
2570 |
createTarif.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE", true));
|
2768 |
createTarif.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE", true));
|
2571 |
createTarif.addColumn("PV_HT", "bigint DEFAULT 0");
|
2769 |
createTarif.addColumn("PV_HT", "bigint DEFAULT 0");
|
2572 |
createTarif.addColumn("PV_TTC", "bigint DEFAULT 0");
|
2770 |
createTarif.addColumn("PV_TTC", "bigint DEFAULT 0");
|
2573 |
createTarif.addColumn("PRIX_METRIQUE_VT_1", "bigint DEFAULT 0");
|
2771 |
createTarif.addColumn("PRIX_METRIQUE_VT_1", "bigint DEFAULT 0");
|
2574 |
createTarif.addColumn("PRIX_METRIQUE_VT_2", "bigint DEFAULT 0");
|
2772 |
createTarif.addColumn("PRIX_METRIQUE_VT_2", "bigint DEFAULT 0");
|
2575 |
createTarif.addColumn("PRIX_METRIQUE_VT_3", "bigint DEFAULT 0");
|
2773 |
createTarif.addColumn("PRIX_METRIQUE_VT_3", "bigint DEFAULT 0");
|
2576 |
createTarif.asString();
|
2774 |
createTarif.asString();
|
2577 |
try {
|
2775 |
try {
|
2578 |
ds.execute(createTarif.asString());
|
2776 |
ds.execute(createTarif.asString());
|
2579 |
insertUndef(createTarif);
|
2777 |
insertUndef(createTarif);
|
2580 |
tableDevis.getSchema().updateVersion();
|
2778 |
tableDevis.getSchema().updateVersion();
|
2581 |
refetchRoot = true;
|
2779 |
refetchRoot = true;
|
2582 |
} catch (SQLException ex) {
|
2780 |
} catch (SQLException ex) {
|
2583 |
throw new IllegalStateException("Erreur lors de la création de la table ARTICLE_TARIF", ex);
|
2781 |
throw new IllegalStateException("Erreur lors de la création de la table ARTICLE_TARIF", ex);
|
2584 |
}
|
2782 |
}
|
2585 |
}
|
2783 |
}
|
2586 |
|
2784 |
|
2587 |
// Création de la table article Désignation
|
2785 |
// Création de la table article Désignation
|
2588 |
if (!root.contains("ARTICLE_DESIGNATION")) {
|
2786 |
if (!root.contains("ARTICLE_DESIGNATION")) {
|
2589 |
|
2787 |
|
2590 |
SQLCreateTable createTarif = new SQLCreateTable(root, "ARTICLE_DESIGNATION");
|
2788 |
SQLCreateTable createTarif = new SQLCreateTable(root, "ARTICLE_DESIGNATION");
|
2591 |
createTarif.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE", true));
|
2789 |
createTarif.addForeignColumn("ID_ARTICLE", root.findTable("ARTICLE", true));
|
2592 |
createTarif.addForeignColumn("ID_LANGUE", root.findTable("LANGUE", true));
|
2790 |
createTarif.addForeignColumn("ID_LANGUE", root.findTable("LANGUE", true));
|
2593 |
createTarif.addVarCharColumn("NOM", 1024);
|
2791 |
createTarif.addVarCharColumn("NOM", 1024);
|
2594 |
createTarif.asString();
|
2792 |
createTarif.asString();
|
2595 |
try {
|
2793 |
try {
|
2596 |
ds.execute(createTarif.asString());
|
2794 |
ds.execute(createTarif.asString());
|
2597 |
insertUndef(createTarif);
|
2795 |
insertUndef(createTarif);
|
2598 |
tableDevis.getSchema().updateVersion();
|
2796 |
tableDevis.getSchema().updateVersion();
|
2599 |
refetchRoot = true;
|
2797 |
refetchRoot = true;
|
2600 |
} catch (SQLException ex) {
|
2798 |
} catch (SQLException ex) {
|
2601 |
throw new IllegalStateException("Erreur lors de la création de la table ARTICLE_DESIGNATION", ex);
|
2799 |
throw new IllegalStateException("Erreur lors de la création de la table ARTICLE_DESIGNATION", ex);
|
2602 |
}
|
2800 |
}
|
2603 |
}
|
2801 |
}
|
2604 |
|
2802 |
|
2605 |
if (!root.contains("UNITE_VENTE")) {
|
2803 |
if (!root.contains("UNITE_VENTE")) {
|
2606 |
|
2804 |
|
2607 |
SQLCreateTable createUnite = new SQLCreateTable(root, "UNITE_VENTE");
|
2805 |
SQLCreateTable createUnite = new SQLCreateTable(root, "UNITE_VENTE");
|
2608 |
createUnite.addVarCharColumn("CODE", 32);
|
2806 |
createUnite.addVarCharColumn("CODE", 32);
|
2609 |
createUnite.addVarCharColumn("NOM", 256);
|
2807 |
createUnite.addVarCharColumn("NOM", 256);
|
2610 |
createUnite.addColumn("A_LA_PIECE", "boolean DEFAULT false");
|
2808 |
createUnite.addColumn("A_LA_PIECE", "boolean DEFAULT false");
|
2611 |
createUnite.addVarCharColumn("INFOS", 256);
|
2809 |
createUnite.addVarCharColumn("INFOS", 256);
|
2612 |
try {
|
2810 |
try {
|
2613 |
ds.execute(createUnite.asString());
|
2811 |
ds.execute(createUnite.asString());
|
2614 |
insertUndef(createUnite);
|
2812 |
insertUndef(createUnite);
|
2615 |
final String insert = "INSERT into " + getTableName(createUnite).quote()
|
2813 |
final String insert = "INSERT into " + getTableName(createUnite).quote()
|
2616 |
+ "(\"CODE\",\"NOM\",\"A_LA_PIECE\",\"ORDRE\") VALUES('pièce','à la pièce',true,1),('m','mètres',false,2),('m²','mètres carré',false,3),('m3','mètres cube',false,4),('l','litres',false,5),('kg','kilos',false,6),('h','heures',false,7),('j','jours',false,8),('mois','mois',false,9)";
|
2814 |
+ "(\"CODE\",\"NOM\",\"A_LA_PIECE\",\"ORDRE\") VALUES('pièce','à la pièce',true,1),('m','mètres',false,2),('m²','mètres carré',false,3),('m3','mètres cube',false,4),('l','litres',false,5),('kg','kilos',false,6),('h','heures',false,7),('j','jours',false,8),('mois','mois',false,9)";
|
2617 |
root.getDBSystemRoot().getDataSource().execute(insert);
|
2815 |
root.getDBSystemRoot().getDataSource().execute(insert);
|
2618 |
tableDevis.getSchema().updateVersion();
|
2816 |
tableDevis.getSchema().updateVersion();
|
2619 |
refetchRoot = true;
|
2817 |
refetchRoot = true;
|
2620 |
} catch (SQLException ex) {
|
2818 |
} catch (SQLException ex) {
|
2621 |
throw new IllegalStateException("Erreur lors de la création de la table UNITE_VENTE", ex);
|
2819 |
throw new IllegalStateException("Erreur lors de la création de la table UNITE_VENTE", ex);
|
2622 |
}
|
2820 |
}
|
2623 |
|
2821 |
|
2624 |
}
|
2822 |
}
|
2625 |
|
2823 |
|
2626 |
// Chargement des tables fraichement créées
|
2824 |
// Chargement des tables fraichement créées
|
2627 |
if (refetchRoot)
|
2825 |
if (refetchRoot)
|
2628 |
root.refetch();
|
2826 |
root.refetch();
|
2629 |
|
2827 |
|
2630 |
if (!tableArticle.getFieldsName().contains("ID_UNITE_VENTE")) {
|
2828 |
if (!tableArticle.getFieldsName().contains("ID_UNITE_VENTE")) {
|
2631 |
AlterTable alterTableArticle = new AlterTable(tableArticle);
|
2829 |
AlterTable alterTableArticle = new AlterTable(tableArticle);
|
2632 |
alterTableArticle.addForeignColumn("ID_UNITE_VENTE", root.findTable("UNITE_VENTE", true).getSQLName(), "ID", "2");
|
2830 |
alterTableArticle.addForeignColumn("ID_UNITE_VENTE", root.findTable("UNITE_VENTE", true).getSQLName(), "ID", "2");
|
2633 |
try {
|
2831 |
try {
|
2634 |
ds.execute(alterTableArticle.asString());
|
2832 |
ds.execute(alterTableArticle.asString());
|
2635 |
tableArticle.getSchema().updateVersion();
|
2833 |
tableArticle.getSchema().updateVersion();
|
2636 |
tableArticle.fetchFields();
|
2834 |
tableArticle.fetchFields();
|
2637 |
} catch (SQLException ex) {
|
2835 |
} catch (SQLException ex) {
|
2638 |
throw new IllegalStateException("Erreur lors de l'ajout du champ UNITE_VENTE sur la table ARTICLE", ex);
|
2836 |
throw new IllegalStateException("Erreur lors de l'ajout du champ UNITE_VENTE sur la table ARTICLE", ex);
|
2639 |
}
|
2837 |
}
|
2640 |
}
|
2838 |
}
|
2641 |
|
2839 |
|
2642 |
SQLTable tableVFElt = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
2840 |
SQLTable tableVFElt = root.getTable("SAISIE_VENTE_FACTURE_ELEMENT");
|
2643 |
addVenteEltField(tableVFElt, root);
|
2841 |
addVenteEltField(tableVFElt, root);
|
2644 |
|
2842 |
|
2645 |
SQLTable tableDevisElt = root.getTable("DEVIS_ELEMENT");
|
2843 |
SQLTable tableDevisElt = root.getTable("DEVIS_ELEMENT");
|
2646 |
addVenteEltField(tableDevisElt, root);
|
2844 |
addVenteEltField(tableDevisElt, root);
|
2647 |
|
2845 |
|
2648 |
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
|
2846 |
SQLTable tableCmdElt = root.getTable("COMMANDE_CLIENT_ELEMENT");
|
2649 |
addVenteEltField(tableCmdElt, root);
|
2847 |
addVenteEltField(tableCmdElt, root);
|
2650 |
|
2848 |
|
2651 |
SQLTable tableBonElt = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
2849 |
SQLTable tableBonElt = root.getTable("BON_DE_LIVRAISON_ELEMENT");
|
2652 |
addVenteEltField(tableBonElt, root);
|
2850 |
addVenteEltField(tableBonElt, root);
|
2653 |
|
2851 |
|
2654 |
SQLTable tableAvoirElt = root.getTable("AVOIR_CLIENT_ELEMENT");
|
2852 |
SQLTable tableAvoirElt = root.getTable("AVOIR_CLIENT_ELEMENT");
|
2655 |
addVenteEltField(tableAvoirElt, root);
|
2853 |
addVenteEltField(tableAvoirElt, root);
|
2656 |
|
2854 |
|
2657 |
SQLTable tableCmdFournElt = root.getTable("COMMANDE_ELEMENT");
|
2855 |
SQLTable tableCmdFournElt = root.getTable("COMMANDE_ELEMENT");
|
2658 |
addHAElementField(tableCmdFournElt, root);
|
2856 |
addHAElementField(tableCmdFournElt, root);
|
2659 |
if (root.contains("DEMANDE_PRIX_ELEMENT")) {
|
2857 |
if (root.contains("DEMANDE_PRIX_ELEMENT")) {
|
2660 |
SQLTable tableDmdFournElt = root.getTable("DEMANDE_PRIX_ELEMENT");
|
2858 |
SQLTable tableDmdFournElt = root.getTable("DEMANDE_PRIX_ELEMENT");
|
2661 |
addHAElementField(tableDmdFournElt, root);
|
2859 |
addHAElementField(tableDmdFournElt, root);
|
2662 |
}
|
2860 |
}
|
2663 |
|
2861 |
|
2664 |
SQLTable tableBonRecptElt = root.getTable("BON_RECEPTION_ELEMENT");
|
2862 |
SQLTable tableBonRecptElt = root.getTable("BON_RECEPTION_ELEMENT");
|
2665 |
addHAElementField(tableBonRecptElt, root);
|
2863 |
addHAElementField(tableBonRecptElt, root);
|
2666 |
|
2864 |
|
2667 |
SQLTable tableBonRecpt = root.getTable("BON_RECEPTION");
|
2865 |
SQLTable tableBonRecpt = root.getTable("BON_RECEPTION");
|
2668 |
addDeviseHAField(tableBonRecpt, root);
|
2866 |
addDeviseHAField(tableBonRecpt, root);
|
2669 |
|
2867 |
|
2670 |
SQLTable tableCommande = root.getTable("COMMANDE");
|
2868 |
SQLTable tableCommande = root.getTable("COMMANDE");
|
2671 |
addDeviseHAField(tableCommande, root);
|
2869 |
addDeviseHAField(tableCommande, root);
|
2672 |
|
2870 |
|
2673 |
patchFieldElt1Dot3(root.getTable("ARTICLE"), root);
|
2871 |
patchFieldElt1Dot3(root.getTable("ARTICLE"), root);
|
2674 |
patchFieldElt1Dot3(root.getTable("ARTICLE_TARIF"), root);
|
2872 |
patchFieldElt1Dot3(root.getTable("ARTICLE_TARIF"), root);
|
2675 |
|
2873 |
|
2676 |
if (!tableCommande.getFieldsName().contains("ID_ADRESSE")) {
|
2874 |
if (!tableCommande.getFieldsName().contains("ID_ADRESSE")) {
|
2677 |
AlterTable alterCmd = new AlterTable(tableCommande);
|
2875 |
AlterTable alterCmd = new AlterTable(tableCommande);
|
2678 |
alterCmd.addForeignColumn("ID_ADRESSE", root.findTable("ADRESSE", true));
|
2876 |
alterCmd.addForeignColumn("ID_ADRESSE", root.findTable("ADRESSE", true));
|
2679 |
try {
|
2877 |
try {
|
2680 |
ds.execute(alterCmd.asString());
|
2878 |
ds.execute(alterCmd.asString());
|
2681 |
tableCommande.getSchema().updateVersion();
|
2879 |
tableCommande.getSchema().updateVersion();
|
2682 |
} catch (SQLException ex) {
|
2880 |
} catch (SQLException ex) {
|
2683 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table COMMANDE", ex);
|
2881 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table COMMANDE", ex);
|
2684 |
}
|
2882 |
}
|
2685 |
|
2883 |
|
2686 |
}
|
2884 |
}
|
2687 |
if (!tableCommande.getFieldsName().contains("ID_CLIENT")) {
|
2885 |
if (!tableCommande.getFieldsName().contains("ID_CLIENT")) {
|
2688 |
AlterTable alterCmd = new AlterTable(tableCommande);
|
2886 |
AlterTable alterCmd = new AlterTable(tableCommande);
|
2689 |
alterCmd.addForeignColumn("ID_CLIENT", root.findTable("CLIENT"));
|
2887 |
alterCmd.addForeignColumn("ID_CLIENT", root.findTable("CLIENT"));
|
2690 |
try {
|
2888 |
try {
|
2691 |
ds.execute(alterCmd.asString());
|
2889 |
ds.execute(alterCmd.asString());
|
2692 |
tableCommande.getSchema().updateVersion();
|
2890 |
tableCommande.getSchema().updateVersion();
|
2693 |
} catch (SQLException ex) {
|
2891 |
} catch (SQLException ex) {
|
2694 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table COMMANDE", ex);
|
2892 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table COMMANDE", ex);
|
2695 |
}
|
2893 |
}
|
2696 |
|
2894 |
|
2697 |
}
|
2895 |
}
|
2698 |
|
2896 |
|
2699 |
{
|
2897 |
{
|
2700 |
addTotalDeviseField(tableDevis, root);
|
2898 |
addTotalDeviseField(tableDevis, root);
|
2701 |
addModeleField(tableDevis, root);
|
2899 |
addModeleField(tableDevis, root);
|
2702 |
|
2900 |
|
2703 |
SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE");
|
2901 |
SQLTable tableVF = root.getTable("SAISIE_VENTE_FACTURE");
|
2704 |
addTotalDeviseField(tableVF, root);
|
2902 |
addTotalDeviseField(tableVF, root);
|
2705 |
addModeleField(tableVF, root);
|
2903 |
addModeleField(tableVF, root);
|
2706 |
|
2904 |
|
2707 |
addTotalDeviseField(tableDevis, root);
|
2905 |
addTotalDeviseField(tableDevis, root);
|
2708 |
addModeleField(tableDevis, root);
|
2906 |
addModeleField(tableDevis, root);
|
2709 |
|
2907 |
|
2710 |
SQLTable tableCmd = root.getTable("COMMANDE_CLIENT");
|
2908 |
SQLTable tableCmd = root.getTable("COMMANDE_CLIENT");
|
2711 |
addTotalDeviseField(tableCmd, root);
|
2909 |
addTotalDeviseField(tableCmd, root);
|
2712 |
addModeleField(tableCmd, root);
|
2910 |
addModeleField(tableCmd, root);
|
2713 |
|
2911 |
|
2714 |
SQLTable tableBon = root.getTable("BON_DE_LIVRAISON");
|
2912 |
SQLTable tableBon = root.getTable("BON_DE_LIVRAISON");
|
2715 |
addTotalDeviseField(tableBon, root);
|
2913 |
addTotalDeviseField(tableBon, root);
|
2716 |
addModeleField(tableBon, root);
|
2914 |
addModeleField(tableBon, root);
|
2717 |
|
2915 |
|
2718 |
SQLTable tableAvoir = root.getTable("AVOIR_CLIENT");
|
2916 |
SQLTable tableAvoir = root.getTable("AVOIR_CLIENT");
|
2719 |
addTotalDeviseField(tableAvoir, root);
|
2917 |
addTotalDeviseField(tableAvoir, root);
|
2720 |
addModeleField(tableAvoir, root);
|
2918 |
addModeleField(tableAvoir, root);
|
2721 |
}
|
2919 |
}
|
2722 |
// Change client
|
2920 |
// Change client
|
2723 |
{
|
2921 |
{
|
2724 |
SQLTable tableClient = root.getTable("CLIENT");
|
2922 |
SQLTable tableClient = root.getTable("CLIENT");
|
2725 |
|
2923 |
|
2726 |
AlterTable tClient = new AlterTable(tableClient);
|
2924 |
AlterTable tClient = new AlterTable(tableClient);
|
2727 |
boolean alterClient = false;
|
2925 |
boolean alterClient = false;
|
2728 |
|
2926 |
|
2729 |
if (!tableClient.getFieldsName().contains("ID_TARIF")) {
|
2927 |
if (!tableClient.getFieldsName().contains("ID_TARIF")) {
|
2730 |
tClient.addForeignColumn("ID_TARIF", root.findTable("TARIF", true));
|
2928 |
tClient.addForeignColumn("ID_TARIF", root.findTable("TARIF", true));
|
2731 |
alterClient = true;
|
2929 |
alterClient = true;
|
2732 |
}
|
2930 |
}
|
2733 |
if (!tableClient.getFieldsName().contains("ID_PAYS")) {
|
2931 |
if (!tableClient.getFieldsName().contains("ID_PAYS")) {
|
2734 |
tClient.addForeignColumn("ID_PAYS", root.findTable("PAYS", true));
|
2932 |
tClient.addForeignColumn("ID_PAYS", root.findTable("PAYS", true));
|
2735 |
alterClient = true;
|
2933 |
alterClient = true;
|
2736 |
}
|
2934 |
}
|
2737 |
if (!tableClient.getFieldsName().contains("ID_LANGUE")) {
|
2935 |
if (!tableClient.getFieldsName().contains("ID_LANGUE")) {
|
2738 |
tClient.addForeignColumn("ID_LANGUE", root.findTable("LANGUE", true));
|
2936 |
tClient.addForeignColumn("ID_LANGUE", root.findTable("LANGUE", true));
|
2739 |
alterClient = true;
|
2937 |
alterClient = true;
|
2740 |
}
|
2938 |
}
|
2741 |
|
2939 |
|
2742 |
if (!tableClient.getFieldsName().contains("ID_DEVISE")) {
|
2940 |
if (!tableClient.getFieldsName().contains("ID_DEVISE")) {
|
2743 |
tClient.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
2941 |
tClient.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
2744 |
alterClient = true;
|
2942 |
alterClient = true;
|
2745 |
}
|
2943 |
}
|
2746 |
if (alterClient) {
|
2944 |
if (alterClient) {
|
2747 |
try {
|
2945 |
try {
|
2748 |
ds.execute(tClient.asString());
|
2946 |
ds.execute(tClient.asString());
|
2749 |
tableClient.getSchema().updateVersion();
|
2947 |
tableClient.getSchema().updateVersion();
|
2750 |
} catch (SQLException ex) {
|
2948 |
} catch (SQLException ex) {
|
2751 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table CLIENT", ex);
|
2949 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table CLIENT", ex);
|
2752 |
}
|
2950 |
}
|
2753 |
}
|
2951 |
}
|
2754 |
}
|
2952 |
}
|
2755 |
|
2953 |
|
2756 |
// Change Pays
|
2954 |
// Change Pays
|
2757 |
{
|
2955 |
{
|
2758 |
SQLTable tablePays = root.getTable("PAYS");
|
2956 |
SQLTable tablePays = root.getTable("PAYS");
|
2759 |
|
2957 |
|
2760 |
AlterTable tPays = new AlterTable(tablePays);
|
2958 |
AlterTable tPays = new AlterTable(tablePays);
|
2761 |
boolean alterPays = false;
|
2959 |
boolean alterPays = false;
|
2762 |
|
2960 |
|
2763 |
if (!tablePays.getFieldsName().contains("ID_TARIF")) {
|
2961 |
if (!tablePays.getFieldsName().contains("ID_TARIF")) {
|
2764 |
tPays.addForeignColumn("ID_TARIF", root.findTable("TARIF", true));
|
2962 |
tPays.addForeignColumn("ID_TARIF", root.findTable("TARIF", true));
|
2765 |
alterPays = true;
|
2963 |
alterPays = true;
|
2766 |
}
|
2964 |
}
|
2767 |
if (!tablePays.getFieldsName().contains("ID_LANGUE")) {
|
2965 |
if (!tablePays.getFieldsName().contains("ID_LANGUE")) {
|
2768 |
tPays.addForeignColumn("ID_LANGUE", root.findTable("LANGUE", true));
|
2966 |
tPays.addForeignColumn("ID_LANGUE", root.findTable("LANGUE", true));
|
2769 |
alterPays = true;
|
2967 |
alterPays = true;
|
2770 |
}
|
2968 |
}
|
2771 |
if (alterPays) {
|
2969 |
if (alterPays) {
|
2772 |
try {
|
2970 |
try {
|
2773 |
ds.execute(tPays.asString());
|
2971 |
ds.execute(tPays.asString());
|
2774 |
tablePays.getSchema().updateVersion();
|
2972 |
tablePays.getSchema().updateVersion();
|
2775 |
} catch (SQLException ex) {
|
2973 |
} catch (SQLException ex) {
|
2776 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table PAYS", ex);
|
2974 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table PAYS", ex);
|
2777 |
}
|
2975 |
}
|
2778 |
}
|
2976 |
}
|
2779 |
}
|
2977 |
}
|
2780 |
// Change Commande
|
2978 |
// Change Commande
|
2781 |
{
|
2979 |
{
|
2782 |
SQLTable tableCmd = root.getTable("COMMANDE");
|
2980 |
SQLTable tableCmd = root.getTable("COMMANDE");
|
2783 |
|
2981 |
|
2784 |
AlterTable tCmd = new AlterTable(tableCmd);
|
2982 |
AlterTable tCmd = new AlterTable(tableCmd);
|
2785 |
boolean alterCmd = false;
|
2983 |
boolean alterCmd = false;
|
2786 |
|
2984 |
|
2787 |
if (!tableCmd.getFieldsName().contains("EN_COURS")) {
|
2985 |
if (!tableCmd.getFieldsName().contains("EN_COURS")) {
|
2788 |
tCmd.addColumn("EN_COURS", "boolean default true");
|
2986 |
tCmd.addColumn("EN_COURS", "boolean default true");
|
2789 |
alterCmd = true;
|
2987 |
alterCmd = true;
|
2790 |
}
|
2988 |
}
|
2791 |
if (alterCmd) {
|
2989 |
if (alterCmd) {
|
2792 |
try {
|
2990 |
try {
|
2793 |
ds.execute(tCmd.asString());
|
2991 |
ds.execute(tCmd.asString());
|
2794 |
tableCmd.getSchema().updateVersion();
|
2992 |
tableCmd.getSchema().updateVersion();
|
2795 |
} catch (SQLException ex) {
|
2993 |
} catch (SQLException ex) {
|
2796 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table COMMANDE", ex);
|
2994 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table COMMANDE", ex);
|
2797 |
}
|
2995 |
}
|
2798 |
}
|
2996 |
}
|
2799 |
}
|
2997 |
}
|
2800 |
|
2998 |
|
2801 |
// Change VF
|
2999 |
// Change VF
|
2802 |
{
|
3000 |
{
|
2803 |
SQLTable tableVenteFacture = root.getTable("SAISIE_VENTE_FACTURE");
|
3001 |
SQLTable tableVenteFacture = root.getTable("SAISIE_VENTE_FACTURE");
|
2804 |
|
3002 |
|
2805 |
AlterTable tVF = new AlterTable(tableVenteFacture);
|
3003 |
AlterTable tVF = new AlterTable(tableVenteFacture);
|
2806 |
boolean alterVF = false;
|
3004 |
boolean alterVF = false;
|
2807 |
|
3005 |
|
2808 |
if (!tableVenteFacture.getFieldsName().contains("ID_TAXE_PORT")) {
|
3006 |
if (!tableVenteFacture.getFieldsName().contains("ID_TAXE_PORT")) {
|
2809 |
tVF.addForeignColumn("ID_TAXE_PORT", root.findTable("TAXE"));
|
3007 |
tVF.addForeignColumn("ID_TAXE_PORT", root.findTable("TAXE"));
|
2810 |
alterVF = true;
|
3008 |
alterVF = true;
|
2811 |
}
|
3009 |
}
|
2812 |
if (alterVF) {
|
3010 |
if (alterVF) {
|
2813 |
try {
|
3011 |
try {
|
2814 |
ds.execute(tVF.asString());
|
3012 |
ds.execute(tVF.asString());
|
2815 |
tableVenteFacture.getSchema().updateVersion();
|
3013 |
tableVenteFacture.getSchema().updateVersion();
|
2816 |
} catch (SQLException ex) {
|
3014 |
} catch (SQLException ex) {
|
2817 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table SAISIE_VENTE_FACTURE", ex);
|
3015 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table SAISIE_VENTE_FACTURE", ex);
|
2818 |
}
|
3016 |
}
|
2819 |
}
|
3017 |
}
|
2820 |
}
|
3018 |
}
|
2821 |
|
3019 |
|
2822 |
// Change Fournisseur
|
3020 |
// Change Fournisseur
|
2823 |
{
|
3021 |
{
|
2824 |
SQLTable tableFournisseur = root.getTable("FOURNISSEUR");
|
3022 |
SQLTable tableFournisseur = root.getTable("FOURNISSEUR");
|
2825 |
|
3023 |
|
2826 |
AlterTable tFourn = new AlterTable(tableFournisseur);
|
3024 |
AlterTable tFourn = new AlterTable(tableFournisseur);
|
2827 |
boolean alterFourn = false;
|
3025 |
boolean alterFourn = false;
|
2828 |
|
3026 |
|
2829 |
if (!tableFournisseur.getFieldsName().contains("ID_LANGUE")) {
|
3027 |
if (!tableFournisseur.getFieldsName().contains("ID_LANGUE")) {
|
2830 |
tFourn.addForeignColumn("ID_LANGUE", root.findTable("LANGUE", true));
|
3028 |
tFourn.addForeignColumn("ID_LANGUE", root.findTable("LANGUE", true));
|
2831 |
alterFourn = true;
|
3029 |
alterFourn = true;
|
2832 |
}
|
3030 |
}
|
2833 |
if (!tableFournisseur.getFieldsName().contains("ID_DEVISE")) {
|
3031 |
if (!tableFournisseur.getFieldsName().contains("ID_DEVISE")) {
|
2834 |
tFourn.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
3032 |
tFourn.addForeignColumn("ID_DEVISE", root.findTable("DEVISE", true));
|
2835 |
alterFourn = true;
|
3033 |
alterFourn = true;
|
2836 |
}
|
3034 |
}
|
2837 |
if (!tableFournisseur.getFieldsName().contains("RESPONSABLE")) {
|
3035 |
if (!tableFournisseur.getFieldsName().contains("RESPONSABLE")) {
|
2838 |
tFourn.addVarCharColumn("RESPONSABLE", 256);
|
3036 |
tFourn.addVarCharColumn("RESPONSABLE", 256);
|
2839 |
alterFourn = true;
|
3037 |
alterFourn = true;
|
2840 |
}
|
3038 |
}
|
2841 |
if (!tableFournisseur.getFieldsName().contains("TEL_P")) {
|
3039 |
if (!tableFournisseur.getFieldsName().contains("TEL_P")) {
|
2842 |
tFourn.addVarCharColumn("TEL_P", 256);
|
3040 |
tFourn.addVarCharColumn("TEL_P", 256);
|
2843 |
alterFourn = true;
|
3041 |
alterFourn = true;
|
2844 |
}
|
3042 |
}
|
2845 |
if (!tableFournisseur.getFieldsName().contains("MAIL")) {
|
3043 |
if (!tableFournisseur.getFieldsName().contains("MAIL")) {
|
2846 |
tFourn.addVarCharColumn("MAIL", 256);
|
3044 |
tFourn.addVarCharColumn("MAIL", 256);
|
2847 |
alterFourn = true;
|
3045 |
alterFourn = true;
|
2848 |
}
|
3046 |
}
|
2849 |
if (!tableFournisseur.getFieldsName().contains("INFOS")) {
|
3047 |
if (!tableFournisseur.getFieldsName().contains("INFOS")) {
|
2850 |
tFourn.addVarCharColumn("INFOS", 2048);
|
3048 |
tFourn.addVarCharColumn("INFOS", 2048);
|
2851 |
alterFourn = true;
|
3049 |
alterFourn = true;
|
2852 |
}
|
3050 |
}
|
2853 |
|
3051 |
|
2854 |
if (alterFourn) {
|
3052 |
if (alterFourn) {
|
2855 |
try {
|
3053 |
try {
|
2856 |
ds.execute(tFourn.asString());
|
3054 |
ds.execute(tFourn.asString());
|
2857 |
tableFournisseur.getSchema().updateVersion();
|
3055 |
tableFournisseur.getSchema().updateVersion();
|
2858 |
} catch (SQLException ex) {
|
3056 |
} catch (SQLException ex) {
|
2859 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table FOURNISSEUR", ex);
|
3057 |
throw new IllegalStateException("Erreur lors de l'ajout des champs sur la table FOURNISSEUR", ex);
|
2860 |
}
|
3058 |
}
|
2861 |
}
|
3059 |
}
|
2862 |
}
|
3060 |
}
|
2863 |
|
3061 |
|
2864 |
updateN4DS(root);
|
3062 |
updateN4DS(root);
|
2865 |
|
3063 |
|
2866 |
root.refetch();
|
3064 |
root.refetch();
|
2867 |
}
|
3065 |
}
|
2868 |
|
3066 |
|
2869 |
/**
|
3067 |
/**
|
2870 |
* Mise à jour du schéma pour N4DS
|
3068 |
* Mise à jour du schéma pour N4DS
|
2871 |
*
|
3069 |
*
|
2872 |
* @param root
|
3070 |
* @param root
|
2873 |
* @throws SQLException
|
3071 |
* @throws SQLException
|
2874 |
*/
|
3072 |
*/
|
2875 |
private void updateN4DS(DBRoot root) throws SQLException {
|
3073 |
private void updateN4DS(DBRoot root) throws SQLException {
|
2876 |
|
3074 |
|
2877 |
{
|
3075 |
{
|
2878 |
SQLTable table = root.findTable("INFOS_SALARIE_PAYE");
|
3076 |
SQLTable table = root.findTable("INFOS_SALARIE_PAYE");
|
2879 |
boolean alter = false;
|
3077 |
boolean alter = false;
|
2880 |
AlterTable t = new AlterTable(table);
|
3078 |
AlterTable t = new AlterTable(table);
|
2881 |
if (!table.getFieldsName().contains("CODE_AT")) {
|
3079 |
if (!table.getFieldsName().contains("CODE_AT")) {
|
2882 |
t.addVarCharColumn("CODE_AT", 18);
|
3080 |
t.addVarCharColumn("CODE_AT", 18);
|
2883 |
alter = true;
|
3081 |
alter = true;
|
2884 |
}
|
3082 |
}
|
2885 |
if (!table.getFieldsName().contains("CODE_SECTION_AT")) {
|
3083 |
if (!table.getFieldsName().contains("CODE_SECTION_AT")) {
|
2886 |
t.addVarCharColumn("CODE_SECTION_AT", 18);
|
3084 |
t.addVarCharColumn("CODE_SECTION_AT", 18);
|
2887 |
alter = true;
|
3085 |
alter = true;
|
2888 |
}
|
3086 |
}
|
2889 |
|
3087 |
|
2890 |
if (alter) {
|
3088 |
if (alter) {
|
2891 |
try {
|
3089 |
try {
|
2892 |
table.getBase().getDataSource().execute(t.asString());
|
3090 |
table.getBase().getDataSource().execute(t.asString());
|
2893 |
table.getSchema().updateVersion();
|
3091 |
table.getSchema().updateVersion();
|
2894 |
table.fetchFields();
|
3092 |
table.fetchFields();
|
2895 |
} catch (SQLException ex) {
|
3093 |
} catch (SQLException ex) {
|
2896 |
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + table.getName(), ex);
|
3094 |
throw new IllegalStateException("Erreur lors de l'ajout des champs à la table " + table.getName(), ex);
|
2897 |
}
|
3095 |
}
|
2898 |
}
|
3096 |
}
|
2899 |
|
3097 |
|
2900 |
}
|
3098 |
}
|
2901 |
|
3099 |
|
2902 |
if (!root.contains("CODE_STATUT_CAT_CONV")) {
|
3100 |
if (!root.contains("CODE_STATUT_CAT_CONV")) {
|
2903 |
|
3101 |
|
2904 |
SQLCreateTable createTarif = new SQLCreateTable(root, "CODE_STATUT_CAT_CONV");
|
3102 |
SQLCreateTable createTarif = new SQLCreateTable(root, "CODE_STATUT_CAT_CONV");
|
2905 |
|
3103 |
|
2906 |
createTarif.addVarCharColumn("CODE", 6);
|
3104 |
createTarif.addVarCharColumn("CODE", 6);
|
2907 |
createTarif.addVarCharColumn("NOM", 256);
|
3105 |
createTarif.addVarCharColumn("NOM", 256);
|
2908 |
createTarif.asString();
|
3106 |
createTarif.asString();
|
2909 |
try {
|
3107 |
try {
|
2910 |
root.getBase().getDataSource().execute(createTarif.asString());
|
3108 |
root.getBase().getDataSource().execute(createTarif.asString());
|
2911 |
insertUndef(createTarif);
|
3109 |
insertUndef(createTarif);
|
2912 |
|
3110 |
|
2913 |
String insert = "INSERT into " + getTableName(createTarif).quote() + "(\"CODE\",\"NOM\") VALUES ";
|
3111 |
String insert = "INSERT into " + getTableName(createTarif).quote() + "(\"CODE\",\"NOM\") VALUES ";
|
2914 |
insert += " ('01','agriculteur salarié de son exploitation')";
|
3112 |
insert += " ('01','agriculteur salarié de son exploitation')";
|
2915 |
insert += ", ('02','artisan ou commerçant salarié de son entreprise')";
|
3113 |
insert += ", ('02','artisan ou commerçant salarié de son entreprise')";
|
2916 |
insert += ", ('03','cadre dirigeant (votant au collège employeur des élections prud''''hommales)')";
|
3114 |
insert += ", ('03','cadre dirigeant (votant au collège employeur des élections prud''''hommales)')";
|
2917 |
insert += ", ('04','autres cadres au sens de la convention collective (ou du statut pour les régimes spéciaux)')";
|
3115 |
insert += ", ('04','autres cadres au sens de la convention collective (ou du statut pour les régimes spéciaux)')";
|
2918 |
insert += ", ('05','profession intermédiaire (technicien, contremaître, agent de maîtrise, clergé)')";
|
3116 |
insert += ", ('05','profession intermédiaire (technicien, contremaître, agent de maîtrise, clergé)')";
|
2919 |
insert += ", ('06','employé administratif d''''entreprise, de commerce, agent de service')";
|
3117 |
insert += ", ('06','employé administratif d''''entreprise, de commerce, agent de service')";
|
2920 |
insert += ", ('07','ouvriers qualifiés et non qualifiés y compris ouvriers agricoles');";
|
3118 |
insert += ", ('07','ouvriers qualifiés et non qualifiés y compris ouvriers agricoles');";
|
2921 |
createTarif.getRoot().getDBSystemRoot().getDataSource().execute(insert);
|
3119 |
createTarif.getRoot().getDBSystemRoot().getDataSource().execute(insert);
|
2922 |
|
3120 |
|
2923 |
root.getSchema().updateVersion();
|
3121 |
root.getSchema().updateVersion();
|
2924 |
root.refetch();
|
3122 |
root.refetch();
|
2925 |
} catch (SQLException ex) {
|
3123 |
} catch (SQLException ex) {
|
2926 |
throw new IllegalStateException("Erreur lors de la création de la table CODE_STATUT_CAT_CONV", ex);
|
3124 |
throw new IllegalStateException("Erreur lors de la création de la table CODE_STATUT_CAT_CONV", ex);
|
2927 |
}
|
3125 |
}
|
2928 |
}
|
3126 |
}
|
2929 |
|
3127 |
|
2930 |
// Création de la table Modéle
|
3128 |
// Création de la table Modéle
|
2931 |
if (!root.contains("CONTACT_ADMINISTRATIF")) {
|
3129 |
if (!root.contains("CONTACT_ADMINISTRATIF")) {
|
2932 |
|
3130 |
|
2933 |
SQLCreateTable createModele = new SQLCreateTable(root, "CONTACT_ADMINISTRATIF");
|
3131 |
SQLCreateTable createModele = new SQLCreateTable(root, "CONTACT_ADMINISTRATIF");
|
2934 |
createModele.addVarCharColumn("NOM", 256);
|
3132 |
createModele.addVarCharColumn("NOM", 256);
|
2935 |
createModele.addVarCharColumn("PRENOM", 256);
|
3133 |
createModele.addVarCharColumn("PRENOM", 256);
|
2936 |
createModele.addVarCharColumn("TEL_DIRECT", 256);
|
3134 |
createModele.addVarCharColumn("TEL_DIRECT", 256);
|
2937 |
createModele.addVarCharColumn("TEL_MOBILE", 256);
|
3135 |
createModele.addVarCharColumn("TEL_MOBILE", 256);
|
2938 |
createModele.addVarCharColumn("EMAIL", 256);
|
3136 |
createModele.addVarCharColumn("EMAIL", 256);
|
2939 |
createModele.addVarCharColumn("FAX", 256);
|
3137 |
createModele.addVarCharColumn("FAX", 256);
|
2940 |
createModele.addVarCharColumn("FONCTION", 256);
|
3138 |
createModele.addVarCharColumn("FONCTION", 256);
|
2941 |
createModele.addVarCharColumn("TEL_PERSONEL", 256);
|
3139 |
createModele.addVarCharColumn("TEL_PERSONEL", 256);
|
2942 |
createModele.addVarCharColumn("TEL_STANDARD", 256);
|
3140 |
createModele.addVarCharColumn("TEL_STANDARD", 256);
|
2943 |
createModele.addForeignColumn("ID_TITRE_PERSONNEL", root.findTable("TITRE_PERSONNEL"));
|
3141 |
createModele.addForeignColumn("ID_TITRE_PERSONNEL", root.findTable("TITRE_PERSONNEL"));
|
2944 |
createModele.addColumn("N4DS", "boolean DEFAULT false");
|
3142 |
createModele.addColumn("N4DS", "boolean DEFAULT false");
|
2945 |
|
3143 |
|
2946 |
try {
|
3144 |
try {
|
2947 |
root.getBase().getDataSource().execute(createModele.asString());
|
3145 |
root.getBase().getDataSource().execute(createModele.asString());
|
2948 |
insertUndef(createModele);
|
3146 |
insertUndef(createModele);
|
2949 |
root.getSchema().updateVersion();
|
3147 |
root.getSchema().updateVersion();
|
2950 |
} catch (SQLException ex) {
|
3148 |
} catch (SQLException ex) {
|
2951 |
throw new IllegalStateException("Erreur lors de la création de la table MODELE", ex);
|
3149 |
throw new IllegalStateException("Erreur lors de la création de la table MODELE", ex);
|
2952 |
}
|
3150 |
}
|
2953 |
}
|
3151 |
}
|
2954 |
|
3152 |
|
2955 |
{
|
3153 |
{
|
2956 |
SQLTable tableContrat = root.findTable("CONTRAT_SALARIE", true);
|
3154 |
SQLTable tableContrat = root.findTable("CONTRAT_SALARIE", true);
|
2957 |
boolean alter2 = false;
|
3155 |
boolean alter2 = false;
|
2958 |
AlterTable t2 = new AlterTable(tableContrat);
|
3156 |
AlterTable t2 = new AlterTable(tableContrat);
|
2959 |
// UGRR
|
3157 |
// UGRR
|
2960 |
if (!tableContrat.getFieldsName().contains("CODE_IRC_UGRR")) {
|
3158 |
if (!tableContrat.getFieldsName().contains("CODE_IRC_UGRR")) {
|
2961 |
t2.addVarCharColumn("CODE_IRC_UGRR", 18);
|
3159 |
t2.addVarCharColumn("CODE_IRC_UGRR", 18);
|
2962 |
alter2 = true;
|
3160 |
alter2 = true;
|
2963 |
}
|
3161 |
}
|
2964 |
if (!tableContrat.getFieldsName().contains("NUMERO_RATTACHEMENT_UGRR")) {
|
3162 |
if (!tableContrat.getFieldsName().contains("NUMERO_RATTACHEMENT_UGRR")) {
|
2965 |
t2.addVarCharColumn("NUMERO_RATTACHEMENT_UGRR", 64);
|
3163 |
t2.addVarCharColumn("NUMERO_RATTACHEMENT_UGRR", 64);
|
2966 |
alter2 = true;
|
3164 |
alter2 = true;
|
2967 |
}
|
3165 |
}
|
2968 |
// UGRC
|
3166 |
// UGRC
|
2969 |
if (!tableContrat.getFieldsName().contains("CODE_IRC_UGRC")) {
|
3167 |
if (!tableContrat.getFieldsName().contains("CODE_IRC_UGRC")) {
|
2970 |
t2.addVarCharColumn("CODE_IRC_UGRC", 18);
|
3168 |
t2.addVarCharColumn("CODE_IRC_UGRC", 18);
|
2971 |
alter2 = true;
|
3169 |
alter2 = true;
|
2972 |
}
|
3170 |
}
|