OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 118 Rev 153
Line 42... Line 42...
42
import org.openconcerto.sql.model.SQLTable;
42
import org.openconcerto.sql.model.SQLTable;
43
import org.openconcerto.sql.model.Where;
43
import org.openconcerto.sql.model.Where;
44
import org.openconcerto.sql.preferences.SQLPreferences;
44
import org.openconcerto.sql.preferences.SQLPreferences;
45
import org.openconcerto.sql.preferences.UserProps;
45
import org.openconcerto.sql.preferences.UserProps;
46
import org.openconcerto.sql.sqlobject.IComboSelectionItem;
46
import org.openconcerto.sql.sqlobject.IComboSelectionItem;
47
import org.openconcerto.sql.users.UserManager;
-
 
48
import org.openconcerto.utils.ExceptionHandler;
47
import org.openconcerto.utils.ExceptionHandler;
49
import org.openconcerto.utils.i18n.TranslationManager;
48
import org.openconcerto.utils.i18n.TranslationManager;
50
 
49
 
51
public class BadgeListener implements Runnable {
50
public class BadgeListener implements Runnable {
52
    private static final int UDP_PORT = 1470;
51
    private static final int UDP_PORT = 1470;
Line 58... Line 57...
58
    public BadgeListener() {
57
    public BadgeListener() {
59
 
58
 
60
    }
59
    }
61
 
60
 
62
    public void init(String id) {
61
    public void init(String id) {
63
 
-
 
-
 
62
        // TODO use HeadlessGestion
64
        TranslationManager.getInstance().addTranslationStreamFromClass(BadgeListener.class);
63
        TranslationManager.getInstance().addTranslationStreamFromClass(BadgeListener.class);
65
        TranslationManager.getInstance().setLocale(Locale.FRANCE);
64
        TranslationManager.getInstance().setLocale(Locale.FRANCE);
66
        final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create(true);
65
        final ComptaPropsConfiguration conf = ComptaPropsConfiguration.create(true);
67
        if (conf == null) {
66
        if (conf == null) {
68
            ServerFinderPanel.main(new String[0]);
67
            ServerFinderPanel.main(new String[0]);
69
            return;
68
            return;
70
        }
69
        }
71
 
70
 
72
        Configuration.setInstance(conf);
71
        Configuration.setInstance(conf);
73
        UserManager.getInstance().setCurrentUser(2);
72
        conf.getUserManager().setCurrentUserID(2);
74
 
73
 
75
        try {
74
        try {
76
            conf.getBase();
75
            conf.getBase();
77
            // create table if necessary
76
            // create table if necessary
78
            SQLPreferences.getPrefTable(conf.getRoot());
77
            SQLPreferences.getPrefTable(conf.getRoot());
Line 274... Line 273...
274
    }
273
    }
275
 
274
 
276
    public boolean isBadgeAllowed(String cardNumber) {
275
    public boolean isBadgeAllowed(String cardNumber) {
277
        SQLBase base = Configuration.getInstance().getBase();
276
        SQLBase base = Configuration.getInstance().getBase();
278
        SQLSelect sel = new SQLSelect(base);
277
        SQLSelect sel = new SQLSelect(base);
-
 
278
        // FIXME use SQLElement
279
        SQLTable tableAdh = Configuration.getInstance().getRoot().findTable("ADHERENT");
279
        SQLTable tableAdh = Configuration.getInstance().getRoot().findTable("ADHERENT");
280
        sel.addSelectStar(tableAdh);
280
        sel.addSelectStar(tableAdh);
281
        sel.setWhere(new Where(tableAdh.getField("NUMERO_CARTE"), "=", cardNumber));
281
        sel.setWhere(new Where(tableAdh.getField("NUMERO_CARTE"), "=", cardNumber));
282
        List<SQLRow> list = (List<SQLRow>) base.getDataSource().execute(sel.asString(), SQLRowListRSH.createFromSelect(sel));
282
        List<SQLRow> list = (List<SQLRow>) base.getDataSource().execute(sel.asString(), SQLRowListRSH.createFromSelect(sel));
283
 
283
 
284
        String motif = "";
284
        String motif = "";
-
 
285
        // FIXME use actual module installed in the DB (MAYBE init() the ModuleManager)
285
        Boolean onlyAdmin = ModuleManager.getInstance().getFactories().get("org.openconcerto.modules.badge").get(new ModuleVersion(1, 0)).getSQLPreferences(tableAdh.getDBRoot())
286
        Boolean onlyAdmin = ModuleManager.getInstance().getFactories().get("org.openconcerto.modules.badge").get(new ModuleVersion(1, 0)).getSQLPreferences(tableAdh.getDBRoot())
286
                .getBoolean(Module.ENTREE_PREF, false);
287
                .getBoolean(Module.ENTREE_PREF, false);
287
        boolean allow = false;
288
        boolean allow = false;
288
        SQLRow adh = null;
289
        SQLRow adh = null;
289
        // Aucun adhérent assigné à cette carte
290
        // Aucun adhérent assigné à cette carte