OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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