OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 30 | Rev 87 | 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);
69
        GlobalMapper.getInstance().map("customerrelationship.lead.default", new LeadGroup());
70
        final LeadSQLElement element = new LeadSQLElement();
71
        dir.addSQLElement(element);
72
 
73
    }
74
 
75
    @Override
76
    protected void setupComponents(ComponentsContext ctxt) {
77 ilm 77
 
78
    }
79
 
80
    @Override
81
    protected void setupMenu(MenuContext ctxt) {
30 ilm 82
        ctxt.addMenuItem(ctxt.createListAction(TABLE_LEAD), MainFrame.LIST_MENU);
83
    }
84
 
85
    @Override
86
    protected void start() {
87
    }
88
 
89
    @Override
90
    protected void stop() {
91
    }
92
 
93
    public static void main(String[] args) throws IOException {
94
        System.setProperty(ConnexionPanel.QUICK_LOGIN, "true");
95
        final File propsFile = new File("module.properties");
96
        System.out.println(propsFile.getAbsolutePath());
97
        final ModuleFactory factory = new RuntimeModuleFactory(propsFile);
98
        SQLRequestLog.setEnabled(true);
99
        SQLRequestLog.showFrame();
100
        // uncomment to create and use the jar
101
        final ModulePackager modulePackager = new ModulePackager(propsFile, new File("bin/"));
102
        modulePackager.writeToDir(new File("../OpenConcerto/Modules"));
103
        // final ModuleFactory factory = new JarModuleFactory(jar);
104
        ModuleManager.getInstance().addFactories(new File("../OpenConcerto/Modules"));
105
        ModuleManager.getInstance().addFactoryAndStart(factory, false);
106
        Gestion.main(args);
107
    }
108
 
109
}