view artifacts/src/main/java/org/dive4elements/river/artifacts/model/fixings/FixingsEventFacet.java @ 9648:c5a496bf1b0b

Fixed: Duplizieren einer Fixierungsanalyse schlägt fehl.
author Gernot Belger <g.belger@bjoernsen.de>
date Wed, 04 Dec 2019 16:10:28 +0100
parents 9744ce3c3853
children
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);

        if (stationRange == null) {
            System.out.println("break");
        }

        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
        this.stationRange = o.stationRange;
    }
}

http://dive4elements.wald.intevation.org