Mercurial > dive4elements > river
changeset 942:796c54058dc4
Added artifacts/states for WMS background an river axis and a configuration for the output-defaults.
flys-artifacts/trunk@2351 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Mon Jul 18 09:20:42 2011 +0000 +++ b/flys-artifacts/ChangeLog Mon Jul 18 10:13:25 2011 +0000 @@ -1,3 +1,43 @@ +2011-07-18 Ingo Weinzierl <ingo@intevation.de> + + * doc/conf/artifacts/wmsbackground.xml, + doc/conf/artifacts/riveraxis.xml: New configurations for an Artifact + that is used as background layer in floodmaps, and an artifact that is + used as layer showing the river axis in a floodmap. + + * doc/conf/output-defaults.xml: New file to configure default artifacts + for specific output states. E.g. the floodmap state recommends a + background layer and a layer displaying the river axis. In suche case, + the floodmap state recommends two artifacts for the two layers. + + * doc/conf/conf.xml: Added new artifacts/artifact-factories and a Hook to + monitor artifacts (-> CollectionMonitor.java). + + * src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java: + New. This facet is used to represent a layer in a map. So, this facet + stores information about a WMS URL and the layer names provided by this + WMS. + + * src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added + facet types for the wmsbackground and riveraxis. + + * src/main/java/de/intevation/flys/artifacts/states/WMSBackgroundState.java, + src/main/java/de/intevation/flys/artifacts/WMSBackgroundArtifact.java: + New. An artifact and its default state. The intent of these classes is + to generate WMSLayerFacets which represent background layers in maps. + + * src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java, + src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java: New. + An artifact and its default state. The intent of these classes is to + generate WMSLayerFacets which represent layers that display a river + axis. + + * src/main/java/de/intevation/flys/artifacts/states/DefaultState.java: + Added the INIT ComputeType. + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: Added a + case for the INIT ComputeType while computing data. + 2011-07-18 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/artifacts/states/DefaultState.java:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/doc/conf/artifacts/riveraxis.xml Mon Jul 18 10:13:25 2011 +0000 @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<artifact name="riveraxis"> + <states> + <state id="state.riveraxis.layer" + description="state.riveraxis.layer.description" + state="de.intevation.flys.artifacts.states.RiverAxisState"> + <outputmodes> + <outputmode name="floodmap" description="output.uesk.map.description" type="map"> + <facets> + <facet name="floodmap.riveraxis"/> + </facets> + </outputmode> + </outputmodes> + </state> + </states> +</artifact>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/doc/conf/artifacts/wmsbackground.xml Mon Jul 18 10:13:25 2011 +0000 @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<artifact name="wmsbackground"> + <states> + <state id="state.wmsbackground.layer" + description="state.wmsbackground.layer.description" + state="de.intevation.flys.artifacts.states.WMSBackgroundState"> + <outputmodes> + <outputmode name="floodmap" description="output.uesk.map.description" type="map"> + <facets> + <facet name="floodmap.wmsbackground"/> + </facets> + </outputmode> + </outputmodes> + </state> + </states> +</artifact>
--- a/flys-artifacts/doc/conf/conf.xml Mon Jul 18 09:20:42 2011 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Mon Jul 18 10:13:25 2011 +0000 @@ -15,6 +15,12 @@ <artifact-factory name="winfo" description="Factory to create an artifact to be used in WINFO" ttl="3600000" artifact="de.intevation.flys.artifacts.WINFOArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory> + <artifact-factory name="riveraxis" description="Factory to create an artifact to be used in WINFO" + ttl="3600000" + artifact="de.intevation.flys.artifacts.RiverAxisArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory> + <artifact-factory name="wmsbackground" description="Factory to create an artifact to be used in WINFO" + ttl="3600000" + artifact="de.intevation.flys.artifacts.WMSBackgroundArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory> </artifact-factories> <user-factory name="default" description="Factory to create new users">de.intevation.artifactdatabase.DefaultUserFactory</user-factory> @@ -46,8 +52,20 @@ <artifacts> <artifact name="winfo" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/winfo.xml" /> + <artifact name="riveraxis" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/riveraxis.xml" /> + <artifact name="wmsbackground" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="${artifacts.config.dir}/artifacts/wmsbackground.xml" /> </artifacts> + + <hooks> + <hook + class="de.intevation.flys.artifacts.CollectionMonitor" + applies="post-feed,post-advance" + xmlns:xlink="http://www.w3.org/1999/xlink" + xlink:href="${artifacts.config.dir}/output-defaults.xml"> + </hook> + </hooks> + <output-generators> <output-generator name="discharge_curve">de.intevation.flys.exports.DischargeCurveGenerator</output-generator> <output-generator name="discharge_curve_chartinfo">de.intevation.flys.exports.DischargeCurveInfoGenerator</output-generator>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/doc/conf/output-defaults.xml Mon Jul 18 10:13:25 2011 +0000 @@ -0,0 +1,6 @@ +<output-defaults> + + <state id="state.winfo.uesk.uesk" artifact-factory="riveraxis" /> + <state id="state.winfo.uesk.uesk" artifact-factory="wmsbackground" /> + +</output-defaults>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Mon Jul 18 09:20:42 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Mon Jul 18 10:13:25 2011 +0000 @@ -1240,6 +1240,8 @@ case ADVANCE: res = state.computeAdvance(this, key, context, fs, old); break; + case INIT: + res = state.computeInit(this, key, context.getMeta(), fs); default: res = null; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/RiverAxisArtifact.java Mon Jul 18 10:13:25 2011 +0000 @@ -0,0 +1,48 @@ +package de.intevation.flys.artifacts; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import de.intevation.artifacts.Artifact; + +import de.intevation.artifactdatabase.state.Facet; + +import de.intevation.flys.artifacts.states.DefaultState; + + +public class RiverAxisArtifact extends StaticFLYSArtifact { + + public static final String NAME = "riveraxis"; + + + private static final Logger logger = + Logger.getLogger(RiverAxisArtifact.class); + + + @Override + public String getName() { + return NAME; + } + + + @Override + protected void initialize(Artifact artifact, Object context) { + logger.debug("Initialize internal state with: "+ artifact.identifier()); + + FLYSArtifact flys = (FLYSArtifact) artifact; + addData("river", flys.getData("river")); + + List<Facet> fs = new ArrayList<Facet>(); + + // TODO Add CallMeta + DefaultState state = (DefaultState) getCurrentState(context); + state.computeInit(this, hash(), null, fs); + + if (!fs.isEmpty()) { + facets.put(getCurrentStateId(), fs); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSBackgroundArtifact.java Mon Jul 18 10:13:25 2011 +0000 @@ -0,0 +1,45 @@ +package de.intevation.flys.artifacts; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import de.intevation.artifacts.Artifact; + +import de.intevation.artifactdatabase.state.Facet; + +import de.intevation.flys.artifacts.states.DefaultState; + + +public class WMSBackgroundArtifact extends StaticFLYSArtifact { + + public static final String NAME = "wmsbackground"; + + + private static final Logger logger = + Logger.getLogger(WMSBackgroundArtifact.class); + + + @Override + public String getName() { + return NAME; + } + + + @Override + protected void initialize(Artifact artifact, Object context) { + logger.debug("Initialize internal state with: "+ artifact.identifier()); + + List<Facet> fs = new ArrayList<Facet>(); + + // TODO Add CallMeta + DefaultState state = (DefaultState) getCurrentState(context); + state.computeInit(this, hash(), null, fs); + + if (!fs.isEmpty()) { + facets.put(getCurrentStateId(), fs); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Mon Jul 18 09:20:42 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Mon Jul 18 10:13:25 2011 +0000 @@ -2,7 +2,9 @@ public interface FacetTypes { - String FLOODMAP_WSPLGEN = "floodmap.wsplgen"; + String FLOODMAP_WSPLGEN = "floodmap.wsplgen"; + String FLOODMAP_RIVERAXIS = "floodmap.riveraxis"; + String FLOODMAP_WMSBACKGROUND = "floodmap.wmsbackground"; String DISCHARGE_LONGITUDINAL_W = "discharge_longitudinal_section.w"; String DISCHARGE_LONGITUDINAL_Q = "discharge_longitudinal_section.q";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java Mon Jul 18 10:13:25 2011 +0000 @@ -0,0 +1,76 @@ +package de.intevation.flys.artifacts.model; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import de.intevation.artifacts.Artifact; +import de.intevation.artifacts.CallContext; + +import de.intevation.artifactdatabase.state.DefaultFacet; + +import de.intevation.flys.artifacts.FLYSArtifact; + +import de.intevation.flys.artifacts.states.DefaultState.ComputeType; + + +public class WMSLayerFacet extends DefaultFacet { + + protected ComputeType type; + protected List<String> layers; + protected String stateId; + protected String hash; + protected String url; + + + private static final Logger logger = Logger.getLogger(WMSLayerFacet.class); + + + public WMSLayerFacet(int index, String name, String description) { + this(index, name, description, ComputeType.FEED, null, null); + } + + + public WMSLayerFacet( + int index, + String name, + String description, + ComputeType type, + String stateId, + String hash + + ) { + super(index, name, description); + this.layers = new ArrayList<String>(); + this.type = type; + this.stateId = stateId; + this.hash = hash; + } + + + public WMSLayerFacet( + int index, + String name, + String description, + ComputeType type, + String stateId, + String hash, + String url + ) { + this(index, name, description, type, stateId, hash); + this.url = url; + } + + + public void addLayer(String name) { + if (name != null && name.length() > 0) { + layers.add(name); + } + } + + + public Object getData(Artifact artifact, CallContext context) { + return null; + } +}
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Mon Jul 18 09:20:42 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DefaultState.java Mon Jul 18 10:13:25 2011 +0000 @@ -40,7 +40,7 @@ private static Logger logger = Logger.getLogger(DefaultState.class); public static enum ComputeType { - FEED, ADVANCE + FEED, ADVANCE, INIT } protected StateData getData(FLYSArtifact artifact, String name) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RiverAxisState.java Mon Jul 18 10:13:25 2011 +0000 @@ -0,0 +1,44 @@ +package de.intevation.flys.artifacts.states; + +import java.util.List; + +import org.apache.log4j.Logger; + +import de.intevation.artifacts.CallMeta; + +import de.intevation.artifactdatabase.state.Facet; + +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.model.WMSLayerFacet; +import de.intevation.flys.artifacts.states.DefaultState.ComputeType; + + +public class RiverAxisState extends OutputState { + + private static final Logger logger = Logger.getLogger(RiverAxisState.class); + + @Override + public Object computeInit( + FLYSArtifact artifact, + String hash, + CallMeta meta, + List<Facet> facets + ) { + logger.debug("RiverAxisState.computeInit()"); + + WMSLayerFacet facet = new WMSLayerFacet( + 0, + FLOODMAP_RIVERAXIS, + "RIVER AXIS", + ComputeType.INIT, + getID(), hash, + "http://localhost/wms/"); // TODO add correct WMS URL + + facet.addLayer("riveraxis"); + + facets.add(facet); + + return null; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/WMSBackgroundState.java Mon Jul 18 10:13:25 2011 +0000 @@ -0,0 +1,44 @@ +package de.intevation.flys.artifacts.states; + +import java.util.List; + +import org.apache.log4j.Logger; + +import de.intevation.artifacts.CallMeta; + +import de.intevation.artifactdatabase.state.Facet; + +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.model.WMSLayerFacet; +import de.intevation.flys.artifacts.states.DefaultState.ComputeType; + + +public class WMSBackgroundState extends OutputState { + + private static final Logger logger = Logger.getLogger(WMSBackgroundState.class); + + @Override + public Object computeInit( + FLYSArtifact artifact, + String hash, + CallMeta meta, + List<Facet> facets + ) { + logger.debug("WMSBackgroundState.computeInit()"); + + WMSLayerFacet facet = new WMSLayerFacet( + 0, + FLOODMAP_WMSBACKGROUND, + "WMS-BACKGROUND", + ComputeType.INIT, + getID(), hash, + "http://vmap0.tiles.osgeo.org/wms/vmap0"); + + facet.addLayer("basic"); + + facets.add(facet); + + return null; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :