Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixLongitudinalAvSectorFacet.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 | e4606eae8ea5 |
children |
rev | line source |
---|---|
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
5994
af13ceeba52a
Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5867
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
5863
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4897a58c8746
River artifacts: Added new copyright headers.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
9 package org.dive4elements.river.artifacts.model.fixings; |
3610 | 10 |
9726 | 11 import org.apache.logging.log4j.Logger; |
12 import org.apache.logging.log4j.LogManager; | |
3610 | 13 |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
14 import org.dive4elements.artifacts.Artifact; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
15 import org.dive4elements.artifacts.CallContext; |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
16 import org.dive4elements.river.artifacts.D4EArtifact; |
5831
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
17 import org.dive4elements.river.artifacts.model.CalculationResult; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
18 import org.dive4elements.river.artifacts.model.DataFacet; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
19 import org.dive4elements.river.artifacts.model.FacetTypes; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
20 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
bd047b71ab37
Repaired internal references
Sascha L. Teichmann <teichmann@intevation.de>
parents:
3610
diff
changeset
|
21 import org.dive4elements.river.utils.KMIndex; |
3610 | 22 |
23 public class FixLongitudinalAvSectorFacet | |
24 extends DataFacet | |
25 implements FacetTypes { | |
26 | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
27 /** House log. */ |
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
28 private static Logger log = |
9726 | 29 LogManager.getLogger(FixLongitudinalAvSectorFacet.class); |
3610 | 30 |
31 /** Trivial Constructor. */ | |
32 public FixLongitudinalAvSectorFacet() { | |
33 } | |
34 | |
35 | |
36 public FixLongitudinalAvSectorFacet( | |
37 int ndx, | |
38 String name, | |
39 String description) | |
40 { | |
41 super( | |
42 ndx, | |
43 name, | |
44 description, | |
45 ComputeType.ADVANCE, | |
46 null, | |
47 null); | |
48 } | |
49 | |
50 | |
51 /** | |
52 * Returns the data this facet requires. | |
53 * | |
54 * @param artifact the owner artifact. | |
55 * @param context the CallContext. | |
56 * | |
57 * @return the data as KMIndex. | |
58 */ | |
59 @Override | |
60 public Object getData(Artifact artifact, CallContext context) { | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
61 log.debug("FixLongitudinalAvSectorFacet.getData"); |
3610 | 62 |
5867
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
63 if (artifact instanceof D4EArtifact) { |
59ff03ff48f1
River artifacts: Renamed FLYSArtifact(Collection) to D4EArtifact(Collection).
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5863
diff
changeset
|
64 D4EArtifact flys = (D4EArtifact)artifact; |
3610 | 65 |
66 CalculationResult res = | |
67 (CalculationResult) flys.compute(context, | |
68 ComputeType.ADVANCE, | |
69 false); | |
70 | |
71 FixAnalysisResult result = (FixAnalysisResult) res.getData(); | |
72 | |
73 KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods(); | |
74 if (kmPeriods == null) { | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
75 log.warn("No analysis periods found."); |
3610 | 76 return null; |
77 } | |
78 int periodNdx = index >> 2; | |
79 KMIndex<AnalysisPeriod> resPeriods = | |
80 new KMIndex<AnalysisPeriod>(); | |
81 for (KMIndex.Entry<AnalysisPeriod[]> entry: kmPeriods) { | |
82 AnalysisPeriod ap = entry.getValue()[periodNdx]; | |
83 resPeriods.add(entry.getKm(), ap); | |
84 } | |
85 | |
86 return resPeriods; | |
87 } | |
88 else { | |
8202
e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5994
diff
changeset
|
89 log.warn("Artifact is no instance of D4EArtifact."); |
3610 | 90 return null; |
91 } | |
92 } | |
93 | |
94 | |
95 /** | |
96 * Create a deep copy of this Facet. | |
97 * @return a deep copy. | |
98 */ | |
99 @Override | |
100 public FixLongitudinalAvSectorFacet deepCopy() { | |
101 FixLongitudinalAvSectorFacet copy = new FixLongitudinalAvSectorFacet(); | |
102 copy.set(this); | |
103 return copy; | |
104 } | |
105 } | |
106 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |