OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 104 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 104 Rev 147
1
package org.openconcerto.modules.finance.accounting.exchangerates;
1
package org.openconcerto.modules.finance.accounting.exchangerates;
2
 
2
 
-
 
3
import java.awt.GraphicsEnvironment;
3
import java.io.File;
4
import java.io.File;
4
import java.io.IOException;
5
import java.io.IOException;
5
import java.math.BigDecimal;
6
import java.math.BigDecimal;
6
import java.sql.ResultSet;
7
import java.sql.ResultSet;
7
import java.sql.SQLException;
8
import java.sql.SQLException;
8
import java.util.ArrayList;
9
import java.util.ArrayList;
9
import java.util.Arrays;
10
import java.util.Arrays;
10
import java.util.Calendar;
11
import java.util.Calendar;
11
import java.util.Date;
12
import java.util.Date;
12
import java.util.HashSet;
13
import java.util.HashSet;
13
import java.util.List;
14
import java.util.List;
14
import java.util.Set;
15
import java.util.Set;
15
import java.util.TimeZone;
16
import java.util.TimeZone;
16
 
17
 
17
import javax.swing.JOptionPane;
18
import javax.swing.JOptionPane;
18
 
19
 
19
import org.apache.commons.dbutils.ResultSetHandler;
20
import org.apache.commons.dbutils.ResultSetHandler;
20
import org.openconcerto.erp.config.ComptaPropsConfiguration;
21
import org.openconcerto.erp.config.ComptaPropsConfiguration;
21
import org.openconcerto.erp.config.Gestion;
22
import org.openconcerto.erp.config.Gestion;
22
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
23
import org.openconcerto.erp.core.finance.accounting.model.CurrencyConverter;
23
import org.openconcerto.erp.modules.AbstractModule;
24
import org.openconcerto.erp.modules.AbstractModule;
24
import org.openconcerto.erp.modules.DBContext;
25
import org.openconcerto.erp.modules.DBContext;
25
import org.openconcerto.erp.modules.ModuleFactory;
26
import org.openconcerto.erp.modules.ModuleFactory;
26
import org.openconcerto.erp.modules.ModuleManager;
27
import org.openconcerto.erp.modules.ModuleManager;
27
import org.openconcerto.erp.modules.ModulePackager;
28
import org.openconcerto.erp.modules.ModulePackager;
28
import org.openconcerto.erp.modules.ModulePreferencePanel;
29
import org.openconcerto.erp.modules.ModulePreferencePanel;
29
import org.openconcerto.erp.modules.ModulePreferencePanelDesc;
30
import org.openconcerto.erp.modules.ModulePreferencePanelDesc;
30
import org.openconcerto.erp.modules.ModuleVersion;
31
import org.openconcerto.erp.modules.ModuleVersion;
31
import org.openconcerto.erp.modules.RuntimeModuleFactory;
32
import org.openconcerto.erp.modules.RuntimeModuleFactory;
32
import org.openconcerto.sql.model.DBRoot;
33
import org.openconcerto.sql.model.DBRoot;
33
import org.openconcerto.sql.model.SQLBase;
34
import org.openconcerto.sql.model.SQLBase;
34
import org.openconcerto.sql.model.SQLRequestLog;
35
import org.openconcerto.sql.model.SQLRequestLog;
35
import org.openconcerto.sql.model.SQLRow;
36
import org.openconcerto.sql.model.SQLRow;
36
import org.openconcerto.sql.model.SQLRowListRSH;
37
import org.openconcerto.sql.model.SQLRowListRSH;
37
import org.openconcerto.sql.model.SQLSelect;
38
import org.openconcerto.sql.model.SQLSelect;
38
import org.openconcerto.sql.model.SQLTable;
39
import org.openconcerto.sql.model.SQLTable;
39
import org.openconcerto.sql.model.Where;
40
import org.openconcerto.sql.model.Where;
40
import org.openconcerto.sql.ui.ConnexionPanel;
41
import org.openconcerto.sql.ui.ConnexionPanel;
41
import org.openconcerto.sql.utils.SQLUtils;
42
import org.openconcerto.sql.utils.SQLUtils;
42
import org.openconcerto.utils.PrefType;
43
import org.openconcerto.utils.PrefType;
43
 
44
 
44
public final class Module extends AbstractModule {
45
public final class Module extends AbstractModule {
45
 
46
 
46
    public static final String TABLE_EXPENSE = "EXPENSE";
47
    public static final String TABLE_EXPENSE = "EXPENSE";
47
    public static final String TABLE_EXPENSE_STATE = "EXPENSE_STATE";
48
    public static final String TABLE_EXPENSE_STATE = "EXPENSE_STATE";
48
    public static final String EXPENSE_RATE_NOT_DOWNLOAD_PREF = "EXPENSE_RATE_NOT_DOWNLOAD_PREF";
49
    public static final String EXPENSE_RATE_NOT_DOWNLOAD_PREF = "EXPENSE_RATE_NOT_DOWNLOAD_PREF";
49
    public static ModuleVersion MODULE_VERSION = new ModuleVersion(1, 0);
50
    public static ModuleVersion MODULE_VERSION = new ModuleVersion(1, 0);
50
    private CurrencyConverter commercialConverter = null;
51
    private CurrencyConverter commercialConverter = null;
51
 
52
 
52
    public Module(ModuleFactory f) throws IOException {
53
    public Module(ModuleFactory f) throws IOException {
53
        super(f);
54
        super(f);
54
    }
55
    }
55
 
56
 
56
    @Override
57
    @Override
57
    protected void install(DBContext ctxt) {
58
    protected void install(DBContext ctxt) {
58
 
59
 
59
    }
60
    }
60
 
61
 
61
    public void setCommercialConverter(CurrencyConverter commercialConverter) {
62
    public void setCommercialConverter(CurrencyConverter commercialConverter) {
62
        this.commercialConverter = commercialConverter;
63
        this.commercialConverter = commercialConverter;
63
    }
64
    }
64
 
65
 
65
    @Override
66
    @Override
66
    protected void start() {
67
    protected void start() {
67
        final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
68
        final DBRoot root = ComptaPropsConfiguration.getInstanceCompta().getRootSociete();
68
        Boolean b = ModuleManager.getInstance().getFactories().get("org.openconcerto.modules.finance.accounting.exchangerates").get(Module.MODULE_VERSION).getSQLPreferences(root)
69
        Boolean b = ModuleManager.getInstance().getFactories().get("org.openconcerto.modules.finance.accounting.exchangerates").get(Module.MODULE_VERSION).getSQLPreferences(root)
69
                .getBoolean(EXPENSE_RATE_NOT_DOWNLOAD_PREF, false);
70
                .getBoolean(EXPENSE_RATE_NOT_DOWNLOAD_PREF, false);
70
        if (!b) {
71
        if (!b) {
71
            final Thread t = new Thread() {
72
            final Thread t = new Thread() {
72
                public void run() {
73
                public void run() {
73
                    // Wait 1s to prevent too many internet access at startup
74
                    // Wait 1s to prevent too many internet access at startup
74
                    try {
75
                    try {
75
                        Thread.sleep(1000);
76
                        Thread.sleep(1000);
76
                    } catch (InterruptedException e1) {
77
                    } catch (InterruptedException e1) {
77
                        e1.printStackTrace();
78
                        e1.printStackTrace();
78
                    }
79
                    }
79
                    updateRates(root, ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getForeign("ID_DEVISE").getString("CODE"));
80
                    updateRates(root, ComptaPropsConfiguration.getInstanceCompta().getRowSociete().getForeign("ID_DEVISE").getString("CODE"));
80
                };
81
                };
81
            };
82
            };
82
            t.setPriority(Thread.MIN_PRIORITY);
83
            t.setPriority(Thread.MIN_PRIORITY);
83
            t.setDaemon(true);
84
            t.setDaemon(true);
84
            t.start();
85
            t.start();
85
        }
86
        }
86
 
87
 
87
    }
88
    }
88
 
89
 
89
    public void updateRates(DBRoot root, String companyCurrencyCode) {
90
    public void updateRates(DBRoot root, String companyCurrencyCode) {
90
        // Check if update need to be done
91
        // Check if update need to be done
91
        final Calendar c = Calendar.getInstance();
92
        final Calendar c = Calendar.getInstance();
92
        c.set(Calendar.HOUR_OF_DAY, 0);
93
        c.set(Calendar.HOUR_OF_DAY, 0);
93
        c.set(Calendar.MINUTE, 0);
94
        c.set(Calendar.MINUTE, 0);
94
        c.set(Calendar.SECOND, 0);
95
        c.set(Calendar.SECOND, 0);
95
        c.set(Calendar.MILLISECOND, 0);
96
        c.set(Calendar.MILLISECOND, 0);
96
 
97
 
97
        if (c.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
98
        if (c.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) {
98
            c.set(Calendar.HOUR, -72);
99
            c.set(Calendar.HOUR, -72);
99
        } else {
100
        } else {
100
            c.add(Calendar.HOUR, -24);
101
            c.add(Calendar.HOUR, -24);
101
        }
102
        }
102
        final Date yesterday = c.getTime();
103
        final Date yesterday = c.getTime();
103
 
104
 
104
        final CurrencyConverter converter = new CurrencyConverter(root, companyCurrencyCode, "EUR");
105
        final CurrencyConverter converter = new CurrencyConverter(root, companyCurrencyCode, "EUR");
105
        final SQLSelect select = new SQLSelect();
106
        final SQLSelect select = new SQLSelect();
106
        final SQLTable t = root.getTable("DEVISE_HISTORIQUE");
107
        final SQLTable t = root.getTable("DEVISE_HISTORIQUE");
107
        select.addAllSelect(t, Arrays.asList("DATE", "SRC", "ID"));
108
        select.addAllSelect(t, Arrays.asList("DATE", "SRC", "ID"));
108
        Where w = new Where(t.getField("SRC"), "=", "EUR");
109
        Where w = new Where(t.getField("SRC"), "=", "EUR");
109
        w = w.and(new Where(t.getField("DATE"), "=", yesterday));
110
        w = w.and(new Where(t.getField("DATE"), "=", yesterday));
110
        select.setWhere(w);
111
        select.setWhere(w);
111
        select.setLimit(1);
112
        select.setLimit(1);
112
        final List<SQLRow> rows = SQLRowListRSH.execute(select);
113
        final List<SQLRow> rows = SQLRowListRSH.execute(select);
113
        if (!rows.isEmpty()) {
114
        if (!rows.isEmpty()) {
114
            // Nothing to update
115
            // Nothing to update
115
            System.out.println("No exchange rates to download");
116
            System.out.println("No exchange rates to download");
116
            return;
117
            return;
117
        }
118
        }
118
        // Get conversion info
119
        // Get conversion info
119
        final ExchangeRatesDownloader d = new ExchangeRatesDownloader();
120
        final ExchangeRatesDownloader d = new ExchangeRatesDownloader();
120
        try {
121
        try {
121
            d.downloadAndParse();
122
            d.downloadAndParse();
122
            Set<Date> dates = getMissingDates(converter, root);
123
            Set<Date> dates = getMissingDates(converter, root);
123
            System.out.println("Missing date:" + dates);
124
            System.out.println("Missing date:" + dates);
124
            List<Report> reports = d.getReports();
125
            List<Report> reports = d.getReports();
125
 
126
 
126
            for (Report report : reports) {
127
            for (Report report : reports) {
127
                if (dates.contains(report.getDate())) {
128
                if (dates.contains(report.getDate())) {
128
                    importReport(d, report, converter, root);
129
                    importReport(d, report, converter, root);
129
                }
130
                }
130
            }
131
            }
131
        } catch (Exception e) {
132
        } catch (Exception e) {
132
            e.printStackTrace();
133
            e.printStackTrace();
-
 
134
            if (!GraphicsEnvironment.isHeadless()) {
133
            JOptionPane.showMessageDialog(null, "Impossible de mettre à jour les taux de change");
135
                JOptionPane.showMessageDialog(null, "Impossible de mettre à jour les taux de change");
134
        }
136
            }
135
    }
137
        }
-
 
138
    }
136
 
139
 
137
    @Override
140
    @Override
138
    public List<ModulePreferencePanelDesc> getPrefDescriptors() {
141
    public List<ModulePreferencePanelDesc> getPrefDescriptors() {
139
        return Arrays.<ModulePreferencePanelDesc> asList(new ModulePreferencePanelDesc("Gestion des devises") {
142
        return Arrays.<ModulePreferencePanelDesc> asList(new ModulePreferencePanelDesc("Gestion des devises") {
140
            @Override
143
            @Override
141
            protected ModulePreferencePanel createPanel() {
144
            protected ModulePreferencePanel createPanel() {
142
                return new ModulePreferencePanel("Gestion des devises") {
145
                return new ModulePreferencePanel("Gestion des devises") {
143
                    @Override
146
                    @Override
144
                    protected void addViews() {
147
                    protected void addViews() {
145
 
148
 
146
                        final SQLPrefView<Boolean> view = new SQLPrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Ne pas télécharger les nouveaux taux au lancement du logiciel",
149
                        final SQLPrefView<Boolean> view = new SQLPrefView<Boolean>(PrefType.BOOLEAN_TYPE, "Ne pas télécharger les nouveaux taux au lancement du logiciel",
147
                                EXPENSE_RATE_NOT_DOWNLOAD_PREF);
150
                                EXPENSE_RATE_NOT_DOWNLOAD_PREF);
148
                        this.addView(view);
151
                        this.addView(view);
149
                    }
152
                    }
150
                };
153
                };
151
            }
154
            }
152
        }.setLocal(false).setKeywords("devise"));
155
        }.setLocal(false).setKeywords("devise"));
153
    }
156
    }
154
 
157
 
155
    protected void importReport(ExchangeRatesDownloader d, Report report, CurrencyConverter converter, DBRoot root) {
158
    protected void importReport(ExchangeRatesDownloader d, Report report, CurrencyConverter converter, DBRoot root) {
156
 
159
 
157
        System.out.println("Module.importReport() " + report.getDate());
160
        System.out.println("Module.importReport() " + report.getDate());
158
 
161
 
159
        SQLTable tDeviseHisto = root.getTable("DEVISE_HISTORIQUE");
162
        SQLTable tDeviseHisto = root.getTable("DEVISE_HISTORIQUE");
160
 
163
 
161
        final List<String> queries = new ArrayList<String>();
164
        final List<String> queries = new ArrayList<String>();
162
        final List<ResultSetHandler> handlers = new ArrayList<ResultSetHandler>();
165
        final List<ResultSetHandler> handlers = new ArrayList<ResultSetHandler>();
163
        final ResultSetHandler handler = new ResultSetHandler() {
166
        final ResultSetHandler handler = new ResultSetHandler() {
164
 
167
 
165
            @Override
168
            @Override
166
            public Object handle(ResultSet rs) throws SQLException {
169
            public Object handle(ResultSet rs) throws SQLException {
167
                if (rs.next()) {
170
                if (rs.next()) {
168
                    return rs.getObject(1);
171
                    return rs.getObject(1);
169
                }
172
                }
170
                return null;
173
                return null;
171
            }
174
            }
172
        };
175
        };
173
        Date date = Calendar.getInstance().getTime();
176
        Date date = Calendar.getInstance().getTime();
174
        final int size = ExchangeRatesDownloader.supportedCurrencyCodes.size();
177
        final int size = ExchangeRatesDownloader.supportedCurrencyCodes.size();
175
        for (int i = 0; i < size; i++) {
178
        for (int i = 0; i < size; i++) {
176
            String code = ExchangeRatesDownloader.supportedCurrencyCodes.get(i);
179
            String code = ExchangeRatesDownloader.supportedCurrencyCodes.get(i);
177
            BigDecimal tauxCommercial;
180
            BigDecimal tauxCommercial;
178
            if (this.commercialConverter != null) {
181
            if (this.commercialConverter != null) {
179
                tauxCommercial = commercialConverter.convert(BigDecimal.ONE, report.getMainCurrencyCode(), code, date, true);
182
                tauxCommercial = commercialConverter.convert(BigDecimal.ONE, report.getMainCurrencyCode(), code, date, true);
180
            } else {
183
            } else {
-
 
184
                try {
181
                tauxCommercial = converter.convert(BigDecimal.ONE, report.getMainCurrencyCode(), code, date, true);
185
                    tauxCommercial = converter.convert(BigDecimal.ONE, report.getMainCurrencyCode(), code, date, true);
-
 
186
                } catch (IllegalStateException e) {
-
 
187
                    // Aucun taux n'existe encore dans la base.
-
 
188
                    tauxCommercial = null;
-
 
189
                }
182
            }
190
            }
183
            if (tauxCommercial == null) {
191
            if (tauxCommercial == null) {
184
                tauxCommercial = BigDecimal.ONE;
192
                tauxCommercial = BigDecimal.ONE;
185
            }
193
            }
186
            tauxCommercial = tauxCommercial.setScale(4, BigDecimal.ROUND_HALF_UP);
194
            tauxCommercial = tauxCommercial.setScale(4, BigDecimal.ROUND_HALF_UP);
187
            String query = "INSERT INTO " + tDeviseHisto.getSQLName().quote();
195
            String query = "INSERT INTO " + tDeviseHisto.getSQLName().quote();
188
            final BigDecimal rate = report.getRate(code);
196
            final BigDecimal rate = report.getRate(code);
189
            if (rate == null) {
197
            if (rate == null) {
190
                System.err.println("RATE " + code + " NOT Supported");
198
                System.err.println("RATE " + code + " NOT Supported");
191
                // Thread.dumpStack();
199
                // Thread.dumpStack();
192
            } else {
200
            } else {
193
                final BigDecimal taux = rate.setScale(4, BigDecimal.ROUND_HALF_UP);
201
                final BigDecimal taux = rate.setScale(4, BigDecimal.ROUND_HALF_UP);
194
 
202
 
195
                final java.sql.Date date2 = new java.sql.Date(report.getDate().getTime());
203
                final java.sql.Date date2 = new java.sql.Date(report.getDate().getTime());
196
                query += " (\"DATE\", \"SRC\", \"DST\", \"TAUX\", \"TAUX_COMMERCIAL\", \"ORDRE\") select " + SQLBase.quoteStringStd(date2.toString()) + ", "
204
                query += " (\"DATE\", \"SRC\", \"DST\", \"TAUX\", \"TAUX_COMMERCIAL\", \"ORDRE\") select " + SQLBase.quoteStringStd(date2.toString()) + ", "
197
                        + SQLBase.quoteStringStd(report.getMainCurrencyCode()) + ", " + SQLBase.quoteStringStd(code) + ", " + taux + ", " + tauxCommercial + ", COALESCE(MAX(\"ORDRE\"), 0) + 1 ";
205
                        + SQLBase.quoteStringStd(report.getMainCurrencyCode()) + ", " + SQLBase.quoteStringStd(code) + ", " + taux + ", " + tauxCommercial + ", COALESCE(MAX(\"ORDRE\"), 0) + 1 ";
198
                query += "FROM " + tDeviseHisto.getSQLName().quote() + " RETURNING \"ID\"";
206
                query += "FROM " + tDeviseHisto.getSQLName().quote() + " RETURNING \"ID\"";
199
 
207
 
200
                queries.add(query);
208
                queries.add(query);
201
                handlers.add(handler);
209
                handlers.add(handler);
202
            }
210
            }
203
        }
211
        }
204
 
212
 
205
        try {
213
        try {
206
            SQLUtils.executeMultiple(tDeviseHisto.getDBSystemRoot(), queries, handlers);
214
            SQLUtils.executeMultiple(tDeviseHisto.getDBSystemRoot(), queries, handlers);
207
 
215
 
208
        } catch (Exception e) {
216
        } catch (Exception e) {
209
            e.printStackTrace();
217
            e.printStackTrace();
210
        }
218
        }
211
 
219
 
212
    }
220
    }
213
 
221
 
214
    protected Set<Date> getMissingDates(CurrencyConverter converter, DBRoot root) {
222
    protected Set<Date> getMissingDates(CurrencyConverter converter, DBRoot root) {
215
        final SQLSelect select = new SQLSelect();
223
        final SQLSelect select = new SQLSelect();
216
 
224
 
217
        final SQLTable t = root.getTable("DEVISE_HISTORIQUE");
225
        final SQLTable t = root.getTable("DEVISE_HISTORIQUE");
218
        select.addAllSelect(t, Arrays.asList("DATE"));
226
        select.addAllSelect(t, Arrays.asList("DATE"));
219
        Where w = new Where(t.getField("SRC"), "=", converter.getCompanyCurrencyCode());
227
        Where w = new Where(t.getField("SRC"), "=", converter.getCompanyCurrencyCode());
220
        w = w.and(new Where(t.getField("DATE"), "<", new Date(System.currentTimeMillis())));
228
        w = w.and(new Where(t.getField("DATE"), "<", new Date(System.currentTimeMillis())));
221
        select.setWhere(w);
229
        select.setWhere(w);
222
        select.addGroupBy(t.getField("DATE"));
230
        select.addGroupBy(t.getField("DATE"));
223
        select.setLimit(30);
231
        select.setLimit(30);
224
        final List<Date> dates = t.getDBSystemRoot().getDataSource().executeCol(select.asString());
232
        final List<Date> dates = t.getDBSystemRoot().getDataSource().executeCol(select.asString());
225
 
233
 
226
        final Set<Date> result = new HashSet<Date>();
234
        final Set<Date> result = new HashSet<Date>();
227
        Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
235
        Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
228
        c.set(Calendar.HOUR_OF_DAY, 0);
236
        c.set(Calendar.HOUR_OF_DAY, 0);
229
        c.set(Calendar.MINUTE, 0);
237
        c.set(Calendar.MINUTE, 0);
230
        c.set(Calendar.SECOND, 0);
238
        c.set(Calendar.SECOND, 0);
231
        c.set(Calendar.MILLISECOND, 0);
239
        c.set(Calendar.MILLISECOND, 0);
232
        for (int i = 0; i < 20; i++) {
240
        for (int i = 0; i < 20; i++) {
233
            c.add(Calendar.HOUR_OF_DAY, -24);
241
            c.add(Calendar.HOUR_OF_DAY, -24);
234
            final Date time = c.getTime();
242
            final Date time = c.getTime();
235
            System.out.println("::" + time);
243
            System.out.println("::" + time);
236
            result.add(time);
244
            result.add(time);
237
        }
245
        }
238
 
246
 
239
        for (Date date : dates) {
247
        for (Date date : dates) {
240
            Calendar c2 = Calendar.getInstance();
248
            Calendar c2 = Calendar.getInstance();
241
            c2.setTime(date);
249
            c2.setTime(date);
242
            c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
250
            c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
243
            c.set(Calendar.YEAR, c2.get(Calendar.YEAR));
251
            c.set(Calendar.YEAR, c2.get(Calendar.YEAR));
244
            c.set(Calendar.DAY_OF_YEAR, c2.get(Calendar.DAY_OF_YEAR));
252
            c.set(Calendar.DAY_OF_YEAR, c2.get(Calendar.DAY_OF_YEAR));
245
            c.set(Calendar.HOUR_OF_DAY, 0);
253
            c.set(Calendar.HOUR_OF_DAY, 0);
246
            c.set(Calendar.MINUTE, 0);
254
            c.set(Calendar.MINUTE, 0);
247
            c.set(Calendar.SECOND, 0);
255
            c.set(Calendar.SECOND, 0);
248
            c.set(Calendar.MILLISECOND, 0);
256
            c.set(Calendar.MILLISECOND, 0);
249
            Date dd = c.getTime();
257
            Date dd = c.getTime();
250
            result.remove(dd);
258
            result.remove(dd);
251
            System.out.println("--" + dd);
259
            System.out.println("--" + dd);
252
        }
260
        }
253
        System.out.println(result.size());
261
        System.out.println(result.size());
254
 
262
 
255
        return result;
263
        return result;
256
    }
264
    }
257
 
265
 
258
    @Override
266
    @Override
259
    protected void stop() {
267
    protected void stop() {
260
    }
268
    }
261
 
269
 
262
    public static void main(String[] args) throws IOException {
270
    public static void main(String[] args) throws IOException {
263
        System.setProperty(ConnexionPanel.QUICK_LOGIN, "true");
271
        System.setProperty(ConnexionPanel.QUICK_LOGIN, "true");
264
        final File propsFile = new File("module.properties");
272
        final File propsFile = new File("module.properties");
265
        System.out.println(propsFile.getAbsolutePath());
273
        System.out.println(propsFile.getAbsolutePath());
266
        final ModuleFactory factory = new RuntimeModuleFactory(propsFile);
274
        final ModuleFactory factory = new RuntimeModuleFactory(propsFile);
267
        SQLRequestLog.setEnabled(true);
275
        SQLRequestLog.setEnabled(true);
268
        SQLRequestLog.showFrame();
276
        SQLRequestLog.showFrame();
269
        // uncomment to create and use the jar
277
        // uncomment to create and use the jar
270
        final ModulePackager modulePackager = new ModulePackager(propsFile, new File("bin/"));
278
        final ModulePackager modulePackager = new ModulePackager(propsFile, new File("bin/"));
271
        modulePackager.writeToDir(new File("../OpenConcerto/Modules"));
279
        modulePackager.writeToDir(new File("../OpenConcerto/Modules"));
272
        // final ModuleFactory factory = new JarModuleFactory(jar);
280
        // final ModuleFactory factory = new JarModuleFactory(jar);
273
        ModuleManager.getInstance().addFactories(new File("../OpenConcerto/Modules"));
281
        ModuleManager.getInstance().addFactories(new File("../OpenConcerto/Modules"));
274
        ModuleManager.getInstance().addFactoryAndStart(factory, false);
282
        ModuleManager.getInstance().addFactoryAndStart(factory, false);
275
        Gestion.main(args);
283
        Gestion.main(args);
276
    }
284
    }
277
 
285
 
278
}
286
}