OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
17 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.sql.view.list;
15
 
16
import org.openconcerto.sql.model.SQLTableEvent;
17
import org.openconcerto.sql.model.graph.Path;
18
import org.openconcerto.utils.CollectionMap;
19
 
20
import java.util.Collection;
21
 
22
final class UpdateOneRunnable extends AbstractUpdateOneRunnable {
23
    private final SQLTableEvent evt;
24
 
25
    public UpdateOneRunnable(ITableModel model, SQLTableEvent evt) {
26
        super(model, evt.getTable(), evt.getId());
27
        this.evt = evt;
28
    }
29
 
30
    public void run() {
31
        if (this.getTable() == this.getReq().getParent().getPrimaryTable()) {
32
            final ListSQLLine line = this.getReq().get(this.getID());
33
            // handle deleted rows (ie line == null) by using this.getID()
34
            if (line == null)
35
                this.getReq().fireLineChanged(this.getID(), line, null);
36
            else {
37
                final CollectionMap<Path, ListSQLLine> affectedPaths = this.getAffectedPaths();
38
                // the line should be in the list (since SQLTableModelLinesSource.get()
39
                // returned it), so if not yet part of the list add it.
40
                if (affectedPaths.getNonNull(new Path(getTable())).isEmpty())
41
                    line.clearCache();
42
                // then, update affectedPaths (it's not because the changed table is the primary
43
                // table, that it's not also referenced, eg CIRCUIT.ORIGINE)
44
                updateLines(affectedPaths);
45
            }
46
        } else {
47
            // eg CONTACT[3] has changed
48
            updateLines(this.getAffectedPaths());
49
        }
50
    }
51
 
52
    @Override
53
    protected Collection<String> getModifedFields() {
54
        return this.evt.getFieldNames();
55
    }
56
}