Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/MiddleBedHeight.java @ 3468:f37e7e8907cb
merged flys-artifacts/2.8.1
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:39 +0200 |
parents | cdbc457e23e2 |
children | 6bfed02f025f |
comparison
equal
deleted
inserted
replaced
3387:5ffad8bde8ad | 3468:f37e7e8907cb |
---|---|
1 package de.intevation.flys.artifacts.states; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 | |
8 import de.intevation.artifacts.CallContext; | |
9 | |
10 import de.intevation.artifactdatabase.state.Facet; | |
11 | |
12 import de.intevation.flys.artifacts.FLYSArtifact; | |
13 import de.intevation.flys.artifacts.access.BedHeightAccess; | |
14 import de.intevation.flys.artifacts.model.CalculationResult; | |
15 import de.intevation.flys.artifacts.model.DataFacet; | |
16 import de.intevation.flys.artifacts.model.FacetTypes; | |
17 import de.intevation.flys.artifacts.model.MiddleBedHeightData; | |
18 import de.intevation.flys.artifacts.model.MiddleBedHeightFacet; | |
19 import de.intevation.flys.artifacts.model.MiddleBedHeightCalculation; | |
20 | |
21 | |
22 public class MiddleBedHeight extends DefaultState implements FacetTypes { | |
23 | |
24 private static final Logger logger = Logger.getLogger(MiddleBedHeight.class); | |
25 | |
26 | |
27 @Override | |
28 public Object computeAdvance( | |
29 FLYSArtifact artifact, | |
30 String hash, | |
31 CallContext context, | |
32 List<Facet> facets, | |
33 Object old | |
34 ) { | |
35 logger.debug("MiddleBedHeight.computeAdvance"); | |
36 | |
37 List<Facet> newFacets = new ArrayList<Facet>(); | |
38 | |
39 BedHeightAccess access = new BedHeightAccess(artifact); | |
40 | |
41 CalculationResult res = old instanceof CalculationResult | |
42 ? (CalculationResult) old | |
43 : new MiddleBedHeightCalculation().calculate(access); | |
44 | |
45 if (facets == null || res == null) { | |
46 return res; | |
47 } | |
48 | |
49 MiddleBedHeightData[] data = (MiddleBedHeightData[]) res.getData(); | |
50 | |
51 logger.debug("Calculated " + data.length + " MiddleBedHeightData objects"); | |
52 | |
53 String id = getID(); | |
54 int idx = 0; | |
55 | |
56 for (MiddleBedHeightData d: data) { | |
57 if (d.getStartYear() == d.getEndYear()) { | |
58 newFacets.add(new MiddleBedHeightFacet( | |
59 idx, | |
60 MIDDLE_BED_HEIGHT_SINGLE, | |
61 d.getSoundingName(context), | |
62 ComputeType.ADVANCE, | |
63 id, | |
64 hash | |
65 )); | |
66 } | |
67 else { | |
68 newFacets.add(new MiddleBedHeightFacet( | |
69 idx, | |
70 MIDDLE_BED_HEIGHT_EPOCH, | |
71 d.getSoundingName(context), | |
72 ComputeType.ADVANCE, | |
73 id, | |
74 hash | |
75 )); | |
76 } | |
77 | |
78 idx++; | |
79 } | |
80 | |
81 Facet csv = new DataFacet( | |
82 CSV, "CSV data", ComputeType.ADVANCE, hash, id); | |
83 | |
84 // TODO ADD PDF FACET | |
85 | |
86 newFacets.add(csv); | |
87 | |
88 logger.debug("Created " + newFacets.size() + " new Facets."); | |
89 | |
90 facets.addAll(newFacets); | |
91 | |
92 return res; | |
93 } | |
94 } | |
95 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |