[Dive4elements-commits] [PATCH 4 of 4] Merged

Wald Commits scm-commit at wald.intevation.org
Mon Oct 29 13:44:05 CET 2012


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1351514926 -3600
# Node ID 45f793826a4334f6a5439daae261db9e4177dbfa
# Parent  d65cf8e40230ff551b91c1dd129ebeb9e91b0a56
# Parent  9ddc1d9b035a837a6ead52ff4f32238495873925
Merged

diff -r d65cf8e40230 -r 45f793826a43 flys-artifacts/doc/conf/artifacts/minfo.xml
--- a/flys-artifacts/doc/conf/artifacts/minfo.xml	Mon Oct 29 13:47:34 2012 +0100
+++ b/flys-artifacts/doc/conf/artifacts/minfo.xml	Mon Oct 29 13:48:46 2012 +0100
@@ -364,7 +364,7 @@
         </state>
 
         <state id="state.minfo.sediment.load.off_epochs" description="state.minfo.bed.off_epochs" state="de.intevation.flys.artifacts.states.minfo.SedimentLoadOffEpochSelect">
-            <data name="off_epochs" type="String"/>
+            <data name="epochs" type="String"/>
         </state>
 
         <transition transition="de.intevation.flys.artifacts.transitions.DefaultTransition">
diff -r d65cf8e40230 -r 45f793826a43 flys-artifacts/doc/conf/conf.xml
--- a/flys-artifacts/doc/conf/conf.xml	Mon Oct 29 13:47:34 2012 +0100
+++ b/flys-artifacts/doc/conf/conf.xml	Mon Oct 29 13:48:46 2012 +0100
@@ -210,6 +210,10 @@
                 name="measurementstationinfo"
                 service="de.intevation.flys.artifacts.services.MeasurementStationInfoService"
                 description="Returns an overview of the measurement stations of a given river.">de.intevation.artifactdatabase.DefaultServiceFactory</service-factory>
+            <service-factory
+                name="sedimentloadinfo"
+                service="de.intevation.flys.artifacts.services.SedimentLoadInfoService"
+                description="Returns sedimentloads.">de.intevation.artifactdatabase.DefaultServiceFactory</service-factory>
         </service-factories>
 
     </factories>
