OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 21 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.core.customerrelationship.customer.element;
15
 
16
import org.openconcerto.sql.element.ConfSQLElement;
17
import org.openconcerto.sql.element.SQLComponent;
18
import org.openconcerto.sql.element.SQLElement;
19
import org.openconcerto.sql.element.UISQLComponent;
20
import org.openconcerto.sql.model.SQLRow;
21
import org.openconcerto.utils.CollectionMap;
22
 
23
import java.util.ArrayList;
24
import java.util.Collections;
25
import java.util.HashSet;
26
import java.util.List;
27
import java.util.Set;
28
 
29
public class ContactSQLElement extends ConfSQLElement {
30
 
31
    public ContactSQLElement() {
32
        super("CONTACT", "un contact", "contacts");
33
    }
34
 
35
    protected List<String> getListFields() {
36
        final List<String> l = new ArrayList<String>();
37
        l.add("NOM");
38
        l.add("PRENOM");
39
        l.add("FONCTION");
40
        if (getTable().contains("ID_CLIENT")) {
41
            l.add("ID_CLIENT");
42
        }
43
        l.add("TEL_STANDARD");
44
        l.add("TEL_DIRECT");
45
        return l;
46
    }
47
 
48
    protected List<String> getComboFields() {
49
        final List<String> l = new ArrayList<String>();
50
        l.add("NOM");
51
        l.add("PRENOM");
52
        l.add("FONCTION");
53
        if (getTable().contains("ID_SITE"))
54
            l.add("ID_SITE");
55
        if (getTable().contains("ID_CLIENT"))
56
            l.add("ID_CLIENT");
57
        return l;
58
    }
59
 
60
    @Override
61
    public CollectionMap<String, String> getShowAs() {
62
        return CollectionMap.singleton(null, "NOM", "TEL_STANDARD");
63
    }
64
 
65
    /*
66
     * (non-Javadoc)
67
     *
68
     * @see org.openconcerto.devis.SQLElement#getComponent()
69
     */
70
    public SQLComponent createComponent() {
71
        return new ContactSQLComponent(this);
72
    }
73
 
74
    public static class ContactSQLComponent extends UISQLComponent {
75
 
76
        public ContactSQLComponent(SQLElement elt) {
77
            super(elt);
78
        }
79
 
80
        @Override
81
        protected Set<String> createRequiredNames() {
82
            final Set<String> s = new HashSet<String>();
83
            s.add("NOM");
84
            return s;
85
        }
86
 
87
        public void addViews() {
88
            if (getTable().contains("ID_CLIENT")) {
89
                this.addView("ID_CLIENT");
90
            }
91
            if (getTable().contains("ID_TITRE_PERSONNEL")) {
92
                this.addView("ID_TITRE_PERSONNEL", "1");
93
                this.addView("NOM", "1");
94
                this.addView("PRENOM", "1");
95
            } else {
96
                this.addView("NOM", "left");
97
                this.addView("PRENOM", "right");
98
            }
99
 
100
            this.addView("FONCTION", "1");
101
 
102
            if (getTable().contains("ID_SITE"))
103
                this.addView("ID_SITE");
104
 
105
            if (getTable().contains("ACTIF"))
106
                this.addView("ACTIF");
107
 
108
            if (getTable().contains("SUFFIXE"))
109
                this.addView("SUFFIXE");
110
 
111
            this.addView("TEL_STANDARD", "left");
112
            this.addView("TEL_DIRECT", "right");
113
 
114
            this.addView("TEL_MOBILE", "left");
115
            this.addView("TEL_PERSONEL", "right");
116
 
117
            this.addView("FAX", "left");
118
            this.addView("EMAIL", "right");
119
 
120
            if (getTable().contains("SERVICE"))
121
                this.addView("SERVICE");
122
 
123
            if (getTable().contains("NOM_ASSISTANTE"))
124
                this.addView("NOM_ASSISTANTE");
125
 
126
            if (getTable().contains("EMAIL_ASSISTANTE"))
127
                this.addView("EMAIL_ASSISTANTE");
128
 
129
            if (getTable().contains("TEL_ASSISTANTE"))
130
                this.addView("TEL_ASSISTANTE");
131
 
132
            if (getTable().contains("NOM_RESPONSABLE"))
133
                this.addView("NOM_RESPONSABLE");
134
 
135
        }
136
 
137
        public void setIdClient(int idClient) {
138
            if (idClient != SQLRow.NONEXISTANT_ID) {
139
                this.setDefaults(Collections.singletonMap("ID_CLIENT", idClient));
140
            } else {
141
                this.clearDefaults();
142
            }
143
        }
144
    }
145
 
146
}