Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixLongitudinalAvSectorFacet.java @ 3610:66f539df4e8b
Issue 716.
FixA: Spilt reference and analysis period themes into one theme for each event.
flys-artifacts/trunk@5239 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 23 Aug 2012 08:49:37 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3609:a16837d73130 | 3610:66f539df4e8b |
---|---|
1 package de.intevation.flys.artifacts.model.fixings; | |
2 | |
3 import org.apache.log4j.Logger; | |
4 | |
5 import de.intevation.artifacts.Artifact; | |
6 import de.intevation.artifacts.CallContext; | |
7 import de.intevation.flys.artifacts.FLYSArtifact; | |
8 import de.intevation.flys.artifacts.model.CalculationResult; | |
9 import de.intevation.flys.artifacts.model.DataFacet; | |
10 import de.intevation.flys.artifacts.model.FacetTypes; | |
11 import de.intevation.flys.artifacts.states.DefaultState.ComputeType; | |
12 import de.intevation.flys.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 : |