diff -r d65cf8e40230 -r 45f793826a43 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/StaticSedimentLoadCacheKey.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/StaticSedimentLoadCacheKey.java	Mon Oct 29 13:48:46 2012 +0100
@@ -0,0 +1,48 @@
+package de.intevation.flys.artifacts.model;
+
+import java.util.Date;
+
+import org.apache.commons.lang.builder.HashCodeBuilder;
+
+
+public class StaticSedimentLoadCacheKey
+{
+    public static final String CACHE_NAME = "sedimentload-value-table-static";
+
+    private String river;
+    private double startKm;
+    private double endKm;
+    private Date date;
+
+    public StaticSedimentLoadCacheKey(
+        String river,
+        double startKm,
+        double endKm,
+        Date date
+    ) {
+        this.river = river;
+        this.startKm = startKm;
+        this.endKm = endKm;
+        this.date = date;
+    }
+
+    public int hashCode() {
+        HashCodeBuilder builder = new HashCodeBuilder();
+        builder.append(river);
+        builder.append(startKm);
+        builder.append(endKm);
+        builder.append(date);
+        return builder.toHashCode();
+    }
+
+    public boolean equals(Object other) {
+        if (!(other instanceof StaticBedHeightCacheKey)) {
+            return false;
+        }
+        StaticSedimentLoadCacheKey o = (StaticSedimentLoadCacheKey) other;
+        return this.river == o.river &&
+            this.startKm == o.startKm &&
+            this.endKm == o.endKm &&
+            this.date == o.date;
+    }
+}
diff -r d65cf8e40230 -r 45f793826a43 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoad.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoad.java	Mon Oct 29 13:48:46 2012 +0100
@@ -0,0 +1,135 @@
+package de.intevation.flys.artifacts.model.minfo;
+
+import gnu.trove.TDoubleArrayList;
+
+import java.util.Date;
+
+import org.apache.log4j.Logger;
+
+import de.intevation.flys.artifacts.model.NamedObjectImpl;
+
+
+public class SedimentLoad
+extends NamedObjectImpl
+{
+    private static Logger log = Logger.getLogger(BedHeight.class);
+
+    protected String description;
+    protected Date start;
+    protected Date end;
+    protected boolean isEpoch;
+
+    protected TDoubleArrayList sand_values;
+    protected TDoubleArrayList fine_middle_values;
+    protected TDoubleArrayList coarse_values;
+    protected TDoubleArrayList susp_sediment_values;
+    protected TDoubleArrayList susp_sand_bed_values;
+
+
+    public SedimentLoad() {
+    }
+
+    public SedimentLoad(
+        String description,
+        Date start,
+        Date end,
+        boolean isEpoch
+    ) {
+        this.description = description;
+        this.start = start;
+        this.end = end;
+        this.isEpoch = isEpoch;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Date getStart() {
+        return start;
+    }
+
+    public void setStart(Date start) {
+        this.start = start;
+    }
+
+    public Date getEnd() {
+        return end;
+    }
+
+    public void setEnd(Date end) {
+        this.end = end;
+    }
+
+    public boolean isEpoch() {
+        return isEpoch;
+    }
+
+    public void setEpoch(boolean isEpoch) {
+        this.isEpoch = isEpoch;
+    }
+
+    public void addSandValue(double value) {
+        this.sand_values.add(value);
+    }
+
+    public void addSandValues(TDoubleArrayList values) {
+        this.sand_values.add(values.toNativeArray());
+    }
+
+    public TDoubleArrayList getSandValues() {
+        return this.sand_values;
+    }
+
+    public void addFineMiddleValue(double value) {
+        this.fine_middle_values.add(value);
+    }
+
+    public void addFineMiddleValues(TDoubleArrayList values) {
+        this.fine_middle_values.add(values.toNativeArray());
+    }
+
+    public TDoubleArrayList getFineMiddleValues() {
+        return this.fine_middle_values;
+    }
+
+    public void addCoarseValue(double value) {
+        this.coarse_values.add(value);
+    }
+
+    public void addCoarseValues(TDoubleArrayList values) {
+        this.coarse_values.add(values.toNativeArray());
+    }
+
+    public TDoubleArrayList getCoarseValues() {
+        return this.coarse_values;
+    }
+
+    public void addSuspSedimentValue(double value) {
+        this.susp_sediment_values.add(value);
+    }
+
+    public void addSuspSedimentValues(TDoubleArrayList values) {
+        this.susp_sediment_values.add(values.toNativeArray());
+    }
+
+   public TDoubleArrayList getSuspSedimentValues() {
+        return this.susp_sediment_values;
+    }
+
+    public void addSuspSandBedValue(double value) {
+        this.susp_sand_bed_values.add(value);
+    }
+
+    public void addSuspSandBedValues(TDoubleArrayList values) {
+        this.susp_sand_bed_values.add(values.toNativeArray());
+    }
+
+    public TDoubleArrayList getSuspSandBedValues() {
+        return this.susp_sand_bed_values;
+    }
+}
diff -r d65cf8e40230 -r 45f793826a43 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFactory.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/SedimentLoadFactory.java	Mon Oct 29 13:48:46 2012 +0100
@@ -0,0 +1,352 @@
+package de.intevation.flys.artifacts.model.minfo;
+
+import gnu.trove.TDoubleArrayList;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.Element;
+
+import org.apache.log4j.Logger;
+import org.hibernate.SQLQuery;
+import org.hibernate.Session;
+import org.hibernate.type.StandardBasicTypes;
+
+import de.intevation.flys.artifacts.cache.CacheFactory;
+import de.intevation.flys.artifacts.model.StaticSedimentLoadCacheKey;
+import de.intevation.flys.backend.SessionHolder;
+
+
+public class SedimentLoadFactory
+{
+    /** Private logger to use here. */
+    private static Logger log = Logger.getLogger(SedimentLoadFactory.class);
+
+    public static final String LOADS_CACHE_NAME = "sedimentloads";
+    public static final String LOAD_DATA_CACHE_NAME = "sedimentload-data";
+
+    /** Query to get km and ws for wst_id and column_pos. */
+    public static final String SQL_SELECT_SINGLES =
+        "SELECT DISTINCT " +
+        "       sy.description AS description, " +
+        "       ti.start_time AS year " +
+        "   FROM     sediment_yield sy " +
+        "       JOIN rivers r ON sy.river_id = r.id " +
+        "       JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id " +
+        "       JOIN time_intervals ti ON sy.time_interval_id = ti.id " +
+        "   WHERE   r.name = :name " +
+        "       AND ti.stop_time IS NULL " +
+        "       AND syv.station BETWEEN :startKm AND :endKm";
+
+    /** Query to get name for wst_id and column_pos. */
+    public static final String SQL_SELECT_EPOCHS =
+        "SELECT DISTINCT " +
+        "       sy.description AS description, " +
+        "       ti.start_time AS start, " +
+        "       ti.stop_time AS end " +
+        "   FROM     sediment_yield sy " +
+        "       JOIN rivers r ON sy.river_id = r.id " +
+        "       JOIN sediment_yield_values syv ON sy.id = syv.sediment_yield_id " +
+        "       JOIN time_intervals ti ON sy.time_interval_id = ti.id " +
+        "   WHERE   r.name = :name " +
+        "       AND ti.stop_time IS NOT NULL " +
+        "       AND syv.station BETWEEN :startKm AND :endKm";
+
+    public static final String SQL_SELECT_SINGLES_DATA =
+        "SELECT" +
+        "       sy.description AS description, " +
+        "       ti.start_time AS year, " +
+        "       syv.value AS load " +
+        "   FROM     sediment_yield sy " +
+        "       JOIN rivers r ON sy.river_id = r.id " +
+        "       JOIN time_intervals ti ON sy.time_interval_id = ti.id " +
+        "       JOIN sediment_yield_vales syv ON sy.id = syv.sediment_yield_id " +
+        "       JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id " +
+        "   WHERE   r.name = :name " +
+        "       AND ti.start_time BETWEEN :begin AND :end " +
+        "       AND ti_stop_time IS NULL " +
+        "       AND gf.name = :grain " +
+        "       AND syv.station BETWEEN :startKm AND :endKm";
+
+    public static final String SQL_SELECT_EPOCHS_DATA =
+        "SELECT" +
+        "       sy.description AS description," +
+        "       ti.start_time AS year," +
+        "       syv.value AS load" +
+        "   FROM     sediment_yield sy" +
+        "       JOIN rivers r ON sy.river_id = r.id " +
+        "       JOIN time_intervals ti ON sy.time_interval_id = ti.id" +
+        "       JOIN sediment_yield_vales syv ON sy.id = syv.sediment_yield_id" +
+        "       JOIN grain_fraction gf ON sy.grain_fraction_id = gf.id" +
+        "   WHERE   r.name = :name" +
+        "       AND ti.start_time BETWEEN :sbegin AND :send" +
+        "       AND ti_stop_time IS NOT NULL" +
+        "       AND ti_stop_time BETWEEN :ebegin AND :eend" +
+        "       AND gf.name = :grain " +
+        "       AND syv.station BETWEEN :startKm AND :endKm";
+
+    private SedimentLoadFactory() {
+    }
+
+    /**
+     *
+     */
+    public static SedimentLoad[] getLoads(
+        String river,
+        String type,
+        double startKm,
+        double endKm
+    ) {
+        log.debug("SedimentLoadFactory.getLoads");
+        Cache cache = CacheFactory.getCache(LOADS_CACHE_NAME);
+
+        if (cache == null) {
+            log.debug("Cache not configured.");
+            return getSedimentLoadsUncached(river, type, startKm, endKm);
+        }
+
+        StaticSedimentLoadCacheKey key =
+            new StaticSedimentLoadCacheKey(river, startKm, endKm, null);
+
+        Element element = cache.get(key);
+
+        if (element != null) {
+            log.debug("SedimentLoad found in cache");
+            return (SedimentLoad[])element.getValue();
+        }
+
+        SedimentLoad[] values =
+            getSedimentLoadsUncached(river, type, startKm, endKm);
+
+        if (values != null && key != null) {
+            log.debug("Store static sediment loads  values in cache.");
+            element = new Element(key, values);
+            cache.put(element);
+        }
+        return values;
+    }
+
+    public static SedimentLoad getLoadwithData(
+        String river,
+        String type,
+        double startKm,
+        double endKm,
+        Date startDate,
+        Date endDate
+    ) {
+        log.debug("SedimentLoadFactory.getLoadWithData");
+        Cache cache = CacheFactory.getCache(LOAD_DATA_CACHE_NAME);
+
+        if (cache == null) {
+            log.debug("Cache not configured.");
+            return getSedimentLoadWithDataUncached(
+                river,
+                type,
+                startKm,
+                endKm,
+                startDate,
+                endDate);
+        }
+
+        StaticSedimentLoadCacheKey key =
+            new StaticSedimentLoadCacheKey(river, startKm, endKm, startDate);
+
+        Element element = cache.get(key);
+
+        if (element != null) {
+            log.debug("SedimentLoad found in cache");
+            return (SedimentLoad)element.getValue();
+        }
+
+        SedimentLoad values =
+            getSedimentLoadWithDataUncached(river, type, startKm, endKm, startDate, endDate);
+
+        if (values != null && key != null) {
+            log.debug("Store static bed height values in cache.");
+            element = new Element(key, values);
+            cache.put(element);
+        }
+        return values;
+    }
+
+    /**
+     * Get sediment loads from db.
+     * @param river the river
+     * @param type the sediment load type (year or epoch)
+     * @return according sediment loads.
+     */
+    public static SedimentLoad[] getSedimentLoadsUncached(
+        String river,
+        String type,
+        double startKm,
+        double endKm
+    ) {
+        log.debug("SedimentLoadFactory.getSedimentLoadsUncached");
+
+        Session session = SessionHolder.HOLDER.get();
+        SQLQuery sqlQuery = null;
+
+
+        if (type.equals("single")) {
+            sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLES)
+                .addScalar("description", StandardBasicTypes.STRING)
+                .addScalar("year", StandardBasicTypes.DATE);
+            sqlQuery.setString("name", river);
+            sqlQuery.setDouble("startKm", startKm);
+            sqlQuery.setDouble("endKm", endKm);
+            List<Object []> results = sqlQuery.list();
+            SedimentLoad[] loads = new SedimentLoad[results.size()];
+            for (int i = 0; i < results.size(); i++) {
+                Object[] row = results.get(i);
+                loads[i] = new SedimentLoad(
+                    (String) row[0],
+                    (Date) row[1],
+                    null,
+                    false);
+            }
+            return loads;
+        }
+        else if (type.equals("epoch")) {
+            sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCHS)
+                .addScalar("description", StandardBasicTypes.STRING)
+                .addScalar("start", StandardBasicTypes.DATE)
+                .addScalar("end", StandardBasicTypes.DATE);
+            sqlQuery.setString("name", river);
+            sqlQuery.setDouble("startKm", startKm);
+            sqlQuery.setDouble("endKm", endKm);
+            List<Object []> results = sqlQuery.list();
+
+            SedimentLoad[] loads = new SedimentLoad[results.size()];
+            for (int i = 0; i < results.size(); i++) {
+                Object[] row = results.get(i);
+                loads[i] = new SedimentLoad(
+                    (String) row[0],
+                    (Date) row[1],
+                    (Date) row[2],
+                    true);
+            }
+            return loads;
+        }
+        return new SedimentLoad[0];
+    }
+
+    /**
+     * Get sediment loads from db.
+     * @param river the river
+     * @param type the sediment load type (year or epoch)
+     * @return according sediment loads.
+     */
+    public static SedimentLoad getSedimentLoadWithDataUncached(
+        String river,
+        String type,
+        double startKm,
+        double endKm,
+        Date sdate,
+        Date edate
+    ) {
+        log.debug("SedimentLoadFactory.getBedHeightUncached");
+
+        Session session = SessionHolder.HOLDER.get();
+        SQLQuery sqlQuery = null;
+
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(sdate);
+        int year = cal.get(Calendar.YEAR);
+        cal.set(year, 1, 1);
+        Calendar end = Calendar.getInstance();
+        end.set(year, 12, 31);
+
+        if (type.equals("single")) {
+            sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLES_DATA)
+                .addScalar("description", StandardBasicTypes.STRING)
+                .addScalar("year", StandardBasicTypes.DATE)
+                .addScalar("load", StandardBasicTypes.DOUBLE);
+            sqlQuery.setString("name", river);
+            sqlQuery.setDouble("startKm", startKm);
+            sqlQuery.setDouble("endKm", endKm);
+            sqlQuery.setDate("begin", cal.getTime());
+            sqlQuery.setDate("end", end.getTime());
+            sqlQuery.setString("grain", "total");
+            List<Object []> results = sqlQuery.list();
+            SedimentLoad load = new SedimentLoad();
+            if (results.size() != 1) {
+                // should not happen. throw some exception.
+                return new SedimentLoad();
+            }
+            Object[] row = results.get(0);
+            load = new SedimentLoad(
+                    (String) row[0],
+                    (Date) row[1],
+                    null,
+                    false);
+            load.addCoarseValues(getValues("coarse", sqlQuery));
+            load.addFineMiddleValues(getValues("fine_middle", sqlQuery));
+            load.addSandValues(getValues("sand", sqlQuery));
+            load.addSuspSandBedValues(getValues("suspended_sediment", sqlQuery));
+            load.addSuspSandBedValues(getValues("susp_sand_bed", sqlQuery));
+            return load;
+        }
+        else if (type.equals("epoch")) {
+            Calendar send = Calendar.getInstance();
+            send.setTime(edate);
+            int eyear = send.get(Calendar.YEAR);
+            send.set(year, 1, 1);
+            Calendar eend = Calendar.getInstance();
+            eend.set(eyear, 12, 31);
+
+            sqlQuery = session.createSQLQuery(SQL_SELECT_EPOCHS)
+                .addScalar("description", StandardBasicTypes.STRING)
+                .addScalar("start_time", StandardBasicTypes.DATE)
+                .addScalar("stop_time", StandardBasicTypes.DATE)
+                .addScalar("load", StandardBasicTypes.DOUBLE);
+            sqlQuery.setString("name", river);
+            sqlQuery.setDouble("startKm", startKm);
+            sqlQuery.setDouble("endKm", endKm);
+            sqlQuery.setDate("sbegin", cal.getTime());
+            sqlQuery.setDate("sbegin", end.getTime());
+            sqlQuery.setDate("ebegin",send.getTime());
+            sqlQuery.setDate("eend", eend.getTime());
+            sqlQuery.setString("grain", "total");
+
+            List<Object []> results = sqlQuery.list();
+
+            SedimentLoad load = new SedimentLoad();
+            if (results.size() != 1) {
+                // should not happen. throw some exception.
+                return new SedimentLoad();
+            }
+            Object[] row = results.get(0);
+            load = new SedimentLoad(
+                    (String) row[0],
+                    (Date) row[1],
+                    null,
+                    false);
+            load.addCoarseValues(getValues("coarse", sqlQuery));
+            load.addFineMiddleValues(getValues("fine_middle", sqlQuery));
+            load.addSandValues(getValues("sand", sqlQuery));
+            load.addSuspSandBedValues(getValues("suspended_sediment", sqlQuery));
+            load.addSuspSandBedValues(getValues("susp_sand_bed", sqlQuery));
+            return load;
+        }
+        return new SedimentLoad();
+    }
+
+    /**
+     * 
+     */
+    protected static TDoubleArrayList getValues (
+        String fraction,
+        SQLQuery query
+    ) {
+        query.setString("grain", fraction);
+        List<Object[]> results = query.list();
+        TDoubleArrayList values = new TDoubleArrayList();
+        for (int i = 0; i < results.size(); i++) {
+            Object[] row = results.get(i);
+            values.add(((Double)row[2]).doubleValue());
+        }
+        return values;
+    }
+}
diff -r d65cf8e40230 -r 45f793826a43 flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/SedimentLoadInfoService.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/SedimentLoadInfoService.java	Mon Oct 29 13:48:46 2012 +0100
@@ -0,0 +1,92 @@
+package de.intevation.flys.artifacts.services;
+
+import java.util.Calendar;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import de.intevation.artifacts.ArtifactNamespaceContext;
+import de.intevation.artifacts.CallMeta;
+import de.intevation.artifacts.GlobalContext;
+import de.intevation.artifacts.common.utils.XMLUtils;
+import de.intevation.flys.artifacts.model.minfo.SedimentLoad;
+import de.intevation.flys.artifacts.model.minfo.SedimentLoadFactory;
+
+
+public class SedimentLoadInfoService
+extends FLYSService
+{
+    /** The logger used in this service. */
+    private static Logger logger = Logger.getLogger(SedimentLoadInfoService.class);
+
+    public static final String RIVER_XPATH = "/art:river/text()";
+    public static final String TYPE_XPATH = "/art:river/art:type/text()";
+    public static final String FROM_XPATH = "/art:river/art:location/art:from/text()";
+    public static final String TO_XPATH = "/art:river/art:location/art:to/text()";
+
+    @Override
+    protected Document doProcess(
+        Document data,
+        GlobalContext globalContext,
+        CallMeta callMeta) {
+        String river = XMLUtils.xpathString(
+            data,
+            RIVER_XPATH,
+            ArtifactNamespaceContext.INSTANCE);
+        String type = XMLUtils.xpathString(
+            data,
+            TYPE_XPATH,
+            ArtifactNamespaceContext.INSTANCE);
+        String from = XMLUtils.xpathString(
+            data,
+            FROM_XPATH,
+            ArtifactNamespaceContext.INSTANCE);
+        String to = XMLUtils.xpathString(
+            data,
+            TO_XPATH,
+            ArtifactNamespaceContext.INSTANCE);
+        double f, t;
+        try {
+            f = Double.parseDouble(from);
+            t = Double.parseDouble(to);
+        }
+        catch (NumberFormatException nfe) {
+            logger.warn("Invalid locations. Cannot return sediment loads.");
+            return XMLUtils.newDocument();
+        }
+
+        SedimentLoad[] loads = SedimentLoadFactory.getLoads(river, type, f, t);
+        return buildDocument(loads);
+    }
+
+    protected Document buildDocument(SedimentLoad[] loads) {
+        Document result = XMLUtils.newDocument();
+        Element all = result.createElement("sedimentloads");
+        for (SedimentLoad sl : loads) {
+            Element load = result.createElement("sedimentload");
+            load.setAttribute("description", sl.getDescription());
+            if (sl.isEpoch()) {
+                Calendar calendarS = Calendar.getInstance();
+                calendarS.setTime(sl.getStart());
+                Calendar calendarE = Calendar.getInstance();
+                calendarE.setTime(sl.getEnd());
+                load.setAttribute(
+                    "date",
+                    calendarS.get(Calendar.YEAR) +
+                        " - " +
+                        calendarE.get(Calendar.YEAR));
+            }
+            else {
+                Calendar calendar = Calendar.getInstance();
+                calendar.setTime(sl.getStart());
+                load.setAttribute(
+                    "date", 
+                    String.valueOf(calendar.get(Calendar.YEAR)));
+            }
+            all.appendChild(load);
+        }
+        result.appendChild(all);
+        return result;
+    }
+}
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Oct 29 13:47:34 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java	Mon Oct 29 13:48:46 2012 +0100
@@ -376,6 +376,8 @@
 
     String chartPropertiesTooltip();
 
+    String year();
+
     // Gauges
 
     String gauge_mnq();
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Oct 29 13:47:34 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties	Mon Oct 29 13:48:46 2012 +0100
@@ -84,7 +84,7 @@
 start_year = Start
 end_year = End
 period = Period
-
+year = Year
 # Header images
 flysLogo = images/flys_logo.gif
 bfgLogo = images/bfg_logo.gif
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Oct 29 13:47:34 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties	Mon Oct 29 13:48:46 2012 +0100
@@ -84,6 +84,7 @@
 start_year = Start
 end_year = Ende
 period = Zeitraum
+year = Jahr
 # Header images
 flysLogo = images/flys_logo.gif
 bfgLogo = images/bfg_logo.gif
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Oct 29 13:47:34 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties	Mon Oct 29 13:48:46 2012 +0100
@@ -84,7 +84,7 @@
 start_year = Start
 end_year = end
 period = Period
-
+year = Year
 # Header images
 flysLogo = images/flys_logo.gif
 bfgLogo = images/bfg_logo.gif
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/client/services/SedimentLoadInfoService.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/SedimentLoadInfoService.java	Mon Oct 29 13:48:46 2012 +0100
@@ -0,0 +1,30 @@
+package de.intevation.flys.client.client.services;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+
+import de.intevation.flys.client.shared.exceptions.ServerException;
+import de.intevation.flys.client.shared.model.DischargeInfoObject;
+import de.intevation.flys.client.shared.model.SedimentLoadInfoObject;
+
+/**
+ * This service is used to fetch a list of SedimentLoadInfoObjects from artifact
+ * server for a specific river.
+ *
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+ at RemoteServiceRelativePath("sedimentloadinfo")
+public interface SedimentLoadInfoService extends RemoteService {
+
+    /**
+     * This method returns a list of SedimentLoadInfoObjects for a specific river.
+     */
+    SedimentLoadInfoObject[] getSedimentLoadInfo(
+        String locale,
+        String river,
+        String type,
+        double startKm,
+        double endKm)
+    throws ServerException;
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/client/services/SedimentLoadInfoServiceAsync.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/services/SedimentLoadInfoServiceAsync.java	Mon Oct 29 13:48:46 2012 +0100
@@ -0,0 +1,20 @@
+package de.intevation.flys.client.client.services;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+import de.intevation.flys.client.shared.model.SedimentLoadInfoObject;
+
+/**
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+public interface SedimentLoadInfoServiceAsync {
+
+    void getSedimentLoadInfo(
+        String locale,
+        String river,
+        String type,
+        double startKm,
+        double endKm,
+        AsyncCallback<SedimentLoadInfoObject[]> cb);
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java	Mon Oct 29 13:47:34 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/UIProviderFactory.java	Mon Oct 29 13:48:46 2012 +0100
@@ -171,7 +171,7 @@
         else if (uiProvider.equals("minfo.sedimentload_epoch_select")) {
             return new SedLoadEpochPanel();
         }
-        else if (uiProvider.equals("minfo.sedimentload_epoch_select")) {
+        else if (uiProvider.equals("minfo.sedimentload_offepoch_select")) {
             return new SedLoadOffEpochPanel();
         }
         else {
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadEpochPanel.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadEpochPanel.java	Mon Oct 29 13:47:34 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadEpochPanel.java	Mon Oct 29 13:48:46 2012 +0100
@@ -4,8 +4,10 @@
 import java.util.List;
 
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
 import com.smartgwt.client.data.Record;
 import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.Button;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
@@ -22,20 +24,30 @@
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
+import de.intevation.flys.client.client.Config;
+import de.intevation.flys.client.client.services.SedimentLoadInfoService;
+import de.intevation.flys.client.client.services.SedimentLoadInfoServiceAsync;
 import de.intevation.flys.client.client.ui.AbstractUIProvider;
+import de.intevation.flys.client.shared.model.ArtifactDescription;
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
 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.SedimentLoadInfoObject;
+import de.intevation.flys.client.shared.model.SedimentLoadInfoRecord;
 
 
 public class SedLoadEpochPanel
 extends AbstractUIProvider
 {
+    protected SedimentLoadInfoServiceAsync sedLoadInfoService =
+        GWT.create(SedimentLoadInfoService.class);
+
     protected ListGrid elements;
     private TextItem start;
     private TextItem end;
+    private ListGrid sedLoadTable;
 
     public Canvas createWidget(DataList data) {
         HLayout input = new HLayout();
@@ -129,9 +141,9 @@
 
         return root;
     }
+
     @Override
     public Canvas createOld(DataList dataList) {
-        GWT.log("old............................");
         HLayout layout = new HLayout();
         layout.setWidth("400px");
         VLayout vLayout = new VLayout();
@@ -162,14 +174,43 @@
     @Override
     public Canvas create(DataList data) {
         VLayout layout = new VLayout();
+        Canvas helper = createHelper();
+        this.helperContainer.addMember(helper);
+
         Canvas submit = getNextButton();
         Canvas widget = createWidget(data);
 
         layout.addMember(widget);
         layout.addMember(submit);
+
+        fetchSedimentLoadData();
+
         return layout;
     }
 
+    private Canvas createHelper() {
+        sedLoadTable = new ListGrid();
+        sedLoadTable.setShowHeaderContextMenu(false);
+        sedLoadTable.setWidth100();
+        sedLoadTable.setShowRecordComponents(true);
+        sedLoadTable.setShowRecordComponentsByCell(true);
+        sedLoadTable.setHeight100();
+        sedLoadTable.setEmptyMessage(MSG.empty_table());
+        sedLoadTable.setCanReorderFields(false);
+
+        ListGridField date = new ListGridField("date", MSG.year());
+        date.setType(ListGridFieldType.TEXT);
+        date.setWidth(100);
+
+        ListGridField descr =
+            new ListGridField("description", MSG.description());
+        descr.setType(ListGridFieldType.TEXT);
+        descr.setWidth("*");
+
+        sedLoadTable.setFields(date, descr);
+        return sedLoadTable;
+    }
+
     @Override
     protected Data[] getData() {
         List<Data> data = new ArrayList<Data>();
@@ -194,4 +235,43 @@
         return data.toArray(new Data[data.size()]);
     }
 
+    protected void fetchSedimentLoadData() {
+        Config config    = Config.getInstance();
+        String locale    = config.getLocale ();
+
+        ArtifactDescription adescr = artifact.getArtifactDescription();
+        DataList[] data = adescr.getOldData();
+
+        double[] km = artifact.getArtifactDescription().getKMRange();
+        String river = artifact.getArtifactDescription().getRiver();
+
+        sedLoadInfoService.getSedimentLoadInfo(locale, river, "single", km[0], km[1],
+            new AsyncCallback<SedimentLoadInfoObject[]>() {
+                public void onFailure(Throwable caught) {
+                    GWT.log("Could not recieve sediment load informations.");
+                    SC.warn(caught.getMessage());
+                }
+
+                public void onSuccess(SedimentLoadInfoObject[] sedLoad) {
+                    int num = sedLoad != null ? sedLoad.length :0;
+                    GWT.log("Recieved " + num + " sediment load informations.");
+
+                    if (num == 0) {
+                        return;
+                    }
+
+                    addSedimentLoadInfo(sedLoad);
+                }
+            }
+        );
+    }
+
+
+    protected void addSedimentLoadInfo (SedimentLoadInfoObject[] sedLoad) {
+        for(SedimentLoadInfoObject sl: sedLoad) {
+            SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl);
+            sedLoadTable.addData(rec);
+        }
+    }
+
 }
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadOffEpochPanel.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadOffEpochPanel.java	Mon Oct 29 13:47:34 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadOffEpochPanel.java	Mon Oct 29 13:48:46 2012 +0100
@@ -1,10 +1,187 @@
 package de.intevation.flys.client.client.ui.minfo;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.SelectionAppearance;
+import com.smartgwt.client.util.SC;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Label;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+import de.intevation.flys.client.client.Config;
+import de.intevation.flys.client.client.services.SedimentLoadInfoService;
+import de.intevation.flys.client.client.services.SedimentLoadInfoServiceAsync;
 import de.intevation.flys.client.client.ui.PeriodPanel;
+import de.intevation.flys.client.shared.model.ArtifactDescription;
+import de.intevation.flys.client.shared.model.Data;
+import de.intevation.flys.client.shared.model.DataItem;
+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.SedimentLoadInfoObject;
+import de.intevation.flys.client.shared.model.SedimentLoadInfoRecord;
 
 
 public class SedLoadOffEpochPanel
 extends PeriodPanel
 {
+    protected SedimentLoadInfoServiceAsync sedLoadInfoService =
+        GWT.create(SedimentLoadInfoService.class);
+
+    private ListGrid sedLoadTable;
+
+    public Canvas createWidget(DataList data) {
+        VLayout root = new VLayout();
+
+        Label title = new Label(data.get(0).getDescription());
+        title.setHeight("25px");
+
+        root.addMember(title);
+
+        return root;
+    }
+
+    @Override
+    public Canvas createOld(DataList dataList) {
+        HLayout layout = new HLayout();
+        layout.setWidth("400px");
+        VLayout vLayout = new VLayout();
+        vLayout.setWidth(130);
+        Label label = new Label(dataList.getLabel());
+        label.setWidth("200px");
+        label.setHeight(25);
+
+        List<Data> items = dataList.getAll();
+        Data str = getData(items, "epochs");
+        DataItem[] strItems = str.getItems();
+
+        String[] pairs = strItems[0].getLabel().split(";");
+        for (int i = 0; i < pairs.length; i++) {
+            String[] vals = pairs[i].split(",");
+            Label dateLabel = new Label(vals[0] + " - " + vals[1]);
+            dateLabel.setHeight(20);
+            vLayout.addMember(dateLabel);
+        }
+        Canvas back = getBackButton(dataList.getState());
+        layout.addMember(label);
+        layout.addMember(vLayout);
+        layout.addMember(back);
+
+        return layout;
+    }
+
+    @Override
+    public Canvas create(DataList data) {
+        VLayout layout = new VLayout();
+        Canvas helper = createHelper();
+        this.helperContainer.addMember(helper);
+
+        Canvas submit = getNextButton();
+        Canvas widget = createWidget(data);
+
+        layout.addMember(widget);
+        layout.addMember(submit);
+
+        fetchSedimentLoadData();
+
+        return layout;
+    }
+
+    protected Canvas createHelper() {
+        sedLoadTable = new ListGrid();
+        sedLoadTable.setShowHeaderContextMenu(false);
+        sedLoadTable.setWidth100();
+        sedLoadTable.setShowRecordComponents(true);
+        sedLoadTable.setShowRecordComponentsByCell(true);
+        sedLoadTable.setHeight100();
+        sedLoadTable.setEmptyMessage(MSG.empty_table());
+        sedLoadTable.setCanReorderFields(false);
+        sedLoadTable.setSelectionAppearance(SelectionAppearance.CHECKBOX);
+
+        ListGridField date = new ListGridField("date", MSG.year());
+        date.setType(ListGridFieldType.TEXT);
+        date.setWidth(100);
+
+        ListGridField descr =
+            new ListGridField("description", MSG.description());
+        descr.setType(ListGridFieldType.TEXT);
+        descr.setWidth("*");
+
+        sedLoadTable.setFields(date, descr);
+        return sedLoadTable;
+    }
+
+    @Override
+    public Data[] getData() {
+        List<Data> data = new ArrayList<Data>();
+
+        ListGridRecord[] lgr = sedLoadTable.getSelectedRecords();
+        if (lgr.length == 0) {
+            return new Data[0];
+        }
+        String d = "";
+        for (int i = 0; i < lgr.length; i++) {
+            Record r = (Record) lgr[i];
+            String date = r.getAttribute("date");
+            String[] range = date.split(" - ");
+            d += range[0] + "," + range[1];
+            d += ";";
+        }
+        DataItem item = new DefaultDataItem("epochs", null, d);
+            data.add(new DefaultData(
+                        "epochs",
+                        null,
+                        null,
+                        new DataItem[] { item }));
+        return data.toArray(new Data[data.size()]);
+    }
+
+    protected void fetchSedimentLoadData() {
+        Config config    = Config.getInstance();
+        String locale    = config.getLocale ();
+
+        ArtifactDescription adescr = artifact.getArtifactDescription();
+        DataList[] data = adescr.getOldData();
+
+        double[] km = artifact.getArtifactDescription().getKMRange();
+        String river = artifact.getArtifactDescription().getRiver();
+
+        sedLoadInfoService.getSedimentLoadInfo(locale, river, "epoch", km[0], km[1],
+            new AsyncCallback<SedimentLoadInfoObject[]>() {
+                public void onFailure(Throwable caught) {
+                    GWT.log("Could not recieve sediment load informations.");
+                    SC.warn(caught.getMessage());
+                }
+
+                public void onSuccess(SedimentLoadInfoObject[] sedLoad) {
+                    int num = sedLoad != null ? sedLoad.length :0;
+                    GWT.log("Recieved " + num + " sediment load informations.");
+
+                    if (num == 0) {
+                        return;
+                    }
+
+                    addSedimentLoadInfo(sedLoad);
+                }
+            }
+        );
+    }
+
+
+    protected void addSedimentLoadInfo (SedimentLoadInfoObject[] sedLoad) {
+        for(SedimentLoadInfoObject sl: sedLoad) {
+            SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl);
+            sedLoadTable.addData(rec);
+        }
+    }
 
 }
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadPeriodPanel.java
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadPeriodPanel.java	Mon Oct 29 13:47:34 2012 +0100
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/minfo/SedLoadPeriodPanel.java	Mon Oct 29 13:48:46 2012 +0100
@@ -4,31 +4,44 @@
 import java.util.List;
 
 import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.util.SC;
 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.TextItem;
 import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
+import com.smartgwt.client.widgets.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridField;
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
+import de.intevation.flys.client.client.Config;
+import de.intevation.flys.client.client.services.SedimentLoadInfoService;
+import de.intevation.flys.client.client.services.SedimentLoadInfoServiceAsync;
 import de.intevation.flys.client.client.ui.AbstractUIProvider;
-import de.intevation.flys.client.client.ui.IntegerRangePanel;
+import de.intevation.flys.client.shared.model.ArtifactDescription;
 import de.intevation.flys.client.shared.model.Data;
 import de.intevation.flys.client.shared.model.DataItem;
 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.SedimentLoadInfoObject;
+import de.intevation.flys.client.shared.model.SedimentLoadInfoRecord;
 
 
 public class SedLoadPeriodPanel
 extends AbstractUIProvider
-//extends SedLoadPanel
 {
+    protected SedimentLoadInfoServiceAsync sedLoadInfoService =
+        GWT.create(SedimentLoadInfoService.class);
 
     private TextItem start;
     private TextItem end;
 
+    private ListGrid sedLoadTable;
+
     public SedLoadPeriodPanel () {
     }
 
@@ -72,17 +85,43 @@
     public Canvas create(DataList data) {
         VLayout layout = new VLayout();
 
-//        Canvas helper = createHelper();
-//        this.helperContainer.addMember(helper);
+        Canvas helper = createHelper();
+        this.helperContainer.addMember(helper);
 
         Canvas submit = getNextButton();
         Canvas widget = createWidget(data);
 
         layout.addMember(widget);
         layout.addMember(submit);
+
+        fetchSedimentLoadData();
+
         return layout;
     }
 
+    private Canvas createHelper() {
+        sedLoadTable = new ListGrid();
+        sedLoadTable.setShowHeaderContextMenu(false);
+        sedLoadTable.setWidth100();
+        sedLoadTable.setShowRecordComponents(true);
+        sedLoadTable.setShowRecordComponentsByCell(true);
+        sedLoadTable.setHeight100();
+        sedLoadTable.setEmptyMessage(MSG.empty_table());
+        sedLoadTable.setCanReorderFields(false);
+
+        ListGridField date = new ListGridField("date", MSG.year());
+        date.setType(ListGridFieldType.TEXT);
+        date.setWidth(100);
+
+        ListGridField descr =
+            new ListGridField("description", MSG.description());
+        descr.setType(ListGridFieldType.TEXT);
+        descr.setWidth("*");
+
+        sedLoadTable.setFields(date, descr);
+        return sedLoadTable;
+    }
+
     public Canvas createWidget(DataList data) {
         VLayout layout = new VLayout();
 
@@ -149,5 +188,43 @@
         return false;
     }
 
+   protected void fetchSedimentLoadData() {
+        Config config    = Config.getInstance();
+        String locale    = config.getLocale ();
+
+        ArtifactDescription adescr = artifact.getArtifactDescription();
+        DataList[] data = adescr.getOldData();
+
+        double[] km = artifact.getArtifactDescription().getKMRange();
+        String river = artifact.getArtifactDescription().getRiver();
+
+        sedLoadInfoService.getSedimentLoadInfo(locale, river, "single", km[0], km[1],
+            new AsyncCallback<SedimentLoadInfoObject[]>() {
+                public void onFailure(Throwable caught) {
+                    GWT.log("Could not recieve sediment load informations.");
+                    SC.warn(caught.getMessage());
+                }
+
+                public void onSuccess(SedimentLoadInfoObject[] sedLoad) {
+                    int num = sedLoad != null ? sedLoad.length :0;
+                    GWT.log("Recieved " + num + " sediment load informations.");
+
+                    if (num == 0) {
+                        return;
+                    }
+
+                    addSedimentLoadInfo(sedLoad);
+                }
+            }
+        );
+    }
+
+
+    protected void addSedimentLoadInfo (SedimentLoadInfoObject[] sedLoad) {
+        for(SedimentLoadInfoObject sl: sedLoad) {
+            SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl);
+            sedLoadTable.addData(rec);
+        }
+    }
 
 }
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/server/SedimentLoadInfoServiceImpl.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/SedimentLoadInfoServiceImpl.java	Mon Oct 29 13:48:46 2012 +0100
@@ -0,0 +1,152 @@
+package de.intevation.flys.client.server;
+
+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.NodeList;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+import de.intevation.artifacts.common.ArtifactNamespaceContext;
+import de.intevation.artifacts.common.utils.XMLUtils;
+import de.intevation.artifacts.httpclient.exceptions.ConnectionException;
+import de.intevation.artifacts.httpclient.http.HttpClient;
+import de.intevation.artifacts.httpclient.http.HttpClientImpl;
+import de.intevation.flys.client.client.services.SedimentLoadInfoService;
+import de.intevation.flys.client.shared.exceptions.ServerException;
+import de.intevation.flys.client.shared.model.SedimentLoadInfoObject;
+import de.intevation.flys.client.shared.model.SedimentLoadInfoObjectImpl;
+
+
+public class SedimentLoadInfoServiceImpl
+extends RemoteServiceServlet
+implements SedimentLoadInfoService
+{
+    private static final Logger logger =
+        Logger.getLogger(SedimentLoadInfoServiceImpl.class);
+
+    public static final String ERROR_NO_SEDIMENTLOADINFO_FOUND =
+        "error_no_sedimentloadinfo_found";
+
+    @Override
+    public SedimentLoadInfoObject[] getSedimentLoadInfo(
+        String locale,
+        String river,
+        String type,
+        double startKm,
+        double endKm)
+    throws ServerException
+    {
+        logger.info("SedimentLoadInfoServiceImpl.getSedimentLoadInfo");
+
+        String url  = getServletContext().getInitParameter("server-url");
+
+        Document doc = XMLUtils.newDocument();
+
+        XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator(
+            doc,
+            ArtifactNamespaceContext.NAMESPACE_URI,
+            ArtifactNamespaceContext.NAMESPACE_PREFIX);
+
+        Element riverEl = ec.create("river");
+        Element location = ec.create("location");
+        Element from = ec.create("from");
+        Element to = ec.create("to");
+        Element typeEl = ec.create("type");
+        riverEl.setTextContent(river);
+        from.setTextContent(String.valueOf(startKm));
+        to.setTextContent(String.valueOf(endKm));
+        typeEl.setTextContent(type);
+
+        location.appendChild(from);
+        location.appendChild(to);
+        riverEl.appendChild(location);
+        riverEl.appendChild(typeEl);
+        doc.appendChild(riverEl);
+
+        HttpClient client = new HttpClientImpl(url, locale);
+
+        try {
+            Document result = client.callService(url, "sedimentloadinfo", doc);
+
+            logger.debug("Extract sedimentload info objects now.");
+            SedimentLoadInfoObject[] objects =
+                extractSedimentLoadInfoObjects(result);
+
+            if (objects != null && objects.length > 0) {
+                return objects;
+            }
+        }
+        catch (ConnectionException ce) {
+            logger.error(ce, ce);
+        }
+
+        throw new ServerException(ERROR_NO_SEDIMENTLOADINFO_FOUND);
+    }
+
+
+    /**
+     * Extracts all distance info objects from <i>result</i> document.
+     *
+     * @param result The document retrieved by the server.
+     *
+     * @return a list of DistanceInfoObjects.
+     */
+    protected SedimentLoadInfoObject[] extractSedimentLoadInfoObjects(
+        Document result)
+    throws ServerException
+    {
+        NodeList list = result.getElementsByTagName("sedimentload");
+
+        if (list == null || list.getLength() == 0) {
+            logger.warn("No sedimentload info found.");
+            throw new ServerException(ERROR_NO_SEDIMENTLOADINFO_FOUND);
+        }
+
+        int num = list.getLength();
+        logger.debug("Response contains " + num + " objects.");
+
+        List<SedimentLoadInfoObject> objects =
+            new ArrayList<SedimentLoadInfoObject>(num);
+
+        for (int i = 0; i < num; i++) {
+            SedimentLoadInfoObject obj = buildSedimentLoadInfoObject(
+                (Element)list.item(i));
+
+            if (obj != null) {
+                objects.add(obj);
+            }
+        }
+
+        logger.debug("Retrieved " + objects.size() + " sediment loads.");
+
+        return (SedimentLoadInfoObject[])
+            objects.toArray(new SedimentLoadInfoObject[num]);
+    }
+
+
+    /**
+     * Extracts information for a single distance info object and intializes an
+     * DistanceInfoObject with them.
+     *
+     * @param node The node that contains the information.
+     *
+     * @return a valid DistanceInfoObject.
+     */
+    protected SedimentLoadInfoObject buildSedimentLoadInfoObject(Element node) {
+
+        String desc      = node.getAttribute("description").trim();
+        String date      = node.getAttribute("date").trim();
+
+        if (desc.length() > 0 && date.length() > 0) {
+            return new SedimentLoadInfoObjectImpl(desc, date);
+        }
+
+        logger.warn("Invalid sediment load info object found.");
+
+        return null;
+    }
+}
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/shared/model/SedimentLoadInfoObject.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/SedimentLoadInfoObject.java	Mon Oct 29 13:48:46 2012 +0100
@@ -0,0 +1,15 @@
+package de.intevation.flys.client.shared.model;
+
+import java.io.Serializable;
+
+
+/**
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+public interface SedimentLoadInfoObject extends Serializable {
+
+    String getDescription();
+
+    String getDate();
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
\ No newline at end of file
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/shared/model/SedimentLoadInfoObjectImpl.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/SedimentLoadInfoObjectImpl.java	Mon Oct 29 13:48:46 2012 +0100
@@ -0,0 +1,31 @@
+package de.intevation.flys.client.shared.model;
+
+
+/**
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+public class SedimentLoadInfoObjectImpl implements SedimentLoadInfoObject {
+
+    protected String description;
+    protected String dateString;
+
+    public SedimentLoadInfoObjectImpl() {
+    }
+
+    public SedimentLoadInfoObjectImpl(
+        String description,
+        String dateString
+    ) {
+        this.description = description;
+        this.dateString = dateString;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public String getDate() {
+        return this.dateString;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
\ No newline at end of file
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/java/de/intevation/flys/client/shared/model/SedimentLoadInfoRecord.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/shared/model/SedimentLoadInfoRecord.java	Mon Oct 29 13:48:46 2012 +0100
@@ -0,0 +1,32 @@
+package de.intevation.flys.client.shared.model;
+
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+
+public class SedimentLoadInfoRecord
+extends ListGridRecord
+{
+    protected SedimentLoadInfoObject sedimentLoadInfo;
+
+    public SedimentLoadInfoRecord(SedimentLoadInfoObject info) {
+        this.sedimentLoadInfo = info;
+        setDescription(info.getDescription());
+        setDate(info.getDate());
+    }
+
+    public void setDescription(String description) {
+        setAttribute("description", description);
+    }
+
+    public void setDate(String date) {
+        setAttribute("date", date);
+    }
+
+    public String getDescription() {
+        return getAttribute("description");
+    }
+
+    public String getDate() {
+        return getAttribute("date");
+    }
+}
diff -r d65cf8e40230 -r 45f793826a43 flys-client/src/main/webapp/WEB-INF/web.xml
--- a/flys-client/src/main/webapp/WEB-INF/web.xml	Mon Oct 29 13:47:34 2012 +0100
+++ b/flys-client/src/main/webapp/WEB-INF/web.xml	Mon Oct 29 13:48:46 2012 +0100
@@ -533,6 +533,16 @@
   </servlet-mapping>
 
   <servlet>
+    <servlet-name>SedimentLoadInfo</servlet-name>
+    <servlet-class>de.intevation.flys.client.server.SedimentLoadInfoServiceImpl</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>SedimentLoadInfo</servlet-name>
+    <url-pattern>/flys/sedimentloadinfo</url-pattern>
+  </servlet-mapping>
+
+  <servlet>
     <servlet-name>login</servlet-name>
     <servlet-class>de.intevation.flys.client.server.LoginServlet</servlet-class>
   </servlet>


More information about the Dive4elements-commits mailing list