changeset 3300:e1cf76b3ecb4

Moved map and WSPLGEN code to subpackage 'map' in the model package. flys-artifacts/trunk@4985 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Fri, 13 Jul 2012 10:19:23 +0000
parents d76a889bc30d
children c8f670ae96e8
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSDBLayerFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENJob.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENLayerFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENReportFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/map/WMSDBLayerFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/map/WMSLayerFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/map/WSPLGENCalculation.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/map/WSPLGENJob.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/map/WSPLGENLayerFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/map/WSPLGENReportFacet.java
diffstat 13 files changed, 957 insertions(+), 936 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Fri Jul 13 10:17:05 2012 +0000
+++ b/flys-artifacts/ChangeLog	Fri Jul 13 10:19:23 2012 +0000
@@ -1,3 +1,21 @@
+2012-07-13  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/WSPLGENJob.java,
+	  src/main/java/de/intevation/flys/artifacts/model/WMSDBLayerFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/WSPLGENLayerFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/WSPLGENCalculation.java,
+	  src/main/java/de/intevation/flys/artifacts/model/WSPLGENReportFacet.java:
+	  Moved to subpackage map.
+
+	* src/main/java/de/intevation/flys/artifacts/model/map/WSPLGENLayerFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/map/WMSLayerFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/map/WSPLGENJob.java,
+	  src/main/java/de/intevation/flys/artifacts/model/map/WMSDBLayerFacet.java,
+	  src/main/java/de/intevation/flys/artifacts/model/map/WSPLGENCalculation.java,
+	  src/main/java/de/intevation/flys/artifacts/model/map/WSPLGENReportFacet.java:
+	  Moved from upper package.
+
 2012-07-13	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/sq/SQOverviewFacet.java,
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSDBLayerFacet.java	Fri Jul 13 10:17:05 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-package de.intevation.flys.artifacts.model;
-
-import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
-
-
-public class WMSDBLayerFacet extends WMSLayerFacet {
-
-    protected String data;
-    protected String filter;
-    protected String labelItem;
-    protected String geometryType;
-    protected String connection;
-    protected String connectionType;
-
-
-    public WMSDBLayerFacet() {
-        super();
-    }
-
-
-    public WMSDBLayerFacet(int index, String name, String description) {
-        this(index, name, description, ComputeType.FEED, null, null);
-    }
-
-
-    public WMSDBLayerFacet(
-        int         index,
-        String      name,
-        String      description,
-        ComputeType type,
-        String      stateId,
-        String      hash
-
-    ) {
-        super(index, name, description, type, stateId, hash);
-    }
-
-
-    public WMSDBLayerFacet(
-        int         index,
-        String      name,
-        String      description,
-        ComputeType type,
-        String      stateId,
-        String      hash,
-        String      url
-    ) {
-        super(index, name, description, type, stateId, hash, url);
-    }
-
-
-    public void setFilter(String filter) {
-        this.filter = filter;
-    }
-
-    public String getFilter() {
-        return filter;
-    }
-
-    public void setData(String data) {
-        this.data = data;
-    }
-
-    public String getData() {
-        return data;
-    }
-
-    public void setGeometryType(String geometryType) {
-        this.geometryType = geometryType;
-    }
-
-    public String getGeometryType() {
-        return geometryType;
-    }
-
-    public void setConnection(String connection) {
-        this.connection = connection;
-    }
-
-    public String getConnection() {
-        return connection;
-    }
-
-    public void setConnectionType(String connectionType) {
-        this.connectionType = connectionType;
-    }
-
-    public String getConnectionType() {
-        return connectionType;
-    }
-
-    public void setLabelItem(String labelItem) {
-        this.labelItem = labelItem;
-    }
-
-    public String getLabelItem() {
-        return labelItem;
-    }
-
-
-    @Override
-    public boolean isQueryable() {
-        return true;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WMSLayerFacet.java	Fri Jul 13 10:17:05 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,173 +0,0 @@
-package de.intevation.flys.artifacts.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-import com.vividsolutions.jts.geom.Envelope;
-
-import de.intevation.artifacts.Artifact;
-import de.intevation.artifacts.ArtifactNamespaceContext;
-import de.intevation.artifacts.CallContext;
-
-import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
-
-import de.intevation.artifactdatabase.state.DefaultFacet;
-import de.intevation.artifactdatabase.state.Facet;
-
-import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
-import de.intevation.flys.utils.GeometryUtils;
-
-
-public class WMSLayerFacet
-extends      DefaultFacet
-{
-    protected ComputeType  type;
-    protected List<String> layers;
-    protected String       stateId;
-    protected String       hash;
-    protected String       url;
-    protected Envelope     extent;
-    protected String       srid;
-
-
-    private static final Logger logger = Logger.getLogger(WMSLayerFacet.class);
-
-    public WMSLayerFacet() {
-    }
-
-
-    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 List<String> getLayers() {
-        return layers;
-    }
-
-
-    public void removeLayer(String layer) {
-        if (layers != null) {
-            layers.remove(layer);
-        }
-    }
-
-
-    public void setExtent(Envelope extent) {
-        if (extent != null) {
-            this.extent = extent;
-        }
-    }
-
-
-    public Envelope getExtent() {
-        return extent;
-    }
-
-
-    public void setSrid(String srid) {
-        if (srid != null) {
-            this.srid = srid;
-        }
-    }
-
-
-    public String getSrid() {
-        return srid;
-    }
-
-
-    public Object getData(Artifact artifact, CallContext context) {
-        return null;
-    }
-
-
-    @Override
-    public Node toXML(Document doc) {
-        ElementCreator ec = new ElementCreator(
-            doc,
-            ArtifactNamespaceContext.NAMESPACE_URI,
-            ArtifactNamespaceContext.NAMESPACE_PREFIX);
-
-        Element facet = ec.create("facet");
-        ec.addAttr(facet, "description", description, true);
-        ec.addAttr(facet, "index", String.valueOf(index), true);
-        ec.addAttr(facet, "name", name, true);
-        ec.addAttr(facet, "url", url, true);
-        ec.addAttr(facet, "layers", layers.get(0), true);
-        ec.addAttr(facet, "srid", srid != null ? srid : "", true);
-        ec.addAttr(facet, "extent", extent != null
-            ? GeometryUtils.jtsBoundsToOLBounds(extent)
-            : "", true);
-        ec.addAttr(facet, "queryable", String.valueOf(isQueryable()), true);
-
-        return facet;
-    }
-
-
-    public boolean isQueryable() {
-        return false;
-    }
-
-
-    @Override
-    public Facet deepCopy() {
-        WMSLayerFacet copy = new WMSLayerFacet();
-        copy.set(this);
-
-        copy.type    = type;
-        copy.layers  = new ArrayList<String>(layers);
-        copy.stateId = stateId;
-        copy.hash    = hash;
-        copy.url     = url;
-        copy.extent  = extent;
-        copy.srid    = srid;
-
-        return copy;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENCalculation.java	Fri Jul 13 10:17:05 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-package de.intevation.flys.artifacts.model;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.apache.log4j.Logger;
-
-import de.intevation.artifacts.CallMeta;
-
-
-public class WSPLGENCalculation extends Calculation {
-
-    private static final Logger log = Logger.getLogger(WSPLGENCalculation.class);
-
-    protected Map<Integer, String> errors;
-    protected Map<Integer, String> warnings;
-
-
-    public WSPLGENCalculation() {
-        errors   = new HashMap<Integer, String>();
-        warnings = new HashMap<Integer, String>();
-    }
-
-
-    public void addError(Integer key, String msg) {
-        log.debug("New error: (" + key + ") " + msg);
-        errors.put(key, msg);
-    }
-
-
-    public void addWarning(Integer key, String msg) {
-        log.debug("New warning: (" + key + ") " + msg);
-        warnings.put(key, msg);
-    }
-
-
-    public int numErrors() {
-        return errors.size();
-    }
-
-
-    public int numWarnings() {
-        return warnings.size();
-    }
-
-
-    @Override
-    public void toXML(Document document, CallMeta meta) {
-        Element root = document.createElement("problems");
-
-        if (numErrors() > 0) {
-            Set<Map.Entry<Integer, String>> entrySet = errors.entrySet();
-
-            for (Map.Entry<Integer, String> entry: entrySet) {
-                Element problem = document.createElement("problem");
-                problem.setAttribute("error", String.valueOf(entry.getKey()));
-                problem.setTextContent(entry.getValue());
-
-                root.appendChild(problem);
-            }
-        }
-
-        if (numWarnings() > 0) {
-            Set<Map.Entry<Integer, String>> entrySet = warnings.entrySet();
-
-            for (Map.Entry<Integer, String> entry: entrySet) {
-                Element problem = document.createElement("problem");
-                problem.setAttribute("error", String.valueOf(entry.getKey()));
-                problem.setTextContent(entry.getValue());
-
-                root.appendChild(problem);
-            }
-        }
-
-        document.appendChild(root);
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENJob.java	Fri Jul 13 10:17:05 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,473 +0,0 @@
-package de.intevation.flys.artifacts.model;
-
-import java.io.IOException;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-import de.intevation.artifacts.CallContext;
-
-import de.intevation.flys.artifacts.FLYSArtifact;
-import de.intevation.flys.wsplgen.FacetCreator;
-
-
-public class WSPLGENJob {
-
-    public static final String GEL_SPERRE   = "SPERRE";
-    public static final String GEL_NOSPERRE = "NOSPERRE";
-
-
-    protected FLYSArtifact artifact;
-
-    protected CallContext callContext;
-
-    protected WSPLGENCalculation calculation;
-
-    protected FacetCreator facetCreator;
-
-    protected File workingDir;
-
-    protected String dgm;
-    protected String pro;
-    protected String wsp;
-    protected String wspTag;
-    protected String axis;
-    protected String area;
-    protected String gel;
-    protected String outFile;
-
-    protected List<String> lin;
-
-    protected int out;
-
-    protected double start;
-    protected double end;
-    protected double from;
-    protected double to;
-    protected double diff;
-    protected double dist;
-
-
-
-    public WSPLGENJob(
-        FLYSArtifact       flys,
-        File               workingDir,
-        FacetCreator       facetCreator,
-        CallContext        context,
-        WSPLGENCalculation calculation)
-    {
-        this.artifact     = flys;
-        this.workingDir   = workingDir;
-        this.facetCreator = facetCreator;
-        this.callContext  = context;
-        this.calculation  = calculation;
-
-        out   = -1;
-        start = Double.NaN;
-        end   = Double.NaN;
-        from  = Double.NaN;
-        to    = Double.NaN;
-        diff  = Double.NaN;
-        dist  = Double.NaN;
-        lin   = new ArrayList<String>(3);
-    }
-
-
-    public File getWorkingDir() {
-        return workingDir;
-    }
-
-
-    public FLYSArtifact getArtifact() {
-        return artifact;
-    }
-
-
-    public FacetCreator getFacetCreator() {
-        return facetCreator;
-    }
-
-
-    public WSPLGENCalculation getCalculation() {
-        return calculation;
-    }
-
-
-    public CallContext getCallContext() {
-        return callContext;
-    }
-
-
-    public void setWsp(String wsp) {
-        this.wsp = wsp;
-    }
-
-
-    public String getWsp() {
-        return wsp;
-    }
-
-
-    public void setWspTag(String wspTag) {
-        this.wspTag = wspTag;
-    }
-
-
-    public String getWspTag() {
-        return wspTag;
-    }
-
-
-    public void addLin(String lin) {
-        this.lin.add(lin);
-    }
-
-
-    public List<String> getLin() {
-        return lin;
-    }
-
-
-    public void setAxis(String axis) {
-        this.axis = axis;
-    }
-
-
-    public String getAxis() {
-        return axis;
-    }
-
-
-    public void setArea(String area) {
-        this.area = area;
-    }
-
-
-    public String getArea() {
-        return area;
-    }
-
-
-    public void setOut(int out) {
-        this.out = out;
-    }
-
-
-    public int getOut() {
-        return out;
-    }
-
-
-    public void setOutFile(String outFile) {
-        this.outFile = outFile;
-    }
-
-
-    public String getOutFile() {
-        return outFile;
-    }
-
-
-    public void setStart(double start) {
-        this.start = start;
-    }
-
-
-    public double getStart() {
-        return start;
-    }
-
-
-    public void setEnd(double end) {
-        this.end = end;
-    }
-
-
-    public double getEnd() {
-        return end;
-    }
-
-
-    public void setPro(String pro) {
-        this.pro = pro;
-    }
-
-
-    public String getPro() {
-        return pro;
-    }
-
-
-    public void setDgm(String dgm) {
-        this.dgm = dgm;
-    }
-
-
-    public String getDgm() {
-        return dgm;
-    }
-
-
-    public void setFrom(double from) {
-        this.from = from;
-    }
-
-
-    public double getFrom() {
-        return from;
-    }
-
-
-    public void setTo(double to) {
-        this.to = to;
-    }
-
-
-    public double getTo() {
-        return to;
-    }
-
-
-    public void setDiff(double diff) {
-        this.diff = diff;
-    }
-
-
-    public double getDiff() {
-        return diff;
-    }
-
-
-    public void setDist(double dist) {
-        this.dist = dist;
-    }
-
-
-    public double getDist() {
-        return dist;
-    }
-
-
-    public void setGel(String gel) {
-        if (gel == null || gel.length() == 0) {
-            return;
-        }
-
-        if (gel.equals(GEL_SPERRE) || gel.equals(GEL_NOSPERRE)) {
-            this.gel = gel;
-        }
-    }
-
-
-    public String getGel() {
-        return gel;
-    }
-
-
-    public void toFile(File file)
-    throws IOException, IllegalArgumentException
-    {
-        PrintWriter writer = null;
-
-        try {
-            writer =
-                new PrintWriter(
-                    new OutputStreamWriter(
-                        new FileOutputStream(file)));
-
-            write(writer);
-        }
-        finally {
-            if (writer != null) {
-                writer.flush();
-                writer.close();
-            }
-        }
-    }
-
-
-    protected void write(PrintWriter writer)
-    throws IOException, IllegalArgumentException
-    {
-        writeWsp(writer);    // required
-        writeWspTag(writer); // required
-        writeLin(writer);
-        writeAxis(writer);
-        writeArea(writer);
-        writeOut(writer);
-        writeOutFile(writer);
-        writeRange(writer);
-        writeDelta(writer);
-        writeGel(writer);
-        writeDist(writer);
-        writePro(writer);
-        writeDgm(writer);    // required
-    }
-
-
-    protected void writeWsp(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        String wsp = getWsp();
-
-        if (wsp != null && wsp.length() > 0) {
-            writer.println("-WSP=\"" + wsp + "\"");
-            return;
-        }
-
-        throw new IllegalArgumentException("Required WSP missing!");
-    }
-
-    protected void writeWspTag(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        String wspTag = getWspTag();
-
-        if (wspTag != null && wspTag.length() > 0) {
-            writer.println("-WSPTAG=\"" + wspTag + "\"");
-            return;
-        }
-
-        throw new IllegalArgumentException("Required WSPTAG missing!");
-    }
-
-    protected void writeLin(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        List<String> lins = getLin();
-
-        if (lins != null && !lins.isEmpty()) {
-            for (String lin: lins) {
-                writer.println("-LIN=\"" + lin + "\"");
-            }
-        }
-    }
-
-    protected void writeAxis(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        String axis = getAxis();
-
-        if (axis != null && axis.length() > 0) {
-            writer.println("-ACHSE=\"" + axis + "\"");
-        }
-    }
-
-    protected void writeGel(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        if (area != null && area.length() > 0) {
-            writer.println("-GEL=" + getGel());
-        }
-    }
-
-    protected void writeArea(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        String area = getArea();
-
-        if (area != null && area.length() > 0) {
-            writer.println("-GEBIET=\"" + area + "\"");
-        }
-    }
-
-
-    protected void writeOut(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        int out = getOut();
-
-        if (out >= 0) {
-            writer.println("-OUTPUT=" + String.valueOf(out));
-        }
-    }
-
-    protected void writeOutFile(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        String outFile = getOutFile();
-
-        if (outFile != null && outFile.length() > 0) {
-            writer.println("-AUSGABE=\""+ outFile + "\"");
-        }
-    }
-
-    protected void writeRange(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        StringBuilder sb = new StringBuilder("-STRECKE=");
-
-        double start = getStart();
-        double end   = getEnd();
-
-        if (Double.isNaN(start) && Double.isNaN(end)) {
-            return;
-        }
-
-        if (! Double.isNaN(getStart())) {
-            sb.append(getStart());
-        }
-
-        sb.append(",");
-
-        if (! Double.isNaN(getEnd())) {
-            sb.append(getEnd());
-        }
-
-        writer.println(sb.toString());
-    }
-
-    protected void writeDelta(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        StringBuilder sb = new StringBuilder("-DELTA=");
-        if (! Double.isNaN(from)) {
-            sb.append(from);
-        }
-
-        sb.append(",");
-
-        if (! Double.isNaN(to)) {
-            sb.append(to);
-        }
-
-        sb.append(",");
-
-        if (! Double.isNaN(diff)) {
-            sb.append(diff);
-        }
-
-        writer.println(sb.toString());
-    }
-
-    protected void writeDist(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        if (! Double.isNaN(getDist())) {
-            writer.println("-DIST=" + String.valueOf(getDist()));
-        }
-    }
-
-    protected void writePro(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        if (pro != null && pro.length() > 0) {
-            writer.println("-PRO=\"" + getPro() + "\"");
-        }
-    }
-
-    protected void writeDgm(PrintWriter writer)
-    throws IllegalArgumentException
-    {
-        if (dgm != null && dgm.length() > 0) {
-            writer.println("-DGM=\"" + getDgm() + "\"");
-            return;
-        }
-
-        throw new IllegalArgumentException("Required DGM missing!");
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENLayerFacet.java	Fri Jul 13 10:17:05 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-package de.intevation.flys.artifacts.model;
-
-import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
-
-public class WSPLGENLayerFacet
-extends      WMSLayerFacet
-{
-    public WSPLGENLayerFacet() {
-    }
-
-
-    public WSPLGENLayerFacet(int index, String name, String description) {
-        this(index, name, description, ComputeType.FEED, null, null);
-    }
-
-
-    public WSPLGENLayerFacet(
-        int         index,
-        String      name,
-        String      description,
-        ComputeType type,
-        String      stateId,
-        String      hash
-    ) {
-        super(index, name, description, type, stateId, hash);
-    }
-
-    public WSPLGENLayerFacet(
-        int         index,
-        String      name,
-        String      description,
-        ComputeType type,
-        String      stateId,
-        String      hash,
-        String      url
-    ) {
-        super(index, name, description, type, stateId, hash, url);
-    }
-
-
-    @Override
-    public boolean isQueryable() {
-        return true;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WSPLGENReportFacet.java	Fri Jul 13 10:17:05 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-package de.intevation.flys.artifacts.model;
-
-import org.apache.log4j.Logger;
-
-import de.intevation.artifacts.Artifact;
-import de.intevation.artifacts.CallContext;
-
-import de.intevation.artifactdatabase.state.Facet;
-
-import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
-
-
-/**
- * This facet is used to provide WSPLGEN reports <b>only</b>.
- */
-public class WSPLGENReportFacet extends ReportFacet {
-
-    private static Logger logger = Logger.getLogger(WSPLGENReportFacet.class);
-
-
-    protected CalculationResult result;
-
-
-    public WSPLGENReportFacet() {
-    }
-
-
-    public WSPLGENReportFacet(
-        ComputeType       type,
-        String            hash,
-        String            stateId,
-        CalculationResult result
-    ) {
-        super(type, hash, stateId);
-        this.result = result;
-    }
-
-
-    @Override
-    public Object getData(Artifact artifact, CallContext context) {
-        return result.getReport();
-    }
-
-
-    @Override
-    public Facet deepCopy() {
-        WSPLGENReportFacet copy = new WSPLGENReportFacet();
-        copy.set(this);
-        copy.type    = type;
-        copy.hash    = hash;
-        copy.stateId = stateId;
-        copy.result  = result;
-        return copy;
-    }
-}
-// 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/model/map/WMSDBLayerFacet.java	Fri Jul 13 10:19:23 2012 +0000
@@ -0,0 +1,106 @@
+package de.intevation.flys.artifacts.model.map;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+
+public class WMSDBLayerFacet extends WMSLayerFacet {
+
+    protected String data;
+    protected String filter;
+    protected String labelItem;
+    protected String geometryType;
+    protected String connection;
+    protected String connectionType;
+
+
+    public WMSDBLayerFacet() {
+        super();
+    }
+
+
+    public WMSDBLayerFacet(int index, String name, String description) {
+        this(index, name, description, ComputeType.FEED, null, null);
+    }
+
+
+    public WMSDBLayerFacet(
+        int         index,
+        String      name,
+        String      description,
+        ComputeType type,
+        String      stateId,
+        String      hash
+
+    ) {
+        super(index, name, description, type, stateId, hash);
+    }
+
+
+    public WMSDBLayerFacet(
+        int         index,
+        String      name,
+        String      description,
+        ComputeType type,
+        String      stateId,
+        String      hash,
+        String      url
+    ) {
+        super(index, name, description, type, stateId, hash, url);
+    }
+
+
+    public void setFilter(String filter) {
+        this.filter = filter;
+    }
+
+    public String getFilter() {
+        return filter;
+    }
+
+    public void setData(String data) {
+        this.data = data;
+    }
+
+    public String getData() {
+        return data;
+    }
+
+    public void setGeometryType(String geometryType) {
+        this.geometryType = geometryType;
+    }
+
+    public String getGeometryType() {
+        return geometryType;
+    }
+
+    public void setConnection(String connection) {
+        this.connection = connection;
+    }
+
+    public String getConnection() {
+        return connection;
+    }
+
+    public void setConnectionType(String connectionType) {
+        this.connectionType = connectionType;
+    }
+
+    public String getConnectionType() {
+        return connectionType;
+    }
+
+    public void setLabelItem(String labelItem) {
+        this.labelItem = labelItem;
+    }
+
+    public String getLabelItem() {
+        return labelItem;
+    }
+
+
+    @Override
+    public boolean isQueryable() {
+        return true;
+    }
+}
+// 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/model/map/WMSLayerFacet.java	Fri Jul 13 10:19:23 2012 +0000
@@ -0,0 +1,173 @@
+package de.intevation.flys.artifacts.model.map;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+import com.vividsolutions.jts.geom.Envelope;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.ArtifactNamespaceContext;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
+
+import de.intevation.artifactdatabase.state.DefaultFacet;
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+import de.intevation.flys.utils.GeometryUtils;
+
+
+public class WMSLayerFacet
+extends      DefaultFacet
+{
+    protected ComputeType  type;
+    protected List<String> layers;
+    protected String       stateId;
+    protected String       hash;
+    protected String       url;
+    protected Envelope     extent;
+    protected String       srid;
+
+
+    private static final Logger logger = Logger.getLogger(WMSLayerFacet.class);
+
+    public WMSLayerFacet() {
+    }
+
+
+    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 List<String> getLayers() {
+        return layers;
+    }
+
+
+    public void removeLayer(String layer) {
+        if (layers != null) {
+            layers.remove(layer);
+        }
+    }
+
+
+    public void setExtent(Envelope extent) {
+        if (extent != null) {
+            this.extent = extent;
+        }
+    }
+
+
+    public Envelope getExtent() {
+        return extent;
+    }
+
+
+    public void setSrid(String srid) {
+        if (srid != null) {
+            this.srid = srid;
+        }
+    }
+
+
+    public String getSrid() {
+        return srid;
+    }
+
+
+    public Object getData(Artifact artifact, CallContext context) {
+        return null;
+    }
+
+
+    @Override
+    public Node toXML(Document doc) {
+        ElementCreator ec = new ElementCreator(
+            doc,
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+
+        Element facet = ec.create("facet");
+        ec.addAttr(facet, "description", description, true);
+        ec.addAttr(facet, "index", String.valueOf(index), true);
+        ec.addAttr(facet, "name", name, true);
+        ec.addAttr(facet, "url", url, true);
+        ec.addAttr(facet, "layers", layers.get(0), true);
+        ec.addAttr(facet, "srid", srid != null ? srid : "", true);
+        ec.addAttr(facet, "extent", extent != null
+            ? GeometryUtils.jtsBoundsToOLBounds(extent)
+            : "", true);
+        ec.addAttr(facet, "queryable", String.valueOf(isQueryable()), true);
+
+        return facet;
+    }
+
+
+    public boolean isQueryable() {
+        return false;
+    }
+
+
+    @Override
+    public Facet deepCopy() {
+        WMSLayerFacet copy = new WMSLayerFacet();
+        copy.set(this);
+
+        copy.type    = type;
+        copy.layers  = new ArrayList<String>(layers);
+        copy.stateId = stateId;
+        copy.hash    = hash;
+        copy.url     = url;
+        copy.extent  = extent;
+        copy.srid    = srid;
+
+        return copy;
+    }
+}
+// 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/model/map/WSPLGENCalculation.java	Fri Jul 13 10:19:23 2012 +0000
@@ -0,0 +1,83 @@
+package de.intevation.flys.artifacts.model.map;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.CallMeta;
+import de.intevation.flys.artifacts.model.Calculation;
+
+
+public class WSPLGENCalculation extends Calculation {
+
+    private static final Logger log = Logger.getLogger(WSPLGENCalculation.class);
+
+    protected Map<Integer, String> errors;
+    protected Map<Integer, String> warnings;
+
+
+    public WSPLGENCalculation() {
+        errors   = new HashMap<Integer, String>();
+        warnings = new HashMap<Integer, String>();
+    }
+
+
+    public void addError(Integer key, String msg) {
+        log.debug("New error: (" + key + ") " + msg);
+        errors.put(key, msg);
+    }
+
+
+    public void addWarning(Integer key, String msg) {
+        log.debug("New warning: (" + key + ") " + msg);
+        warnings.put(key, msg);
+    }
+
+
+    public int numErrors() {
+        return errors.size();
+    }
+
+
+    public int numWarnings() {
+        return warnings.size();
+    }
+
+
+    @Override
+    public void toXML(Document document, CallMeta meta) {
+        Element root = document.createElement("problems");
+
+        if (numErrors() > 0) {
+            Set<Map.Entry<Integer, String>> entrySet = errors.entrySet();
+
+            for (Map.Entry<Integer, String> entry: entrySet) {
+                Element problem = document.createElement("problem");
+                problem.setAttribute("error", String.valueOf(entry.getKey()));
+                problem.setTextContent(entry.getValue());
+
+                root.appendChild(problem);
+            }
+        }
+
+        if (numWarnings() > 0) {
+            Set<Map.Entry<Integer, String>> entrySet = warnings.entrySet();
+
+            for (Map.Entry<Integer, String> entry: entrySet) {
+                Element problem = document.createElement("problem");
+                problem.setAttribute("error", String.valueOf(entry.getKey()));
+                problem.setTextContent(entry.getValue());
+
+                root.appendChild(problem);
+            }
+        }
+
+        document.appendChild(root);
+    }
+}
+// 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/model/map/WSPLGENJob.java	Fri Jul 13 10:19:23 2012 +0000
@@ -0,0 +1,473 @@
+package de.intevation.flys.artifacts.model.map;
+
+import java.io.IOException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.wsplgen.FacetCreator;
+
+
+public class WSPLGENJob {
+
+    public static final String GEL_SPERRE   = "SPERRE";
+    public static final String GEL_NOSPERRE = "NOSPERRE";
+
+
+    protected FLYSArtifact artifact;
+
+    protected CallContext callContext;
+
+    protected WSPLGENCalculation calculation;
+
+    protected FacetCreator facetCreator;
+
+    protected File workingDir;
+
+    protected String dgm;
+    protected String pro;
+    protected String wsp;
+    protected String wspTag;
+    protected String axis;
+    protected String area;
+    protected String gel;
+    protected String outFile;
+
+    protected List<String> lin;
+
+    protected int out;
+
+    protected double start;
+    protected double end;
+    protected double from;
+    protected double to;
+    protected double diff;
+    protected double dist;
+
+
+
+    public WSPLGENJob(
+        FLYSArtifact       flys,
+        File               workingDir,
+        FacetCreator       facetCreator,
+        CallContext        context,
+        WSPLGENCalculation calculation)
+    {
+        this.artifact     = flys;
+        this.workingDir   = workingDir;
+        this.facetCreator = facetCreator;
+        this.callContext  = context;
+        this.calculation  = calculation;
+
+        out   = -1;
+        start = Double.NaN;
+        end   = Double.NaN;
+        from  = Double.NaN;
+        to    = Double.NaN;
+        diff  = Double.NaN;
+        dist  = Double.NaN;
+        lin   = new ArrayList<String>(3);
+    }
+
+
+    public File getWorkingDir() {
+        return workingDir;
+    }
+
+
+    public FLYSArtifact getArtifact() {
+        return artifact;
+    }
+
+
+    public FacetCreator getFacetCreator() {
+        return facetCreator;
+    }
+
+
+    public WSPLGENCalculation getCalculation() {
+        return calculation;
+    }
+
+
+    public CallContext getCallContext() {
+        return callContext;
+    }
+
+
+    public void setWsp(String wsp) {
+        this.wsp = wsp;
+    }
+
+
+    public String getWsp() {
+        return wsp;
+    }
+
+
+    public void setWspTag(String wspTag) {
+        this.wspTag = wspTag;
+    }
+
+
+    public String getWspTag() {
+        return wspTag;
+    }
+
+
+    public void addLin(String lin) {
+        this.lin.add(lin);
+    }
+
+
+    public List<String> getLin() {
+        return lin;
+    }
+
+
+    public void setAxis(String axis) {
+        this.axis = axis;
+    }
+
+
+    public String getAxis() {
+        return axis;
+    }
+
+
+    public void setArea(String area) {
+        this.area = area;
+    }
+
+
+    public String getArea() {
+        return area;
+    }
+
+
+    public void setOut(int out) {
+        this.out = out;
+    }
+
+
+    public int getOut() {
+        return out;
+    }
+
+
+    public void setOutFile(String outFile) {
+        this.outFile = outFile;
+    }
+
+
+    public String getOutFile() {
+        return outFile;
+    }
+
+
+    public void setStart(double start) {
+        this.start = start;
+    }
+
+
+    public double getStart() {
+        return start;
+    }
+
+
+    public void setEnd(double end) {
+        this.end = end;
+    }
+
+
+    public double getEnd() {
+        return end;
+    }
+
+
+    public void setPro(String pro) {
+        this.pro = pro;
+    }
+
+
+    public String getPro() {
+        return pro;
+    }
+
+
+    public void setDgm(String dgm) {
+        this.dgm = dgm;
+    }
+
+
+    public String getDgm() {
+        return dgm;
+    }
+
+
+    public void setFrom(double from) {
+        this.from = from;
+    }
+
+
+    public double getFrom() {
+        return from;
+    }
+
+
+    public void setTo(double to) {
+        this.to = to;
+    }
+
+
+    public double getTo() {
+        return to;
+    }
+
+
+    public void setDiff(double diff) {
+        this.diff = diff;
+    }
+
+
+    public double getDiff() {
+        return diff;
+    }
+
+
+    public void setDist(double dist) {
+        this.dist = dist;
+    }
+
+
+    public double getDist() {
+        return dist;
+    }
+
+
+    public void setGel(String gel) {
+        if (gel == null || gel.length() == 0) {
+            return;
+        }
+
+        if (gel.equals(GEL_SPERRE) || gel.equals(GEL_NOSPERRE)) {
+            this.gel = gel;
+        }
+    }
+
+
+    public String getGel() {
+        return gel;
+    }
+
+
+    public void toFile(File file)
+    throws IOException, IllegalArgumentException
+    {
+        PrintWriter writer = null;
+
+        try {
+            writer =
+                new PrintWriter(
+                    new OutputStreamWriter(
+                        new FileOutputStream(file)));
+
+            write(writer);
+        }
+        finally {
+            if (writer != null) {
+                writer.flush();
+                writer.close();
+            }
+        }
+    }
+
+
+    protected void write(PrintWriter writer)
+    throws IOException, IllegalArgumentException
+    {
+        writeWsp(writer);    // required
+        writeWspTag(writer); // required
+        writeLin(writer);
+        writeAxis(writer);
+        writeArea(writer);
+        writeOut(writer);
+        writeOutFile(writer);
+        writeRange(writer);
+        writeDelta(writer);
+        writeGel(writer);
+        writeDist(writer);
+        writePro(writer);
+        writeDgm(writer);    // required
+    }
+
+
+    protected void writeWsp(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        String wsp = getWsp();
+
+        if (wsp != null && wsp.length() > 0) {
+            writer.println("-WSP=\"" + wsp + "\"");
+            return;
+        }
+
+        throw new IllegalArgumentException("Required WSP missing!");
+    }
+
+    protected void writeWspTag(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        String wspTag = getWspTag();
+
+        if (wspTag != null && wspTag.length() > 0) {
+            writer.println("-WSPTAG=\"" + wspTag + "\"");
+            return;
+        }
+
+        throw new IllegalArgumentException("Required WSPTAG missing!");
+    }
+
+    protected void writeLin(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        List<String> lins = getLin();
+
+        if (lins != null && !lins.isEmpty()) {
+            for (String lin: lins) {
+                writer.println("-LIN=\"" + lin + "\"");
+            }
+        }
+    }
+
+    protected void writeAxis(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        String axis = getAxis();
+
+        if (axis != null && axis.length() > 0) {
+            writer.println("-ACHSE=\"" + axis + "\"");
+        }
+    }
+
+    protected void writeGel(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        if (area != null && area.length() > 0) {
+            writer.println("-GEL=" + getGel());
+        }
+    }
+
+    protected void writeArea(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        String area = getArea();
+
+        if (area != null && area.length() > 0) {
+            writer.println("-GEBIET=\"" + area + "\"");
+        }
+    }
+
+
+    protected void writeOut(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        int out = getOut();
+
+        if (out >= 0) {
+            writer.println("-OUTPUT=" + String.valueOf(out));
+        }
+    }
+
+    protected void writeOutFile(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        String outFile = getOutFile();
+
+        if (outFile != null && outFile.length() > 0) {
+            writer.println("-AUSGABE=\""+ outFile + "\"");
+        }
+    }
+
+    protected void writeRange(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        StringBuilder sb = new StringBuilder("-STRECKE=");
+
+        double start = getStart();
+        double end   = getEnd();
+
+        if (Double.isNaN(start) && Double.isNaN(end)) {
+            return;
+        }
+
+        if (! Double.isNaN(getStart())) {
+            sb.append(getStart());
+        }
+
+        sb.append(",");
+
+        if (! Double.isNaN(getEnd())) {
+            sb.append(getEnd());
+        }
+
+        writer.println(sb.toString());
+    }
+
+    protected void writeDelta(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        StringBuilder sb = new StringBuilder("-DELTA=");
+        if (! Double.isNaN(from)) {
+            sb.append(from);
+        }
+
+        sb.append(",");
+
+        if (! Double.isNaN(to)) {
+            sb.append(to);
+        }
+
+        sb.append(",");
+
+        if (! Double.isNaN(diff)) {
+            sb.append(diff);
+        }
+
+        writer.println(sb.toString());
+    }
+
+    protected void writeDist(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        if (! Double.isNaN(getDist())) {
+            writer.println("-DIST=" + String.valueOf(getDist()));
+        }
+    }
+
+    protected void writePro(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        if (pro != null && pro.length() > 0) {
+            writer.println("-PRO=\"" + getPro() + "\"");
+        }
+    }
+
+    protected void writeDgm(PrintWriter writer)
+    throws IllegalArgumentException
+    {
+        if (dgm != null && dgm.length() > 0) {
+            writer.println("-DGM=\"" + getDgm() + "\"");
+            return;
+        }
+
+        throw new IllegalArgumentException("Required DGM missing!");
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/map/WSPLGENLayerFacet.java	Fri Jul 13 10:19:23 2012 +0000
@@ -0,0 +1,46 @@
+package de.intevation.flys.artifacts.model.map;
+
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+public class WSPLGENLayerFacet
+extends      WMSLayerFacet
+{
+    public WSPLGENLayerFacet() {
+    }
+
+
+    public WSPLGENLayerFacet(int index, String name, String description) {
+        this(index, name, description, ComputeType.FEED, null, null);
+    }
+
+
+    public WSPLGENLayerFacet(
+        int         index,
+        String      name,
+        String      description,
+        ComputeType type,
+        String      stateId,
+        String      hash
+    ) {
+        super(index, name, description, type, stateId, hash);
+    }
+
+    public WSPLGENLayerFacet(
+        int         index,
+        String      name,
+        String      description,
+        ComputeType type,
+        String      stateId,
+        String      hash,
+        String      url
+    ) {
+        super(index, name, description, type, stateId, hash, url);
+    }
+
+
+    @Override
+    public boolean isQueryable() {
+        return true;
+    }
+}
+// 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/model/map/WSPLGENReportFacet.java	Fri Jul 13 10:19:23 2012 +0000
@@ -0,0 +1,58 @@
+package de.intevation.flys.artifacts.model.map;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.artifacts.Artifact;
+import de.intevation.artifacts.CallContext;
+
+import de.intevation.artifactdatabase.state.Facet;
+
+import de.intevation.flys.artifacts.model.CalculationResult;
+import de.intevation.flys.artifacts.model.ReportFacet;
+import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
+
+
+/**
+ * This facet is used to provide WSPLGEN reports <b>only</b>.
+ */
+public class WSPLGENReportFacet extends ReportFacet {
+
+    private static Logger logger = Logger.getLogger(WSPLGENReportFacet.class);
+
+
+    protected CalculationResult result;
+
+
+    public WSPLGENReportFacet() {
+    }
+
+
+    public WSPLGENReportFacet(
+        ComputeType       type,
+        String            hash,
+        String            stateId,
+        CalculationResult result
+    ) {
+        super(type, hash, stateId);
+        this.result = result;
+    }
+
+
+    @Override
+    public Object getData(Artifact artifact, CallContext context) {
+        return result.getReport();
+    }
+
+
+    @Override
+    public Facet deepCopy() {
+        WSPLGENReportFacet copy = new WSPLGENReportFacet();
+        copy.set(this);
+        copy.type    = type;
+        copy.hash    = hash;
+        copy.stateId = stateId;
+        copy.result  = result;
+        return copy;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org