OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 77 | Rev 140 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
30 ilm 1
package org.openconcerto.modules.customerrelationship.lead;
2
 
3
import java.io.File;
4
import java.io.IOException;
5
 
6
import org.openconcerto.erp.config.Gestion;
7
import org.openconcerto.erp.config.MainFrame;
8
import org.openconcerto.erp.modules.AbstractModule;
9
import org.openconcerto.erp.modules.ComponentsContext;
10
import org.openconcerto.erp.modules.DBContext;
77 ilm 11
import org.openconcerto.erp.modules.MenuContext;
30 ilm 12
import org.openconcerto.erp.modules.ModuleFactory;
13
import org.openconcerto.erp.modules.ModuleManager;
14
import org.openconcerto.erp.modules.ModulePackager;
15
import org.openconcerto.erp.modules.RuntimeModuleFactory;
16
import org.openconcerto.sql.element.GlobalMapper;
17
import org.openconcerto.sql.element.SQLElementDirectory;
18
import org.openconcerto.sql.model.SQLRequestLog;
19
import org.openconcerto.sql.ui.ConnexionPanel;
20
import org.openconcerto.sql.utils.SQLCreateTable;
21
 
22
public final class Module extends AbstractModule {
23
 
24
    public static final String TABLE_LEAD = "LEAD";
25
 
26
    public Module(ModuleFactory f) throws IOException {
27
        super(f);
28
    }
29
 
30
    @Override
31
    protected void install(DBContext ctxt) {
32
        super.install(ctxt);
33
        // TODO use version to upgrade
77 ilm 34
        if (ctxt.getRoot().getTable(TABLE_LEAD) == null) {
30 ilm 35
            final SQLCreateTable createTable = ctxt.getCreateTable(TABLE_LEAD);
36
 
37
            createTable.addVarCharColumn("NUMBER", 20);
38
            createTable.addDateAndTimeColumn("DATE");
39
            createTable.addVarCharColumn("FIRSTNAME", 64);
40
            createTable.addVarCharColumn("NAME", 64);
41
            createTable.addVarCharColumn("COMPANY", 64);
42
            //
43
            createTable.addVarCharColumn("PHONE", 16);
44
            createTable.addVarCharColumn("MOBILE", 16);
45
            createTable.addVarCharColumn("FAX", 16);
46
            createTable.addVarCharColumn("EMAIL", 32);
47
            createTable.addVarCharColumn("WEBSITE", 64);
48
            //
49
            createTable.addVarCharColumn("SOURCE", 200);
50
            createTable.addVarCharColumn("STATUS", 50);
51
            //
52
            createTable.addForeignColumn("ADRESSE");
53
            createTable.addForeignColumn("COMMERCIAL");
54
            //
55
            createTable.addVarCharColumn("INFORMATION", 512);
56
            //
57
            createTable.addVarCharColumn("INDUSTRY", 200);
58
            createTable.addVarCharColumn("RATING", 200);
59
 
60
            createTable.addIntegerColumn("REVENUE", 0);
61
            createTable.addIntegerColumn("EMPLOYEES", 0);
62
 
63
        }
64
    }
65
 
66
    @Override
67
    protected void setupElements(SQLElementDirectory dir) {
68
        super.setupElements(dir);
87 ilm 69
        final LeadSQLElement element = new LeadSQLElement(this);
70
        GlobalMapper.getInstance().map(element.getCode() + ".default", new LeadGroup());
30 ilm 71
        dir.addSQLElement(element);
72
    }
73
 
74
    @Override
75
    protected void setupComponents(ComponentsContext ctxt) {
77 ilm 76
 
77
    }
78
 
79
    @Override
80
    protected void setupMenu(MenuContext ctxt) {
30 ilm 81
        ctxt.addMenuItem(ctxt.createListAction(TABLE_LEAD), MainFrame.LIST_MENU);
82
    }
83
 
84
    @Override
85
    protected void start() {
86
    }
87
 
88
    @Override
89
    protected void stop() {
90
    }
91
 
92
    public static void main(String[] args) throws IOException {
93
        System.setProperty(ConnexionPanel.QUICK_LOGIN, "true");
94
        final File propsFile = new File("module.properties");
95
        System.out.println(propsFile.getAbsolutePath());
96
        final ModuleFactory factory = new RuntimeModuleFactory(propsFile);
97
        SQLRequestLog.setEnabled(true);
98
        SQLRequestLog.showFrame();
99
        // uncomment to create and use the jar
100
        final ModulePackager modulePackager = new ModulePackager(propsFile, new File("bin/"));
101
        modulePackager.writeToDir(new File("../OpenConcerto/Modules"));
102
        // final ModuleFactory factory = new JarModuleFactory(jar);
103
        ModuleManager.getInstance().addFactories(new File("../OpenConcerto/Modules"));
104
        ModuleManager.getInstance().addFactoryAndStart(factory, false);
105
        Gestion.main(args);
106
    }
107
 
108
}