OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 151 Rev 156
Line 30... Line 30...
30
 
30
 
31
    public HeadlessGestion setup(int userId, int companyId) {
31
    public HeadlessGestion setup(int userId, int companyId) {
32
        try {
32
        try {
33
            this.comptaPropsConfiguration.getUserManager().setCurrentUserID(userId);
33
            this.comptaPropsConfiguration.getUserManager().setCurrentUserID(userId);
34
            this.comptaPropsConfiguration.setUpSocieteDataBaseConnexion(companyId);
34
            this.comptaPropsConfiguration.setUpSocieteDataBaseConnexion(companyId);
-
 
35
            // finish filling the configuration before going any further, otherwise the
-
 
36
            // SQLElementDirectory is not coherent
-
 
37
            this.comptaPropsConfiguration.getModuleManager().init();
35
        } catch (Exception e) {
38
        } catch (Exception e) {
36
            e.printStackTrace();
-
 
37
            throw new IllegalStateException("Unable to configure connection for userId: " + userId + " companyId: " + companyId);
39
            throw new IllegalStateException("Unable to configure connection for userId: " + userId + " companyId: " + companyId, e);
38
 
-
 
39
        }
40
        }
40
        return this;
41
        return this;
41
    }
42
    }
42
 
43
 
43
    public HeadlessGestion setupGlobalState(int userId, int companyId) {
44
    public HeadlessGestion setupGlobalState(int userId, int companyId) {
-
 
45
        // setUpSocieteDataBaseConnexion() called by setup() needs the directory and elements need
44
        setupGlobalState(userId, companyId);
46
        // Configuration.getInstance()
45
        setGlobalState();
47
        setGlobalState();
-
 
48
        setup(userId, companyId);
46
        return this;
49
        return this;
47
    }
50
    }
48
 
51
 
49
    public HeadlessGestion setGlobalState() {
52
    public HeadlessGestion setGlobalState() {
50
        System.setProperty("java.awt.headless", "true");
53
        System.setProperty("java.awt.headless", "true");
51
 
-
 
52
        TranslationManager.getInstance().addTranslationStreamFromClass(MainFrame.class);
54
        TranslationManager.getInstance().addTranslationStreamFromClass(MainFrame.class);
53
        TranslationManager.getInstance().setLocale(Locale.getDefault());
55
        TranslationManager.getInstance().setLocale(Locale.getDefault());
-
 
56
        // TODO remove
54
        Configuration.setInstance(this.comptaPropsConfiguration);
57
        Configuration.setInstance(this.comptaPropsConfiguration);
55
 
-
 
56
        System.out.println("HeadlessOpenConcerto ready");
-
 
57
        System.out.println(
-
 
58
                "Connected to " + this.comptaPropsConfiguration.getServerIp() + " on " + this.comptaPropsConfiguration.getSystemRootName() + "/" + this.comptaPropsConfiguration.getSocieteBaseName());
-
 
59
        return this;
58
        return this;
60
    }
59
    }
61
 
60
 
62
    public ComptaPropsConfiguration getComptaPropsConfiguration() {
61
    public ComptaPropsConfiguration getComptaPropsConfiguration() {
63
        return this.comptaPropsConfiguration;
62
        return this.comptaPropsConfiguration;