Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java @ 5838:5aa05a7a34b7
Rename modules to more fitting names.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 15:23:37 +0200 |
parents | flys-artifacts/src/main/java/org/dive4elements/river/artifacts/BedHeightsArtifact.java@bd047b71ab37 |
children | 4897a58c8746 |
comparison
equal
deleted
inserted
replaced
5837:d9901a08d0a6 | 5838:5aa05a7a34b7 |
---|---|
1 package org.dive4elements.river.artifacts; | |
2 | |
3 import java.util.ArrayList; | |
4 import java.util.List; | |
5 | |
6 import org.apache.log4j.Logger; | |
7 import org.w3c.dom.Document; | |
8 | |
9 import org.dive4elements.artifactdatabase.state.DefaultOutput; | |
10 import org.dive4elements.artifactdatabase.state.Facet; | |
11 import org.dive4elements.artifactdatabase.state.FacetActivity; | |
12 import org.dive4elements.artifacts.ArtifactFactory; | |
13 import org.dive4elements.artifacts.Artifact; | |
14 import org.dive4elements.artifacts.CallMeta; | |
15 import org.dive4elements.artifacts.common.utils.XMLUtils; | |
16 import org.dive4elements.river.artifacts.model.minfo.BedHeightFacet; | |
17 import org.dive4elements.river.artifacts.model.minfo.BedHeightFactory; | |
18 import org.dive4elements.river.artifacts.states.StaticState; | |
19 | |
20 public class BedHeightsArtifact | |
21 extends AbstractStaticStateArtifact | |
22 { | |
23 /** The logger for this class. */ | |
24 private static Logger logger = | |
25 Logger.getLogger(BedHeightsArtifact.class); | |
26 | |
27 private static final String NAME = "bedheights"; | |
28 private static final String STATIC_FACET_NAME = "bedheight"; | |
29 | |
30 static { | |
31 // TODO: Move to configuration. | |
32 FacetActivity.Registry.getInstance() | |
33 .register(NAME, FacetActivity.INACTIVE); | |
34 } | |
35 | |
36 public static final String STATIC_STATE_NAME = | |
37 "state.additional_bedheights.static"; | |
38 | |
39 /** Data Item name to know whether we are Heighmarks and reveive | |
40 * some data slightly different. */ | |
41 public static final String DATA_HEIGHT_TYPE = | |
42 "height_marks"; | |
43 | |
44 /** | |
45 * Trivial Constructor. | |
46 */ | |
47 public BedHeightsArtifact() { | |
48 logger.debug("BedHeightsArtifact.BedHeightsArtifact"); | |
49 } | |
50 | |
51 @Override | |
52 public String getName() { | |
53 return NAME; | |
54 } | |
55 | |
56 /** | |
57 * Gets called from factory, to set things up. | |
58 */ | |
59 @Override | |
60 public void setup( | |
61 String identifier, | |
62 ArtifactFactory factory, | |
63 Object context, | |
64 CallMeta callMeta, | |
65 Document data) | |
66 { | |
67 logger.debug("BedHeightsArtifact.setup"); | |
68 | |
69 if (logger.isDebugEnabled()) { | |
70 logger.debug(XMLUtils.toString(data)); | |
71 } | |
72 | |
73 String code = getDatacageIDValue(data); | |
74 | |
75 if (code != null) { | |
76 String [] parts = code.split("-"); | |
77 | |
78 if (parts.length >= 4) { | |
79 String name = parts[0]; | |
80 String type = parts[1]; | |
81 String btype = type; | |
82 int hId = Integer.parseInt(parts[2]); | |
83 if (name.equals("bedheight")) { | |
84 addStringData("type", type); | |
85 addStringData("height_id", parts[2]); | |
86 addStringData("time", parts[3]); | |
87 } | |
88 if (type.equals("singlevalues")) { | |
89 btype = "single"; | |
90 } | |
91 | |
92 String bedHName = BedHeightFactory.getHeightName(btype, hId); | |
93 | |
94 Facet facet = new BedHeightFacet( | |
95 STATIC_FACET_NAME, bedHName, type); | |
96 | |
97 ArrayList<Facet> facets = new ArrayList<Facet>(1); | |
98 facets.add(facet); | |
99 | |
100 addFacets(STATIC_STATE_NAME, facets); | |
101 } | |
102 } | |
103 super.setup(identifier, factory, context, callMeta, data); | |
104 } | |
105 | |
106 @Override | |
107 protected void initStaticState() { | |
108 | |
109 logger.debug("initStaticState " + getName() + " " + identifier()); | |
110 | |
111 StaticState state = new StaticState(STATIC_STATE_NAME); | |
112 DefaultOutput output = new DefaultOutput( | |
113 "general", | |
114 "general", | |
115 "image/png", | |
116 "chart"); | |
117 | |
118 List<Facet> facets = getFacets(STATIC_STATE_NAME); | |
119 output.addFacets(facets); | |
120 state.addOutput(output); | |
121 | |
122 setStaticState(state); | |
123 } | |
124 | |
125 @Override | |
126 protected void initialize(Artifact artifact, Object context, CallMeta meta) { | |
127 // do not clone facets, etc. from master artifact | |
128 | |
129 logger.debug("initialize"); | |
130 importData((FLYSArtifact)artifact, "ld_from"); | |
131 importData((FLYSArtifact)artifact, "ld_to"); | |
132 | |
133 logger.debug("ld_from " + getDataAsString("ld_from")); | |
134 logger.debug("ld_to " + getDataAsString("ld_to")); | |
135 } | |
136 } | |
137 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : |