Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/PredefinedVegetationZonesArtifact.java @ 9506:8b7bf26b8782
Predefined artifact for standard vegetation zones.
Some minor adaptions.
author | gernotbelger |
---|---|
date | Fri, 28 Sep 2018 13:44:12 +0200 |
parents | |
children | ee6508687e3f |
comparison
equal
deleted
inserted
replaced
9505:3f230fe8eb19 | 9506:8b7bf26b8782 |
---|---|
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.uinfo.salix; | |
11 | |
12 import java.util.ArrayList; | |
13 import java.util.List; | |
14 | |
15 import org.apache.log4j.Logger; | |
16 import org.dive4elements.artifactdatabase.state.DefaultOutput; | |
17 import org.dive4elements.artifactdatabase.state.Facet; | |
18 import org.dive4elements.artifactdatabase.state.FacetActivity; | |
19 import org.dive4elements.artifacts.Artifact; | |
20 import org.dive4elements.artifacts.ArtifactFactory; | |
21 import org.dive4elements.artifacts.CallMeta; | |
22 import org.dive4elements.artifacts.common.utils.XMLUtils; | |
23 import org.dive4elements.river.artifacts.AbstractStaticStateArtifact; | |
24 import org.dive4elements.river.artifacts.D4EArtifact; | |
25 import org.dive4elements.river.artifacts.model.FacetTypes; | |
26 import org.dive4elements.river.artifacts.resources.Resources; | |
27 import org.dive4elements.river.artifacts.states.StaticState; | |
28 import org.dive4elements.river.artifacts.uinfo.UINFOArtifact; | |
29 import org.dive4elements.river.artifacts.uinfo.vegetationzones.VegetationZonesCrossSectionProcessor; | |
30 import org.w3c.dom.Document; | |
31 | |
32 /** | |
33 * Display of vegetation zones loaded from database | |
34 * | |
35 * @author Gernot Belger | |
36 * | |
37 */ | |
38 public class PredefinedVegetationZonesArtifact extends AbstractStaticStateArtifact implements FacetTypes { | |
39 | |
40 private static final long serialVersionUID = 1L; | |
41 | |
42 /** Artifact name. */ | |
43 private static final String NAME = "predefined_vegetation_zones"; | |
44 | |
45 private static final String DEFAULT_VEGZONES_DESCRIPTION = "uinfo_facet_vegetation_default_zones_cross_section.description"; | |
46 | |
47 private static final String STATIC_STATE_NAME = "state.predefined_vegetation_zones.static"; | |
48 | |
49 static { | |
50 // TODO: Move to configuration. | |
51 FacetActivity.Registry.getInstance().register(NAME, FacetActivity.INACTIVE); | |
52 } | |
53 | |
54 /** The log for this class. */ | |
55 private static Logger log = Logger.getLogger(PredefinedVegetationZonesArtifact.class); | |
56 | |
57 @Override | |
58 public String getName() { | |
59 return NAME; | |
60 } | |
61 | |
62 @Override | |
63 protected void initStaticState() { | |
64 | |
65 final StaticState state = new StaticState(STATIC_STATE_NAME); | |
66 final DefaultOutput output = new DefaultOutput("general", "general", "image/png", "chart"); | |
67 | |
68 final List<Facet> facets = getFacets(STATIC_STATE_NAME); | |
69 output.addFacets(facets); | |
70 state.addOutput(output); | |
71 | |
72 setStaticState(state); | |
73 } | |
74 | |
75 /** | |
76 * Gets called from factory, to set things up. | |
77 */ | |
78 @Override | |
79 public void setup(final String identifier, final ArtifactFactory factory, final Object context, final CallMeta callMeta, final Document data, | |
80 final List<Class> loadFacets) { | |
81 | |
82 if (log.isDebugEnabled()) | |
83 log.debug(XMLUtils.toString(data)); | |
84 | |
85 final String vegZoneData = getDatacageIDValue(data); | |
86 | |
87 createFacets(callMeta, vegZoneData); | |
88 | |
89 super.setup(identifier, factory, context, callMeta, data, loadFacets); | |
90 } | |
91 | |
92 private void createFacets(final CallMeta callMeta, final String vegZoneData) { | |
93 if (vegZoneData == null) | |
94 return; | |
95 | |
96 addStringData(UINFOArtifact.FIELD_VEGZONES, vegZoneData); | |
97 | |
98 final String seriesName = Resources.getMsg(callMeta, DEFAULT_VEGZONES_DESCRIPTION); | |
99 | |
100 final List<Facet> facets = new ArrayList<>(1); | |
101 facets.add(VegetationZonesCrossSectionProcessor.createVegetationZonesCrossSectionFacet(seriesName)); | |
102 addFacets(STATIC_STATE_NAME, facets); | |
103 } | |
104 | |
105 @Override | |
106 protected void initialize(final Artifact artifact, final Object context, final CallMeta meta) { | |
107 // do not clone facets, etc. from master artifact | |
108 | |
109 log.debug("initialize"); | |
110 importData((D4EArtifact) artifact, "river"); | |
111 importData((D4EArtifact) artifact, "ld_from"); | |
112 importData((D4EArtifact) artifact, "ld_to"); | |
113 | |
114 log.debug("ld_from " + getDataAsString("ld_from")); | |
115 log.debug("ld_to " + getDataAsString("ld_to")); | |
116 } | |
117 } |