Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java @ 7182:87c32adb7088
Initial commit for untested standalone sediment yield artifact.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 26 Sep 2013 22:03:27 +0200 |
parents | |
children | 644b2f461272 |
rev | line source |
---|---|
7182
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
2 * Software engineering by Intevation GmbH |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
3 * |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
7 */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
8 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
9 package org.dive4elements.river.artifacts; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
10 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
11 import java.util.ArrayList; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
12 import java.util.List; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
13 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
14 import org.apache.log4j.Logger; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
15 import org.w3c.dom.Document; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
16 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
17 import org.dive4elements.artifactdatabase.state.DefaultOutput; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
18 import org.dive4elements.artifactdatabase.state.Facet; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
19 import org.dive4elements.artifactdatabase.state.FacetActivity; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
20 import org.dive4elements.artifactdatabase.state.State; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
21 import org.dive4elements.artifacts.Artifact; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
22 import org.dive4elements.artifacts.ArtifactFactory; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
23 import org.dive4elements.artifacts.CallMeta; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
24 import org.dive4elements.artifacts.common.utils.XMLUtils; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
25 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
26 import org.dive4elements.river.artifacts.model.minfo.SedimentLoad; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
27 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFacet; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
28 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFactory; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
29 import org.dive4elements.river.artifacts.states.StaticState; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
30 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
31 import org.dive4elements.river.artifacts.model.FacetTypes; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
32 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
33 import org.dive4elements.river.utils.Formatter; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
34 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
35 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
36 /** Artifact to access sediment yield measurements (inspired from flow velocity artifact). */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
37 public class SedimentYieldArtifact |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
38 extends StaticD4EArtifact |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
39 implements FacetTypes |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
40 { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
41 /** The logger for this class. */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
42 private static Logger logger = |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
43 Logger.getLogger(SedimentYieldArtifact.class); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
44 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
45 /** Artifact key name. */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
46 private static final String NAME = "sedimentyield"; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
47 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
48 /** Spawn only inactive facets. */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
49 static { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
50 // TODO: Move to configuration. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
51 FacetActivity.Registry.getInstance() |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
52 .register(NAME, FacetActivity.INACTIVE); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
53 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
54 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
55 /** Need to give the state an id. */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
56 public static final String STATIC_STATE_NAME = |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
57 "state.sedimentyield.static"; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
58 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
59 /** One and only state to be in. */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
60 protected transient State state = null; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
61 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
62 protected String DATA_NAME = "ID"; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
63 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
64 /** |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
65 * Trivial Constructor. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
66 */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
67 public SedimentYieldArtifact() { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
68 logger.debug("SedimentYieldArtifact.SedimentYieldArtifact"); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
69 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
70 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
71 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
72 /** Get artifact key name. */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
73 @Override |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
74 public String getName() { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
75 return NAME; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
76 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
77 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
78 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
79 /** Create a new state with bogus output. */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
80 protected State spawnState() { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
81 state = new StaticState(STATIC_STATE_NAME); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
82 List<Facet> fs = getFacets(STATIC_STATE_NAME); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
83 DefaultOutput output = new DefaultOutput( |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
84 "general", |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
85 "general", |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
86 "image/png", |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
87 fs, |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
88 "chart"); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
89 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
90 state.getOutputs().add(output); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
91 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
92 return state; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
93 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
94 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
95 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
96 /** |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
97 * Gets called from factory, to set things up. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
98 */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
99 @Override |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
100 public void setup( |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
101 String identifier, |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
102 ArtifactFactory factory, |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
103 Object context, |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
104 CallMeta callMeta, |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
105 Document data) |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
106 { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
107 logger.debug("SedimentYieldArtifact.setup"); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
108 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
109 // Store id, yield yields. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
110 state = new StaticState(STATIC_STATE_NAME); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
111 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
112 if (logger.isDebugEnabled()) { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
113 logger.debug(XMLUtils.toString(data)); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
114 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
115 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
116 List<Facet> fs = new ArrayList<Facet>(); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
117 String code = getDatacageIDValue(data); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
118 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
119 // TODO need river, too. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
120 // |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
121 if (code != null) { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
122 // parse code, interact with factory, add real facets. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
123 // store relevant parts of code as data. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
124 // TODO no fakes |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
125 String fakeRiver = "Elbe"; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
126 SedimentLoad myLoad = SedimentLoadFactory.getSedimentLoadWithDataUncached(code, fakeRiver); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
127 String name = myLoad.getDescription(); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
128 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
129 Facet facet = new SedimentLoadFacet( |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
130 0, name, |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
131 SEDIMENT_LOAD_COARSE, |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
132 //???? |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
133 ComputeType.ADVANCE, state.getID(), "hash" |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
134 ); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
135 fs.add(facet); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
136 addFacets(state.getID(), fs); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
137 addStringData(DATA_NAME, code); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
138 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
139 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
140 spawnState(); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
141 super.setup(identifier, factory, context, callMeta, data); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
142 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
143 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
144 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
145 /** |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
146 * Get a list containing the one and only State. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
147 * @param context ignored. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
148 * @return list with one and only state. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
149 */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
150 @Override |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
151 protected List<State> getStates(Object context) { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
152 ArrayList<State> states = new ArrayList<State>(); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
153 states.add(getState()); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
154 return states; |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
155 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
156 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
157 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
158 /** |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
159 * Get the "current" state (there is but one). |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
160 * @param cc ignored. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
161 * @return the "current" (only possible) state. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
162 */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
163 @Override |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
164 public State getCurrentState(Object cc) { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
165 return getState(); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
166 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
167 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
168 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
169 /** |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
170 * Get the only possible state. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
171 * @return the state. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
172 */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
173 protected State getState() { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
174 return getState(null, null); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
175 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
176 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
177 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
178 /** |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
179 * Get the state. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
180 * @param context ignored. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
181 * @param stateID ignored. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
182 * @return the state. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
183 */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
184 @Override |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
185 protected State getState(Object context, String stateID) { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
186 return (state != null) |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
187 ? state |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
188 : spawnState(); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
189 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
190 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
191 |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
192 /** |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
193 * Called via setup. Overridden to avoid cloning all data. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
194 * |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
195 * @param artifact The master-artifact. |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
196 */ |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
197 @Override |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
198 protected void initialize( |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
199 Artifact artifact, |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
200 Object context, |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
201 CallMeta meta) |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
202 { |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
203 logger.debug("initialize"); |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
204 // TODO Copy river data! |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
205 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
206 } |
87c32adb7088
Initial commit for untested standalone sediment yield artifact.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
diff
changeset
|
207 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |