Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ReferenceCurveState.java @ 3318:dbe2f85bf160
merged flys-artifacts/2.8
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:35 +0200 |
parents | 23b4ff116015 |
children |
comparison
equal
deleted
inserted
replaced
2987:98c7a46ec5ae | 3318:dbe2f85bf160 |
---|---|
1 package de.intevation.flys.artifacts.states; | |
2 | |
3 import de.intevation.artifactdatabase.state.Facet; | |
4 | |
5 import de.intevation.artifacts.CallContext; | |
6 | |
7 import de.intevation.flys.artifacts.FLYSArtifact; | |
8 import de.intevation.flys.artifacts.WINFOArtifact; | |
9 | |
10 import de.intevation.flys.artifacts.model.CalculationResult; | |
11 import de.intevation.flys.artifacts.model.DataFacet; | |
12 import de.intevation.flys.artifacts.model.FacetTypes; | |
13 import de.intevation.flys.artifacts.model.ReferenceCurveFacet; | |
14 import de.intevation.flys.artifacts.model.ReportFacet; | |
15 import de.intevation.flys.artifacts.model.WWQQ; | |
16 | |
17 import java.util.List; | |
18 | |
19 import org.apache.log4j.Logger; | |
20 | |
21 | |
22 /** State of WINFO in which reference curves can be produced. */ | |
23 public class ReferenceCurveState | |
24 extends DefaultState | |
25 implements FacetTypes | |
26 { | |
27 private static Logger logger = Logger.getLogger(ReferenceCurveState.class); | |
28 | |
29 | |
30 public ReferenceCurveState() { | |
31 } | |
32 | |
33 | |
34 @Override | |
35 public Object computeAdvance( | |
36 FLYSArtifact artifact, | |
37 String hash, | |
38 CallContext context, | |
39 List<Facet> facets, | |
40 Object old | |
41 ) { | |
42 if (!(artifact instanceof WINFOArtifact)) { | |
43 return null; | |
44 } | |
45 | |
46 String id = getID(); | |
47 | |
48 WINFOArtifact winfo = (WINFOArtifact)artifact; | |
49 | |
50 CalculationResult res = old instanceof CalculationResult | |
51 ? (CalculationResult)old | |
52 : winfo.getReferenceCurveData(context); | |
53 | |
54 if (facets == null) { | |
55 return res; | |
56 } | |
57 | |
58 WWQQ [] wws = (WWQQ [])res.getData(); | |
59 | |
60 for (int i = 0; i < wws.length; ++i) { | |
61 String wwsName = wws[i].getName(); | |
62 facets.add(new ReferenceCurveFacet(i, | |
63 REFERENCE_CURVE, | |
64 wwsName | |
65 )); | |
66 facets.add(new ReferenceCurveFacet(i, | |
67 REFERENCE_CURVE_NORMALIZED, | |
68 wwsName | |
69 )); | |
70 } | |
71 | |
72 if (wws.length > 0) { | |
73 logger.debug("Adding CSV and PDF data facet."); | |
74 Facet csv = new DataFacet (CSV, "CSV data", ComputeType.ADVANCE, hash, id); | |
75 Facet pdf = new DataFacet (PDF, "PDF data", ComputeType.ADVANCE, hash, id); | |
76 facets.add(csv); | |
77 facets.add(pdf); | |
78 } | |
79 | |
80 if (res.getReport().hasProblems()) { | |
81 facets.add(new ReportFacet(ComputeType.ADVANCE, hash, id)); | |
82 } | |
83 | |
84 return res; | |
85 } | |
86 } | |
87 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |