OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 147 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
106 ilm 1
package org.openconcerto.modules.humanresources.travel.expense;
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.MenuContext;
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_EXPENSE = "EXPENSE";
25
    public static final String TABLE_EXPENSE_STATE = "EXPENSE_STATE";
26
 
27
    public Module(ModuleFactory f) throws IOException {
28
        super(f);
29
    }
30
 
31
    @Override
32
    protected void install(DBContext ctxt) {
33
        // TODO use version to upgrade
34
        if (!ctxt.getTablesPreviouslyCreated().contains(TABLE_EXPENSE)) {
35
            final SQLCreateTable createTableState = ctxt.getCreateTable(TABLE_EXPENSE_STATE);
36
            createTableState.addVarCharColumn("NAME", 128);
37
 
38
            final SQLCreateTable createTable = ctxt.getCreateTable(TABLE_EXPENSE);
39
            createTable.addForeignColumn("ID_USER_COMMON", ctxt.getRoot().findTable("USER_COMMON"));
40
            createTable.addDateAndTimeColumn("DATE");
41
            createTable.addVarCharColumn("DESCRIPTION", 1024);
42
            createTable.addNumberColumn("TRAVEL_DISTANCE", Float.class, 0f, false);
43
            createTable.addNumberColumn("TRAVEL_RATE", Float.class, 0f, false);
44
            createTable.addLongColumn("TRAVEL_AMOUNT", 0L, false);
45
            createTable.addLongColumn("MISC_AMOUNT", 0L, false);
46
            createTable.addForeignColumn(createTableState);
47
        }
48
    }
49
 
50
    @Override
51
    protected void setupElements(SQLElementDirectory dir) {
52
        super.setupElements(dir);
53
        GlobalMapper.getInstance().map(ExpenseSQLElement.ELEMENT_CODE + ".default", new ExpenseGroup());
54
        GlobalMapper.getInstance().map(ExpenseStateSQLElement.ELEMENT_CODE + ".default", new ExpenseStateGroup());
55
        dir.addSQLElement(new ExpenseSQLElement());
56
        dir.addSQLElement(new ExpenseStateSQLElement());
147 ilm 57
        dir.getShowAs().show(Module.TABLE_EXPENSE_STATE, "NAME");
106 ilm 58
    }
59
 
60
    @Override
61
    protected void setupComponents(ComponentsContext ctxt) {
62
 
63
    }
64
 
65
    @Override
66
    protected void setupMenu(MenuContext ctxt) {
67
        ctxt.addMenuItem(ctxt.createListAction(TABLE_EXPENSE), MainFrame.LIST_MENU);
68
    }
69
 
70
    @Override
71
    protected void start() {
72
    }
73
 
74
    @Override
75
    protected void stop() {
76
    }
77
 
78
}