OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
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
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.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.config;
15
 
16
import static java.util.Arrays.asList;
132 ilm 17
 
18 ilm 18
import org.openconcerto.erp.core.common.element.AdresseCommonSQLElement;
19
import org.openconcerto.erp.core.common.element.AdresseSQLElement;
83 ilm 20
import org.openconcerto.erp.core.common.element.BanqueSQLElement;
18 ilm 21
import org.openconcerto.erp.core.common.element.DepartementSQLElement;
19 ilm 22
import org.openconcerto.erp.core.common.element.LangueSQLElement;
18 ilm 23
import org.openconcerto.erp.core.common.element.MoisSQLElement;
24
import org.openconcerto.erp.core.common.element.NumerotationAutoSQLElement;
25
import org.openconcerto.erp.core.common.element.PaysSQLElement;
156 ilm 26
import org.openconcerto.erp.core.common.element.SocieteCommonSQLElement;
18 ilm 27
import org.openconcerto.erp.core.common.element.StyleSQLElement;
28
import org.openconcerto.erp.core.common.element.TitrePersonnelSQLElement;
93 ilm 29
import org.openconcerto.erp.core.customerrelationship.customer.element.ClientDepartementSQLElement;
174 ilm 30
import org.openconcerto.erp.core.customerrelationship.customer.element.ComptaContactSQLElement.ContactAdministratifSQLElement;
31
import org.openconcerto.erp.core.customerrelationship.customer.element.ComptaContactSQLElement.ContactFournisseurSQLElement;
32
import org.openconcerto.erp.core.customerrelationship.customer.element.ComptaContactSQLElement.ContactSQLElement;
33
import org.openconcerto.erp.core.customerrelationship.customer.element.ComptaContactSQLElement.ContactSalarieSQLElement;
142 ilm 34
import org.openconcerto.erp.core.customerrelationship.customer.element.CompteClientTransactionSQLELement;
18 ilm 35
import org.openconcerto.erp.core.customerrelationship.customer.element.CourrierClientSQLElement;
93 ilm 36
import org.openconcerto.erp.core.customerrelationship.customer.element.CustomerCategorySQLElement;
37
import org.openconcerto.erp.core.customerrelationship.customer.element.CustomerSQLElement;
18 ilm 38
import org.openconcerto.erp.core.customerrelationship.customer.element.ModeleCourrierClientSQLElement;
39
import org.openconcerto.erp.core.customerrelationship.customer.element.ReferenceClientSQLElement;
40
import org.openconcerto.erp.core.customerrelationship.customer.element.RelanceSQLElement;
41
import org.openconcerto.erp.core.customerrelationship.customer.element.TypeLettreRelanceSQLElement;
174 ilm 42
import org.openconcerto.erp.core.customerrelationship.mail.EmailTemplateSQLElement;
142 ilm 43
import org.openconcerto.erp.core.edm.AttachmentSQLElement;
18 ilm 44
import org.openconcerto.erp.core.finance.accounting.element.AssociationAnalytiqueSQLElement;
45
import org.openconcerto.erp.core.finance.accounting.element.AssociationCompteAnalytiqueSQLElement;
93 ilm 46
import org.openconcerto.erp.core.finance.accounting.element.AxeAnalytiqueSQLElement;
156 ilm 47
import org.openconcerto.erp.core.finance.accounting.element.CategorieComptableSQLElement;
18 ilm 48
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
49
import org.openconcerto.erp.core.finance.accounting.element.ComptePCGSQLElement;
93 ilm 50
import org.openconcerto.erp.core.finance.accounting.element.DeviseHistoriqueSQLElement;
18 ilm 51
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
52
import org.openconcerto.erp.core.finance.accounting.element.ExerciceCommonSQLElement;
156 ilm 53
import org.openconcerto.erp.core.finance.accounting.element.FraisDocumentSQLElement;
18 ilm 54
import org.openconcerto.erp.core.finance.accounting.element.JournalSQLElement;
55
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
56
import org.openconcerto.erp.core.finance.accounting.element.NatureCompteSQLElement;
57
import org.openconcerto.erp.core.finance.accounting.element.PieceSQLElement;
58
import org.openconcerto.erp.core.finance.accounting.element.PosteAnalytiqueSQLElement;
59
import org.openconcerto.erp.core.finance.accounting.element.RepartitionAnalytiqueSQLElement;
60
import org.openconcerto.erp.core.finance.accounting.element.SaisieKmItemSQLElement;
61
import org.openconcerto.erp.core.finance.accounting.element.SaisieKmSQLElement;
62
import org.openconcerto.erp.core.finance.accounting.element.TypeComptePCGSQLElement;
142 ilm 63
import org.openconcerto.erp.core.finance.accounting.model.Currency;
18 ilm 64
import org.openconcerto.erp.core.finance.payment.element.ChequeAEncaisserSQLElement;
65
import org.openconcerto.erp.core.finance.payment.element.ChequeAvoirClientSQLElement;
66
import org.openconcerto.erp.core.finance.payment.element.ChequeFournisseurSQLElement;
156 ilm 67
import org.openconcerto.erp.core.finance.payment.element.DepotChequeElementSQLElement;
68
import org.openconcerto.erp.core.finance.payment.element.DepotChequeSQLElement;
18 ilm 69
import org.openconcerto.erp.core.finance.payment.element.EncaisserMontantElementSQLElement;
70
import org.openconcerto.erp.core.finance.payment.element.EncaisserMontantSQLElement;
71
import org.openconcerto.erp.core.finance.payment.element.ModeDeReglementSQLElement;
80 ilm 72
import org.openconcerto.erp.core.finance.payment.element.ReglerMontantElementSQLElement;
18 ilm 73
import org.openconcerto.erp.core.finance.payment.element.ReglerMontantSQLElement;
151 ilm 74
import org.openconcerto.erp.core.finance.payment.element.SDDMessageSQLElement;
75
import org.openconcerto.erp.core.finance.payment.element.SEPAMandateSQLElement;
18 ilm 76
import org.openconcerto.erp.core.finance.payment.element.TypeReglementSQLElement;
77
import org.openconcerto.erp.core.finance.tax.element.EcoTaxeSQLElement;
142 ilm 78
import org.openconcerto.erp.core.finance.tax.element.TaxeComplementaireSQLElement;
18 ilm 79
import org.openconcerto.erp.core.finance.tax.element.TaxeSQLElement;
80
import org.openconcerto.erp.core.humanresources.employe.element.CommercialSQLElement;
81
import org.openconcerto.erp.core.humanresources.employe.element.EtatCivilSQLElement;
61 ilm 82
import org.openconcerto.erp.core.humanresources.employe.element.ObjectifSQLElement;
156 ilm 83
import org.openconcerto.erp.core.humanresources.employe.element.SituationFamilialeSQLElement;
18 ilm 84
import org.openconcerto.erp.core.humanresources.payroll.element.AcompteSQLElement;
142 ilm 85
import org.openconcerto.erp.core.humanresources.payroll.element.AyantDroitContratPrevSQLElement;
86
import org.openconcerto.erp.core.humanresources.payroll.element.AyantDroitSQLElement;
87
import org.openconcerto.erp.core.humanresources.payroll.element.AyantDroitTypeSQLElement;
88
import org.openconcerto.erp.core.humanresources.payroll.element.CaisseCotisationRenseignentSQLElement;
18 ilm 89
import org.openconcerto.erp.core.humanresources.payroll.element.CaisseCotisationSQLElement;
142 ilm 90
import org.openconcerto.erp.core.humanresources.payroll.element.CaisseModePaiementSQLElement;
18 ilm 91
import org.openconcerto.erp.core.humanresources.payroll.element.ClassementConventionnelSQLElement;
132 ilm 92
import org.openconcerto.erp.core.humanresources.payroll.element.CodeBaseAssujettieSQLElement;
93
import org.openconcerto.erp.core.humanresources.payroll.element.CodeCaisseTypeRubriqueSQLElement;
18 ilm 94
import org.openconcerto.erp.core.humanresources.payroll.element.CodeCaractActiviteSQLElement;
95
import org.openconcerto.erp.core.humanresources.payroll.element.CodeContratTravailSQLElement;
142 ilm 96
import org.openconcerto.erp.core.humanresources.payroll.element.CodeCotisationEtablissementSQLElement;
97
import org.openconcerto.erp.core.humanresources.payroll.element.CodeCotisationIndividuelleSQLElement;
18 ilm 98
import org.openconcerto.erp.core.humanresources.payroll.element.CodeDroitContratSQLElement;
99
import org.openconcerto.erp.core.humanresources.payroll.element.CodeEmploiSQLElement;
100
import org.openconcerto.erp.core.humanresources.payroll.element.CodeIdccSQLElement;
142 ilm 101
import org.openconcerto.erp.core.humanresources.payroll.element.CodePenibiliteContratSQLElement;
102
import org.openconcerto.erp.core.humanresources.payroll.element.CodePenibiliteSQLElement;
18 ilm 103
import org.openconcerto.erp.core.humanresources.payroll.element.CodeRegimeSQLElement;
41 ilm 104
import org.openconcerto.erp.core.humanresources.payroll.element.CodeStatutCategorielConventionnelSQLElement;
18 ilm 105
import org.openconcerto.erp.core.humanresources.payroll.element.CodeStatutCategorielSQLElement;
106
import org.openconcerto.erp.core.humanresources.payroll.element.CodeStatutProfSQLElement;
132 ilm 107
import org.openconcerto.erp.core.humanresources.payroll.element.CodeTypeRubriqueBrutSQLElement;
108
import org.openconcerto.erp.core.humanresources.payroll.element.CoefficientPrimeSQLElement;
109
import org.openconcerto.erp.core.humanresources.payroll.element.ContratDetacheExpatrieSQLElement;
110
import org.openconcerto.erp.core.humanresources.payroll.element.ContratDispositifPolitiqueSQLElement;
111
import org.openconcerto.erp.core.humanresources.payroll.element.ContratModaliteTempsSQLElement;
112
import org.openconcerto.erp.core.humanresources.payroll.element.ContratMotifRecoursSQLElement;
142 ilm 113
import org.openconcerto.erp.core.humanresources.payroll.element.ContratPrevoyanceRubriqueNetSQLElement;
114
import org.openconcerto.erp.core.humanresources.payroll.element.ContratPrevoyanceRubriqueSQLElement;
115
import org.openconcerto.erp.core.humanresources.payroll.element.ContratPrevoyanceSQLElement;
116
import org.openconcerto.erp.core.humanresources.payroll.element.ContratPrevoyanceSalarieSQLElement;
132 ilm 117
import org.openconcerto.erp.core.humanresources.payroll.element.ContratRegimeMaladieSQLElement;
118
import org.openconcerto.erp.core.humanresources.payroll.element.ContratRegimeVieillesseSQLElement;
18 ilm 119
import org.openconcerto.erp.core.humanresources.payroll.element.ContratSalarieSQLElement;
120
import org.openconcerto.erp.core.humanresources.payroll.element.CumulsCongesSQLElement;
121
import org.openconcerto.erp.core.humanresources.payroll.element.CumulsPayeSQLElement;
132 ilm 122
import org.openconcerto.erp.core.humanresources.payroll.element.DSNNatureSQLElement;
18 ilm 123
import org.openconcerto.erp.core.humanresources.payroll.element.FichePayeElementSQLElement;
124
import org.openconcerto.erp.core.humanresources.payroll.element.FichePayeSQLElement;
125
import org.openconcerto.erp.core.humanresources.payroll.element.ImpressionRubriqueSQLElement;
126
import org.openconcerto.erp.core.humanresources.payroll.element.InfosSalariePayeSQLElement;
127
import org.openconcerto.erp.core.humanresources.payroll.element.ModeReglementPayeSQLElement;
132 ilm 128
import org.openconcerto.erp.core.humanresources.payroll.element.MotifArretTravailSQLElement;
129
import org.openconcerto.erp.core.humanresources.payroll.element.MotifFinContratSQLElement;
130
import org.openconcerto.erp.core.humanresources.payroll.element.MotifRepriseArretTravailSQLElement;
156 ilm 131
import org.openconcerto.erp.core.humanresources.payroll.element.PasSQLElement;
18 ilm 132
import org.openconcerto.erp.core.humanresources.payroll.element.PeriodeValiditeSQLElement;
133
import org.openconcerto.erp.core.humanresources.payroll.element.ProfilPayeElementSQLElement;
134
import org.openconcerto.erp.core.humanresources.payroll.element.ProfilPayeSQLElement;
135
import org.openconcerto.erp.core.humanresources.payroll.element.RegimeBaseSQLElement;
136
import org.openconcerto.erp.core.humanresources.payroll.element.ReglementPayeSQLElement;
137
import org.openconcerto.erp.core.humanresources.payroll.element.RubriqueBrutSQLElement;
138
import org.openconcerto.erp.core.humanresources.payroll.element.RubriqueCommSQLElement;
139
import org.openconcerto.erp.core.humanresources.payroll.element.RubriqueCotisationSQLElement;
140
import org.openconcerto.erp.core.humanresources.payroll.element.RubriqueNetSQLElement;
141
import org.openconcerto.erp.core.humanresources.payroll.element.SalarieSQLElement;
142 ilm 142
import org.openconcerto.erp.core.humanresources.payroll.element.TypeComposantBaseAssujettieSQLElement;
143
import org.openconcerto.erp.core.humanresources.payroll.element.TypePreavisSQLElement;
18 ilm 144
import org.openconcerto.erp.core.humanresources.payroll.element.TypeRubriqueBrutSQLElement;
145
import org.openconcerto.erp.core.humanresources.payroll.element.TypeRubriqueNetSQLElement;
156 ilm 146
import org.openconcerto.erp.core.humanresources.payroll.element.TypeTauxPasSQLElement;
18 ilm 147
import org.openconcerto.erp.core.humanresources.payroll.element.VariablePayeSQLElement;
148
import org.openconcerto.erp.core.humanresources.payroll.element.VariableSalarieSQLElement;
149
import org.openconcerto.erp.core.humanresources.timesheet.element.PointageSQLElement;
90 ilm 150
import org.openconcerto.erp.core.project.element.CalendarItemGroupSQLElement;
151
import org.openconcerto.erp.core.project.element.CalendarItemSQLElement;
18 ilm 152
import org.openconcerto.erp.core.sales.credit.element.AvoirClientElementSQLElement;
153
import org.openconcerto.erp.core.sales.credit.element.AvoirClientSQLElement;
154
import org.openconcerto.erp.core.sales.invoice.element.EcheanceClientSQLElement;
155
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureItemSQLElement;
156
import org.openconcerto.erp.core.sales.invoice.element.SaisieVenteFactureSQLElement;
73 ilm 157
import org.openconcerto.erp.core.sales.invoice.element.TransferInvoiceSQLElement;
144 ilm 158
import org.openconcerto.erp.core.sales.order.element.ChiffrageCommandeClientSQLElement;
18 ilm 159
import org.openconcerto.erp.core.sales.order.element.CommandeClientElementSQLElement;
160
import org.openconcerto.erp.core.sales.order.element.CommandeClientSQLElement;
144 ilm 161
import org.openconcerto.erp.core.sales.order.element.FacturationCommandeClientSQLElement;
73 ilm 162
import org.openconcerto.erp.core.sales.order.element.TransferCustomerOrderSQLElement;
144 ilm 163
import org.openconcerto.erp.core.sales.pos.element.CaisseJournalSQLElement;
18 ilm 164
import org.openconcerto.erp.core.sales.pos.element.CaisseTicketSQLElement;
144 ilm 165
import org.openconcerto.erp.core.sales.pos.element.ClôtureCaisseSQLElement;
18 ilm 166
import org.openconcerto.erp.core.sales.pos.element.SaisieVenteComptoirSQLElement;
167
import org.openconcerto.erp.core.sales.pos.element.TicketCaisseSQLElement;
142 ilm 168
import org.openconcerto.erp.core.sales.pos.io.BarcodeReader;
19 ilm 169
import org.openconcerto.erp.core.sales.price.element.DeviseSQLElement;
18 ilm 170
import org.openconcerto.erp.core.sales.price.element.TarifSQLElement;
156 ilm 171
import org.openconcerto.erp.core.sales.product.element.ArticleCatComptableSQLElement;
144 ilm 172
import org.openconcerto.erp.core.sales.product.element.ArticleCodeClientSQLElement;
19 ilm 173
import org.openconcerto.erp.core.sales.product.element.ArticleDesignationSQLElement;
156 ilm 174
import org.openconcerto.erp.core.sales.product.element.ArticleFournisseurSecondaireSQLElement;
19 ilm 175
import org.openconcerto.erp.core.sales.product.element.ArticleTarifSQLElement;
156 ilm 176
import org.openconcerto.erp.core.sales.product.element.CoutRevientSQLElement;
174 ilm 177
import org.openconcerto.erp.core.sales.product.element.CustomerProductQtyPriceSQLElement;
142 ilm 178
import org.openconcerto.erp.core.sales.product.element.EcoContributionSQLElement;
18 ilm 179
import org.openconcerto.erp.core.sales.product.element.FamilleArticleSQLElement;
142 ilm 180
import org.openconcerto.erp.core.sales.product.element.FamilleEcoContributionSQLElement;
18 ilm 181
import org.openconcerto.erp.core.sales.product.element.MetriqueSQLElement;
182
import org.openconcerto.erp.core.sales.product.element.ModeVenteArticleSQLElement;
94 ilm 183
import org.openconcerto.erp.core.sales.product.element.ProductItemSQLElement;
184
import org.openconcerto.erp.core.sales.product.element.ProductQtyPriceSQLElement;
18 ilm 185
import org.openconcerto.erp.core.sales.product.element.ReferenceArticleSQLElement;
94 ilm 186
import org.openconcerto.erp.core.sales.product.element.ReliquatSQLElement;
187
import org.openconcerto.erp.core.sales.product.element.ReliquatSQLElement.ReliquatBRSQLElement;
156 ilm 188
import org.openconcerto.erp.core.sales.product.element.SupplierPriceListSQLElement;
61 ilm 189
import org.openconcerto.erp.core.sales.product.element.UniteVenteArticleSQLElement;
18 ilm 190
import org.openconcerto.erp.core.sales.quote.element.DevisItemSQLElement;
149 ilm 191
import org.openconcerto.erp.core.sales.quote.element.DevisLogMailSQLElement;
18 ilm 192
import org.openconcerto.erp.core.sales.quote.element.DevisSQLElement;
193
import org.openconcerto.erp.core.sales.quote.element.EtatDevisSQLElement;
73 ilm 194
import org.openconcerto.erp.core.sales.quote.element.TransferQuoteSQLElement;
18 ilm 195
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonItemSQLElement;
196
import org.openconcerto.erp.core.sales.shipment.element.BonDeLivraisonSQLElement;
73 ilm 197
import org.openconcerto.erp.core.sales.shipment.element.TransferShipmentSQLElement;
18 ilm 198
import org.openconcerto.erp.core.supplychain.credit.element.AvoirFournisseurSQLElement;
199
import org.openconcerto.erp.core.supplychain.order.element.CommandeElementSQLElement;
200
import org.openconcerto.erp.core.supplychain.order.element.CommandeSQLElement;
144 ilm 201
import org.openconcerto.erp.core.supplychain.order.element.DemandeAchatItemSQLElement;
202
import org.openconcerto.erp.core.supplychain.order.element.DemandePrixItemSQLElement;
203
import org.openconcerto.erp.core.supplychain.order.element.DemandePrixSQLElement;
204
import org.openconcerto.erp.core.supplychain.order.element.EtatDemandeAchatItemSQLElement;
205
import org.openconcerto.erp.core.supplychain.order.element.EtatDemandePrixSQLElement;
206
import org.openconcerto.erp.core.supplychain.order.element.FabricantSQLElement;
80 ilm 207
import org.openconcerto.erp.core.supplychain.order.element.FactureFournisseurElementSQLElement;
208
import org.openconcerto.erp.core.supplychain.order.element.FactureFournisseurSQLElement;
18 ilm 209
import org.openconcerto.erp.core.supplychain.order.element.SaisieAchatSQLElement;
73 ilm 210
import org.openconcerto.erp.core.supplychain.order.element.TransferPurchaseSQLElement;
211
import org.openconcerto.erp.core.supplychain.order.element.TransferSupplierOrderSQLElement;
83 ilm 212
import org.openconcerto.erp.core.supplychain.product.element.ArticleFournisseurSQLElement;
213
import org.openconcerto.erp.core.supplychain.product.element.FamilleArticleFounisseurSQLElement;
18 ilm 214
import org.openconcerto.erp.core.supplychain.receipt.element.BonReceptionElementSQLElement;
215
import org.openconcerto.erp.core.supplychain.receipt.element.BonReceptionSQLElement;
67 ilm 216
import org.openconcerto.erp.core.supplychain.receipt.element.CodeFournisseurSQLElement;
73 ilm 217
import org.openconcerto.erp.core.supplychain.receipt.element.TransferReceiptSQLElement;
156 ilm 218
import org.openconcerto.erp.core.supplychain.stock.element.DepotStockSQLElement;
219
import org.openconcerto.erp.core.supplychain.stock.element.EtatStockItemSQLElement;
220
import org.openconcerto.erp.core.supplychain.stock.element.EtatStockSQLElement;
18 ilm 221
import org.openconcerto.erp.core.supplychain.stock.element.MouvementStockSQLElement;
222
import org.openconcerto.erp.core.supplychain.stock.element.StockSQLElement;
223
import org.openconcerto.erp.core.supplychain.supplier.element.EcheanceFournisseurSQLElement;
224
import org.openconcerto.erp.core.supplychain.supplier.element.FournisseurSQLElement;
21 ilm 225
import org.openconcerto.erp.generationDoc.element.ModeleSQLElement;
226
import org.openconcerto.erp.generationDoc.element.TypeModeleSQLElement;
67 ilm 227
import org.openconcerto.erp.generationDoc.provider.AdresseFullClientValueProvider;
228
import org.openconcerto.erp.generationDoc.provider.AdresseRueClientValueProvider;
229
import org.openconcerto.erp.generationDoc.provider.AdresseVilleCPClientValueProvider;
230
import org.openconcerto.erp.generationDoc.provider.AdresseVilleClientValueProvider;
231
import org.openconcerto.erp.generationDoc.provider.AdresseVilleNomClientValueProvider;
144 ilm 232
import org.openconcerto.erp.generationDoc.provider.ArticleCodeClientProvider;
174 ilm 233
import org.openconcerto.erp.generationDoc.provider.ArticleCodeFournisseurProvider;
149 ilm 234
import org.openconcerto.erp.generationDoc.provider.ConditionsReglementDetailsProvider;
93 ilm 235
import org.openconcerto.erp.generationDoc.provider.DateBLProvider;
142 ilm 236
import org.openconcerto.erp.generationDoc.provider.DateProvider;
80 ilm 237
import org.openconcerto.erp.generationDoc.provider.FacturableValueProvider;
238
import org.openconcerto.erp.generationDoc.provider.FormatedGlobalQtyTotalProvider;
239
import org.openconcerto.erp.generationDoc.provider.LabelAccountInvoiceProvider;
240
import org.openconcerto.erp.generationDoc.provider.MergedGlobalQtyTotalProvider;
73 ilm 241
import org.openconcerto.erp.generationDoc.provider.ModeDeReglementDetailsProvider;
149 ilm 242
import org.openconcerto.erp.generationDoc.provider.PaiementRemainedDevisProvider;
83 ilm 243
import org.openconcerto.erp.generationDoc.provider.PaiementRemainedProvider;
244
import org.openconcerto.erp.generationDoc.provider.PrixUVProvider;
245
import org.openconcerto.erp.generationDoc.provider.PrixUnitaireProvider;
63 ilm 246
import org.openconcerto.erp.generationDoc.provider.PrixUnitaireRemiseProvider;
174 ilm 247
import org.openconcerto.erp.generationDoc.provider.QteTotalDocProvider;
67 ilm 248
import org.openconcerto.erp.generationDoc.provider.QteTotalProvider;
132 ilm 249
import org.openconcerto.erp.generationDoc.provider.RecapFactureProvider;
73 ilm 250
import org.openconcerto.erp.generationDoc.provider.RefClientValueProvider;
90 ilm 251
import org.openconcerto.erp.generationDoc.provider.RemiseProvider;
132 ilm 252
import org.openconcerto.erp.generationDoc.provider.RemiseTotalProvider;
253
import org.openconcerto.erp.generationDoc.provider.RestantAReglerProvider;
254
import org.openconcerto.erp.generationDoc.provider.SaledTotalNotDiscountedProvider;
255
import org.openconcerto.erp.generationDoc.provider.StockLocationProvider;
80 ilm 256
import org.openconcerto.erp.generationDoc.provider.TotalAcompteProvider;
257
import org.openconcerto.erp.generationDoc.provider.TotalCommandeClientProvider;
63 ilm 258
import org.openconcerto.erp.generationDoc.provider.UserCreateInitialsValueProvider;
259
import org.openconcerto.erp.generationDoc.provider.UserCurrentInitialsValueProvider;
260
import org.openconcerto.erp.generationDoc.provider.UserModifyInitialsValueProvider;
73 ilm 261
import org.openconcerto.erp.generationEcritures.provider.SalesCreditAccountingRecordsProvider;
67 ilm 262
import org.openconcerto.erp.generationEcritures.provider.SalesInvoiceAccountingRecordsProvider;
73 ilm 263
import org.openconcerto.erp.generationEcritures.provider.SupplyOrderAccountingRecordsProvider;
65 ilm 264
import org.openconcerto.erp.injector.AchatAvoirSQLInjector;
19 ilm 265
import org.openconcerto.erp.injector.ArticleCommandeEltSQLInjector;
142 ilm 266
import org.openconcerto.erp.injector.BonFactureEltSQLInjector;
18 ilm 267
import org.openconcerto.erp.injector.BonFactureSQLInjector;
94 ilm 268
import org.openconcerto.erp.injector.BonReceptionFactureFournisseurSQLInjector;
18 ilm 269
import org.openconcerto.erp.injector.BrFactureAchatSQLInjector;
270
import org.openconcerto.erp.injector.CommandeBlEltSQLInjector;
271
import org.openconcerto.erp.injector.CommandeBlSQLInjector;
156 ilm 272
import org.openconcerto.erp.injector.CommandeBrEltSQLInjector;
18 ilm 273
import org.openconcerto.erp.injector.CommandeBrSQLInjector;
19 ilm 274
import org.openconcerto.erp.injector.CommandeCliCommandeSQLInjector;
18 ilm 275
import org.openconcerto.erp.injector.CommandeFactureAchatSQLInjector;
276
import org.openconcerto.erp.injector.CommandeFactureClientSQLInjector;
174 ilm 277
import org.openconcerto.erp.injector.CommandeFactureEltSQLInjector;
278
import org.openconcerto.erp.injector.CommandeFactureFournisseurSQLInjector;
156 ilm 279
import org.openconcerto.erp.injector.DevisBlEltSQLInjector;
280
import org.openconcerto.erp.injector.DevisBlSQLInjector;
19 ilm 281
import org.openconcerto.erp.injector.DevisCommandeFournisseurSQLInjector;
18 ilm 282
import org.openconcerto.erp.injector.DevisCommandeSQLInjector;
283
import org.openconcerto.erp.injector.DevisEltFactureEltSQLInjector;
284
import org.openconcerto.erp.injector.DevisFactureSQLInjector;
144 ilm 285
import org.openconcerto.erp.injector.DmdAchatDmdPrixEltSQLInjector;
156 ilm 286
import org.openconcerto.erp.injector.DmdPrixCmdSQLInjector;
18 ilm 287
import org.openconcerto.erp.injector.EcheanceEncaisseSQLInjector;
80 ilm 288
import org.openconcerto.erp.injector.EcheanceRegleSQLInjector;
18 ilm 289
import org.openconcerto.erp.injector.FactureAvoirSQLInjector;
19 ilm 290
import org.openconcerto.erp.injector.FactureBonSQLInjector;
291
import org.openconcerto.erp.injector.FactureCommandeSQLInjector;
156 ilm 292
import org.openconcerto.erp.modules.ModuleManager;
18 ilm 293
import org.openconcerto.erp.preferences.DefaultNXProps;
142 ilm 294
import org.openconcerto.erp.preferences.GestionClientPreferencePanel;
295
import org.openconcerto.erp.preferences.GestionCommercialeGlobalPreferencePanel;
25 ilm 296
import org.openconcerto.erp.preferences.TemplateNXProps;
61 ilm 297
import org.openconcerto.erp.storage.CloudStorageEngine;
298
import org.openconcerto.erp.storage.StorageEngines;
18 ilm 299
import org.jopendocument.link.OOConnexion;
300
import org.openconcerto.sql.ShowAs;
41 ilm 301
import org.openconcerto.sql.element.SQLElement;
18 ilm 302
import org.openconcerto.sql.element.SQLElementDirectory;
303
import org.openconcerto.sql.element.SharedSQLElement;
304
import org.openconcerto.sql.model.DBRoot;
94 ilm 305
import org.openconcerto.sql.model.DBStructureItemNotFound;
18 ilm 306
import org.openconcerto.sql.model.DBSystemRoot;
73 ilm 307
import org.openconcerto.sql.model.FieldMapper;
18 ilm 308
import org.openconcerto.sql.model.SQLDataSource;
309
import org.openconcerto.sql.model.SQLRow;
310
import org.openconcerto.sql.model.SQLServer;
80 ilm 311
import org.openconcerto.sql.model.SQLSystem;
18 ilm 312
import org.openconcerto.sql.model.SQLTable;
142 ilm 313
import org.openconcerto.sql.preferences.SQLPreferences;
18 ilm 314
import org.openconcerto.task.TacheActionManager;
315
import org.openconcerto.task.config.ComptaBasePropsConfiguration;
94 ilm 316
import org.openconcerto.task.element.FWKListPrefs;
317
import org.openconcerto.task.element.FWKSessionState;
142 ilm 318
import org.openconcerto.utils.BaseDirs;
18 ilm 319
import org.openconcerto.utils.DesktopEnvironment;
320
import org.openconcerto.utils.ExceptionHandler;
149 ilm 321
import org.openconcerto.utils.ExceptionUtils;
41 ilm 322
import org.openconcerto.utils.NetUtils;
323
import org.openconcerto.utils.ProductInfo;
324
import org.openconcerto.utils.StringInputStream;
18 ilm 325
 
