comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixingsEventFacet.java @ 9415:9744ce3c3853

Rework of fixanalysis computation and dWt and WQ facets. Got rid of strange remapping and bitshifting code by explicitely saving the column information and using it in the facets. The facets also put the valid station range into their xml-metadata
author gernotbelger
date Thu, 16 Aug 2018 16:27:53 +0200
parents
children c5a496bf1b0b
comparison
equal deleted inserted replaced
9414:096f151a0a9f 9415:9744ce3c3853
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU AGPL (>=v3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6 * documentation coming with Dive4Elements River for details.
7 */
8
9 package org.dive4elements.river.artifacts.model.fixings;
10
11 import org.apache.commons.lang.math.DoubleRange;
12 import org.dive4elements.artifactdatabase.state.Facet;
13 import org.dive4elements.artifacts.ArtifactNamespaceContext;
14 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
15 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
16 import org.w3c.dom.Document;
17 import org.w3c.dom.Element;
18 import org.w3c.dom.Node;
19
20 /**
21 * Facet to access the current Km from the context safely
22 *
23 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a>
24 */
25 abstract class FixingsEventFacet extends FixingsFacet {
26
27 private static final long serialVersionUID = 1L;
28
29 private DoubleRange stationRange;
30
31 public FixingsEventFacet() {
32 }
33
34 public FixingsEventFacet(final int facetIndex, final String name, final String description, final ComputeType type, final String hash, final String stateId,
35 final DoubleRange stationRange) {
36 super(facetIndex, name, description, type, hash, stateId);
37
38 this.stationRange = stationRange;
39 }
40
41 @Override
42 public Node toXML(final Document doc) {
43
44 final ElementCreator ec = new ElementCreator(doc, ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX);
45
46 final Element e = (Element) super.toXML(doc);
47 ec.addAttr(e, "startKm", Double.toString(this.stationRange.getMinimumDouble()), true);
48 ec.addAttr(e, "endKm", Double.toString(this.stationRange.getMaximumDouble()), true);
49 return e;
50 }
51
52 @Override
53 public void set(final Facet other) {
54 super.set(other);
55
56 final FixingsEventFacet o = (FixingsEventFacet) other;
57 // DoubleRange is immutable, so we can copy the reference here
58 o.stationRange = this.stationRange;
59 }
60 }

http://dive4elements.wald.intevation.org