Mercurial > dive4elements > river
view artifacts/src/main/java/org/dive4elements/river/artifacts/SQRelationArtifact.java @ 5994:af13ceeba52a
Removed trailing whitespace.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sun, 12 May 2013 18:13:50 +0200 |
parents | 4897a58c8746 |
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; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import org.w3c.dom.Document; import org.dive4elements.artifactdatabase.data.DefaultStateData; import org.dive4elements.artifactdatabase.state.DefaultOutput; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.artifacts.ArtifactFactory; import org.dive4elements.artifacts.ArtifactNamespaceContext; import org.dive4elements.artifacts.CallMeta; import org.dive4elements.artifacts.common.utils.XMLUtils; import org.dive4elements.river.artifacts.model.sq.StaticSQRelation; import org.dive4elements.river.artifacts.resources.Resources; import org.dive4elements.river.artifacts.states.StaticState; import org.dive4elements.river.artifacts.states.sq.SQStaticState; public class SQRelationArtifact extends AbstractStaticStateArtifact { private static final Logger logger = Logger.getLogger(SQRelationArtifact.class); public static final String XPATH_RIVER = "/art:action/art:river/@art:name"; public static final String XPATH_STATION = "/art:action/art:measurement_station/@art:number"; public static final String NAME = "staticsqrelation"; public static final String STATIC_STATE_NAME = "state.sqrelation.static"; public static final String UIPROVIDER = "static_sqrelation"; public static final String SQ_RELATION_OUT_A = "sq_relation_a"; public static final String SQ_RELATION_OUT_B = "sq_relation_b"; public static final String SQ_RELATION_OUT_C = "sq_relation_c"; public static final String SQ_RELATION_OUT_D = "sq_relation_d"; public static final String SQ_RELATION_OUT_E = "sq_relation_e"; public static final String SQ_RELATION_OUT_F = "sq_relation_f"; @Override public void setup( String identifier, ArtifactFactory factory, Object context, CallMeta callmeta, Document data ) { logger.debug("SQRelationArtifact.setup()"); String river = XMLUtils.xpathString( data, XPATH_RIVER, ArtifactNamespaceContext.INSTANCE); String station = XMLUtils.xpathString( data, XPATH_STATION, ArtifactNamespaceContext.INSTANCE); addData( "river", new DefaultStateData( "river", Resources.getMsg(callmeta, "static.sq.river", "Rivername"), "String", river)); addData( "station", new DefaultStateData( "station", Resources.getMsg(callmeta, "static.sq.station", "Station"), "String", station)); super.setup(identifier, factory, context, callmeta, data); } @Override protected void initStaticState() { StaticState state = new SQStaticState(STATIC_STATE_NAME); List<Facet> fs = new ArrayList<Facet>(); state.staticCompute(fs, this); if (hasParameter(StaticSQRelation.Parameter.A, fs)) { DefaultOutput outputA = new DefaultOutput( SQ_RELATION_OUT_A, "output.static.sqrelation.a", "image/png", fs, "chart"); state.addOutput(outputA); } if (hasParameter(StaticSQRelation.Parameter.B, fs)) { DefaultOutput outputB = new DefaultOutput( SQ_RELATION_OUT_B, "output.static.sqrelation.b", "image/png", fs, "chart"); state.addOutput(outputB); } if (hasParameter(StaticSQRelation.Parameter.C, fs)) { DefaultOutput outputC = new DefaultOutput( SQ_RELATION_OUT_C, "output.static.sqrelation.c", "image/png", fs, "chart"); state.addOutput(outputC); } if (hasParameter(StaticSQRelation.Parameter.D, fs)) { DefaultOutput outputD = new DefaultOutput( SQ_RELATION_OUT_D, "output.static.sqrelation.d", "image/png", fs, "chart"); state.addOutput(outputD); } if (hasParameter(StaticSQRelation.Parameter.E, fs)) { DefaultOutput outputE = new DefaultOutput( SQ_RELATION_OUT_E, "output.static.sqrelation.e", "image/png", fs, "chart"); state.addOutput(outputE); } if (hasParameter(StaticSQRelation.Parameter.F, fs)) { DefaultOutput outputF = new DefaultOutput( SQ_RELATION_OUT_F, "output.static.sqrelation.f", "image/png", fs, "chart"); state.addOutput(outputF); } addFacets(STATIC_STATE_NAME, fs); state.setUIProvider(UIPROVIDER); setStaticState(state); } @Override public String getName() { return NAME; } private boolean hasParameter(StaticSQRelation.Parameter p, List<Facet> fs) { for (Facet f : fs) { if (f.getName().equals("sq_" + p.toString().toLowerCase() + "_curve")) { return true; } } return false; } }