comparison flys-artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixLongitudinalAvSectorFacet.java @ 5831:bd047b71ab37

Repaired internal references
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 12:06:39 +0200
parents flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalAvSectorFacet.java@66f539df4e8b
children
comparison
equal deleted inserted replaced
5830:160f53ee0870 5831:bd047b71ab37
1 package org.dive4elements.river.artifacts.model.fixings;
2
3 import org.apache.log4j.Logger;
4
5 import org.dive4elements.artifacts.Artifact;
6 import org.dive4elements.artifacts.CallContext;
7 import org.dive4elements.river.artifacts.FLYSArtifact;
8 import org.dive4elements.river.artifacts.model.CalculationResult;
9 import org.dive4elements.river.artifacts.model.DataFacet;
10 import org.dive4elements.river.artifacts.model.FacetTypes;
11 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
12 import org.dive4elements.river.utils.KMIndex;
13
14 public class FixLongitudinalAvSectorFacet
15 extends DataFacet
16 implements FacetTypes {
17
18 /** House logger. */
19 private static Logger logger =
20 Logger.getLogger(FixLongitudinalAvSectorFacet.class);
21
22 /** Trivial Constructor. */
23 public FixLongitudinalAvSectorFacet() {
24 }
25
26
27 public FixLongitudinalAvSectorFacet(
28 int ndx,
29 String name,
30 String description)
31 {
32 super(
33 ndx,
34 name,
35 description,
36 ComputeType.ADVANCE,
37 null,
38 null);
39 }
40
41
42 /**
43 * Returns the data this facet requires.
44 *
45 * @param artifact the owner artifact.
46 * @param context the CallContext.
47 *
48 * @return the data as KMIndex.
49 */
50 @Override
51 public Object getData(Artifact artifact, CallContext context) {
52 logger.debug("FixLongitudinalAvSectorFacet.getData");
53
54 if (artifact instanceof FLYSArtifact) {
55 FLYSArtifact flys = (FLYSArtifact)artifact;
56
57 CalculationResult res =
58 (CalculationResult) flys.compute(context,
59 ComputeType.ADVANCE,
60 false);
61
62 FixAnalysisResult result = (FixAnalysisResult) res.getData();
63
64 KMIndex<AnalysisPeriod []> kmPeriods = result.getAnalysisPeriods();
65 if (kmPeriods == null) {
66 logger.warn("No analysis periods found.");
67 return null;
68 }
69 int periodNdx = index >> 2;
70 KMIndex<AnalysisPeriod> resPeriods =
71 new KMIndex<AnalysisPeriod>();
72 for (KMIndex.Entry<AnalysisPeriod[]> entry: kmPeriods) {
73 AnalysisPeriod ap = entry.getValue()[periodNdx];
74 resPeriods.add(entry.getKm(), ap);
75 }
76
77 return resPeriods;
78 }
79 else {
80 logger.warn("Artifact is no instance of FLYSArtifact.");
81 return null;
82 }
83 }
84
85
86 /**
87 * Create a deep copy of this Facet.
88 * @return a deep copy.
89 */
90 @Override
91 public FixLongitudinalAvSectorFacet deepCopy() {
92 FixLongitudinalAvSectorFacet copy = new FixLongitudinalAvSectorFacet();
93 copy.set(this);
94 return copy;
95 }
96 }
97 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org