OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 18 | Details | Compare with Previous | 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.element.objet;
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
180 ilm 17
import org.openconcerto.sql.model.DBRoot;
18 ilm 18
import org.openconcerto.sql.model.SQLSelect;
19
import org.openconcerto.sql.model.SQLTable;
20
 
21
import java.util.ArrayList;
22
import java.util.List;
23
import java.util.Map;
24
 
25
public class ClasseCompte {
26
    private int id;
27
    private String nom;
28
    private String typeNumeroCompte;
29
 
30
    private static List<ClasseCompte> liste;
31
 
180 ilm 32
    public static void loadClasseCompte(ComptaPropsConfiguration conf) {
33
        DBRoot base = conf.getRootSociete();
18 ilm 34
 
35
        SQLTable classeCompteTable = base.getTable("CLASSE_COMPTE");
36
 
180 ilm 37
        SQLSelect selClasse = new SQLSelect();
18 ilm 38
 
39
        selClasse.addSelect(classeCompteTable.getField("ID"));
40
        selClasse.addSelect(classeCompteTable.getField("NOM"));
41
        selClasse.addSelect(classeCompteTable.getField("TYPE_NUMERO_COMPTE"));
42
 
43
        selClasse.addRawOrder("\"CLASSE_COMPTE\".\"TYPE_NUMERO_COMPTE\"");
44
 
45
        String reqClasse = selClasse.asString();
46
        System.err.println(reqClasse);
180 ilm 47
        List<Map<String, Object>> obClasse = base.getDBSystemRoot().getDataSource().execute(reqClasse);
18 ilm 48
        liste = new ArrayList<ClasseCompte>();
49
        for (Map<String, Object> map : obClasse) {
50
 
51
            liste.add(new ClasseCompte(Integer.parseInt(map.get("ID").toString()), map.get("NOM").toString(), map.get("TYPE_NUMERO_COMPTE").toString()));
52
 
53
        }
54
    }
55
 
56
    public static List<ClasseCompte> getClasseCompte() {
57
        return liste;
58
    }
59
 
60
    public ClasseCompte(final int id, final String nom, final String typeNumeroCompte) {
61
        this.id = id;
62
        this.nom = nom;
63
        this.typeNumeroCompte = typeNumeroCompte;
64
    }
65
 
66
    public int getId() {
67
        return this.id;
68
    }
69
 
70
    public String getNom() {
71
        return this.nom;
72
    }
73
 
74
    public String getTypeNumeroCompte() {
75
        return this.typeNumeroCompte;
76
    }
77
 
78
    public void setId(final int id) {
79
        this.id = id;
80
    }
81
 
82
    public void setNom(final String nom) {
83
        this.nom = nom;
84
    }
85
 
86
    public void setTypeNumeroCompte(final String type) {
87
        this.typeNumeroCompte = type;
88
    }
89
 
90
    @Override
91
    public String toString() {
92
        return "ID : " + this.id + " nom : " + this.nom + " type numero de compte : " + this.typeNumeroCompte;
93
    }
94
}