OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 174 Rev 177
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
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
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
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.
9
 * language governing permissions and limitations under the License.
10
 * 
10
 * 
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.erp.generationEcritures;
14
 package org.openconcerto.erp.generationEcritures;
15
 
15
 
16
import org.openconcerto.sql.model.DBRoot;
16
import org.openconcerto.sql.model.DBRoot;
17
import org.openconcerto.sql.model.SQLInsert;
17
import org.openconcerto.sql.model.SQLInsert;
-
 
18
import org.openconcerto.sql.model.SQLTable;
-
 
19
import org.openconcerto.sql.users.User;
18
 
20
 
19
import java.util.ArrayList;
21
import java.util.ArrayList;
20
import java.util.List;
22
import java.util.List;
21
 
23
 
22
public class Piece {
24
public class Piece {
23
    private String nom;
25
    private String nom;
24
    private List<Mouvement> mouvements = new ArrayList<>();
26
    private List<Mouvement> mouvements = new ArrayList<>();
25
    private Number id;
27
    private Number id;
26
 
28
 
27
    public Piece(String nom) {
29
    public Piece(String nom) {
28
        this.nom = nom;
30
        this.nom = nom;
29
    }
31
    }
30
 
32
 
31
    public String getNom() {
33
    public String getNom() {
32
        return nom;
34
        return nom;
33
    }
35
    }
34
 
36
 
35
    public void add(Mouvement mouvement) {
37
    public void add(Mouvement mouvement) {
36
        this.mouvements.add(mouvement);
38
        this.mouvements.add(mouvement);
37
        mouvement.setPiece(this);
39
        mouvement.setPiece(this);
38
    }
40
    }
39
 
41
 
40
    public List<Mouvement> getMouvements() {
42
    public List<Mouvement> getMouvements() {
41
        return mouvements;
43
        return mouvements;
42
    }
44
    }
43
 
45
 
44
    public SQLInsert createInsert(final DBRoot root) {
46
    public SQLInsert createInsert(final DBRoot root, User user) {
45
        final SQLInsert insert = new SQLInsert();
47
        final SQLInsert insert = new SQLInsert();
-
 
48
        final SQLTable table = root.getTable("PIECE");
46
        insert.add(root.getTable("PIECE").getField("NOM"), this.nom);
49
        insert.add(table.getField("NOM"), this.nom);
-
 
50
        insert.addCreationTrackedField(user, table);
47
        return insert;
51
        return insert;
48
    }
52
    }
49
 
53
 
50
    public Number getId() {
54
    public Number getId() {
51
        return this.id;
55
        return this.id;
52
    }
56
    }
53
 
57
 
54
    public void setId(Number id) {
58
    public void setId(Number id) {
55
        this.id = id;
59
        this.id = id;
56
    }
60
    }
57
 
61
 
58
}
62
}