Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQStaticState.java @ 8312:9f5059f4f01a
Configured "static" sq relation to use a default D4EArtifact and two states to hold the parameters and outs.
* Updated configuration
* Added new state
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 24 Sep 2014 11:59:49 +0200 |
parents | a56fe3bc6700 |
children | d4c501d2c098 |
comparison
equal
deleted
inserted
replaced
8311:7b282a3f50f0 | 8312:9f5059f4f01a |
---|---|
13 import java.text.SimpleDateFormat; | 13 import java.text.SimpleDateFormat; |
14 | 14 |
15 import org.apache.log4j.Logger; | 15 import org.apache.log4j.Logger; |
16 | 16 |
17 import org.dive4elements.artifactdatabase.state.Facet; | 17 import org.dive4elements.artifactdatabase.state.Facet; |
18 import org.dive4elements.artifacts.CallContext; | |
18 import org.dive4elements.artifacts.CallMeta; | 19 import org.dive4elements.artifacts.CallMeta; |
19 import org.dive4elements.river.artifacts.D4EArtifact; | 20 import org.dive4elements.river.artifacts.D4EArtifact; |
20 import org.dive4elements.river.artifacts.access.StaticSQRelationAccess; | 21 import org.dive4elements.river.artifacts.access.StaticSQRelationAccess; |
22 import org.dive4elements.river.artifacts.model.DataFacet; | |
23 import org.dive4elements.river.artifacts.model.FacetTypes; | |
21 import org.dive4elements.river.artifacts.model.sq.StaticSQContainer; | 24 import org.dive4elements.river.artifacts.model.sq.StaticSQContainer; |
22 import org.dive4elements.river.artifacts.model.sq.StaticSQFactory; | 25 import org.dive4elements.river.artifacts.model.sq.StaticSQFactory; |
23 import org.dive4elements.river.artifacts.model.sq.StaticSQRelation; | 26 import org.dive4elements.river.artifacts.model.sq.StaticSQRelation; |
24 import org.dive4elements.river.artifacts.states.StaticState; | 27 import org.dive4elements.river.artifacts.states.StaticState; |
25 | 28 |
26 import org.dive4elements.river.artifacts.resources.Resources; | 29 import org.dive4elements.river.artifacts.resources.Resources; |
27 | 30 |
28 public class SQStaticState | 31 public class SQStaticState |
29 extends StaticState | 32 extends StaticState |
33 implements FacetTypes | |
30 { | 34 { |
31 | 35 |
32 private static final Logger log = | 36 private static final Logger log = |
33 Logger.getLogger(SQStaticState.class); | 37 Logger.getLogger(SQStaticState.class); |
34 | 38 |
39 super(); | 43 super(); |
40 } | 44 } |
41 | 45 |
42 public SQStaticState(String name) { | 46 public SQStaticState(String name) { |
43 super(name); | 47 super(name); |
48 } | |
49 | |
50 @Override | |
51 public Object computeAdvance( | |
52 D4EArtifact artifact, | |
53 String hash, | |
54 CallContext context, | |
55 List<Facet> facets, | |
56 Object old) { | |
57 StaticSQContainer sqRelations; | |
58 StaticSQRelationAccess access = new StaticSQRelationAccess(artifact); | |
59 String river = access.getRiverName(); | |
60 String measurementStation = access.getMeasurementStation(); | |
61 | |
62 int ms = -1; | |
63 try { | |
64 ms = Integer.parseInt(measurementStation); | |
65 } | |
66 catch (NumberFormatException nfe) { | |
67 log.error("Unparseable measurement station: " + measurementStation); | |
68 return null; | |
69 } | |
70 log.debug("Parsed measurement station: " + ms); | |
71 | |
72 sqRelations = StaticSQFactory.getSQRelations(river, ms); | |
73 DateFormat df = new SimpleDateFormat("yyyy"); | |
74 | |
75 for (StaticSQRelation.Parameter p: StaticSQRelation.Parameter.values()) { | |
76 log.debug("parameter: " + p.toString()); | |
77 List<StaticSQRelation> relations = | |
78 sqRelations.getRelationsByParameter(p); | |
79 | |
80 if (!relations.isEmpty()) { | |
81 int count = 0; | |
82 | |
83 for (StaticSQRelation relation : relations) { | |
84 log.debug("add facet for " + p.toString().toLowerCase()); | |
85 String name = "sq_" + p.toString().toLowerCase() + "_curve"; | |
86 String desc = | |
87 Resources.getMsg(context.getMeta(), | |
88 FACET_DESCRIPTION, | |
89 FACET_DESCRIPTION, | |
90 new Object[] { | |
91 df.format(relation.getStartTime()), | |
92 df.format(relation.getStopTime())}); | |
93 facets.add(new StaticSQRelationFacet( | |
94 count, | |
95 name, | |
96 desc, | |
97 relation)); | |
98 count++; | |
99 } | |
100 } | |
101 } | |
102 return null; | |
44 } | 103 } |
45 | 104 |
46 @Override | 105 @Override |
47 public Object computeInit( | 106 public Object computeInit( |
48 D4EArtifact artifact, | 107 D4EArtifact artifact, |