61 ilm 326
import java.awt.Color;
327
import java.awt.Font;
328
import java.awt.Graphics;
329
import java.awt.Graphics2D;
81 ilm 330
import java.awt.GraphicsEnvironment;
61 ilm 331
import java.awt.Image;
332
import java.awt.RenderingHints;
333
import java.awt.geom.Rectangle2D;
334
import java.awt.image.BufferedImage;
18 ilm 335
import java.io.File;
336
import java.io.FileInputStream;
337
import java.io.IOException;
338
import java.io.InputStream;
339
import java.sql.SQLException;
28 ilm 340
import java.text.DateFormat;
341
import java.text.SimpleDateFormat;
18 ilm 342
import java.util.ArrayList;
343
import java.util.Arrays;
41 ilm 344
import java.util.Collection;
18 ilm 345
import java.util.List;
346
import java.util.Properties;
347
 
61 ilm 348
import javax.imageio.ImageIO;
41 ilm 349
import javax.swing.JFrame;
18 ilm 350
import javax.swing.JOptionPane;
351
import javax.swing.SwingUtilities;
352
 
353
/***************************************************************************************************
354
 * Configuration de la gestion: Une base commune "Common" --> société, user, tasks. Une base
355
 * par défaut pour créer une société "Default". Un fichier mapping.xml pour la base commune.
356
 * Un fichier mappingCompta.xml pour les bases sociétés.
357
 **************************************************************************************************/
358
// final so we can use setupLogging(), see the constructor comment
144 ilm 359
public class ComptaPropsConfiguration extends ComptaBasePropsConfiguration {
18 ilm 360
 
41 ilm 361
    public static final ProductInfo productInfo = ProductInfo.getInstance();
362
    public static final String APP_NAME = productInfo.getName();
18 ilm 363
    private static final String DEFAULT_ROOT = "Common";
80 ilm 364
 
365
    static final Properties createDefaults() {
366
        final Properties defaults = new Properties();
367
        defaults.setProperty("base.root", DEFAULT_ROOT);
368
        return defaults;
369
    }
370
 
18 ilm 371
    // the properties path from this class
372
    private static final String PROPERTIES = "main.properties";
373
 
374
    public static final String DATA_DIR_VAR = "${data.dir}";
375
 
144 ilm 376
    protected String version = "";
18 ilm 377
    private static OOConnexion conn;
378
 
379
    public static OOConnexion getOOConnexion() {
380
        if (conn == null || conn.isClosed()) {
381
            try {
382
                conn = OOConnexion.create();
383
 
384
                if (conn == null) {
385
                    SwingUtilities.invokeLater(new Runnable() {
386
 
387
                        @Override
388
                        public void run() {
389
                            JOptionPane.showMessageDialog(null, "Impossible de trouver une installation d'OpenOffice sur votre ordinateur.\nMerci d'installer OpenOffice (http://fr.openoffice.org).");
390
                        }
391
                    });
392
                }
393
 
394
            } catch (IllegalStateException e) {
395
                JOptionPane.showMessageDialog(null, "Impossible d'obtenir une connexion avec openoffice. Contactez votre revendeur.");
396
                e.printStackTrace();
397
                conn = null;
398
            }
399
        }
400
 
401
        return conn;
402
    }
403
 
404
    public static void closeOOConnexion() {
405
        if (conn != null) {
406
            conn.closeConnexion();
407
        }
408
    }
409
 
410
    public static ComptaPropsConfiguration create() {
411
        return create(false);
412
    }
413
 
414
    public static ComptaPropsConfiguration create(final boolean nullAllowed) {
142 ilm 415
        return create(nullAllowed, getConfFile(productInfo));
18 ilm 416
    }
417
 
418
    public static ComptaPropsConfiguration create(final boolean nullAllowed, final File confFile) {
419
        // Log pour debug demarrage
94 ilm 420
        System.out.println("Loading configuration from: " + (confFile == null ? "null" : confFile.getAbsolutePath()));
18 ilm 421
        final boolean inWebStart = Gestion.inWebStart();
80 ilm 422
        final Properties defaults = createDefaults();
18 ilm 423
        // Ordre de recherche:
424
        // a/ fichier de configuration
425
        // b/ dans le jar
426
        try {
427
            final Properties props;
428
            // webstart should be self-contained, e.g. if a user launches from the web it shoudln't
429
            // read an old preference file but should always read its own configuration.
61 ilm 430
            if (confFile != null && confFile.exists() && !inWebStart) {
18 ilm 431
                props = create(new FileInputStream(confFile), defaults);
432
            } else {
433
                final InputStream stream = ComptaPropsConfiguration.class.getResourceAsStream(PROPERTIES);
434
                if (stream != null)
435
                    props = create(stream, defaults);
436
                else if (nullAllowed)
437
                    return null;
438
                else
439
                    throw new IOException("found neither " + confFile + " nor embedded " + PROPERTIES);
440
            }
80 ilm 441
            return new ComptaPropsConfiguration(props, inWebStart, true);
18 ilm 442
        } catch (final IOException e) {
443
            e.printStackTrace();
83 ilm 444
            String title = "Logiciel non configuré";
445
            String message = "Impossible de lire le fichier de configuration.\nIl est nécessaire d'utiliser le logiciel de Configuration pour paramétrer le logiciel.";
446
            JOptionPane.showMessageDialog(new JFrame(), message, title, JOptionPane.ERROR_MESSAGE);
447
            System.exit(2);
18 ilm 448
            // never reached since we're already dead
449
            return null;
450
        }
451
 
452
    }
453
 
454
    // *** instance
455
 
80 ilm 456
    private final boolean isMain;
18 ilm 457
    private final boolean inWebstart;
458
    private final boolean isServerless;
41 ilm 459
    private boolean isOnCloud;
94 ilm 460
    private boolean isPortable;
461
    private File portableDir = null;
142 ilm 462
    private Currency currency = null;
156 ilm 463
    private final ModuleManager moduleMngr = new ModuleManager();
18 ilm 464
 
144 ilm 465
    public ComptaPropsConfiguration(Properties props, final ProductInfo productInfo) {
466
        super(props, productInfo);
467
        this.isServerless = false;
468
        this.isMain = true;
469
        this.inWebstart = false;
470
    }
471
 
80 ilm 472
    // isMain=true also set up some VM wide settings
142 ilm 473
    public ComptaPropsConfiguration(Properties props, final boolean inWebstart, final boolean main) {
41 ilm 474
        super(props, productInfo);
80 ilm 475
        this.isMain = main;
18 ilm 476
        this.inWebstart = inWebstart;
94 ilm 477
        this.isPortable = Boolean.parseBoolean(this.getProperty("portable", "false"));
478
        String pDir = this.getProperty("portableDir", null);
479
        if (isPortable) {
480
            if (pDir == null) {
481
                System.out.println("Portable mode, using current directory");
482
                portableDir = new File(".");
483
            } else {
484
                System.out.println("Portable mode, using provided directory : " + pDir);
485
                portableDir = new File(pDir);
486
            }
487
            if (!portableDir.exists()) {
488
                System.out.println("Error: portable dir missing : " + portableDir);
489
                portableDir = new File(".");
490
            }
491
            System.out.println("Portable mode in : " + portableDir.getAbsolutePath());
492
            if (this.getProperty("portableDirMessage", "true").equalsIgnoreCase("true")) {
493
                if (!GraphicsEnvironment.isHeadless()) {
494
                    System.out.println("Add portableDirMessage=false in your " + PROPERTIES + " to prevent the popup message.");
495
                    JOptionPane.showMessageDialog(null, "Portable version :\n" + portableDir.getAbsolutePath());
496
                }
497
            }
498
        }
499
        if (isPortable) {
500
            this.setProperty("wd", new File(portableDir, "UserData").getAbsolutePath());
501
        } else {
502
            this.setProperty("wd", DesktopEnvironment.getDE().getDocumentsFolder().getAbsolutePath() + File.separator + this.getAppName());
503
        }
18 ilm 504
        if (this.getProperty("version.date") != null) {
505
            this.version = this.getProperty("version.date");
506
        }
41 ilm 507
 
508
        //
61 ilm 509
        String token = getToken();
41 ilm 510
        if (token != null) {
511
            this.isServerless = false;
512
            this.isOnCloud = true;
61 ilm 513
            if (this.getProperty("storage.server") == null) {
514
                InProgressFrame progress = new InProgressFrame();
515
                progress.show("Connexion sécurisée au cloud en cours");
516
                String result = NetUtils.getHTTPContent("https://cloud.openconcerto.org/getAuthInfo?token=" + token, false);
517
                if (result != null && !result.contains("ERROR")) {
518
                    Properties cProperty = new Properties();
519
                    try {
520
                        cProperty.loadFromXML(new StringInputStream(result));
521
                        setProperty("server.wan.only", "true");
522
                        setProperty("server.wan.port", "22");
523
                        // SSH
524
                        setProperty("server.wan.addr", cProperty.getProperty("ssh.server"));
525
                        setProperty("server.wan.user", cProperty.getProperty("ssh.login"));
526
                        setProperty("server.wan.password", cProperty.getProperty("ssh.pass"));
527
                        // DB
528
                        setProperty("server.ip", "127.0.0.1:5432");
529
                        setProperty("server.driver", "postgresql");
530
                        setProperty("server.login", cProperty.getProperty("db.login"));
531
                        setProperty("server.password", cProperty.getProperty("db.pass"));
532
                        setProperty("systemRoot", cProperty.getProperty("db.name"));
533
                        // Storage
534
                        props.put("storage.server", cProperty.getProperty("storage.server"));
65 ilm 535
 
61 ilm 536
                    } catch (Exception e) {
537
                        e.printStackTrace();
149 ilm 538
                        String s = ExceptionUtils.getStackTrace(e);
156 ilm 539
                        JOptionPane.showMessageDialog(new JFrame(),
540
                                "Impossible récupérer les informations de connexion\n" + s + "\ntoken: " + token + "\nr: " + result + "\nMerci de vérifier votre connexion internet.");
61 ilm 541
                        System.exit(1);
542
                    }
543
 
544
                } else if (result != null && result.contains("not paid")) {
545
                    JOptionPane.showMessageDialog(new JFrame(), "Compte Cloud non crédité");
41 ilm 546
                    System.exit(1);
61 ilm 547
                } else {
548
                    JOptionPane.showMessageDialog(new JFrame(), "Connexion impossible au Cloud");
549
                    System.exit(1);
41 ilm 550
                }
65 ilm 551
                progress.dispose();
41 ilm 552
            }
61 ilm 553
            StorageEngines.getInstance().addEngine(new CloudStorageEngine());
41 ilm 554
        } else {
132 ilm 555
            // FIXME
41 ilm 556
            // Local database
132 ilm 557
            {
142 ilm 558
                if (getProperty("server.login") == null) {
559
                    setProperty("server.login", "openconcerto");
560
                }
561
                if (getProperty("server.password") == null) {
562
                    setProperty("server.password", "openconcerto");
563
                }
132 ilm 564
            }
80 ilm 565
            this.setProperty("server.ip", getProperty("server.ip").replace(DATA_DIR_VAR, getDataDir().getPath()));
566
            final SQLSystem system = getSystem();
567
            this.isServerless = system == SQLSystem.H2 && system.getHostname(getServerIp()) == null;
18 ilm 568
        }
80 ilm 569
        if (this.isMain) {
570
            // ATTN this works because this is executed last (i.e. if you put this in a superclass
571
            // this won't work since e.g. app.name won't have its correct value)
93 ilm 572
            try {
573
                this.setupLogging("logs");
574
            } catch (Exception e) {
575
                System.err.println("ComptaPropsConfiguration() error in log setup : " + e.getMessage());
576
            }
80 ilm 577
            registerAccountingProvider();
578
            registerCellValueProvider();
579
        }
18 ilm 580
    }
581
 
67 ilm 582
    private void registerAccountingProvider() {
583
        SalesInvoiceAccountingRecordsProvider.register();
73 ilm 584
        SalesCreditAccountingRecordsProvider.register();
585
        SupplyOrderAccountingRecordsProvider.register();
67 ilm 586
    }
587
 
63 ilm 588
    private void registerCellValueProvider() {
589
        UserCreateInitialsValueProvider.register();
590
        UserModifyInitialsValueProvider.register();
591
        UserCurrentInitialsValueProvider.register();
592
        PrixUnitaireRemiseProvider.register();
83 ilm 593
        PrixUnitaireProvider.register();
594
        PrixUVProvider.register();
80 ilm 595
        TotalAcompteProvider.register();
144 ilm 596
        ArticleCodeClientProvider.register();
149 ilm 597
        ConditionsReglementDetailsProvider.register();
80 ilm 598
        FacturableValueProvider.register();
599
        TotalCommandeClientProvider.register();
600
        LabelAccountInvoiceProvider.register();
93 ilm 601
        DateBLProvider.register();
67 ilm 602
        AdresseRueClientValueProvider.register();
603
        AdresseVilleClientValueProvider.register();
604
        AdresseVilleCPClientValueProvider.register();
605
        AdresseVilleNomClientValueProvider.register();
606
        AdresseFullClientValueProvider.register();
607
        QteTotalProvider.register();
174 ilm 608
        QteTotalDocProvider.register();
132 ilm 609
        StockLocationProvider.register();
73 ilm 610
        RefClientValueProvider.register();
611
        ModeDeReglementDetailsProvider.register();
80 ilm 612
        FormatedGlobalQtyTotalProvider.register();
613
        MergedGlobalQtyTotalProvider.register();
83 ilm 614
        PaiementRemainedProvider.register();
149 ilm 615
        PaiementRemainedDevisProvider.register();
90 ilm 616
        RemiseProvider.register();
142 ilm 617
        DateProvider.register();
132 ilm 618
        RemiseTotalProvider.register();
619
        RecapFactureProvider.register();
620
        RestantAReglerProvider.register();
621
        SaledTotalNotDiscountedProvider.register();
174 ilm 622
        ArticleCodeFournisseurProvider.register();
63 ilm 623
    }
624
 
625
    @Override
626
    protected void initDS(SQLDataSource ds) {
627
        super.initDS(ds);
628
        ds.setInitialSize(3);
629
        ds.setMinIdle(2);
630
        ds.setMaxActive(4);
631
    }
632
 
61 ilm 633
    public String getToken() {
634
        return getProperty("token");
635
    }
636
 
18 ilm 637
    public final boolean isServerless() {
638
        return this.isServerless;
639
    }
640
 
41 ilm 641
    public final boolean isOnCloud() {
642
        return this.isOnCloud;
643
    }
644
 
18 ilm 645
    public final String getVersion() {
646
        return this.version;
647
    }
648
 
649
    @Override
142 ilm 650
    public String getAppVariant() {
18 ilm 651
        if (inWebstart())
25 ilm 652
            // so we don't remove files of a normal GestionNX
142 ilm 653
            return super.getAppVariant() + "-webstart";
18 ilm 654
        else
142 ilm 655
            return super.getAppVariant();
18 ilm 656
    }
657
 
658
    @Override
142 ilm 659
    protected BaseDirs createBaseDirs() {
660
        if (isPortable()) {
661
            return BaseDirs.createPortable(getPortableDir(), this.getProductInfo(), this.getAppVariant());
662
        } else {
663
            return super.createBaseDirs();
664
        }
665
    }
666
 
667
    @Override
668
    protected final File getOldConfDir() {
94 ilm 669
        if (isPortable) {
670
            return getWD();
671
        } else {
142 ilm 672
            return Gestion.MAC_OS_X ? new File(System.getProperty("user.home") + "/Library/Application Support/" + getAppID()) : super.getOldConfDir();
94 ilm 673
        }
18 ilm 674
    }
675
 
94 ilm 676
    public boolean isPortable() {
677
        return isPortable;
678
    }
679
 
680
    public File getPortableDir() {
681
        return portableDir;
682
    }
683
 
18 ilm 684
    private boolean inWebstart() {
685
        return this.inWebstart;
686
    }
687
 
142 ilm 688
    @Deprecated
689
    public File getOldDataDir() {
690
        return new File(this.getOldConfDir(), "DBData");
691
    }
692
 
18 ilm 693
    public File getDataDir() {
142 ilm 694
        return new File(this.getBaseDirs().getAppDataFolder(), "DBData");
18 ilm 695
    }
696
 
83 ilm 697
    private final void createDB(final DBSystemRoot sysRoot) {
18 ilm 698
        if (!this.isServerless())
699
            return;
700
        try {
701
            // H2 create the database on connection
83 ilm 702
            // don't create if root explicitly excluded (e.g. map no roots just to quickly test
703
            // connection)
704
            if (sysRoot.shouldMap(getRootName()) && !sysRoot.contains(getRootName())) {
705
                Log.get().warning("Creating DB");
19 ilm 706
                String createScript = null;
707
                try {
708
                    createScript = this.getResource("/webstart/create.sql");
709
                } catch (Exception e) {
710
                    e.printStackTrace();
711
                }
18 ilm 712
                if (createScript == null)
713
                    throw new IllegalStateException("Couldn't find database creation script");
714
                final SQLDataSource ds = sysRoot.getDataSource();
83 ilm 715
                ds.execute("RUNSCRIPT from '" + createScript + "' CHARSET 'UTF-8' ;");
716
                sysRoot.refetch();
717
                this.setupSystemRoot(sysRoot);
18 ilm 718
            }
83 ilm 719
        } catch (RuntimeException e) {
720
            throw e;
721
        } catch (Exception e) {
722
            throw new IllegalStateException("Couldn't create database", e);
18 ilm 723
        }
724
    }
725
 
726
    @Override
727
    protected DBSystemRoot createSystemRoot() {
83 ilm 728
        final DBSystemRoot res = super.createSystemRoot();
729
        // Don't create a separate server for createDB() as on normal databases just setting up a
730
        // data source can take 2 seconds (e.g. validateConnectionFactory()). And this is for every
731
        // boot.
732
        this.createDB(res);
733
        return res;
18 ilm 734
    }
735
 
736
    @Override
737
    public String getDefaultBase() {
738
        return super.getDefaultBase();
739
 
740
    }
741
 
742
    @Override
743
    protected SQLElementDirectory createDirectory() {
744
        final SQLElementDirectory dir = super.createDirectory();
156 ilm 745
        final DBRoot root = getRoot();
746
        dir.addSQLElement(new AdresseCommonSQLElement(root));
747
        dir.addSQLElement(new ExerciceCommonSQLElement(root));
748
        dir.addSQLElement(DeviseSQLElement.class, root);
749
        dir.addSQLElement(TypeModeleSQLElement.class, root);
750
        dir.addSQLElement(new SocieteCommonSQLElement(root));
132 ilm 751
 
752
        // DSN
156 ilm 753
        dir.addSQLElement(CaisseCotisationRenseignentSQLElement.class, root);
754
        dir.addSQLElement(CodeBaseAssujettieSQLElement.class, root);
755
        dir.addSQLElement(ContratModaliteTempsSQLElement.class, root);
756
        dir.addSQLElement(CodeCaisseTypeRubriqueSQLElement.class, root);
757
        dir.addSQLElement(CodeTypeRubriqueBrutSQLElement.class, root);
758
        dir.addSQLElement(MotifArretTravailSQLElement.class, root);
759
        dir.addSQLElement(ContratDispositifPolitiqueSQLElement.class, root);
760
        dir.addSQLElement(ContratDetacheExpatrieSQLElement.class, root);
761
        dir.addSQLElement(ContratRegimeMaladieSQLElement.class, root);
762
        dir.addSQLElement(ContratMotifRecoursSQLElement.class, root);
763
        dir.addSQLElement(ContratRegimeVieillesseSQLElement.class, root);
764
        dir.addSQLElement(MotifFinContratSQLElement.class, root);
765
        dir.addSQLElement(MotifRepriseArretTravailSQLElement.class, root);
766
        dir.addSQLElement(TypePreavisSQLElement.class, root);
767
        dir.addSQLElement(DSNNatureSQLElement.class, root);
768
        dir.addSQLElement(TypeTauxPasSQLElement.class, root);
132 ilm 769
 
142 ilm 770
        // ECO
156 ilm 771
        dir.addSQLElement(FamilleEcoContributionSQLElement.class, root);
772
        dir.addSQLElement(EcoContributionSQLElement.class, root);
142 ilm 773
 
156 ilm 774
        dir.addSQLElement(new RubriqueCotisationSQLElement(root));
775
        dir.addSQLElement(new RubriqueCommSQLElement(root));
776
        dir.addSQLElement(new RubriqueNetSQLElement(root));
777
        dir.addSQLElement(new RubriqueBrutSQLElement(root));
778
 
779
        dir.addSQLElement(new CaisseCotisationSQLElement(root));
780
        dir.addSQLElement(new ProfilPayeSQLElement(root));
781
        dir.addSQLElement(new ProfilPayeElementSQLElement(root));
782
        dir.addSQLElement(new PeriodeValiditeSQLElement(root));
783
 
784
        dir.addSQLElement(new TypeRubriqueBrutSQLElement(root));
785
        dir.addSQLElement(new TypeRubriqueNetSQLElement(root));
786
 
787
        dir.addSQLElement(AyantDroitTypeSQLElement.class, root);
788
        dir.addSQLElement(TypeComposantBaseAssujettieSQLElement.class, root);
789
        dir.addSQLElement(CaisseModePaiementSQLElement.class, root);
790
        dir.addSQLElement(CodeCotisationIndividuelleSQLElement.class, root);
791
        dir.addSQLElement(CodeCotisationEtablissementSQLElement.class, root);
792
        dir.addSQLElement(CodePenibiliteSQLElement.class, root);
793
        dir.addSQLElement(new ImpressionRubriqueSQLElement(root));
794
 
795
        dir.addSQLElement(new VariablePayeSQLElement(root));
796
 
18 ilm 797
        return dir;
798
    }
799
 
800
    private void setSocieteDirectory() {
94 ilm 801
        try {
149 ilm 802
            // Check 1.5.3 updated
803
            if (!this.getRootSociete().getTable("SAISIE_VENTE_FACTURE").contains("T_ACOMPTE")) {
804
                throw new DBStructureItemNotFound("Base de données non à jour");
805
            }
156 ilm 806
            // Check 1.6 updated
807
            if (!this.getRootSociete().contains("ETAT_STOCK")) {
808
                throw new DBStructureItemNotFound("Base de données non à jour");
809
            }
94 ilm 810
            SQLElementDirectory dir = this.getDirectory();
93 ilm 811
 
142 ilm 812
            dir.addSQLElement(AttachmentSQLElement.class);
813
 
174 ilm 814
            dir.addSQLElement(CustomerProductQtyPriceSQLElement.class);
156 ilm 815
            dir.addSQLElement(EtatStockSQLElement.class);
816
            dir.addSQLElement(EtatStockItemSQLElement.class);
94 ilm 817
            dir.addSQLElement(ArticleTarifSQLElement.class);
156 ilm 818
            dir.addSQLElement(CoutRevientSQLElement.class);
94 ilm 819
            dir.addSQLElement(ReliquatBRSQLElement.class);
820
            dir.addSQLElement(ReliquatSQLElement.class);
821
            dir.addSQLElement(ProductQtyPriceSQLElement.class);
822
            dir.addSQLElement(ProductItemSQLElement.class);
156 ilm 823
            dir.addSQLElement(CategorieComptableSQLElement.class);
824
            dir.addSQLElement(ArticleCatComptableSQLElement.class);
825
            dir.addSQLElement(ArticleFournisseurSecondaireSQLElement.class);
826
            dir.addSQLElement(SupplierPriceListSQLElement.class);
827
            dir.addSQLElement(FraisDocumentSQLElement.class);
94 ilm 828
            dir.addSQLElement(ArticleDesignationSQLElement.class);
829
            dir.addSQLElement(BanqueSQLElement.class);
830
            dir.addSQLElement(ClientDepartementSQLElement.class);
132 ilm 831
            dir.addSQLElement(CoefficientPrimeSQLElement.class);
94 ilm 832
            dir.addSQLElement(ContactFournisseurSQLElement.class);
833
            dir.addSQLElement(ContactAdministratifSQLElement.class);
174 ilm 834
            dir.addSQLElement(ContactSalarieSQLElement.class);
94 ilm 835
            dir.addSQLElement(new TitrePersonnelSQLElement());
836
            dir.addSQLElement(new ContactSQLElement());
837
            dir.addSQLElement(new SaisieKmItemSQLElement());
838
            dir.addSQLElement(new EcritureSQLElement());
18 ilm 839
 
156 ilm 840
            dir.addSQLElement(new SharedSQLElement(this, "EMPLOYEUR_MULTIPLE", "humanresources.multipleEmployer"));
94 ilm 841
            dir.addSQLElement(PosteAnalytiqueSQLElement.class);
156 ilm 842
            dir.addSQLElement(new SharedSQLElement(this, "CLASSE_COMPTE", "finance.accounting.accountClass"));
18 ilm 843
 
94 ilm 844
            dir.addSQLElement(CaisseTicketSQLElement.class);
18 ilm 845
 
94 ilm 846
            dir.addSQLElement(ModeleSQLElement.class);
21 ilm 847
 
94 ilm 848
            dir.addSQLElement(new AdresseSQLElement());
144 ilm 849
            dir.addSQLElement(ArticleCodeClientSQLElement.class);
94 ilm 850
            dir.addSQLElement(ReferenceArticleSQLElement.class);
851
            dir.addSQLElement(ArticleFournisseurSQLElement.class);
852
            dir.addSQLElement(FamilleArticleFounisseurSQLElement.class);
18 ilm 853
 
94 ilm 854
            dir.addSQLElement(new AssociationCompteAnalytiqueSQLElement());
855
            dir.addSQLElement(new AvoirClientSQLElement());
856
            dir.addSQLElement(new AvoirClientElementSQLElement());
857
            dir.addSQLElement(AvoirFournisseurSQLElement.class);
858
            dir.addSQLElement(new AcompteSQLElement());
18 ilm 859
 
94 ilm 860
            dir.addSQLElement(new AxeAnalytiqueSQLElement());
18 ilm 861
 
94 ilm 862
            dir.addSQLElement(new BonDeLivraisonItemSQLElement());
863
            dir.addSQLElement(new BonDeLivraisonSQLElement());
864
            dir.addSQLElement(new TransferShipmentSQLElement());
73 ilm 865
 
94 ilm 866
            dir.addSQLElement(new BonReceptionElementSQLElement());
867
            dir.addSQLElement(new BonReceptionSQLElement());
868
            dir.addSQLElement(new TransferReceiptSQLElement());
869
            dir.addSQLElement(new ChequeAEncaisserSQLElement());
156 ilm 870
            dir.addSQLElement(DepotChequeSQLElement.class);
871
            dir.addSQLElement(DepotChequeElementSQLElement.class);
94 ilm 872
            dir.addSQLElement(new ChequeAvoirClientSQLElement());
873
            dir.addSQLElement(new ChequeFournisseurSQLElement());
874
                dir.addSQLElement(new CustomerCategorySQLElement());
875
                dir.addSQLElement(new CustomerSQLElement());
142 ilm 876
                dir.addSQLElement(new CompteClientTransactionSQLELement());
94 ilm 877
            dir.addSQLElement(new CourrierClientSQLElement());
18 ilm 878
 
94 ilm 879
            dir.addSQLElement(new ClassementConventionnelSQLElement());
880
            dir.addSQLElement(CodeFournisseurSQLElement.class);
881
            dir.addSQLElement(new CommandeSQLElement());
882
            dir.addSQLElement(new TransferSupplierOrderSQLElement());
883
            dir.addSQLElement(new CommandeElementSQLElement());
884
            dir.addSQLElement(new TransferCustomerOrderSQLElement());
885
            dir.addSQLElement(new CommandeClientSQLElement());
144 ilm 886
            dir.addSQLElement(FacturationCommandeClientSQLElement.class);
94 ilm 887
            dir.addSQLElement(new CommandeClientElementSQLElement());
18 ilm 888
 
144 ilm 889
            dir.addSQLElement(DemandeAchatItemSQLElement.class);
890
            dir.addSQLElement(EtatDemandeAchatItemSQLElement.class);
891
            dir.addSQLElement(EtatDemandePrixSQLElement.class);
892
            dir.addSQLElement(DemandePrixSQLElement.class);
893
            dir.addSQLElement(DemandePrixItemSQLElement.class);
894
            dir.addSQLElement(FabricantSQLElement.class);
895
            dir.addSQLElement(ChiffrageCommandeClientSQLElement.class);
896
 
156 ilm 897
            dir.addSQLElement(new CommercialSQLElement());
898
 
94 ilm 899
            dir.addSQLElement(ObjectifSQLElement.class);
900
            dir.addSQLElement(new ComptePCESQLElement());
901
            dir.addSQLElement(new ComptePCGSQLElement());
18 ilm 902
 
94 ilm 903
            dir.addSQLElement(new ContratSalarieSQLElement());
142 ilm 904
            dir.addSQLElement(ContratPrevoyanceSQLElement.class);
905
            dir.addSQLElement(ContratPrevoyanceRubriqueSQLElement.class);
906
            dir.addSQLElement(ContratPrevoyanceRubriqueNetSQLElement.class);
907
            dir.addSQLElement(ContratPrevoyanceSalarieSQLElement.class);
908
            dir.addSQLElement(AyantDroitSQLElement.class);
909
            dir.addSQLElement(AyantDroitContratPrevSQLElement.class);
18 ilm 910
 
94 ilm 911
            dir.addSQLElement(new CodeRegimeSQLElement());
912
            dir.addSQLElement(new CodeEmploiSQLElement());
913
            dir.addSQLElement(new CodeContratTravailSQLElement());
914
            dir.addSQLElement(new CodeDroitContratSQLElement());
915
            dir.addSQLElement(new CodeCaractActiviteSQLElement());
18 ilm 916
 
94 ilm 917
            dir.addSQLElement(new CodeStatutCategorielSQLElement());
918
            dir.addSQLElement(CodeStatutCategorielConventionnelSQLElement.class);
919
            dir.addSQLElement(new CodeStatutProfSQLElement());
142 ilm 920
            dir.addSQLElement(CodePenibiliteContratSQLElement.class);
921
 
156 ilm 922
            dir.addSQLElement(PasSQLElement.class);
923
 
94 ilm 924
            dir.addSQLElement(new CumulsCongesSQLElement());
925
            dir.addSQLElement(new CumulsPayeSQLElement());
18 ilm 926
 
94 ilm 927
            dir.addSQLElement(new DepartementSQLElement());
156 ilm 928
            dir.addSQLElement(new DevisSQLElement());
94 ilm 929
            dir.addSQLElement(new TransferQuoteSQLElement());
930
            dir.addSQLElement(new DevisItemSQLElement());
18 ilm 931
 
94 ilm 932
            dir.addSQLElement(new EcheanceClientSQLElement());
933
            dir.addSQLElement(new EcheanceFournisseurSQLElement());
934
            dir.addSQLElement(EncaisserMontantSQLElement.class);
935
            dir.addSQLElement(EncaisserMontantElementSQLElement.class);
936
            dir.addSQLElement(EcoTaxeSQLElement.class);
18 ilm 937
 
94 ilm 938
            dir.addSQLElement(new EtatCivilSQLElement());
939
            dir.addSQLElement(new EtatDevisSQLElement());
18 ilm 940
 
94 ilm 941
            dir.addSQLElement(new FamilleArticleSQLElement());
942
            dir.addSQLElement(new FichePayeSQLElement());
943
            dir.addSQLElement(new FichePayeElementSQLElement());
18 ilm 944
 
94 ilm 945
            dir.addSQLElement(new FournisseurSQLElement());
18 ilm 946
 
94 ilm 947
            dir.addSQLElement(new CodeIdccSQLElement());
18 ilm 948
 
94 ilm 949
            dir.addSQLElement(new InfosSalariePayeSQLElement());
18 ilm 950
 
94 ilm 951
            dir.addSQLElement(new JournalSQLElement());
18 ilm 952
 
94 ilm 953
            dir.addSQLElement(LangueSQLElement.class);
19 ilm 954
 
94 ilm 955
            dir.addSQLElement(new MetriqueSQLElement());
956
            dir.addSQLElement(new ModeleCourrierClientSQLElement());
957
            dir.addSQLElement(new ModeVenteArticleSQLElement());
958
            dir.addSQLElement(new ModeDeReglementSQLElement());
959
            dir.addSQLElement(new ModeReglementPayeSQLElement());
960
            dir.addSQLElement(new MoisSQLElement());
961
            dir.addSQLElement(new MouvementSQLElement());
962
            dir.addSQLElement(new MouvementStockSQLElement());
156 ilm 963
            dir.addSQLElement(DepotStockSQLElement.class);
18 ilm 964
 
94 ilm 965
            dir.addSQLElement(new NatureCompteSQLElement());
18 ilm 966
 
94 ilm 967
            dir.addSQLElement(new NumerotationAutoSQLElement());
18 ilm 968
 
94 ilm 969
            dir.addSQLElement(new PaysSQLElement());
18 ilm 970
 
94 ilm 971
            dir.addSQLElement(new PieceSQLElement());
18 ilm 972
 
94 ilm 973
            dir.addSQLElement(ReferenceClientSQLElement.class);
974
            dir.addSQLElement(new RegimeBaseSQLElement());
975
            dir.addSQLElement(new RelanceSQLElement());
976
            dir.addSQLElement(new ReglementPayeSQLElement());
977
            dir.addSQLElement(new ReglerMontantSQLElement());
978
            dir.addSQLElement(ReglerMontantElementSQLElement.class);
979
            dir.addSQLElement(RepartitionAnalytiqueSQLElement.class);
18 ilm 980
 
94 ilm 981
            dir.addSQLElement(new SaisieAchatSQLElement());
982
            dir.addSQLElement(new FactureFournisseurSQLElement());
983
            dir.addSQLElement(new FactureFournisseurElementSQLElement());
984
            dir.addSQLElement(new TransferPurchaseSQLElement());
985
            dir.addSQLElement(new SaisieKmSQLElement());
986
            dir.addSQLElement(new SaisieVenteComptoirSQLElement());
987
            dir.addSQLElement(new SaisieVenteFactureSQLElement());
988
            dir.addSQLElement(new TransferInvoiceSQLElement());
989
            // at the end since it specifies action which initialize foreign keys
990
            dir.addSQLElement(AssociationAnalytiqueSQLElement.class);
156 ilm 991
                dir.addSQLElement(new SaisieVenteFactureItemSQLElement(this));
18 ilm 992
 
94 ilm 993
            dir.addSQLElement(SituationFamilialeSQLElement.class);
994
            dir.addSQLElement(new StockSQLElement());
995
            dir.addSQLElement(new StyleSQLElement());
18 ilm 996
 
94 ilm 997
            dir.addSQLElement(new SalarieSQLElement());
18 ilm 998
 
94 ilm 999
            dir.addSQLElement(TarifSQLElement.class);
1000
            dir.addSQLElement(new TaxeSQLElement());
142 ilm 1001
            dir.addSQLElement(TaxeComplementaireSQLElement.class);
94 ilm 1002
            dir.addSQLElement(TicketCaisseSQLElement.class);
144 ilm 1003
            dir.addSQLElement(ClôtureCaisseSQLElement.class);
1004
            dir.addSQLElement(CaisseJournalSQLElement.class);
18 ilm 1005
 
94 ilm 1006
            dir.addSQLElement(new TypeComptePCGSQLElement());
1007
            dir.addSQLElement(new TypeLettreRelanceSQLElement());
1008
            dir.addSQLElement(new TypeReglementSQLElement());
151 ilm 1009
            dir.addSQLElement(new SDDMessageSQLElement(this));
1010
            dir.addSQLElement(new SEPAMandateSQLElement(this));
18 ilm 1011
 
94 ilm 1012
            dir.addSQLElement(new VariableSalarieSQLElement());
1013
            dir.addSQLElement(UniteVenteArticleSQLElement.class);
73 ilm 1014
 
94 ilm 1015
            dir.addSQLElement(CalendarItemSQLElement.class);
1016
            dir.addSQLElement(CalendarItemGroupSQLElement.class);
1017
            dir.addSQLElement(DeviseHistoriqueSQLElement.class);
174 ilm 1018
            dir.addSQLElement(EmailTemplateSQLElement.class);
94 ilm 1019
 
1020
            if (getRootSociete().contains("FWK_LIST_PREFS")) {
1021
                dir.addSQLElement(new FWKListPrefs(getRootSociete()));
1022
            }
1023
            if (getRootSociete().contains("FWK_SESSION_STATE")) {
1024
                dir.addSQLElement(new FWKSessionState(getRootSociete()));
1025
            }
1026
 
1027
            // check that all codes are unique
1028
            Collection<SQLElement> elements = dir.getElements();
1029
            String s = "";
1030
            for (SQLElement sqlElement : elements) {
1031
                try {
1032
                    SQLElement e = dir.getElementForCode(sqlElement.getCode());
1033
                    if (e != sqlElement) {
1034
                        s += "Error while retrieving element from code " + sqlElement.getCode() + "\n";
1035
                    }
1036
                } catch (Throwable e) {
1037
                    s += "Error while retrieving element from code " + sqlElement.getCode() + " :\n " + e.getMessage() + "\n";
57 ilm 1038
                }
1039
            }
94 ilm 1040
            if (!s.trim().isEmpty()) {
1041
                ExceptionHandler.handle(s);
1042
            }
1043
        } catch (DBStructureItemNotFound e) {
144 ilm 1044
            if (!GraphicsEnvironment.isHeadless()) {
1045
 
149 ilm 1046
                if (this.getServer().getSQLSystem().equals(SQLSystem.H2)) {
1047
                    JOptionPane.showMessageDialog(null,
1048
                            "Une table ou un champ est manquant dans la base de données.\nMettez à jour la base de données si vous venez de changer de version d'Openconcerto.");
1049
 
1050
                    final JFrame f = new JFrame("Mise à jour de la base de données");
1051
                    f.setContentPane(new InstallationPanel(null));
1052
                    f.pack();
1053
                    f.setVisible(true);
1054
                    f.setLocationRelativeTo(null);
1055
                    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
1056
 
1057
                } else {
1058
                    JOptionPane.showMessageDialog(null,
1059
                            "Une table ou un champ est manquant dans la base de données. Mettez à jour votre base de données via l'outil de configuration si vous venez de changer de version d'Openconcerto.");
1060
 
1061
                }
1062
 
144 ilm 1063
            }
94 ilm 1064
            throw e;
57 ilm 1065
        }
18 ilm 1066
    }
1067
 
1068
    private void setSocieteSQLInjector() {
1069
        final DBRoot rootSociete = getRootSociete();
73 ilm 1070
        setSocieteSQLInjector(rootSociete);
1071
 
1072
    }
1073
 
1074
    public static void setSocieteSQLInjector(final DBRoot rootSociete) {
65 ilm 1075
        new AchatAvoirSQLInjector(rootSociete);
174 ilm 1076
        new CommandeFactureEltSQLInjector(rootSociete);
19 ilm 1077
        new ArticleCommandeEltSQLInjector(rootSociete);
1078
        new CommandeCliCommandeSQLInjector(rootSociete);
18 ilm 1079
        new FactureAvoirSQLInjector(rootSociete);
19 ilm 1080
        new FactureBonSQLInjector(rootSociete);
1081
        new FactureCommandeSQLInjector(rootSociete);
18 ilm 1082
        new DevisFactureSQLInjector(rootSociete);
1083
        new DevisCommandeSQLInjector(rootSociete);
19 ilm 1084
        new DevisCommandeFournisseurSQLInjector(rootSociete);
156 ilm 1085
        new DevisBlEltSQLInjector(rootSociete);
1086
        new DevisBlSQLInjector(rootSociete);
18 ilm 1087
        new CommandeBlEltSQLInjector(rootSociete);
156 ilm 1088
        new CommandeBrEltSQLInjector(rootSociete);
18 ilm 1089
        new CommandeBlSQLInjector(rootSociete);
1090
        new BonFactureSQLInjector(rootSociete);
142 ilm 1091
        new BonFactureEltSQLInjector(rootSociete);
18 ilm 1092
        new CommandeFactureClientSQLInjector(rootSociete);
1093
        new CommandeBrSQLInjector(rootSociete);
94 ilm 1094
        new BonReceptionFactureFournisseurSQLInjector(rootSociete);
18 ilm 1095
        new CommandeFactureAchatSQLInjector(rootSociete);
174 ilm 1096
        new CommandeFactureFournisseurSQLInjector(rootSociete);
18 ilm 1097
        new EcheanceEncaisseSQLInjector(rootSociete);
80 ilm 1098
        new EcheanceRegleSQLInjector(rootSociete);
18 ilm 1099
        new BrFactureAchatSQLInjector(rootSociete);
1100
        new DevisEltFactureEltSQLInjector(rootSociete);
144 ilm 1101
 
1102
        if (rootSociete.contains("DEMANDE_PRIX_ACHAT_ELEMENT")) {
1103
            new DmdAchatDmdPrixEltSQLInjector(rootSociete);
156 ilm 1104
            new DmdPrixCmdSQLInjector(rootSociete);
144 ilm 1105
        }
1106
 
18 ilm 1107
    }
1108
 
1109
 
1110
    private void setSocieteShowAs() {
19 ilm 1111
        final ShowAs showAs = this.getShowAs();
94 ilm 1112
        final DBRoot root = this.getRootSociete();
18 ilm 1113
        showAs.setRoot(getRootSociete());
83 ilm 1114
 
94 ilm 1115
        List<String> listAdrShowAs = SQLRow.toList("RUE,CODE_POSTAL,VILLE");
1116
        if (root.contains("ADRESSE") && root.getTable("ADRESSE").contains("DISTRICT")) {
1117
            listAdrShowAs = SQLRow.toList("RUE,DISTRICT,DEPARTEMENT,CODE_POSTAL,VILLE");
1118
        }
1119
        showAs.show("ADRESSE", listAdrShowAs);
80 ilm 1120
 
18 ilm 1121
        showAs.show("AXE_ANALYTIQUE", "NOM");
1122
 
83 ilm 1123
        List<String> lEcr = new ArrayList<String>();
1124
 
1125
        lEcr.add("ID_MOUVEMENT");
1126
        lEcr.add("ID_JOURNAL");
1127
        lEcr.add("ID_COMPTE_PCE");
1128
        lEcr.add("DATE");
1129
 
1130
        showAs.show(root.getTable("ASSOCIATION_ANALYTIQUE").getField("ID_ECRITURE"), lEcr);
1131
 
18 ilm 1132
        showAs.show("CHEQUE_A_ENCAISSER", "MONTANT", "ID_CLIENT");
142 ilm 1133
 
41 ilm 1134
                if (getRootSociete().getTable("CLIENT").getFieldsName().contains("LOCALISATION")) {
1135
                    showAs.show("CLIENT", "NOM", "LOCALISATION");
1136
                } else {
174 ilm 1137
                    SQLPreferences prefs = SQLPreferences.getMemCached(root);
142 ilm 1138
                    if (prefs.getBoolean(GestionClientPreferencePanel.DISPLAY_CLIENT_PCE, false)) {
1139
                        showAs.show("CLIENT", "ID_PAYS", "GROUPE", "NOM", "ID_COMPTE_PCE");
1140
                    } else {
1141
                        showAs.show("CLIENT", "ID_PAYS", "GROUPE", "NOM");
1142
                    }
41 ilm 1143
                }
18 ilm 1144
 
83 ilm 1145
        showAs.show(BanqueSQLElement.TABLENAME, "NOM");
1146
 
18 ilm 1147
        showAs.show("CLASSEMENT_CONVENTIONNEL", "NIVEAU", "COEFF");
1148
        showAs.show("CODE_EMPLOI", SQLRow.toList("CODE,NOM"));
1149
        showAs.show("CODE_CONTRAT_TRAVAIL", SQLRow.toList("CODE,NOM"));
1150
        showAs.show("CODE_DROIT_CONTRAT", SQLRow.toList("CODE,NOM"));
1151
        showAs.show("CODE_CARACT_ACTIVITE", SQLRow.toList("CODE,NOM"));
1152
        showAs.show("CODE_STATUT_PROF", SQLRow.toList("CODE,NOM"));
1153
        showAs.show("CODE_STATUT_CATEGORIEL", SQLRow.toList("CODE,NOM"));
1154
        showAs.show("CODE_REGIME", SQLRow.toList("CODE,NOM"));
156 ilm 1155
 
149 ilm 1156
        showAs.show("COMMANDE", "NUMERO", "DATE", "DATE_RECEPTION_DEMANDEE", "NOM", "ID_FOURNISSEUR");
156 ilm 1157
        if (root.getTable("COMMANDE_CLIENT").contains("ID_AFFAIRE")) {
151 ilm 1158
            showAs.show("COMMANDE_CLIENT", "NUMERO", "DATE", "ID_CLIENT", "ID_AFFAIRE", "NOM", "T_HT");
144 ilm 1159
        } else {
156 ilm 1160
            showAs.show("COMMANDE_CLIENT", "NUMERO", "ID_CLIENT", "DATE", "NOM", "T_HT");
144 ilm 1161
        }
156 ilm 1162
 
18 ilm 1163
        showAs.show("COMPTE_PCE", "NUMERO", "NOM");
1164
        showAs.show("COMPTE_PCG", "NUMERO", "NOM");
1165
        showAs.show("CONTACT", "NOM");
1166
        showAs.show("CONTRAT_SALARIE", "NATURE");
1167
 
41 ilm 1168
        List<String> listFieldDevisElt = new ArrayList<String>();
1169
        listFieldDevisElt.add("NUMERO");
1170
        listFieldDevisElt.add("DATE");
1171
        listFieldDevisElt.add("ID_CLIENT");
93 ilm 1172
 
1173
        listFieldDevisElt.add("ID_ETAT_DEVIS");
41 ilm 1174
        showAs.showField("DEVIS_ELEMENT.ID_DEVIS", listFieldDevisElt);
1175
 
18 ilm 1176
        showAs.show("DEPARTEMENT", "NUMERO", "NOM");
1177
 
1178
        showAs.show("ECRITURE", SQLRow.toList("NOM,DATE,ID_COMPTE_PCE,DEBIT,CREDIT"));
1179
        showAs.show("ECHEANCE_CLIENT", SQLRow.toList("ID_CLIENT,ID_MOUVEMENT"));
83 ilm 1180
        final List<String> lEchFact = new ArrayList<String>();
1181
        lEchFact.add("NUMERO");
1182
        lEchFact.add("DATE");
174 ilm 1183
        lEchFact.add("ID_MODE_REGLEMENT");
149 ilm 1184
        lEchFact.add("ID_COMMERCIAL");
83 ilm 1185
        SQLTable tableEch = root.getTable("ECHEANCE_CLIENT");
1186
        showAs.show(tableEch.getField("ID_SAISIE_VENTE_FACTURE"), lEchFact);
18 ilm 1187
 
1188
        showAs.show("ECHEANCE_FOURNISSEUR", SQLRow.toList("ID_FOURNISSEUR,ID_MOUVEMENT"));
174 ilm 1189
        showAs.show("FICHE_PAYE", SQLRow.toList("ID_MOIS,ANNEE,ID_PROFIL_PAYE"));
1190
 
19 ilm 1191
        showAs.show("FOURNISSEUR", "NOM");
18 ilm 1192
 
1193
        showAs.show("IDCC", "NOM");
1194
 
1195
        showAs.show("JOURNAL", "NOM");
1196
        showAs.show("MOIS", "NOM");
1197
        showAs.show("MOUVEMENT", "NUMERO", "ID_PIECE");
1198
        showAs.show("MODE_VENTE_ARTICLE", "NOM");
1199
        showAs.show("MODE_REGLEMENT", "ID_TYPE_REGLEMENT", "AJOURS");
1200
        showAs.show("MODE_REGLEMENT_PAYE", "NOM");
1201
        showAs.show("MODELE_COURRIER_CLIENT", "NOM", "CONTENU");
1202
 
1203
        showAs.show("NATURE_COMPTE", "NOM");
93 ilm 1204
        showAs.show("POSTE_ANALYTIQUE", "NOM", "ID_AXE_ANALYTIQUE");
18 ilm 1205
        showAs.show("PAYS", "CODE", "NOM");
1206
        showAs.show("PIECE", "ID", "NOM");
1207
 
19 ilm 1208
        final SQLElementDirectory directory = this.getDirectory();
18 ilm 1209
        showAs.show("REPARTITION_ANALYTIQUE", "NOM");
1210
        showAs.show("REGIME_BASE", "ID_CODE_REGIME_BASE");
1211
        showAs.show("REGLEMENT_PAYE", "NOM_BANQUE", "RIB");
1212
 
1213
        List<String> listFieldModReglMontant = new ArrayList<String>();
1214
        listFieldModReglMontant.add("ID_TYPE_REGLEMENT");
1215
 
1216
        showAs.showField("REGLER_MONTANT.ID_MODE_REGLEMENT", listFieldModReglMontant);
1217
        showAs.showField("ENCAISSER_MONTANT.ID_MODE_REGLEMENT", listFieldModReglMontant);
1218
 
1219
        List<String> listFieldFactureElt = new ArrayList<String>();
1220
        listFieldFactureElt.add("NUMERO");
1221
        listFieldFactureElt.add("DATE");
149 ilm 1222
        listFieldFactureElt.add("ID_COMMERCIAL");
18 ilm 1223
        listFieldFactureElt.add("ID_CLIENT");
1224
        showAs.showField("SAISIE_VENTE_FACTURE_ELEMENT.ID_SAISIE_VENTE_FACTURE", listFieldFactureElt);
1225
 
1226
        showAs.show("SALARIE", SQLRow.toList("CODE,NOM,PRENOM"));
1227
 
1228
        showAs.show("SITUATION_FAMILIALE", "NOM");
156 ilm 1229
        if (root.getTable("STOCK").contains("ID_ARTICLE")) {
1230
            List<String> listFieldArtElt = new ArrayList<String>();
1231
            listFieldArtElt.add("CODE");
1232
            listFieldArtElt.add("NOM");
1233
            listFieldArtElt.add("ID_FAMILLE_ARTICLE");
1234
            showAs.showField("STOCK.ID_ARTICLE", listFieldArtElt);
1235
        }
18 ilm 1236
        showAs.show("STYLE", "NOM");
1237
 
1238
        showAs.show("TAXE", "TAUX");
1239
 
1240
        showAs.show(directory.getElement("TITRE_PERSONNEL").getTable(), asList("NOM"));
1241
 
1242
        showAs.show("TYPE_COMPTE_PCG", "NOM");
1243
        showAs.show("TYPE_LETTRE_RELANCE", "NOM");
1244
        showAs.show("TYPE_REGLEMENT", "NOM");
1245
 
1246
    }
1247
 
80 ilm 1248
    public String setUpSocieteStructure(int base) {
18 ilm 1249
        setRowSociete(base);
1250
 
1251
        // find customer
1252
        String customerName = "openconcerto";
80 ilm 1253
        final String dbMD = getRootSociete().getMetadata("CUSTOMER");
18 ilm 1254
        if (dbMD != null && !dbMD.equals(customerName))
1255
            throw new IllegalStateException("customer is '" + customerName + "' but db says '" + dbMD + "'");
80 ilm 1256
        return customerName;
1257
    }
1258
 
93 ilm 1259
    @Override
80 ilm 1260
    public void setUpSocieteDataBaseConnexion(int base) {
1261
        final String customerName = setUpSocieteStructure(base);
1262
        final DBRoot rootSociete = this.getRootSociete();
174 ilm 1263
 
1264
        try {
1265
            // create table if necessary
1266
            SQLPreferences.getPrefTable(rootSociete);
1267
            SQLPreferences.startMemCached(rootSociete);
1268
        } catch (Exception e) {
1269
            // don't die now, we might not need them
1270
            ExceptionHandler.handle("Impossible d'accéder aux préférences", e);
1271
        }
1272
 
18 ilm 1273
        closeSocieteConnexion();
1274
        setSocieteDirectory();
1275
        NumerotationAutoSQLElement.addListeners();
73 ilm 1276
        loadTranslations(this.getTranslator(), rootSociete, Arrays.asList("mappingCompta", "mapping-" + customerName));
18 ilm 1277
        setSocieteShowAs();
1278
        setSocieteSQLInjector();
83 ilm 1279
        configureGlobalMapper();
1280
        setFieldMapper(new FieldMapper(this.getRootSociete()));
1281
        getFieldMapper().addMapperStreamFromClass(Gestion.class);
25 ilm 1282
        TemplateNXProps.getInstance();
67 ilm 1283
        // Prefetch undefined
1284
        rootSociete.getTables().iterator().next().getUndefinedID();
144 ilm 1285
 
156 ilm 1286
        this.getModuleManager().addFactories(Gestion.MODULES_DIR);
1287
        this.getModuleManager().setup(this.getRootSociete(), this);
144 ilm 1288
    }
1289
 
156 ilm 1290
    public final ModuleManager getModuleManager() {
1291
        return this.moduleMngr;
1292
    }
1293
 
144 ilm 1294
    public void setupBarCodeIfNeeded() {
1295
        final DBRoot rootSociete = this.getRootSociete();
174 ilm 1296
        SQLPreferences pref = SQLPreferences.getMemCached(rootSociete);
142 ilm 1297
        if (pref.getBoolean(GestionCommercialeGlobalPreferencePanel.BARCODE_INSERTION, false)) {
1298
            this.barcodeReader = new BarcodeReader(80);
1299
            this.barcodeReader.start();
1300
        }
18 ilm 1301
    }
1302
 
142 ilm 1303
    private BarcodeReader barcodeReader = null;
1304
 
1305
    public BarcodeReader getBarcodeReader() {
1306
        return barcodeReader;
1307
    }
1308
 
83 ilm 1309
    private void configureGlobalMapper() {
1310
 
80 ilm 1311
        FieldMapper fieldMapper = new FieldMapper(this.getRootSociete());
73 ilm 1312
        fieldMapper.addMapperStreamFromClass(Gestion.class);
83 ilm 1313
 
25 ilm 1314
    }
1315
 
18 ilm 1316
    private void closeSocieteConnexion() {
1317
 
1318
    }
1319
 
1320
    public String getServerIp() {
1321
        return getProperty("server.ip");
1322
    }
19 ilm 1323
 
28 ilm 1324
    @Override
1325
    protected DateFormat getLogDateFormat() {
1326
        return new SimpleDateFormat("yyyy-MM/dd_HH-mm EEEE");
1327
    }
1328
 
41 ilm 1329
    @Override
1330
    protected SQLServer createServer() {
81 ilm 1331
        if (GraphicsEnvironment.isHeadless()) {
156 ilm 1332
            return super.createServer();
81 ilm 1333
        }
41 ilm 1334
        InProgressFrame progress = new InProgressFrame();
156 ilm 1335
        if (isOnCloud) {
1336
            progress.show("Connexion au cloud en cours");
1337
        } else {
1338
            progress.show("Connexion à la base de données en cours");
1339
        }
73 ilm 1340
        try {
1341
            SQLServer server = super.createServer();
1342
            return server;
1343
        } catch (Throwable e) {
156 ilm 1344
            if (isOnCloud) {
1345
                JOptionPane.showMessageDialog(null, "Impossible de se connecter au cloud.\n\nVérifiez votre connexion internet.", "Erreur", JOptionPane.ERROR_MESSAGE);
1346
            } else {
1347
                JOptionPane.showMessageDialog(null, "Impossible de se connecter à la base de données.\n\nVérifiez votre connexion.", "Erreur réseau", JOptionPane.ERROR_MESSAGE);
1348
            }
1349
            System.exit(1);
73 ilm 1350
            return null;
1351
        } finally {
1352
            progress.dispose();
1353
        }
1354
 
41 ilm 1355
    }
61 ilm 1356
 
1357
    public static ComptaPropsConfiguration getInstanceCompta() {
1358
        return (ComptaPropsConfiguration) getInstance();
1359
    }
1360
 
1361
    public String getStorageServer() {
1362
        return this.getProperty("storage.server");
1363
    }
1364
 
1365
    public Image getCustomLogo() {
142 ilm 1366
        final File dir = new File(getConfFile(getProductInfo()).getParent());
61 ilm 1367
        final File file = new File(dir, "logo.png");
1368
 
1369
        BufferedImage im = null;
1370
        if (file.exists()) {
1371
            try {
1372
                im = ImageIO.read(file);
1373
                if (im.getHeight() < 16) {
1374
                    JOptionPane.showMessageDialog(new JFrame(), "Logo too small (height < 16 pixels)");
1375
                    return null;
1376
                }
1377
                if (im.getWidth() < 200) {
1378
                    JOptionPane.showMessageDialog(new JFrame(), "Logo too small (width < 200 pixels)");
1379
                    return null;
1380
                }
1381
                final Graphics g = im.getGraphics();
1382
 
1383
                g.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 11));
1384
                ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
1385
                final String str = "Powered by OpenConcerto";
1386
                final Rectangle2D r = g.getFontMetrics().getStringBounds(str, g);
1387
                g.setColor(new Color(255, 255, 255, 200));
1388
                g.fillRect(0, im.getHeight() - (int) r.getHeight() - 2, (int) r.getWidth() + 8, (int) r.getHeight() + 4);
1389
                g.setColor(Color.BLACK);
1390
                g.drawString(str, 4, im.getHeight() - 4);
1391
                g.dispose();
1392
            } catch (IOException e) {
1393
                e.printStackTrace();
1394
            }
1395
 
1396
        }
1397
        return im;
1398
    }
142 ilm 1399
 
1400
    public synchronized Currency getCurrency() {
1401
        if (currency == null) {
1402
            String code = getRowSociete().getForeign("ID_DEVISE").getString("CODE");
1403
            currency = new Currency(code);
1404
        }
1405
        return currency;
1406
    }
144 ilm 1407
 
1408
    public static void checkJava() {
1409
        final String javaversion = System.getProperty("java.version");
1410
        if (javaversion != null && javaversion.startsWith("1.")) {
1411
            final String v = javaversion.substring(2);
1412
            final StringBuilder b = new StringBuilder();
1413
            for (int i = 0; i < v.length(); i++) {
1414
                final char c = v.charAt(i);
1415
                if (Character.isDigit(c)) {
1416
                    b.append(c);
1417
                } else {
1418
                    break;
1419
                }
1420
            }
1421
            final int version = Integer.parseInt(b.toString());
1422
            if (version < 8) {
1423
                System.err.println("Java " + javaversion + " not supported, please upgrade your java from https://www.java.com");
1424
                if (GraphicsEnvironment.isHeadless()) {
1425
                    JOptionPane.showMessageDialog(null, "Please upgrade your Java.\n\nMerci de mettre à jour votre Java.\n\n https://www.java.com", "Java version", JOptionPane.ERROR_MESSAGE);
1426
                }
1427
                System.exit(666);
1428
            }
1429
        }
1430
    }
1431
 
18 ilm 1432
}