OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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