annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/RankRemapper.java @ 9726:0a5239a1e46e 3.2.x

Upgrade to Log4j 2
author Tom Gottfried <tom@intevation.de>
date Wed, 02 Mar 2022 10:26:50 +0100
parents 8efef772a488
children
rev   line source
6891
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
3 *
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
7 */
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
8
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.artifacts.model.fixings;
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
10
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
11 import java.util.IdentityHashMap;
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
12
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 6891
diff changeset
13 import org.apache.logging.log4j.Logger;
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 6891
diff changeset
14 import org.apache.logging.log4j.LogManager;
6891
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
15
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
16 import gnu.trove.TIntIntHashMap;
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
17
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
18 public class RankRemapper {
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
19
9726
0a5239a1e46e Upgrade to Log4j 2
Tom Gottfried <tom@intevation.de>
parents: 6891
diff changeset
20 private static Logger log = LogManager.getLogger(RankRemapper.class);
6891
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
21
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
22 private TIntIntHashMap index2rank;
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
23 private IdentityHashMap<QWI, Boolean> visited;
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
24
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
25 public RankRemapper() {
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
26 index2rank = new TIntIntHashMap();
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
27 visited = new IdentityHashMap<QWI, Boolean>();
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
28 }
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
29
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
30 public void toMap(int index) {
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
31 index2rank.put(index, index2rank.size());
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
32 }
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
33
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
34 public <I extends QWI> void remap(I qwi) {
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
35 if (!visited.containsKey(qwi)) {
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
36 int idx = qwi.index;
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
37 if (index2rank.containsKey(idx)) {
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
38 qwi.index = index2rank.get(idx);
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
39 } else if (log.isDebugEnabled()) {
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
40 log.debug("Cannot remap " + idx);
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
41 }
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
42 visited.put(qwi, true);
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
43 }
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
44 }
8efef772a488 FixA: Remapped indices of analysis periods, too. Needs testing!
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
45 }

http://dive4elements.wald.intevation.org