view 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
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU AGPL (>=v3)
 * and comes with ABSOLUTELY NO WARRANTY! Check out the
 * documentation coming with Dive4Elements River for details.
 */

package org.dive4elements.river.artifacts.model.fixings;

import org.apache.commons.lang.math.DoubleRange;
import org.dive4elements.artifactdatabase.state.Facet;
import org.dive4elements.artifacts.ArtifactNamespaceContext;
import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;

/**
 * Facet to access the current Km from the context safely
 *
 * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a>
 */
abstract class FixingsEventFacet extends FixingsFacet {

    private static final long serialVersionUID = 1L;

    private DoubleRange stationRange;

    public FixingsEventFacet() {
    }

    public FixingsEventFacet(final int facetIndex, final String name, final String description, final ComputeType type, final String hash, final String stateId,
            final DoubleRange stationRange) {
        super(facetIndex, name, description, type, hash, stateId);

        this.stationRange = stationRange;
    }

    @Override
    public Node toXML(final Document doc) {

        final ElementCreator ec = new ElementCreator(doc, ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX);

        final Element e = (Element) super.toXML(doc);
        ec.addAttr(e, "startKm", Double.toString(this.stationRange.getMinimumDouble()), true);
        ec.addAttr(e, "endKm", Double.toString(this.stationRange.getMaximumDouble()), true);
        return e;
    }

    @Override
    public void set(final Facet other) {
        super.set(other);

        final FixingsEventFacet o = (FixingsEventFacet) other;
        // DoubleRange is immutable, so we can copy the reference here
        o.stationRange = this.stationRange;
    }
}

http://dive4elements.wald.intevation.org