OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
174 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.generationEcritures;
15
 
16
import org.openconcerto.sql.model.DBRoot;
17
import org.openconcerto.sql.model.SQLInsert;
177 ilm 18
import org.openconcerto.sql.model.SQLTable;
19
import org.openconcerto.sql.users.User;
174 ilm 20
 
21
import java.util.ArrayList;
22
import java.util.List;
23
 
24
public class Piece {
25
    private String nom;
26
    private List<Mouvement> mouvements = new ArrayList<>();
27
    private Number id;
28
 
29
    public Piece(String nom) {
30
        this.nom = nom;
31
    }
32
 
33
    public String getNom() {
34
        return nom;
35
    }
36
 
37
    public void add(Mouvement mouvement) {
38
        this.mouvements.add(mouvement);
39
        mouvement.setPiece(this);
40
    }
41
 
42
    public List<Mouvement> getMouvements() {
43
        return mouvements;
44
    }
45
 
177 ilm 46
    public SQLInsert createInsert(final DBRoot root, User user) {
174 ilm 47
        final SQLInsert insert = new SQLInsert();
177 ilm 48
        final SQLTable table = root.getTable("PIECE");
49
        insert.add(table.getField("NOM"), this.nom);
50
        insert.addCreationTrackedField(user, table);
174 ilm 51
        return insert;
52
    }
53
 
54
    public Number getId() {
55
        return this.id;
56
    }
57
 
58
    public void setId(Number id) {
59
        this.id = id;
60
    }
61
 
62
}