Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQStaticState.java @ 6618:e8e76d50d119
issue1399: Use WKms instead of WQKms object, as W-Difference artifact themselves
only deliver WKms, and no Q-Difference is ever built.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Fri, 19 Jul 2013 13:36:45 +0200 |
parents | af13ceeba52a |
children | a9bd4a23a852 |
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.states.sq; import java.text.DateFormat; import java.util.List; import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.StaticSQRelationAccess; import org.dive4elements.river.artifacts.model.sq.StaticSQContainer; import org.dive4elements.river.artifacts.model.sq.StaticSQFactory; import org.dive4elements.river.artifacts.model.sq.StaticSQRelation; import org.dive4elements.river.artifacts.states.StaticState; public class SQStaticState extends StaticState { private static final Logger log = Logger.getLogger(SQStaticState.class); public SQStaticState() { super(); } public SQStaticState(String name) { super(name); } @Override public Object staticCompute( List<Facet> facets, D4EArtifact artifact ) { StaticSQRelationAccess access = new StaticSQRelationAccess(artifact); String river = access.getRiver(); String measurementStation = access.getMeasurementStation(); int ms = -1; try { ms = Integer.parseInt(measurementStation); } catch (NumberFormatException nfe) { log.error("Unparseable measurement station: " + measurementStation); return null; } StaticSQContainer sqRelations = StaticSQFactory.getSQRelations(river, ms); for (StaticSQRelation.Parameter p: StaticSQRelation.Parameter.values()) { List<StaticSQRelation> relations = sqRelations.getRelationsByParameter(p); if (!relations.isEmpty()) { int count = 0; for (StaticSQRelation relation : relations) { String name = "sq_" + p.toString().toLowerCase() + "_curve"; DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); String desc = p.toString() + ": " + df.format(relation.getStartTime()) + " - " + df.format(relation.getStopTime()); facets.add(new StaticSQRelationFacet( count, name, desc, relation)); count++; } } } return null; } }