OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
140 ilm 1
/*
2
 * Créé le 5 nov. 2012
3
 */
4
package org.openconcerto.modules.customerrelationship.lead;
5
 
181 ilm 6
import java.util.Date;
7
 
140 ilm 8
import org.openconcerto.sql.Configuration;
9
import org.openconcerto.sql.model.SQLInjector;
10
import org.openconcerto.sql.model.SQLRowAccessor;
11
import org.openconcerto.sql.model.SQLRowValues;
12
import org.openconcerto.sql.model.SQLTable;
13
 
14
public class LeadCustomerSQLInjector extends SQLInjector {
15
 
16
    private final static SQLTable customerTable = Configuration.getInstance().getDirectory().getElement("CLIENT").getTable();
17
    private static final SQLTable leadTable = Configuration.getInstance().getDirectory().getElement(Module.TABLE_LEAD).getTable();
18
 
19
    public LeadCustomerSQLInjector() {
20
        super(leadTable, customerTable, false);
21
        createDefaultMap();
22
        map(leadTable.getField("NAME"), customerTable.getField("RESPONSABLE"));
23
        map(leadTable.getField("COMPANY"), customerTable.getField("NOM"));
24
        map(leadTable.getField("PHONE"), customerTable.getField("TEL"));
25
        map(leadTable.getField("MOBILE"), customerTable.getField("TEL_P"));
26
        map(leadTable.getField("FAX"), customerTable.getField("FAX"));
27
        map(leadTable.getField("EMAIL"), customerTable.getField("MAIL"));
28
        map(leadTable.getField("MOBILE"), customerTable.getField("TEL_P"));
29
        // map(leadTable.getField("INFORMATION"), customerTable.getField("INFOS"));
30
        map(getSource().getField("INFOS"), getDestination().getField("INFOS"));
181 ilm 31
        remove(leadTable.getField("DATE"), customerTable.getField("DATE"));
32
        mapDefaultValues(customerTable.getField("DATE"), new Date());
140 ilm 33
        remove(leadTable.getField("ID_ADRESSE"), customerTable.getField("ID_ADRESSE"));
34
    }
35
 
36
    @Override
37
    protected void merge(SQLRowAccessor srcRow, SQLRowValues rowVals) {
38
        // TODO Auto-generated method stub
39
        super.merge(srcRow, rowVals);
40
        if (rowVals.getString("NOM") == null || rowVals.getString("NOM").trim().length() == 0) {
41
            rowVals.put("NOM", srcRow.getString("NAME"));
42
        }
43
    }
44
}