OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev 94 Rev 174
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.injector;
14
 package org.openconcerto.erp.injector;
15
 
15
 
16
import org.openconcerto.sql.model.DBRoot;
16
import org.openconcerto.sql.model.DBRoot;
17
import org.openconcerto.sql.model.SQLInjector;
17
import org.openconcerto.sql.model.SQLInjector;
18
import org.openconcerto.sql.model.SQLRowAccessor;
18
import org.openconcerto.sql.model.SQLRowAccessor;
19
import org.openconcerto.sql.model.SQLRowValues;
19
import org.openconcerto.sql.model.SQLRowValues;
20
import org.openconcerto.sql.model.SQLTable;
20
import org.openconcerto.sql.model.SQLTable;
21
 
21
 
22
import java.math.BigDecimal;
22
import java.math.BigDecimal;
23
import java.util.Collection;
23
import java.util.Collection;
24
 
24
 
25
public class CommandeFactureFournisseurSQLInjector extends SQLInjector {
25
public class CommandeFactureFournisseurSQLInjector extends SQLInjector {
26
    public CommandeFactureFournisseurSQLInjector(final DBRoot root) {
26
    public CommandeFactureFournisseurSQLInjector(final DBRoot root) {
27
        super(root, "COMMANDE", "FACTURE_FOURNISSEUR", true);
27
        super(root, "COMMANDE", "FACTURE_FOURNISSEUR", true);
28
        map(getSource().getField("ID_FOURNISSEUR"), getDestination().getField("ID_FOURNISSEUR"));
28
        map(getSource().getField("ID_FOURNISSEUR"), getDestination().getField("ID_FOURNISSEUR"));
29
        map(getSource().getField("NOM"), getDestination().getField("NOM"));
29
        map(getSource().getField("NOM"), getDestination().getField("NOM"));
30
        map(getSource().getField("INFOS"), getDestination().getField("INFOS"));
30
        map(getSource().getField("INFOS"), getDestination().getField("INFOS"));
31
    }
31
    }
32
 
32
 
33
    @Override
33
    @Override
34
    protected void merge(SQLRowAccessor srcRow, SQLRowValues rowVals) {
34
    protected void merge(SQLRowAccessor srcRow, SQLRowValues rowVals) {
35
        super.merge(srcRow, rowVals);
35
        super.merge(srcRow, rowVals);
36
 
36
 
37
        // Merge elements
37
        // Merge elements
38
        final SQLTable tableElementSource = getSource().getTable("COMMANDE_ELEMENT");
38
        final SQLTable tableElementSource = getSource().getTable("COMMANDE_ELEMENT");
39
        final SQLTable tableElementDestination = getSource().getTable("FACTURE_FOUNRISSEUR_ELEMENT");
39
        final SQLTable tableElementDestination = getSource().getTable("FACTURE_FOURNISSEUR_ELEMENT");
40
        final Collection<? extends SQLRowAccessor> myListItem = srcRow.asRow().getReferentRows(tableElementSource);
40
        final Collection<? extends SQLRowAccessor> myListItem = srcRow.asRow().getReferentRows(tableElementSource);
41
        transfertReference(srcRow, rowVals, "NOM", "NOM");
-
 
42
        transfertReference(srcRow, rowVals, "INFOS", "INFOS");
-
 
43
        transfertNumberReference(srcRow, rowVals, tableElementDestination, "ID_FACTURE_FOURNISSEUR");
41
        transfertNumberReference(srcRow, rowVals, tableElementDestination, "ID_FACTURE_FOURNISSEUR");
-
 
42
        transfertReference(srcRow, rowVals, tableElementDestination, "ID_FACTURE_FOURNISSEUR", "NOM", "NOM");
-
 
43
        transfertReference(srcRow, rowVals, tableElementDestination, "ID_FACTURE_FOURNISSEUR", "INFOS", "INFOS");
44
        if (myListItem.size() != 0) {
44
        if (myListItem.size() != 0) {
45
            final SQLInjector injector = SQLInjector.getInjector(tableElementSource, tableElementDestination);
45
            final SQLInjector injector = SQLInjector.getInjector(tableElementSource, tableElementDestination);
46
            for (SQLRowAccessor rowElt : myListItem) {
46
            for (SQLRowAccessor rowElt : myListItem) {
47
                final SQLRowValues createRowValuesFrom = injector.createRowValuesFrom(rowElt.asRow());
47
                final SQLRowValues createRowValuesFrom = injector.createRowValuesFrom(rowElt.asRow());
48
                if (createRowValuesFrom.getTable().getFieldsName().contains("POURCENT_ACOMPTE")) {
48
                if (createRowValuesFrom.getTable().getFieldsName().contains("POURCENT_ACOMPTE")) {
49
                    if (createRowValuesFrom.getObject("POURCENT_ACOMPTE") == null) {
49
                    if (createRowValuesFrom.getObject("POURCENT_ACOMPTE") == null) {
50
                        createRowValuesFrom.put("POURCENT_ACOMPTE", new BigDecimal(100.0));
50
                        createRowValuesFrom.put("POURCENT_ACOMPTE", new BigDecimal(100.0));
51
                    }
51
                    }
52
                }
52
                }
53
                createRowValuesFrom.put("ID_FACTURE_FOURNISSEUR", rowVals);
53
                createRowValuesFrom.put("ID_FACTURE_FOURNISSEUR", rowVals);
54
            }
54
            }
55
        }
55
        }
56
    }
56
    }
57
 
57
 
58
}
58
}