Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/SQRelationArtifact.java @ 5604:7e837c5c377b
Datacage: toValue/fromValue: Use constant instead of hard coded number.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Tue, 09 Apr 2013 08:28:07 +0200 |
parents | 9a14eac637ec |
children |
line wrap: on
line source
package de.intevation.flys.artifacts; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import org.w3c.dom.Document; import de.intevation.artifactdatabase.data.DefaultStateData; import de.intevation.artifactdatabase.state.DefaultOutput; import de.intevation.artifactdatabase.state.Facet; import de.intevation.artifacts.ArtifactFactory; import de.intevation.artifacts.ArtifactNamespaceContext; import de.intevation.artifacts.CallMeta; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.flys.artifacts.model.sq.StaticSQRelation; import de.intevation.flys.artifacts.resources.Resources; import de.intevation.flys.artifacts.states.StaticState; import de.intevation.flys.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; } }