changeset 5452:5287440b57b3

merged.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 27 Mar 2013 11:48:53 +0100
parents 278d8759c92b (current diff) 504a62887217 (diff)
children 303701ab73c6
files flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java
diffstat 47 files changed, 519 insertions(+), 415 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/doc/conf/artifacts/map.xml	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/doc/conf/artifacts/map.xml	Wed Mar 27 11:48:53 2013 +0100
@@ -32,6 +32,7 @@
                         <facet name="floodmap.floodmaps"/>
                         <facet name="floodmap.gauge_location"/>
                         <facet name="floodmap.externalwms"/>
+                        <facet name="floodmap.jetties"/>
                     </facets>
                 </outputmode>
             </outputmodes>
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/doc/conf/artifacts/winfo.xml	Wed Mar 27 11:48:53 2013 +0100
@@ -566,6 +566,7 @@
                         <facet name="floodmap.floodmaps"/>
                         <facet name="floodmap.gauge_location"/>
                         <facet name="floodmap.externalwms"/>
+                        <facet name="floodmap.jetties"/>
                     </facets>
                 </outputmode>
                 <outputmode name="wsplgen_report" description="output.wsplgen_report" mime-type="text/xml" type="report">
--- a/flys-artifacts/doc/conf/conf.xml	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/doc/conf/conf.xml	Wed Mar 27 11:48:53 2013 +0100
@@ -111,6 +111,9 @@
             <artifact-factory name="wmshwspointsfactory" description="Factory to create an artifact that generates WMS facets for HWS Points"
                 ttl="3600000"
                 artifact="de.intevation.flys.artifacts.WMSHWSPointsArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
+            <artifact-factory name="wmsjettiesfactory" description="Factory to create an artifact to be used in WINFO"
+                ttl="3600000"
+                artifact="de.intevation.flys.artifacts.WMSJettiesArtifact">de.intevation.artifactdatabase.DefaultArtifactFactory</artifact-factory>
 
             <!-- MINFO specific Artifacts -->
             <artifact-factory name="minfo" description="Factory to create an artifact to be used in module minfo."
--- a/flys-artifacts/doc/conf/meta-data.xml	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/doc/conf/meta-data.xml	Wed Mar 27 11:48:53 2013 +0100
@@ -1526,7 +1526,8 @@
                 bk.name AS building_kind
                 FROM buildings b
                 JOIN building_kinds bk ON b.kind_id = bk.id
-                WHERE river_id = ${river_id}
+                WHERE b.river_id = ${river_id}
+                AND b.kind_id != 0
               </dc:statement>
               <dc:elements>
                 <buildings>
@@ -1536,6 +1537,51 @@
                 </buildings>
               </dc:elements>
             </dc:context>
+            <dc:context>
+              <dc:statement>
+                SELECT DISTINCT
+                b.kind_id AS building_kind_id,
+                b.name AS building_name,
+                bk.name AS building_kind
+                FROM buildings b
+                JOIN building_kinds bk ON b.kind_id = bk.id
+                WHERE river_id = ${river_id}
+                AND kind_id = 0 OR
+                kind_id IS NULL
+              </dc:statement>
+              <dc:elements>
+                <dc:element name="${building_kind}">
+                  <dc:elements>
+                    <buildings>
+                      <dc:attribute name="description" value="${building_name}"/>
+                      <dc:attribute name="factory" value="wmsbuildingsfactory"/>
+                      <dc:attribute name="ids" value="${river_id};${building_name}"/>
+                    </buildings>
+                  </dc:elements>
+                </dc:element>
+              </dc:elements>
+            </dc:context>
+            <dc:context>
+              <dc:statement>
+                SELECT DISTINCT
+                j.kind_id AS jetty_kind_id,
+                jk.name AS jetty_kind
+                FROM jetties j
+                JOIN jetty_kinds jk ON j.kind_id = jk.id
+                WHERE river_id = ${river_id}
+              </dc:statement>
+              <dc:if test="dc:has-result()">
+                <jetties>
+                  <dc:elements>
+                    <jetty>
+                      <dc:attribute name="description" value="${jetty_kind}"/>
+                      <dc:attribute name="factory" value="wmsjettiesfactory"/>
+                      <dc:attribute name="ids" value="${river_id};${jetty_kind};${jetty_kind_id}"/>
+                    </jetty>
+                  </dc:elements>
+                </jetties>
+              </dc:if>
+            </dc:context>
           </dc:macro>
             <dc:macro name="flood-map-fixpoints">
               <dc:context>
--- a/flys-artifacts/doc/conf/themes.xml	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/doc/conf/themes.xml	Wed Mar 27 11:48:53 2013 +0100
@@ -214,6 +214,7 @@
         <mapping from="floodmap.fixpoints" to="Fixpoints" />
         <mapping from="floodmap.floodmaps" to="Floodmaps" />
         <mapping from="floodmap.gauge_location" to="GaugeLocation" />
+        <mapping from="floodmap.jetties" to="Jetties" />
         <mapping from="other.wq" to="WQPoints" />
         <mapping from="other.wkms" to="WKms" />
         <mapping from="other.wkms.marks" to="WKmsAnnotation" />
--- a/flys-artifacts/doc/conf/themes/default/floodmap.xml	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/doc/conf/themes/default/floodmap.xml	Wed Mar 27 11:48:53 2013 +0100
@@ -121,4 +121,12 @@
             <inherit from="Map" />
         </inherits>
     </theme>
+
+    <theme name="Jetties">
+        <inherits>
+            <inherit from="MapLines"/>
+            <inherit from="Label" />
+            <inherit from="Symbol" />
+        </inherits>
+    </theme>
 <!--/themegroup-->
--- a/flys-artifacts/doc/conf/themes/second/floodmap.xml	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/doc/conf/themes/second/floodmap.xml	Wed Mar 27 11:48:53 2013 +0100
@@ -121,4 +121,12 @@
             <inherit from="Map" />
         </inherits>
     </theme>
+
+    <theme name="Jetties">
+        <inherits>
+            <inherit from="MapLines"/>
+            <inherit from="Label" />
+            <inherit from="Symbol" />
+        </inherits>
+    </theme>
 <!--/themegroup-->
--- a/flys-artifacts/doc/howto_wmsartifact.txt	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/doc/howto_wmsartifact.txt	Wed Mar 27 11:48:53 2013 +0100
@@ -19,3 +19,10 @@
 - German localization:
     flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties
 
+You might also want a theme:
+- Add a mapping from your Facet to the theme in:
+    flys-artifacts/doc/conf/themes.xml
+- Define the theme in:
+    flys-artifacts/doc/conf/themes/default/floodmap.xml
+    flys-artifacts/doc/conf/themes/second/floodmap.xml
+
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/Builder.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/Builder.java	Wed Mar 27 11:48:53 2013 +0100
@@ -21,6 +21,7 @@
 
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
 import javax.xml.xpath.XPathExpressionException;
 import javax.xml.xpath.XPathFactory;
 
@@ -57,6 +58,8 @@
 
     protected Map<String, CompiledStatement> compiledStatements;
 
+    protected Map<String, Element> macros;
+
     /** Connection to either of the databases. */
     public static class NamedConnection {
 
@@ -94,6 +97,9 @@
         protected Map<String, CompiledStatement.Instance>  statements;
         protected Deque<Pair<NamedConnection, ResultData>> connectionsStack;
         protected Deque<NodeList>                          macroBodies;
+        protected FunctionResolver                         functionResolver;
+        protected Map<String, XPathExpression>             expressions;
+
 
         public BuildHelper(
             Node                  output,
@@ -110,9 +116,11 @@
             this.output      = output;
             frames           = new StackFrames(parameters);
             owner            = getOwnerDocument(output);
-            statements =
+            macroBodies      = new ArrayDeque<NodeList>();
+            functionResolver = new FunctionResolver(this);
+            expressions      = new HashMap<String, XPathExpression>();
+            statements       =
                 new HashMap<String, CompiledStatement.Instance>();
-            macroBodies = new ArrayDeque<NodeList>();
         }
 
         public void build() throws SQLException {
@@ -236,6 +244,10 @@
             }
         }
 
+        public boolean hasResult() {
+            return !connectionsStack.isEmpty()
+                && !connectionsStack.peek().getB().isEmpty();
+        }
 
         protected ResultData createFilteredResultData(ResultData rd, String filter) {
             if (filter == null) return rd;
@@ -403,18 +415,7 @@
                 return;
             }
 
-            NodeList macros = template.getElementsByTagNameNS(
-                DC_NAMESPACE_URI, "macro");
-
-            Element macro = null;
-
-            for (int i = 0, N = macros.getLength(); i < N; ++i) {
-                Element m = (Element) macros.item(i);
-                if (name.equals(m.getAttribute("name"))) {
-                    macro = m;
-                    break;
-                }
-            }
+            Element macro = macros.get(name);
 
             if (macro != null) {
                 macroBodies.push(current.getChildNodes());
@@ -534,6 +535,20 @@
             }
         }
 
+        protected XPathExpression getXPathExpression(String expr)
+        throws XPathExpressionException
+        {
+            XPathExpression x = expressions.get(expr);
+            if (x == null) {
+                XPath xpath = XPATH_FACTORY.newXPath();
+                xpath.setXPathVariableResolver(frames);
+                xpath.setXPathFunctionResolver(functionResolver);
+                x = xpath.compile(expr);
+                expressions.put(expr, x);
+            }
+            return x;
+        }
+
         protected Object evaluateXPath(String expr, QName returnType) {
 
             if (log.isDebugEnabled()) {
@@ -541,10 +556,8 @@
             }
 
             try {
-                XPath xpath = XPATH_FACTORY.newXPath();
-                xpath.setXPathVariableResolver(frames);
-                xpath.setXPathFunctionResolver(FunctionResolver.FUNCTIONS);
-                return xpath.evaluate(expr, EVAL_DOCUMENT, returnType);
+                XPathExpression x = getXPathExpression(expr);
+                return x.evaluate(EVAL_DOCUMENT, returnType);
             }
             catch (XPathExpressionException xpee) {
                 log.error("expression: " + expr, xpee);
@@ -695,11 +708,13 @@
 
     public Builder() {
         compiledStatements = new HashMap<String, CompiledStatement>();
+        macros             = new HashMap<String, Element>();
     }
 
     public Builder(Document template) {
         this();
         this.template = template;
+        extractMacros();
         compileStatements();
     }
 
@@ -731,6 +746,16 @@
         }
     }
 
+    protected void extractMacros() {
+        NodeList ms = template.getElementsByTagNameNS(
+            DC_NAMESPACE_URI, "macro");
+
+        for (int i = 0, N = ms.getLength(); i < N; ++i) {
+            Element m = (Element)ms.item(i);
+            macros.put(m.getAttribute("name"), m);
+        }
+    }
+
     protected List<Node> rootsToList() {
 
         NodeList roots = template.getElementsByTagNameNS(
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/FunctionResolver.java	Wed Mar 27 11:48:53 2013 +0100
@@ -39,168 +39,48 @@
         }
     } // class Entry
 
-    public static final FunctionResolver FUNCTIONS = new FunctionResolver();
-
-    static {
-        /** Implementation of case-ignoring dc:contains. */
-        FUNCTIONS.addFunction("contains", 2, new XPathFunction() {
-            @Override
-            public Object evaluate(List args) throws XPathFunctionException {
-                Object haystack = args.get(0);
-                Object needle   = args.get(1);
-
-                if (needle instanceof String) {
-                    needle = ((String)needle).toUpperCase();
-                }
-
-                try {
-                    if (haystack instanceof Collection) {
-                        return Boolean.valueOf(
-                            ((Collection)haystack).contains(needle));
-                    }
-
-                    if (haystack instanceof Map) {
-                        return Boolean.valueOf(
-                            ((Map)haystack).containsKey(needle));
-                    }
-
-                    if (haystack instanceof Object []) {
-                        for (Object straw: (Object [])haystack) {
-                            if (straw.equals(needle)) {
-                                return Boolean.TRUE;
-                            }
-                        }
-                    }
-
-                    return Boolean.FALSE;
-                }
-                catch (Exception e) {
-                    log.error(e);
-                    throw new XPathFunctionException(e);
-                }
-            }
-        });
-    }
-
-    static {
-        /** Implementation for getting the minimum value of location or distance
-         *  dc:fromValue. */
-        FUNCTIONS.addFunction("fromValue", 3, new XPathFunction() {
-            @Override
-            public Object evaluate(List args) throws XPathFunctionException {
-                Object mode      = args.get(0);
-                Object locations = args.get(1);
-                Object from      = args.get(2);
-
-                if (!(mode instanceof String)){
-                    return -99999d;
-                }
-
-                if (mode.equals("locations")) {
-                    if (!(locations instanceof String)) {
-                        return -99999d;
-                    }
-                    String loc = ((String)locations).replace(" ", "");
-                    String[] split = loc.split(",");
-                    if (split.length < 1) {
-                        return -99999d;
-                    }
-                    try {
-                        double min = Double.parseDouble(split[0]);
-                        for (int i = 1; i < split.length; ++i) {
-                            double v = Double.parseDouble(split[i]);
-                            if (v < min) {
-                                min = v;
-                            }
-                        }
-                        return min;
-                    }
-                    catch (NumberFormatException nfe) {
-                        return -99999d;
-                    }
-                }
-                else if (mode.equals("distance")) {
-                    if (!(from instanceof String)) {
-                        return -99999d;
-                    }
-                    String f = (String)from;
-                    try {
-                        return Double.parseDouble(f);
-                    }
-                    catch(NumberFormatException nfe) {
-                        return -99999d;
-                    }
-                }
-                else {
-                    return -99999d;
-                }
-            }
-        });
-    }
-
-    static {
-        /** Implementation for getting the maximum value of location or distance
-         *  dc:toValue. */
-        FUNCTIONS.addFunction("toValue", 3, new XPathFunction() {
-            @Override
-            public Object evaluate(List args) throws XPathFunctionException {
-                Object mode      = args.get(0);
-                Object locations = args.get(1);
-                Object to        = args.get(2);
-
-                if (!(mode instanceof String)){
-                    return 99999d;
-                }
-
-                if (mode.equals("locations")) {
-                    if (!(locations instanceof String)) {
-                        return 99999d;
-                    }
-                    try {
-                        String loc = ((String)locations).replace(" ", "");
-                        String[] split = loc.split(",");
-                        if (split.length < 1) {
-                            return 99999d;
-                        }
-                        double max = Double.parseDouble(split[0]);
-                        for (int i = 1; i < split.length; ++i) {
-                            double v = Double.parseDouble(split[i]);
-                            if (v > max) {
-                                max = v;
-                            }
-                        }
-                        return max;
-                    }
-                    catch (NumberFormatException nfe) {
-                        return 99999d;
-                    }
-                }
-                else if (mode.equals("distance")) {
-                    if (!(to instanceof String)) {
-                        return 99999d;
-                    }
-                    else {
-                        String t = (String)to;
-                        try {
-                            return Double.parseDouble(t);
-                        }
-                        catch(NumberFormatException nfe) {
-                            return 99999d;
-                        }
-                    }
-                }
-                else {
-                    return 99999d;
-                }
-            }
-        });
-    }
-
     /** List of functions. */
     protected List<Entry> functions;
 
+    protected Builder.BuildHelper buildHelper;
+
+
     public FunctionResolver() {
+        this(null);
+    }
+
+    public FunctionResolver(Builder.BuildHelper buildHelper) {
+        this.buildHelper = buildHelper;
+
         functions = new ArrayList<Entry>();
+
+        addFunction("contains", 2, new XPathFunction() {
+            @Override
+            public Object evaluate(List args) throws XPathFunctionException {
+                return contains(args);
+            }
+        });
+
+        addFunction("fromValue", 3, new XPathFunction() {
+            @Override
+            public Object evaluate(List args) throws XPathFunctionException {
+                return fromValue(args);
+            }
+        });
+
+        addFunction("toValue", 3, new XPathFunction() {
+            @Override
+            public Object evaluate(List args) throws XPathFunctionException {
+                return toValue(args);
+            }
+        });
+
+        addFunction("has-result", 0, new XPathFunction() {
+            @Override
+            public Object evaluate(List args) throws XPathFunctionException {
+                return FunctionResolver.this.buildHelper.hasResult();
+            }
+        });
     }
 
     /**
@@ -229,5 +109,147 @@
 
         return null;
     }
+
+    /** Implementation of case-ignoring dc:contains. */
+    public Object contains(List args) throws XPathFunctionException {
+        Object haystack = args.get(0);
+        Object needle   = args.get(1);
+
+        if (needle instanceof String) {
+            needle = ((String)needle).toUpperCase();
+        }
+
+        try {
+            if (haystack instanceof Collection) {
+                return Boolean.valueOf(
+                    ((Collection)haystack).contains(needle));
+            }
+
+            if (haystack instanceof Map) {
+                return Boolean.valueOf(
+                    ((Map)haystack).containsKey(needle));
+            }
+
+            if (haystack instanceof Object []) {
+                for (Object straw: (Object [])haystack) {
+                    if (straw.equals(needle)) {
+                        return Boolean.TRUE;
+                    }
+                }
+            }
+
+            return Boolean.FALSE;
+        }
+        catch (Exception e) {
+            log.error(e);
+            throw new XPathFunctionException(e);
+        }
+    }
+
+    /** Implementation for getting the minimum value of location or distance
+     *  dc:fromValue.
+     */
+    public Object fromValue(List args) throws XPathFunctionException {
+        Object mode      = args.get(0);
+        Object locations = args.get(1);
+        Object from      = args.get(2);
+
+        if (!(mode instanceof String)){
+            return -99999d;
+        }
+
+        if (mode.equals("locations")) {
+            if (!(locations instanceof String)) {
+                return -99999d;
+            }
+            String loc = ((String)locations).replace(" ", "");
+            String[] split = loc.split(",");
+            if (split.length < 1) {
+                return -99999d;
+            }
+            try {
+                double min = Double.parseDouble(split[0]);
+                for (int i = 1; i < split.length; ++i) {
+                    double v = Double.parseDouble(split[i]);
+                    if (v < min) {
+                        min = v;
+                    }
+                }
+                return min;
+            }
+            catch (NumberFormatException nfe) {
+                return -99999d;
+            }
+        }
+        else if (mode.equals("distance")) {
+            if (!(from instanceof String)) {
+                return -99999d;
+            }
+            String f = (String)from;
+            try {
+                return Double.parseDouble(f);
+            }
+            catch(NumberFormatException nfe) {
+                return -99999d;
+            }
+        }
+        else {
+            return -99999d;
+        }
+    }
+
+    /** Implementation for getting the maximum value of location or distance
+     *  dc:toValue.
+     */
+    public Object toValue(List args) throws XPathFunctionException {
+        Object mode      = args.get(0);
+        Object locations = args.get(1);
+        Object to        = args.get(2);
+
+        if (!(mode instanceof String)){
+            return 99999d;
+        }
+
+        if (mode.equals("locations")) {
+            if (!(locations instanceof String)) {
+                return 99999d;
+            }
+            try {
+                String loc = ((String)locations).replace(" ", "");
+                String[] split = loc.split(",");
+                if (split.length < 1) {
+                    return 99999d;
+                }
+                double max = Double.parseDouble(split[0]);
+                for (int i = 1; i < split.length; ++i) {
+                    double v = Double.parseDouble(split[i]);
+                    if (v > max) {
+                        max = v;
+                    }
+                }
+                return max;
+            }
+            catch (NumberFormatException nfe) {
+                return 99999d;
+            }
+        }
+        else if (mode.equals("distance")) {
+            if (!(to instanceof String)) {
+                return 99999d;
+            }
+            else {
+                String t = (String)to;
+                try {
+                    return Double.parseDouble(t);
+                }
+                catch(NumberFormatException nfe) {
+                    return 99999d;
+                }
+            }
+        }
+        else {
+            return 99999d;
+        }
+    }
 }
 // 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	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java	Wed Mar 27 11:48:53 2013 +0100
@@ -174,6 +174,7 @@
     String FLOODMAP_FLOODMAPS          = "floodmap.floodmaps";
     String FLOODMAP_GAUGE_LOCATION     = "floodmap.gauge_location";
     String FLOODMAP_EXTERNAL_WMS       = "floodmap.externalwms";
+    String FLOODMAP_JETTIES            = "floodmap.jetties";
 
     String DISCHARGE_LONGITUDINAL_W = "discharge_longitudinal_section.w";
     String DISCHARGE_LONGITUDINAL_Q = "discharge_longitudinal_section.q";
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WaterlevelFacet.java	Wed Mar 27 11:48:53 2013 +0100
@@ -38,7 +38,13 @@
     protected WQKms [] getWQKms(CalculationResult res) {
         if (res.getData() instanceof ExtremeResult)
             return ((ExtremeResult) res.getData()).getWQKms();
-        return (WQKms []) res.getData();
+        else if (res.getData() instanceof WQKms[]) {
+            return (WQKms []) res.getData();
+        }
+        else {
+            logger.error("WaterlevelFacet got wrong data type " + res.getData());
+            return null;
+        }
     }
 
     /**
@@ -70,47 +76,73 @@
 
         WQKms [] wqkms = getWQKms(res);
         Object KM = context.getContextValue("currentKm");
-        if (KM != null) {
-            logger.debug("interpolate at given km");
-            // TODO handle exact match.
-
-            WQKms wqkmsI = wqkms[index];
-            double km = (Double)KM;
 
-            // TODO employ DataUtils interface to TDoubleArraList
-            int size = wqkmsI.size();
-            boolean kmIncreasing = wqkmsI.getKm(0) < wqkmsI.getKm(size-1);
-            int mod = kmIncreasing ? +1 : -1;
-            int idx = 0;
-            if (!kmIncreasing) {
-                while (idx < size && wqkmsI.getKm(idx) < km) {
-                    idx++;
+        // Interpolation.
+        if (KM != null) {
+            linearInterpolate(wqkms[index], (Double) KM);
+        }
+        else {
+            logger.debug("Do not interpolate.");
+        }
+
+        return wqkms != null ? wqkms[index] : null;
+    }
+
+
+    /**
+     * Linear interpolation of WQKms.
+     * TODO rewrite.
+     * @return [w, q, km]
+     */
+    public WQKms linearInterpolate(WQKms wqkms, double km) {
+        logger.debug("interpolate at given km (" + km + ")");
+
+        WQKms resultWQKms = new WQKms();
+        int size = wqkms.size();
+        boolean kmIncreasing = wqkms.getKm(0) < wqkms.getKm(size-1);
+        int mod = kmIncreasing ? +1 : -1;
+        int idx = 0;
+        // Move idx to closest from one direction, check for match.
+        if (!kmIncreasing) {
+            while (idx < size && wqkms.getKm(idx) < km) {
+                if (Math.abs(wqkms.getKm(idx) - km) < 0.01d) {
+                    resultWQKms.add(wqkms.getW(idx), wqkms.getQ(idx), wqkms.getKm(idx));
+                    return resultWQKms;
                 }
+                idx++;
             }
-            else {
-                idx = size-1;
-                while (idx > 0 && wqkmsI.getKm(idx) > km) {
-                    idx--;
+        }
+        else {
+            idx = size-1;
+            while (idx > 0 && wqkms.getKm(idx) > km) {
+                if (Math.abs(wqkms.getKm(idx) - km) < 0.01d) {
+                    resultWQKms.add(wqkms.getW(idx), wqkms.getQ(idx), wqkms.getKm(idx));
+                    return resultWQKms;
                 }
+                idx--;
             }
-
-            WQKms resultWQKms = new WQKms();
-            if ((idx != -1) && (idx < size) && (idx - mod != -1) && (idx - mod < size)) {
-                double inW = Linear.linear(
-                    km,
-                    wqkmsI.getKm(idx), wqkmsI.getKm(idx - mod),
-                    wqkmsI.getW(idx), wqkmsI.getW(idx - mod));
-                double inQ = Linear.linear(
-                    km,
-                    wqkmsI.getKm(idx), wqkmsI.getKm(idx - mod),
-                    wqkmsI.getQ(idx), wqkmsI.getQ(idx - mod));
-                resultWQKms.add(inW, inQ, km);
-            }
-
+        }
+        if (Math.abs(wqkms.getKm(idx) - km) < 0.01d) {
+            resultWQKms.add(wqkms.getW(idx), wqkms.getQ(idx), wqkms.getKm(idx));
             return resultWQKms;
         }
 
-        return wqkms != null ? wqkms[index] : null;
+        if ((idx != -1) && (idx < size) && (idx - mod != -1) && (idx - mod < size)) {
+            double inW = Linear.linear(
+                km,
+                wqkms.getKm(idx), wqkms.getKm(idx - mod),
+                wqkms.getW(idx), wqkms.getW(idx - mod));
+            double inQ = Linear.linear(
+                km,
+                wqkms.getKm(idx), wqkms.getKm(idx - mod),
+                wqkms.getQ(idx), wqkms.getQ(idx - mod));
+            resultWQKms.add(inW, inQ, km);
+        }
+        else {
+            logger.debug("waterlevelfacet stuff " + idx + " size " + size + " mod: " + mod);
+        }
+
+        return resultWQKms;
     }
 
 
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Outlier.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/sq/Outlier.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,7 +1,5 @@
 package de.intevation.flys.artifacts.model.sq;
 
-import de.intevation.artifacts.common.utils.Config;
-
 import de.intevation.flys.artifacts.math.GrubbsOutlier;
 import de.intevation.flys.artifacts.math.StdDevOutlier;
 
@@ -16,9 +14,6 @@
 {
     private static Logger log = Logger.getLogger(Outlier.class);
 
-    private static final String OUTLIER_METHOD =
-        "/artifact-database/options/minfo-sq/outlier-method/@name";
-
     private static final String GRUBBS = "outlier.method.grubbs";
 
     //private static final String STD_DEV = "std-dev";
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/DischargeTablesOverview.java	Wed Mar 27 11:48:53 2013 +0100
@@ -25,7 +25,6 @@
 import de.intevation.artifacts.CallMeta;
 import de.intevation.artifacts.GlobalContext;
 import de.intevation.flys.artifacts.model.DischargeTables;
-import de.intevation.flys.artifacts.model.GaugeRange;
 import de.intevation.flys.artifacts.model.GaugesFactory;
 import de.intevation.flys.artifacts.resources.Resources;
 import de.intevation.flys.backend.SessionHolder;
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/GeometryUtils.java	Wed Mar 27 11:48:53 2013 +0100
@@ -73,9 +73,10 @@
             }
         }
         catch(HibernateException iae) {
-            logger.warn("No vaild river axis forund for " + rivername);
+            logger.warn("No vaild river axis found for " + rivername);
             return null;
         }
+        logger.warn("No vaild river axis found for " + rivername);
 
         return null;
     }
--- a/flys-backend/contrib/shpimporter/jetties.py	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/contrib/shpimporter/jetties.py	Wed Mar 27 11:48:53 2013 +0100
@@ -68,6 +68,8 @@
 
         newFeat.SetGeometry(geometry)
 
+        newFeat.SetField("river_id", self.river_id)
+
         artname = self.searchField("^type$")
         if self.IsFieldSet(feat, artname):
             self.handled(artname)
--- a/flys-backend/doc/schema/oracle-drop-minfo.sql	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/doc/schema/oracle-drop-minfo.sql	Wed Mar 27 11:48:53 2013 +0100
@@ -12,9 +12,7 @@
 ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_cur_elevation_model;
 ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_old_elevation_model;
 ALTER TABLE bed_height_epoch DROP CONSTRAINT fk_epoch_range;
-ALTER TABLE depths DROP CONSTRAINT fk_depths_unit_id;
 ALTER TABLE sediment_density DROP CONSTRAINT fk_sd_depth_id;
-ALTER TABLE sediment_density DROP CONSTRAINT fk_sd_unit_id;
 ALTER TABLE sediment_density_values DROP CONSTRAINT fk_sdv_sediment_density_id;
 ALTER TABLE morphologic_width DROP CONSTRAINT fk_mw_river_id;
 ALTER TABLE morphologic_width DROP CONSTRAINT fk_mw_unit_id;
--- a/flys-backend/doc/schema/oracle-minfo.sql	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/doc/schema/oracle-minfo.sql	Wed Mar 27 11:48:53 2013 +0100
@@ -40,13 +40,13 @@
 CREATE TABLE bed_height_single (
     id                      NUMBER(38,0) NOT NULL,
     river_id                NUMBER(38,0) NOT NULL,
-    year                    NUMBER(38,0) NOT NULL,
-    sounding_width          NUMBER(38,0) NOT NULL,
+    year                    NUMBER(38,0),
+    sounding_width          NUMBER(38,0),
     type_id                 NUMBER(38,0) NOT NULL,
     location_system_id      NUMBER(38,0) NOT NULL,
     cur_elevation_model_id  NUMBER(38,0) NOT NULL,
     old_elevation_model_id  NUMBER(38,0),
-    range_id                NUMBER(38,0) NOT NULL,
+    range_id                NUMBER(38,0),
     evaluation_by           VARCHAR(255),
     description             VARCHAR(255),
     PRIMARY KEY(id),
@@ -69,7 +69,7 @@
     -- type_id                 NUMBER(38,0) NOT NULL,
     cur_elevation_model_id  NUMBER(38,0) NOT NULL,
     old_elevation_model_id  NUMBER(38,0),
-    range_id                NUMBER(38,0) NOT NULL,
+    range_id                NUMBER(38,0),
     evaluation_by           VARCHAR(255),
     description             VARCHAR(255),
     PRIMARY KEY(id),
@@ -114,9 +114,7 @@
     id      NUMBER(38,0) NOT NULL,
     lower   NUMBER(38,2) NOT NULL,
     upper   NUMBER(38,2) NOT NULL,
-    unit_id NUMBER(38,0) NOT NULL,
-    PRIMARY KEY(id),
-    CONSTRAINT fk_depths_unit_id FOREIGN KEY (unit_id) REFERENCES units(id)
+    PRIMARY KEY(id)
 );
 
 
@@ -126,12 +124,10 @@
     id          NUMBER(38,0) NOT NULL,
     river_id    NUMBER(38,0) NOT NULL,
     depth_id    NUMBER(38,0) NOT NULL,
-    unit_id     NUMBER(38,0) NOT NULL,
     description VARCHAR(256),
     PRIMARY KEY(id),
     CONSTRAINT fk_sd_river_id FOREIGN KEY (river_id) REFERENCES rivers(id),
-    CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id),
-    CONSTRAINT fk_sd_unit_id FOREIGN KEY (unit_id) REFERENCES units(id)
+    CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id)
 );
 
 
@@ -287,7 +283,7 @@
     name                     VARCHAR(256) NOT NULL,
     river_id                 NUMBER(38)   NOT NULL,
     station                  NUMBER(38,3) NOT NULL,
-    range_id                 NUMBER(38)   NOT NULL,
+    range_id                 NUMBER(38),
     measurement_type         VARCHAR(64)  NOT NULL,
     riverside                VARCHAR(16),
     reference_gauge_id       NUMBER(38),
@@ -322,7 +318,6 @@
     id                       NUMBER(38,0) NOT NULL,
     sq_relation_id           NUMBER(38,0) NOT NULL,
     measurement_station_id   NUMBER(38,0) NOT NULL,
-    parameter                VARCHAR(16)  NOT NULL,
     fraction                 VARCHAR(32)  NOT NULL,
     a                        NUMBER(38,20) NOT NULL,
     b                        NUMBER(38,20) NOT NULL,
@@ -334,5 +329,5 @@
     cduan                    NUMBER(38,20),
     PRIMARY KEY (id),
     CONSTRAINT fk_sqr_id FOREIGN KEY (sq_relation_id) REFERENCES sq_relation(id),
-    CONSTRAINT fk_mstation_id FOREIGN KEY (m_station_id) REFERENCES measurement_station(id)
+    CONSTRAINT fk_mstation_id FOREIGN KEY (measurement_station_id) REFERENCES measurement_station(id)
 );
--- a/flys-backend/doc/schema/postgresql-minfo.sql	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/doc/schema/postgresql-minfo.sql	Wed Mar 27 11:48:53 2013 +0100
@@ -40,13 +40,13 @@
 CREATE TABLE bed_height_single (
     id                      int NOT NULL,
     river_id                int NOT NULL,
-    year                    int NOT NULL,
-    sounding_width          int NOT NULL,
+    year                    int,
+    sounding_width          int,
     type_id                 int NOT NULL,
     location_system_id      int NOT NULL,
     cur_elevation_model_id  int NOT NULL,
     old_elevation_model_id  int,
-    range_id                int NOT NULL,
+    range_id                int,
     evaluation_by           VARCHAR(255),
     description             VARCHAR(255),
     PRIMARY KEY(id),
@@ -69,7 +69,7 @@
     -- type_id                 int NOT NULL,
     cur_elevation_model_id  int NOT NULL,
     old_elevation_model_id  int,
-    range_id                int NOT NULL,
+    range_id                int,
     evaluation_by           VARCHAR(255),
     description             VARCHAR(255),
     PRIMARY KEY(id),
@@ -114,9 +114,7 @@
     id      int NOT NULL,
     lower   NUMERIC NOT NULL,
     upper   NUMERIC NOT NULL,
-    unit_id int NOT NULL,
-    PRIMARY KEY(id),
-    CONSTRAINT fk_depths_unit_id FOREIGN KEY (unit_id) REFERENCES units(id)
+    PRIMARY KEY(id)
 );
 
 
@@ -126,12 +124,10 @@
     id          int NOT NULL,
     river_id    int NOT NULL,
     depth_id    int NOT NULL,
-    unit_id     int NOT NULL,
     description VARCHAR(256),
     PRIMARY KEY(id),
     CONSTRAINT fk_sd_river_id FOREIGN KEY (river_id) REFERENCES rivers(id) ON DELETE CASCADE,
-    CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id),
-    CONSTRAINT fk_sd_unit_id FOREIGN KEY (unit_id) REFERENCES units(id)
+    CONSTRAINT fk_sd_depth_id FOREIGN KEY (depth_id) REFERENCES depths(id)
 );
 
 
@@ -287,7 +283,7 @@
     name                     VARCHAR(256) NOT NULL,
     river_id                 int          NOT NULL,
     station                  NUMERIC      NOT NULL,
-    range_id                 int          NOT NULL,
+    range_id                 int,
     measurement_type         VARCHAR(64)  NOT NULL,
     riverside                VARCHAR(16),
     reference_gauge_id       int,
@@ -322,7 +318,6 @@
     id                     int NOT NULL,
     sq_relation_id         int NOT NULL,
     measurement_station_id int NOT NULL,
-    parameter              VARCHAR(16)  NOT NULL,
     fraction               VARCHAR(32)  NOT NULL,
     a                      NUMERIC NOT NULL,
     b                      NUMERIC NOT NULL,
@@ -334,6 +329,6 @@
     cduan                  NUMERIC,
     PRIMARY KEY (id),
     CONSTRAINT fk_sqr_id FOREIGN KEY (sq_relation_id) REFERENCES sq_relation(id) ON DELETE CASCADE,
-    CONSTRAINT fk_mstation_id FOREIGN KEY (m_station_id) REFERENCES measurement_station(id)
+    CONSTRAINT fk_mstation_id FOREIGN KEY (measurement_station_id) REFERENCES measurement_station(id)
 );
 COMMIT;
--- a/flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/backend/FLYSCredentials.java	Wed Mar 27 11:48:53 2013 +0100
@@ -47,6 +47,7 @@
 import de.intevation.flys.model.HYKFormation;
 import de.intevation.flys.model.HydrBoundary;
 import de.intevation.flys.model.HydrBoundaryPoly;
+import de.intevation.flys.model.Jetty;
 import de.intevation.flys.model.LocationSystem;
 import de.intevation.flys.model.MainValue;
 import de.intevation.flys.model.MainValueType;
@@ -167,6 +168,7 @@
         HYKFormation.class,
         HYKFlowZoneType.class,
         HYKFlowZone.class,
+        Jetty.class,
         LocationSystem.class,
         MainValueType.class,
         MeasurementStation.class,
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightEpoch.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,13 +1,11 @@
 package de.intevation.flys.importer;
 
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.log4j.Logger;
 import org.hibernate.Query;
 import org.hibernate.Session;
-import org.hibernate.exception.ConstraintViolationException;
 
 import de.intevation.flys.model.BedHeightEpoch;
 import de.intevation.flys.model.ElevationModel;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportBedHeightSingle.java	Wed Mar 27 11:48:53 2013 +0100
@@ -3,13 +3,10 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import java.sql.SQLException;
-
 import org.apache.log4j.Logger;
 
 import org.hibernate.Session;
 import org.hibernate.Query;
-import org.hibernate.exception.ConstraintViolationException;
 
 import de.intevation.flys.model.BedHeightSingle;
 import de.intevation.flys.model.BedHeightType;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportDepth.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportDepth.java	Wed Mar 27 11:48:53 2013 +0100
@@ -22,13 +22,10 @@
     protected BigDecimal lower;
     protected BigDecimal upper;
 
-    protected ImportUnit unit;
 
-
-    public ImportDepth(BigDecimal lower, BigDecimal upper, ImportUnit unit) {
+    public ImportDepth(BigDecimal lower, BigDecimal upper) {
         this.lower = lower;
         this.upper = upper;
-        this.unit  = unit;
     }
 
 
@@ -48,19 +45,17 @@
             Query query = session.createQuery(
                 "from Depth where " +
                 "   lower=:lower and " +
-                "   upper=:upper and " +
-                "   unit=:unit");
+                "   upper=:upper");
 
             query.setParameter("lower", lower);
             query.setParameter("upper", upper);
-            query.setParameter("unit", unit.getPeer());
 
             List<Depth> depths = query.list();
 
             if (depths.isEmpty()) {
                 log.debug("Create new Depth DB instance.");
 
-                peer = new Depth(lower, upper, unit.getPeer());
+                peer = new Depth(lower, upper);
 
                 session.save(peer);
             }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportDischargeZone.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportDischargeZone.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,14 +1,12 @@
 package de.intevation.flys.importer;
 
 import java.math.BigDecimal;
-import java.sql.SQLException;
 import java.util.List;
 
 import org.apache.log4j.Logger;
 
 import org.hibernate.Session;
 import org.hibernate.Query;
-import org.hibernate.exception.ConstraintViolationException;
 
 import de.intevation.flys.model.DischargeZone;
 import de.intevation.flys.model.River;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurement.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurement.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,6 +1,5 @@
 package de.intevation.flys.importer;
 
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -8,7 +7,6 @@
 
 import org.hibernate.Session;
 import org.hibernate.Query;
-import org.hibernate.exception.ConstraintViolationException;
 
 import de.intevation.flys.model.FlowVelocityMeasurement;
 import de.intevation.flys.model.River;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurementValue.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityMeasurementValue.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,7 +1,7 @@
 package de.intevation.flys.importer;
 
 import java.math.BigDecimal;
-import java.sql.SQLException;
+
 import java.util.Date;
 import java.util.List;
 
@@ -9,7 +9,6 @@
 
 import org.hibernate.Session;
 import org.hibernate.Query;
-import org.hibernate.exception.ConstraintViolationException;
 
 import de.intevation.flys.model.FlowVelocityMeasurement;
 import de.intevation.flys.model.FlowVelocityMeasurementValue;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModel.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,6 +1,5 @@
 package de.intevation.flys.importer;
 
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -8,7 +7,6 @@
 
 import org.hibernate.Session;
 import org.hibernate.Query;
-import org.hibernate.exception.ConstraintViolationException;
 
 import de.intevation.flys.model.DischargeZone;
 import de.intevation.flys.model.FlowVelocityModel;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportFlowVelocityModelValue.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,12 +1,11 @@
 package de.intevation.flys.importer;
 
 import java.math.BigDecimal;
-import java.sql.SQLException;
+
 import java.util.List;
 
 import org.hibernate.Session;
 import org.hibernate.Query;
-import org.hibernate.exception.ConstraintViolationException;
 
 import de.intevation.flys.model.FlowVelocityModel;
 import de.intevation.flys.model.FlowVelocityModelValue;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportGrainFraction.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportGrainFraction.java	Wed Mar 27 11:48:53 2013 +0100
@@ -8,7 +8,6 @@
 import org.hibernate.Query;
 
 import de.intevation.flys.model.GrainFraction;
-import de.intevation.flys.model.Unit;
 
 
 public class ImportGrainFraction {
@@ -21,8 +20,6 @@
     private Double lower;
     private Double upper;
 
-    private ImportUnit unit;
-
     private GrainFraction peer;
 
 
@@ -34,13 +31,11 @@
     public ImportGrainFraction(
         String     name,
         Double     lower,
-        Double     upper,
-        ImportUnit unit
+        Double     upper
     ) {
         this.name  = name;
         this.lower = lower;
         this.upper = upper;
-        this.unit  = unit;
     }
 
 
@@ -54,28 +49,24 @@
     public GrainFraction getPeer() {
         log.debug("get peer");
 
-        Unit u = unit != null ? unit.getPeer() : null;
-
         if (peer == null) {
             Session session = ImporterSession.getInstance().getDatabaseSession();
             Query query = session.createQuery(
                 "from GrainFraction where " +
                 "   name=:name and " +
                 "   lower=:lower and " +
-                "   upper=:upper and " +
-                "   unit=:unit"
+                "   upper=:upper"
             );
 
             query.setParameter("name", name);
             query.setParameter("lower", lower);
             query.setParameter("upper", upper);
-            query.setParameter("unit", u);
 
             List<GrainFraction> fractions = query.list();
             if (fractions.isEmpty()) {
                 log.info("create new GrainFraction");
 
-                peer = new GrainFraction(name, lower, upper, u);
+                peer = new GrainFraction(name, lower, upper);
                 session.save(peer);
             }
             else {
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportMeasurementStation.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,11 +1,9 @@
 package de.intevation.flys.importer;
 
-import java.sql.SQLException;
 import java.util.List;
 
 import org.apache.log4j.Logger;
 import org.hibernate.Session;
-import org.hibernate.exception.ConstraintViolationException;
 
 import de.intevation.flys.model.Gauge;
 import de.intevation.flys.model.MeasurementStation;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportMorphWidth.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportMorphWidth.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,16 +1,15 @@
 package de.intevation.flys.importer;
 
-import java.sql.SQLException;
+import de.intevation.flys.model.MorphologicalWidth;
+import de.intevation.flys.model.River;
+
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.log4j.Logger;
+
 import org.hibernate.Query;
 import org.hibernate.Session;
-import org.hibernate.exception.ConstraintViolationException;
-
-import de.intevation.flys.model.MorphologicalWidth;
-import de.intevation.flys.model.River;
 
 
 public class ImportMorphWidth {
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportRiver.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,23 +1,9 @@
 package de.intevation.flys.importer;
 
-import java.io.File;
-import java.io.IOException;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.exception.ConstraintViolationException;
+import de.intevation.artifacts.common.utils.FileTools.HashedFile;
 
 import de.intevation.artifacts.common.utils.FileTools;
-import de.intevation.artifacts.common.utils.FileTools.HashedFile;
+
 import de.intevation.flys.importer.parsers.AnnotationClassifier;
 import de.intevation.flys.importer.parsers.AnnotationsParser;
 import de.intevation.flys.importer.parsers.BedHeightEpochParser;
@@ -39,9 +25,26 @@
 import de.intevation.flys.importer.parsers.WaterlevelDifferencesParser;
 import de.intevation.flys.importer.parsers.WaterlevelParser;
 import de.intevation.flys.importer.parsers.WstParser;
+
 import de.intevation.flys.model.River;
 import de.intevation.flys.model.Unit;
 
+import java.io.File;
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+
+import org.hibernate.Query;
+import org.hibernate.Session;
+
 
 /** Import all river-related data (files) that can be found. */
 public class ImportRiver
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentDensity.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentDensity.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,13 +1,11 @@
 package de.intevation.flys.importer;
 
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.log4j.Logger;
 import org.hibernate.Query;
 import org.hibernate.Session;
-import org.hibernate.exception.ConstraintViolationException;
 
 import de.intevation.flys.model.River;
 import de.intevation.flys.model.SedimentDensity;
@@ -21,8 +19,6 @@
 
     protected ImportDepth depth;
 
-    protected ImportUnit unit;
-
     protected String description;
 
     protected List<ImportSedimentDensityValue> values;
@@ -40,10 +36,6 @@
         this.depth = depth;
     }
 
-    public void setUnit(ImportUnit unit) {
-        this.unit = unit;
-    }
-
     public void addValue(ImportSedimentDensityValue value) {
         values.add(value);
     }
@@ -74,23 +66,15 @@
             return null;
         }
 
-        if (unit == null) {
-            log.warn("cannot store sediment density '" + description
-                + "': no unit");
-            return null;
-        }
-
         if (peer == null) {
             Session session = ImporterSession.getInstance()
                 .getDatabaseSession();
 
             Query query = session.createQuery("from SedimentDensity where "
-                + "   river=:river and " + "   depth=:depth and "
-                + "   unit=:unit");
+                + "   river=:river and " + "   depth=:depth");
 
             query.setParameter("river", river);
             query.setParameter("depth", depth.getPeer());
-            query.setParameter("unit", unit.getPeer());
 
             List<SedimentDensity> density = query.list();
 
@@ -98,7 +82,7 @@
                 log.debug("Create new SedimentDensity DB instance.");
 
                 peer = new SedimentDensity(river, depth.getPeer(),
-                    unit.getPeer(), description);
+                    description);
 
                 session.save(peer);
             }
--- a/flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentYield.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/ImportSedimentYield.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,6 +1,5 @@
 package de.intevation.flys.importer;
 
-import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -8,7 +7,6 @@
 
 import org.hibernate.Session;
 import org.hibernate.Query;
-import org.hibernate.exception.ConstraintViolationException;
 
 import de.intevation.flys.model.GrainFraction;
 import de.intevation.flys.model.River;
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightParser.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/BedHeightParser.java	Wed Mar 27 11:48:53 2013 +0100
@@ -67,7 +67,7 @@
         Pattern.compile("^ausgewertete Peilbreite: (\\d*).*");
 
     public static final Pattern META_RANGE =
-        Pattern.compile("^Strecke:\\D*(\\d++.\\d*)-(\\d++.\\d*).*");
+        Pattern.compile("^Strecke:\\D*(\\d++.?\\d*)-(\\d++.?\\d*).*");
 
     public static final Pattern META_EVALUATION_BY =
         Pattern.compile("^Auswerter: (.*).*");
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SQRelationParser.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SQRelationParser.java	Wed Mar 27 11:48:53 2013 +0100
@@ -14,7 +14,6 @@
 import de.intevation.flys.importer.ImportSQRelation;
 import de.intevation.flys.importer.ImportSQRelationValue;
 import de.intevation.flys.importer.ImportTimeInterval;
-import de.intevation.flys.model.MeasurementStation;
 
 
 public class SQRelationParser extends LineParser {
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentDensityParser.java	Wed Mar 27 11:48:53 2013 +0100
@@ -20,7 +20,6 @@
 import de.intevation.flys.importer.ImportDepth;
 import de.intevation.flys.importer.ImportSedimentDensity;
 import de.intevation.flys.importer.ImportSedimentDensityValue;
-import de.intevation.flys.importer.ImportUnit;
 import de.intevation.flys.utils.DateGuesser;
 
 
@@ -34,9 +33,6 @@
     public static final NumberFormat nf = NumberFormat.getInstance(DEFAULT_LOCALE);
 
 
-    public static final Pattern META_UNIT =
-        Pattern.compile("^Einheit: \\[(.*)\\].*");
-
     public static final Pattern META_DEPTH =
         Pattern.compile("^Tiefe: (\\w++)-(\\w++)( (\\w++))?.*");
 
@@ -86,10 +82,7 @@
 
 
     protected void handleMetaLine(String line) {
-        if (handleMetaUnit(line)) {
-            return;
-        }
-        else if (handleMetaDepth(line)) {
+        if (handleMetaDepth(line)) {
             return;
         }
         else if (handleMetaColumns(line)) {
@@ -113,36 +106,19 @@
     }
 
 
-    protected boolean handleMetaUnit(String line) {
-        Matcher m = META_UNIT.matcher(line);
-
-        if (m.matches()) {
-            String unit = m.group(1);
-
-            current.setUnit(new ImportUnit(unit));
-
-            return true;
-        }
-
-        return false;
-    }
-
-
     protected boolean handleMetaDepth(String line) {
         Matcher m = META_DEPTH.matcher(line);
 
         if (m.matches()) {
             String lo   = m.group(1);
             String up   = m.group(2);
-            String unit = m.group(4);
 
-            log.info("Found sediment density depth: " + lo + " - " + up + " " + unit);
+            log.info("Found sediment density depth: " + lo + " - " + up + " cm");
 
             try {
                 ImportDepth depth = new ImportDepth(
                     new BigDecimal(nf.parse(lo).doubleValue()),
-                    new BigDecimal(nf.parse(up).doubleValue()),
-                    new ImportUnit(unit)
+                    new BigDecimal(nf.parse(up).doubleValue())
                 );
 
                 current.setDepth(depth);
--- a/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/importer/parsers/SedimentYieldParser.java	Wed Mar 27 11:48:53 2013 +0100
@@ -285,7 +285,6 @@
             String upperA = a.group(4);
             String upperB = a.group(5);
 
-            String unitStr = a.group(7);
             String lower = lowerA != null ? lowerA : lowerB;
             String upper = upperA != null ? upperA : upperB;
 
@@ -293,8 +292,7 @@
                 return new ImportGrainFraction(
                     getGrainFractionTypeName(this.description),
                     nf.parse(lower).doubleValue(),
-                    nf.parse(upper).doubleValue(),
-                    new ImportUnit(unitStr)
+                    nf.parse(upper).doubleValue()
                 );
             }
             catch (ParseException pe) {
@@ -308,7 +306,6 @@
             String lowerB  = b.group(5);
             String upperA  = b.group(6);
             String upperB  = b.group(7);
-            String unitStr = b.group(9);
 
             String lower = lowerA != null ? lowerA : lowerB;
             String upper = upperA != null ? upperA : upperB;
@@ -317,8 +314,7 @@
                 return new ImportGrainFraction(
                     getGrainFractionTypeName(this.description),
                     nf.parse(lower).doubleValue(),
-                    nf.parse(upper).doubleValue(),
-                    new ImportUnit(unitStr)
+                    nf.parse(upper).doubleValue()
                 );
             }
             catch (ParseException pe) {
@@ -330,7 +326,6 @@
         if (c.matches()) {
             String oper     = c.group(1);
             String valueStr = c.group(3);
-            String unitStr  = c.group(6);
 
             try {
                 Double value = nf.parse(valueStr).doubleValue();
@@ -339,16 +334,14 @@
                     return new ImportGrainFraction(
                         getGrainFractionTypeName(this.description),
                         value,
-                        null,
-                        new ImportUnit(unitStr)
+                        null
                     );
                 }
                 else {
                     return new ImportGrainFraction(
                         getGrainFractionTypeName(this.description),
                         null,
-                        value,
-                        new ImportUnit(unitStr)
+                        value
                     );
                 }
             }
--- a/flys-backend/src/main/java/de/intevation/flys/model/Depth.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/Depth.java	Wed Mar 27 11:48:53 2013 +0100
@@ -10,8 +10,6 @@
 import javax.persistence.Column;
 import javax.persistence.SequenceGenerator;
 import javax.persistence.GenerationType;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToOne;
 
 
 @Entity
@@ -23,17 +21,14 @@
     private BigDecimal lower;
     private BigDecimal upper;
 
-    private Unit unit;
-
 
     public Depth() {
     }
 
 
-    public Depth(BigDecimal lower, BigDecimal upper, Unit unit) {
+    public Depth(BigDecimal lower, BigDecimal upper) {
         this.lower = lower;
         this.upper = upper;
-        this.unit  = unit;
     }
 
     @Id
@@ -71,14 +66,5 @@
         this.upper = upper;
     }
 
-    @OneToOne
-    @JoinColumn(name = "unit_id")
-    public Unit getUnit() {
-        return unit;
-    }
-
-    public void setUnit(Unit unit) {
-        this.unit = unit;
-    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/model/GrainFraction.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/GrainFraction.java	Wed Mar 27 11:48:53 2013 +0100
@@ -9,8 +9,6 @@
 import javax.persistence.Column;
 import javax.persistence.SequenceGenerator;
 import javax.persistence.GenerationType;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToOne;
 
 import org.apache.log4j.Logger;
 
@@ -38,17 +36,14 @@
     private Double lower;
     private Double upper;
 
-    private Unit unit;
-
 
     public GrainFraction() {
     }
 
-    public GrainFraction(String name, Double lower, Double upper, Unit unit) {
+    public GrainFraction(String name, Double lower, Double upper) {
         this.name  = name;
         this.lower = lower;
         this.upper = upper;
-        this.unit  = unit;
     }
 
     @Id
@@ -95,14 +90,5 @@
         this.upper = upper;
     }
 
-    @OneToOne
-    @JoinColumn(name = "unit_id")
-    public Unit getUnit() {
-        return unit;
-    }
-
-    public void setUnit(Unit unit) {
-        this.unit = unit;
-    }
 }
 // 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-backend/src/main/java/de/intevation/flys/model/Jetty.java	Wed Mar 27 11:48:53 2013 +0100
@@ -0,0 +1,79 @@
+package de.intevation.flys.model;
+
+import java.io.Serializable;
+import java.util.List;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+import com.vividsolutions.jts.geom.Geometry;
+
+import org.hibernate.Session;
+import org.hibernate.Query;
+import org.hibernate.annotations.Type;
+
+import de.intevation.flys.backend.SessionHolder;
+
+@Entity
+@Table(name = "jetties")
+public class Jetty
+implements   Serializable
+{
+    private Integer    id;
+    private River      river;
+    private Geometry   geom;
+
+    public Jetty() {
+    }
+
+
+    @Id
+    @Column(name = "id")
+    public Integer getId() {
+        return id;
+    }
+
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+
+    @OneToOne
+    @JoinColumn(name = "river_id")
+    public River getRiver() {
+        return river;
+    }
+
+
+    public void setRiver(River river) {
+        this.river = river;
+    }
+
+    @Column(name = "geom")
+    @Type(type = "org.hibernatespatial.GeometryUserType")
+    public Geometry getGeom() {
+        return geom;
+    }
+
+
+    public void setGeom(Geometry geom) {
+        this.geom = geom;
+    }
+
+    public static List<Jetty> getJetties(int riverId, int kindId) {
+        Session session = SessionHolder.HOLDER.get();
+
+        Query query = session.createQuery(
+            "from Jetty where river.id =:river_id and kind_id=:kind_id");
+        query.setParameter("kind_id", kindId);
+        query.setParameter("river_id", riverId);
+
+        return query.list();
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-backend/src/main/java/de/intevation/flys/model/SedimentDensity.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-backend/src/main/java/de/intevation/flys/model/SedimentDensity.java	Wed Mar 27 11:48:53 2013 +0100
@@ -25,8 +25,6 @@
 
     private Depth depth;
 
-    private Unit unit;
-
     private List<SedimentDensityValue> values;
 
     private String description;
@@ -36,10 +34,9 @@
     }
 
 
-    public SedimentDensity(River river, Depth depth, Unit unit, String desc) {
+    public SedimentDensity(River river, Depth depth, String desc) {
         this.river       = river;
         this.depth       = depth;
-        this.unit        = unit;
         this.description = desc;
     }
 
@@ -80,16 +77,6 @@
         this.depth = depth;
     }
 
-    @OneToOne
-    @JoinColumn(name = "unit_id")
-    public Unit getUnit() {
-        return unit;
-    }
-
-    public void setUnit(Unit unit) {
-        this.unit = unit;
-    }
-
     @Column(name = "description")
     public String getDescription() {
         return description;
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1164,6 +1164,7 @@
 
     String hws_fed_unknown();
 
+    String jetties();
 
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Wed Mar 27 11:48:53 2013 +0100
@@ -461,6 +461,7 @@
 hws_lines = Lines
 hws_points = Points
 hws_fed_unknown = Unknown State
+jetties = Jetties
 
 startcolor = Colorrange start color
 endcolor = Colorrange end color
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Wed Mar 27 11:48:53 2013 +0100
@@ -462,6 +462,7 @@
 hws_lines = Liniendaten
 hws_points = Punktdaten
 hws_fed_unknown = Unbekanntes Bundesland
+jetties = Buhnen
 
 startcolor = Farbverlauf Startfarbe
 endcolor = Farbverlauf Endfarbe
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/HWSDatacagePanel.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/HWSDatacagePanel.java	Wed Mar 27 11:48:53 2013 +0100
@@ -1,12 +1,10 @@
 package de.intevation.flys.client.client.ui;
 
-import java.util.ArrayList;
-import java.util.List;
+import com.google.gwt.core.client.GWT;
 
-import com.google.gwt.core.client.GWT;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
+
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
@@ -15,10 +13,11 @@
 import de.intevation.flys.client.shared.model.DataList;
 import de.intevation.flys.client.shared.model.DefaultData;
 import de.intevation.flys.client.shared.model.DefaultDataItem;
-import de.intevation.flys.client.shared.model.Recommendation;
-import de.intevation.flys.client.shared.model.ToLoad;
 import de.intevation.flys.client.shared.model.User;
 
+import java.util.ArrayList;
+import java.util.List;
+
 
 public class HWSDatacagePanel
 extends DatacagePanel
@@ -126,4 +125,4 @@
         return data;
     }
 }
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
\ No newline at end of file
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java	Wed Mar 27 11:47:56 2013 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/WQAdaptedInputPanel.java	Wed Mar 27 11:48:53 2013 +0100
@@ -11,7 +11,6 @@
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
 import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.FormItem;
 import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
 import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
 import com.smartgwt.client.widgets.form.fields.events.BlurHandler;

http://dive4elements.wald.intevation.org