OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 182
Line 1... Line 1...
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-2019 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.
Line 27... Line 27...
27
import org.openconcerto.utils.ListMap;
27
import org.openconcerto.utils.ListMap;
28
import org.openconcerto.utils.Value;
28
import org.openconcerto.utils.Value;
29
import org.openconcerto.utils.cc.ITransformer;
29
import org.openconcerto.utils.cc.ITransformer;
30
 
30
 
31
import java.util.Collection;
31
import java.util.Collection;
-
 
32
import java.util.HashSet;
32
import java.util.List;
33
import java.util.List;
33
import java.util.Map.Entry;
34
import java.util.Map.Entry;
-
 
35
import java.util.Set;
34
 
36
 
35
abstract class AbstractUpdateOneRunnable extends UpdateRunnable {
37
abstract class AbstractUpdateOneRunnable extends UpdateRunnable {
36
 
38
 
37
    public AbstractUpdateOneRunnable(ITableModel model, final SQLRow r) {
39
    public AbstractUpdateOneRunnable(ITableModel model, final SQLRow r) {
38
        super(model, r);
40
        super(model, r);
Line 132... Line 134...
132
                }
134
                }
133
            }
135
            }
134
        }
136
        }
135
    }
137
    }
136
 
138
 
-
 
139
    protected final void updateLines(final Set<Integer> affectedLines, final Integer primaryID) {
-
 
140
        final Set<Integer> idsToFetch;
-
 
141
        if (primaryID != null && !affectedLines.contains(primaryID)) {
-
 
142
            idsToFetch = new HashSet<>(affectedLines);
-
 
143
            idsToFetch.add(primaryID);
-
 
144
        } else {
-
 
145
            idsToFetch = affectedLines;
-
 
146
        }
-
 
147
        final List<ListSQLLine> newLines = getModel().getLinesSource().get(idsToFetch);
-
 
148
 
-
 
149
        final Set<Integer> notUpdated = new HashSet<>(affectedLines);
-
 
150
        synchronized (this.getUpdateQ().getFullList()) {
-
 
151
            for (final ListSQLLine newLine : newLines) {
-
 
152
                this.getUpdateQ().replaceLine(newLine.getID(), newLine);
-
 
153
                notUpdated.remove(newLine.getID());
-
 
154
            }
-
 
155
            for (final Integer toRemove : notUpdated) {
-
 
156
                this.getUpdateQ().replaceLine(toRemove, null);
-
 
157
            }
-
 
158
        }
-
 
159
    }
-
 
160
 
137
    protected abstract Collection<String> getModifedFields();
161
    protected abstract Collection<String> getModifedFields();
138
}
162
}