changeset 7515:e4eb85fbcec4

Merged
author Sascha L. Teichmann <teichmann@intevation.de>
date Mon, 04 Nov 2013 11:26:02 +0100
parents 69138ab4a942 (current diff) 969afcc1ca26 (diff)
children 7e95bdb72a40
files .hgtags artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java
diffstat 15 files changed, 440 insertions(+), 177 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/minfo.xml	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/doc/conf/artifacts/minfo.xml	Mon Nov 04 11:26:02 2013 +0100
@@ -501,16 +501,25 @@
             <outputmodes>
                 <outputmode name="sedimentload_ls" description="output.sedimentload.ls" mime-type="image/png" type="chart">
                     <facets>
-                        <facet name="sedimentload.coarse"/>
-                        <facet name="sedimentload.sand"/>
-                        <facet name="sedimentload.finemiddle"/>
-                        <facet name="sedimentload.susp_sand"/>
-                        <facet name="sedimentload.susp_sand_bed"/>
-                        <facet name="sedimentload.susp_sediment"/>
-                        <facet name="sedimentload.total_load"/>
-                        <facet name="sedimentload.unknown"/>
+                        <facet name="sedimentload.ta.coarse"/>
+                        <facet name="sedimentload.ta.sand"/>
+                        <facet name="sedimentload.ta.finemiddle"/>
+                        <facet name="sedimentload.ta.susp_sand"/>
+                        <facet name="sedimentload.ta.susp_sand_bed"/>
+                        <facet name="sedimentload.ta.susp_sediment"/>
+                        <facet name="sedimentload.ta.total_load"/>
+                        <facet name="sedimentload.ta.unknown"/>
+                        <facet name="sedimentload.ta.total"/>
+                        <facet name="sedimentload.m3a.coarse"/>
+                        <facet name="sedimentload.m3a.sand"/>
+                        <facet name="sedimentload.m3a.finemiddle"/>
+                        <facet name="sedimentload.m3a.susp_sand"/>
+                        <facet name="sedimentload.m3a.susp_sand_bed"/>
+                        <facet name="sedimentload.m3a.susp_sediment"/>
+                        <facet name="sedimentload.m3a.total_load"/>
+                        <facet name="sedimentload.m3a.unknown"/>
+                        <facet name="sedimentload.m3a.total"/>
                         <facet name="sedimentload_ls.manualpoints"/>
-                        <facet name="sedimentload.total"/>
                         <facet name="flow_velocity.totalchannel" description="A facet for total channels"/>
                         <facet name="flow_velocity.mainchannel" description="A facet for main channels"/>
                         <facet name="flow_velocity.totalchannel.filtered" description="A facet for total channels"/>
--- a/artifacts/doc/conf/longitudinal-diagram-defaults.xml	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/doc/conf/longitudinal-diagram-defaults.xml	Mon Nov 04 11:26:02 2013 +0100
@@ -12,7 +12,8 @@
     <axis name="Diameter"/>
     <axis name="Density"/>
     <axis name="Porosity"/>
-    <axis name="SedimentLoad"/>
+    <axis name="SedimentLoadM3A"/>
+    <axis name="SedimentLoadTA"/>
     <axis name="Velocity"/>
     <axis name="Tau"/>
     <axis name="Q" include-zero="true"/>
@@ -35,7 +36,8 @@
     <processor class="org.dive4elements.river.exports.process.BedQualityDiameterProcessor" axis="Diameter"/>
     <processor class="org.dive4elements.river.exports.process.BedQualityPorosityProcessor" axis="Porosity"/>
     <processor class="org.dive4elements.river.exports.process.BedQualityDensityProcessor" axis="Density"/>
-    <processor class="org.dive4elements.river.exports.process.SedimentLoadProcessor" axis="SedimentLoad"/>
+    <processor class="org.dive4elements.river.exports.process.SedimentLoadTAProcessor" axis="SedimentLoadTA"/>
+    <processor class="org.dive4elements.river.exports.process.SedimentLoadM3AProcessor" axis="SedimentLoadM3A"/>
     <processor class="org.dive4elements.river.exports.process.FlowVelocityProcessor" axis="Velocity"/>
     <processor class="org.dive4elements.river.exports.process.ShearStressProcessor" axis="Tau"/>
     <processor class="org.dive4elements.river.exports.process.SedimentDensityProcessor" axis="Density"/>
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/MainValuesArtifact.java	Mon Nov 04 11:26:02 2013 +0100
@@ -184,6 +184,7 @@
         }
     }
 
+
     /**
      * The MainValueArtifact can be set up with a document giving the
      * river and gauge.  This happens in context of GaugeDischargeArtifact.
@@ -221,7 +222,7 @@
 
 
     /**
-     * Create "the" state.
+     * Create "the" (one possible) state.
      */
     protected State spawnState() {
         state = new StaticState(STATIC_STATE_NAME);
@@ -377,6 +378,7 @@
      * @return list of Q main values.
      */
     public List<NamedDouble> getMainValuesQ(double[] kms) {
+        logger.debug("MainValuesArtifact.getMainValuesQ(d)");
         List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
         boolean atGauge = false;
         Gauge gauge = getGauge(kms[0]);
@@ -409,9 +411,11 @@
 
     /**
      * Get a list of "Q" main values.
+     * @param atGauge whether is at gauge or needs interpolation.
      * @return list of Q main values.
      */
     public List<NamedDouble> getMainValuesQ(boolean atGauge) {
+        logger.debug("MainValuesArtifact.getMainValuesQ(b)");
         List<NamedDouble> filteredList = new ArrayList<NamedDouble>();
         Gauge gauge = getGauge();
         WstValueTable interpolator = WstValueTableFactory.getTable(RiverUtils.getRiver(this));
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/SedimentYieldArtifact.java	Mon Nov 04 11:26:02 2013 +0100
@@ -146,9 +146,10 @@
         String code = getDatacageIDValue(data);
 
         if (code != null) {
-            String fraction = SedimentLoadFactory.getSedimentYieldFractionName(Integer.valueOf(code));
+            int id = Integer.valueOf(code);
+            String fraction = SedimentLoadFactory.getSedimentYieldFractionName(id);
             String fractionName = Resources.getMsg(callMeta, fraction, "-");
-            Date[] dates = SedimentLoadFactory.getSedimentYieldTimes(Integer.valueOf(code));
+            Date[] dates = SedimentLoadFactory.getSedimentYieldTimes(id);
             Calendar date = Calendar.getInstance();
             date.setTime(dates[0]);
             String name = fractionName + " - " + date.get(Calendar.YEAR);
@@ -157,27 +158,65 @@
                 name += " - " + date.get(Calendar.YEAR);
             }
 
+            boolean unitIsTA =
+                SedimentLoadFactory.getSedimentYieldUnitName(id).startsWith("t");
+
             String facetType = "";
             if (fraction.equals("coarse")) {
-                facetType = SEDIMENT_LOAD_COARSE;
+                if (unitIsTA) {
+                    facetType = SEDIMENT_LOAD_TA_COARSE;
+                }
+                else {
+                    facetType = SEDIMENT_LOAD_M3A_COARSE;
+                }
             }
             else if (fraction.equals("sand")) {
-                facetType = SEDIMENT_LOAD_SAND;
+                if (unitIsTA) {
+                    facetType = SEDIMENT_LOAD_TA_SAND;
+                }
+                else {
+                    facetType = SEDIMENT_LOAD_M3A_SAND;
+                }
             }
             else if (fraction.equals("fine_middle")) {
-                facetType = SEDIMENT_LOAD_FINEMIDDLE;
+                if (unitIsTA) {
+                    facetType = SEDIMENT_LOAD_TA_FINEMIDDLE;
+                }
+                else {
+                    facetType = SEDIMENT_LOAD_M3A_FINEMIDDLE;
+                }
             }
             else if (fraction.equals("susp_sand")) {
-                facetType = SEDIMENT_LOAD_SUSP_SAND;
+                if (unitIsTA) {
+                    facetType = SEDIMENT_LOAD_TA_SUSP_SAND;
+                }
+                else {
+                    facetType = SEDIMENT_LOAD_M3A_SAND;
+                }
             }
             else if (fraction.equals("susp_sand_bed")) {
-                facetType = SEDIMENT_LOAD_SUSP_SAND_BED;
+                if (unitIsTA) {
+                    facetType = SEDIMENT_LOAD_TA_SUSP_SAND_BED;
+                }
+                else {
+                    facetType = SEDIMENT_LOAD_M3A_SUSP_SAND_BED;
+                }
             }
             else if (fraction.equals("suspended_sediment")) {
-                facetType = SEDIMENT_LOAD_SUSP_SEDIMENT;
+                if (unitIsTA) {
+                    facetType = SEDIMENT_LOAD_TA_SUSP_SEDIMENT;
+                }
+                else {
+                    facetType = SEDIMENT_LOAD_M3A_SUSP_SEDIMENT;
+                }
             }
             else if (fraction.equals("total")) {
-                facetType = SEDIMENT_LOAD_TOTAL_LOAD;
+                if (unitIsTA) {
+                    facetType = SEDIMENT_LOAD_TA_TOTAL_LOAD;
+                }
+                else {
+                    facetType = SEDIMENT_LOAD_M3A_TOTAL_LOAD;
+                }
             }
             else {
                 logger.error("Do not know fraction type " + fraction);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FunctionResolver.java	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FunctionResolver.java	Mon Nov 04 11:26:02 2013 +0100
@@ -370,7 +370,7 @@
     }
 
     /** Implementation for doing a string replace
-     *  dc:replace
+     *  dc:replace .
      */
     public Object replace(List args) throws XPathFunctionException {
         Object haystack    = args.get(0);
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/FacetTypes.java	Mon Nov 04 11:26:02 2013 +0100
@@ -111,11 +111,47 @@
 
             return false;
         }
-        public static boolean SEDIMENT_LOAD(String type) {
-            return type.startsWith("sedimentload") && !type.contains("unknown");
+        public static boolean SEDIMENT_LOAD_TOTAL_LOAD(String type) {
+            return type.equals(SEDIMENT_LOAD_TA_TOTAL_LOAD) ||
+                type.equals(SEDIMENT_LOAD_M3A_TOTAL_LOAD);
+        }
+        public static boolean SEDIMENT_LOAD_TOTAL(String type) {
+            return type.equals(SEDIMENT_LOAD_TA_TOTAL) ||
+                type.equals(SEDIMENT_LOAD_M3A_TOTAL);
+        }
+        public static boolean SEDIMENT_LOAD_SUSP_SEDIMENT(String type) {
+            return type.equals(SEDIMENT_LOAD_TA_SUSP_SEDIMENT) ||
+                type.equals(SEDIMENT_LOAD_M3A_SUSP_SEDIMENT);
+        }
+        public static boolean SEDIMENT_LOAD_SUSP_SAND_BED(String type) {
+            return type.equals(SEDIMENT_LOAD_TA_SUSP_SAND_BED) ||
+                type.equals(SEDIMENT_LOAD_M3A_SUSP_SAND_BED);
+        }
+        public static boolean SEDIMENT_LOAD_SUSP_SAND(String type) {
+            return type.equals(SEDIMENT_LOAD_TA_SUSP_SAND) ||
+                type.equals(SEDIMENT_LOAD_M3A_SUSP_SAND);
+        }
+        public static boolean SEDIMENT_LOAD_FINEMIDDLE(String type) {
+            return type.equals(SEDIMENT_LOAD_TA_FINEMIDDLE) ||
+                type.equals(SEDIMENT_LOAD_M3A_FINEMIDDLE);
+        }
+        public static boolean SEDIMENT_LOAD_COARSE(String type) {
+            return type.equals(SEDIMENT_LOAD_TA_COARSE) ||
+                type.equals(SEDIMENT_LOAD_M3A_COARSE);
+        }
+        public static boolean SEDIMENT_LOAD_SAND(String type) {
+            return type.equals(SEDIMENT_LOAD_TA_SAND) ||
+                type.equals(SEDIMENT_LOAD_M3A_SAND);
+        }
+        public static boolean SEDIMENT_LOAD_M3A(String type) {
+            return type.startsWith("sedimentload.m3a") && !type.contains("unknown");
+        }
+        public static boolean SEDIMENT_LOAD_TA(String type) {
+            return type.startsWith("sedimentload.ta") && !type.contains("unknown");
         }
         public static boolean SEDIMENT_LOAD_UNKNOWN(String type) {
-            return type.equals("sedimentload.unknown");
+            return type.equals("sedimentload.m3a.unknown") ||
+              type.equals("sedimentload.ta.unknown");
         }
         public static boolean SEDIMENT_LOAD_NO_FLOAT(String type) {
             return type.startsWith("sedimentload") && !type.contains("susp");
@@ -264,7 +300,7 @@
     String HISTORICAL_DISCHARGE_MAINVALUES_Q = "historical_discharge.mainvalues.q";
     String HISTORICAL_DISCHARGE_MAINVALUES_W = "historical_discharge.mainvalues.w";
 
-    String REFERENCE_CURVE = "reference_curve";
+    String REFERENCE_CURVE            = "reference_curve";
     String REFERENCE_CURVE_NORMALIZED = "reference_curve_normalized";
 
     String FLOW_VELOCITY_MAINCHANNEL           = "flow_velocity.mainchannel";
@@ -309,19 +345,30 @@
     String BED_DIFFERENCE_EPOCH_HEIGHT2          = "bedheight_difference.epoch.height2";
     String BED_DIFFERENCE_EPOCH_HEIGHT1_FILTERED = "bedheight_difference.epoch.height1.filtered";
     String BED_DIFFERENCE_EPOCH_HEIGHT2_FILTERED = "bedheight_difference.epoch.height2.filtered";
+
     String MORPHOLOGIC_WIDTH = "morph-width";
 
     String SEDIMENT_DENSITY            = "sediment.density";
 
-    String SEDIMENT_LOAD_COARSE        = "sedimentload.coarse";
-    String SEDIMENT_LOAD_SAND          = "sedimentload.sand";
-    String SEDIMENT_LOAD_FINEMIDDLE    = "sedimentload.finemiddle";
-    String SEDIMENT_LOAD_SUSP_SAND     = "sedimentload.susp_sand";
-    String SEDIMENT_LOAD_SUSP_SAND_BED = "sedimentload.susp_sand_bed";
-    String SEDIMENT_LOAD_SUSP_SEDIMENT = "sedimentload.susp_sediment";
-    String SEDIMENT_LOAD_TOTAL         = "sedimentload.total";
-    String SEDIMENT_LOAD_TOTAL_LOAD    = "sedimentload.total_load";
-    String SEDIMENT_LOAD_UNKNOWN       = "sedimentload.unknown";
+    String SEDIMENT_LOAD_TA_COARSE        = "sedimentload.ta.coarse";
+    String SEDIMENT_LOAD_TA_SAND          = "sedimentload.ta.sand";
+    String SEDIMENT_LOAD_TA_FINEMIDDLE    = "sedimentload.ta.finemiddle";
+    String SEDIMENT_LOAD_TA_SUSP_SAND     = "sedimentload.ta.susp_sand";
+    String SEDIMENT_LOAD_TA_SUSP_SAND_BED = "sedimentload.ta.susp_sand_bed";
+    String SEDIMENT_LOAD_TA_SUSP_SEDIMENT = "sedimentload.ta.susp_sediment";
+    String SEDIMENT_LOAD_TA_TOTAL         = "sedimentload.ta.total";
+    String SEDIMENT_LOAD_TA_TOTAL_LOAD    = "sedimentload.ta.total_load";
+    String SEDIMENT_LOAD_TA_UNKNOWN       = "sedimentload.ta.unknown";
+
+    String SEDIMENT_LOAD_M3A_COARSE        = "sedimentload.m3a.coarse";
+    String SEDIMENT_LOAD_M3A_SAND          = "sedimentload.m3a.sand";
+    String SEDIMENT_LOAD_M3A_FINEMIDDLE    = "sedimentload.m3a.finemiddle";
+    String SEDIMENT_LOAD_M3A_SUSP_SAND     = "sedimentload.m3a.susp_sand";
+    String SEDIMENT_LOAD_M3A_SUSP_SAND_BED = "sedimentload.m3a.susp_sand_bed";
+    String SEDIMENT_LOAD_M3A_SUSP_SEDIMENT = "sedimentload.m3a.susp_sediment";
+    String SEDIMENT_LOAD_M3A_TOTAL         = "sedimentload.m3a.total";
+    String SEDIMENT_LOAD_M3A_TOTAL_LOAD    = "sedimentload.m3a.total_load";
+    String SEDIMENT_LOAD_M3A_UNKNOWN       = "sedimentload.m3a.unknown";
 
     String SQ_OVERVIEW       = "sq_overview";
 
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java	Mon Nov 04 11:26:02 2013 +0100
@@ -101,7 +101,8 @@
 
         // Handle sediment load differently, as it respects already
         // the ranges that were added to SedimentLoad/Fraction.
-        if (getName().equals(FacetTypes.SEDIMENT_LOAD_TOTAL)) {
+        if (getName().equals(FacetTypes.SEDIMENT_LOAD_TA_TOTAL)
+           ||getName().equals(FacetTypes.SEDIMENT_LOAD_M3A_TOTAL)) {
             SedimentLoad load = result.getLoad();
             TDoubleArrayList xPos = new TDoubleArrayList();
             TDoubleArrayList yPos = new TDoubleArrayList();
@@ -197,24 +198,25 @@
 
     /** Get data according to type of facet. */
     private double[][] getLoadData(SedimentLoadResult result) {
-        if (getName().equals(FacetTypes.SEDIMENT_LOAD_SAND))
+        String name = getName();
+        if (FacetTypes.IS.SEDIMENT_LOAD_SAND(name))
             return result.getSandData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_COARSE))
+        else if (FacetTypes.IS.SEDIMENT_LOAD_COARSE(name))
             return result.getCoarseData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_FINEMIDDLE))
+        else if (FacetTypes.IS.SEDIMENT_LOAD_FINEMIDDLE(name))
             return result.getFineMiddleData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_SUSP_SAND))
+        else if (FacetTypes.IS.SEDIMENT_LOAD_SUSP_SAND(name))
             return result.getSuspSandData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_SUSP_SAND_BED))
+        else if (FacetTypes.IS.SEDIMENT_LOAD_SUSP_SAND_BED(name))
             return result.getSuspSandBedData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_SUSP_SEDIMENT))
+        else if (FacetTypes.IS.SEDIMENT_LOAD_SUSP_SEDIMENT(name))
             return result.getSuspSedimentData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_TOTAL_LOAD))
+        else if (FacetTypes.IS.SEDIMENT_LOAD_TOTAL_LOAD(name))
             return result.getTotalLoadData();
-        else if (getName().equals(FacetTypes.SEDIMENT_LOAD_TOTAL))
+        else if (FacetTypes.IS.SEDIMENT_LOAD_TOTAL(name))
             return result.getTotalData();
         else {
-            logger.error("SedimentLoadFacet " + getName() + " cannot determine data type.");
+            logger.error("SedimentLoadFacet " + name + " cannot determine data type.");
             return null;
         }
     }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFactory.java	Mon Nov 04 11:26:02 2013 +0100
@@ -71,6 +71,14 @@
         "   JOIN    grain_fraction gf ON gf.id = grain_fraction_id " +
         "   WHERE   sy.id = :id ";
 
+    /** Query to get unit name of single sediment_yield. */
+    public static final String SQL_SELECT_SINGLE_UNIT_BY_ID =
+        "SELECT DISTINCT " +
+        "       u.name AS unit " +
+        "   FROM    sediment_yield sy " +
+        "   JOIN    units u ON u.id = unit_id " +
+        "   WHERE   sy.id = :id ";
+
     /** Query to get description of single sediment_yield. */
     public static final String SQL_SELECT_SINGLE_BY_ID =
         "SELECT DISTINCT " +
@@ -315,6 +323,24 @@
     }
 
     /**
+     * Get sediment load unit name.
+     * @param id the sediment yield by id.
+     * @return sediment yields unit name.
+     */
+    public static String getSedimentYieldUnitName(int id) {
+        log.debug("SedimentLoadFactory.getSedimentYieldUnitName");
+
+        Session session = SessionHolder.HOLDER.get();
+        SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_SINGLE_UNIT_BY_ID)
+                .addScalar("unit", StandardBasicTypes.STRING);
+        sqlQuery.setDouble("id", id);
+
+        List<Object> results = sqlQuery.list();
+
+        return (String) results.get(0);
+    }
+
+    /**
      * Get sediment load fraction name.
      * @param id the sediment yield by id.
      * @return sediment yields fraction name.
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadCalculate.java	Mon Nov 04 11:26:02 2013 +0100
@@ -54,6 +54,8 @@
     public static final String I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD = "facet.sedimentload.total_load";
     public static final String I18N_FACET_SEDIMENTLOAD_TOTAL = "facet.sedimentload.total";
 
+    private transient SedimentLoadAccess access;
+
     static {
         // Active/deactivate facets.
         FacetActivity.Registry.getInstance().register(
@@ -66,15 +68,22 @@
                     String   output
                 ) {
                     String name = facet.getName();
-                    if (name.equals(SEDIMENT_LOAD_COARSE) ||
-                        name.equals(SEDIMENT_LOAD_FINEMIDDLE) ||
-                        name.equals(SEDIMENT_LOAD_SAND) ||
-                        name.equals(SEDIMENT_LOAD_SUSP_SAND) ||
-                        name.equals(SEDIMENT_LOAD_SUSP_SEDIMENT) ||
-                        name.equals(SEDIMENT_LOAD_SUSP_SAND_BED)){
+                    if (name.equals(SEDIMENT_LOAD_TA_COARSE) ||
+                        name.equals(SEDIMENT_LOAD_TA_FINEMIDDLE) ||
+                        name.equals(SEDIMENT_LOAD_TA_SAND) ||
+                        name.equals(SEDIMENT_LOAD_TA_SUSP_SAND) ||
+                        name.equals(SEDIMENT_LOAD_TA_SUSP_SEDIMENT) ||
+                        name.equals(SEDIMENT_LOAD_TA_SUSP_SAND_BED) ||
+                        name.equals(SEDIMENT_LOAD_M3A_COARSE) ||
+                        name.equals(SEDIMENT_LOAD_M3A_FINEMIDDLE) ||
+                        name.equals(SEDIMENT_LOAD_M3A_SAND) ||
+                        name.equals(SEDIMENT_LOAD_M3A_SUSP_SAND) ||
+                        name.equals(SEDIMENT_LOAD_M3A_SUSP_SEDIMENT) ||
+                        name.equals(SEDIMENT_LOAD_M3A_SUSP_SAND_BED)){
                         return Boolean.FALSE;
                     }
-                    else if (name.equals(SEDIMENT_LOAD_UNKNOWN)) {
+                    else if (name.equals(SEDIMENT_LOAD_TA_UNKNOWN)
+                        || name.equals(SEDIMENT_LOAD_M3A_UNKNOWN)) {
                         D4EArtifact d4e = (D4EArtifact)artifact;
                         SedimentLoadUnknownFacet f =
                             (SedimentLoadUnknownFacet)
@@ -124,7 +133,9 @@
 
         List<Facet> newFacets = new ArrayList<Facet>();
 
-        SedimentLoadAccess access = new SedimentLoadAccess(artifact);
+        if (access == null) {
+            access = new SedimentLoadAccess(artifact);
+        }
 
         CalculationResult res = old instanceof CalculationResult ? (CalculationResult) old
             : new SedimentLoadCalculation().calculate(access);
@@ -157,6 +168,8 @@
             SedimentLoadFactory.getSedimentLoadUnknown(river,
                 access.getUnit().replace("_per_","/"), type);
 
+        boolean isUnitTA = access.getUnit().startsWith("t");
+
         if (res.getReport().hasProblems()) {
             newFacets.add(new ReportFacet(ComputeType.ADVANCE, hash, id));
         }
@@ -164,7 +177,7 @@
         for (int i = 0; i < unknown.length; i++) {
             newFacets.add(new SedimentLoadUnknownFacet(
                 i,
-                SEDIMENT_LOAD_UNKNOWN,
+                (isUnitTA)? SEDIMENT_LOAD_TA_UNKNOWN:SEDIMENT_LOAD_M3A_UNKNOWN,
                 unknown[i].getDescription(),
                 ComputeType.ADVANCE,
                 getID(),
@@ -184,6 +197,7 @@
         logger.debug("SedimentLoadCalculate.generateFacets");
 
         CallMeta meta = context.getMeta();
+        boolean isUnitTA = access.getUnit().startsWith("t");
 
 //      newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
         for (int idx = 0; idx < results.length; idx++) {
@@ -191,7 +205,9 @@
             if (res.hasCoarseData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_COARSE,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_COARSE
+                    :SEDIMENT_LOAD_M3A_COARSE,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_COARSE,
@@ -204,7 +220,9 @@
             if (res.hasSandData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SAND,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SAND
+                    :SEDIMENT_LOAD_M3A_SAND,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SAND,
@@ -217,7 +235,9 @@
             if (res.hasFineMiddleData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_FINEMIDDLE,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_FINEMIDDLE
+                    :SEDIMENT_LOAD_M3A_FINEMIDDLE,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE,
@@ -230,7 +250,9 @@
             if (res.hasSuspSandData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SUSP_SAND,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SUSP_SAND
+                    :SEDIMENT_LOAD_M3A_SUSP_SAND,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSAND,
@@ -243,7 +265,9 @@
             if (res.hasSuspSandBedData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SUSP_SAND_BED,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SUSP_SAND_BED
+                    :SEDIMENT_LOAD_M3A_SUSP_SAND_BED,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSANDBED,
@@ -256,7 +280,9 @@
             if (res.hasSuspSedimentData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SUSP_SEDIMENT,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SUSP_SEDIMENT
+                    :SEDIMENT_LOAD_M3A_SUSP_SEDIMENT,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT,
@@ -270,7 +296,9 @@
             if (res.hasTotalData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_TOTAL,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_TOTAL
+                    :SEDIMENT_LOAD_M3A_TOTAL,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_TOTAL,
@@ -293,6 +321,7 @@
         logger.debug("SedimentLoadCalculate.generateEpochFacets");
 
         CallMeta meta = context.getMeta();
+        boolean isUnitTA = access.getUnit().startsWith("t");
 
 //      newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
         for (int idx = 0; idx < results.length; idx++) {
@@ -300,7 +329,9 @@
             if (res.hasCoarseData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_COARSE,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_COARSE
+                    :SEDIMENT_LOAD_M3A_COARSE,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_COARSE,
@@ -313,7 +344,9 @@
             if (res.hasSandData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SAND,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SAND
+                    :SEDIMENT_LOAD_M3A_SAND,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SAND,
@@ -326,7 +359,9 @@
             if (res.hasFineMiddleData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_FINEMIDDLE,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_FINEMIDDLE
+                    :SEDIMENT_LOAD_M3A_FINEMIDDLE,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE,
@@ -339,7 +374,9 @@
             if (res.hasSuspSandData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SUSP_SAND,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SUSP_SAND
+                    :SEDIMENT_LOAD_M3A_SUSP_SAND,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSAND,
@@ -352,7 +389,9 @@
             if (res.hasSuspSandBedData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SUSP_SAND_BED,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SUSP_SAND_BED
+                    :SEDIMENT_LOAD_M3A_SUSP_SAND,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSANDBED,
@@ -365,7 +404,9 @@
             if (res.hasSuspSedimentData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SUSP_SEDIMENT,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SUSP_SEDIMENT
+                    :SEDIMENT_LOAD_M3A_SUSP_SEDIMENT,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT,
@@ -379,7 +420,9 @@
             if (res.hasTotalLoadData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_TOTAL_LOAD,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_TOTAL_LOAD
+                    :SEDIMENT_LOAD_M3A_TOTAL_LOAD,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD,
@@ -392,7 +435,9 @@
             if (res.hasTotalData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_TOTAL,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_TOTAL
+                    :SEDIMENT_LOAD_M3A_TOTAL,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_TOTAL,
@@ -415,6 +460,7 @@
         logger.debug("SedimentLoadCalculate.generateOffEpochFacets");
 
         CallMeta meta = context.getMeta();
+        boolean isUnitTA = access.getUnit().startsWith("t");
 
 //      newFacets.add(new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
         for (int idx = 0; idx < results.length; idx++) {
@@ -422,7 +468,9 @@
             if (res.hasCoarseData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_COARSE,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_COARSE
+                    :SEDIMENT_LOAD_M3A_COARSE,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_COARSE,
@@ -435,7 +483,9 @@
             if (res.hasSandData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SAND,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SAND
+                    :SEDIMENT_LOAD_M3A_SAND,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SAND,
@@ -448,7 +498,9 @@
             if (res.hasFineMiddleData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_FINEMIDDLE,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_FINEMIDDLE
+                    :SEDIMENT_LOAD_M3A_FINEMIDDLE,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_FINE_MIDDLE,
@@ -461,7 +513,9 @@
             if (res.hasSuspSandData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SUSP_SAND,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SUSP_SAND
+                    :SEDIMENT_LOAD_M3A_SUSP_SAND,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSAND,
@@ -474,7 +528,9 @@
             if (res.hasSuspSandBedData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SUSP_SAND_BED,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SUSP_SAND_BED
+                    :SEDIMENT_LOAD_M3A_SUSP_SAND_BED,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSANDBED,
@@ -487,7 +543,9 @@
             if (res.hasSuspSedimentData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_SUSP_SEDIMENT,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_SUSP_SEDIMENT
+                    :SEDIMENT_LOAD_M3A_SUSP_SEDIMENT,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_SUSPSEDIMENT,
@@ -501,7 +559,9 @@
             if (res.hasTotalLoadData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_TOTAL_LOAD,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_TOTAL_LOAD
+                    :SEDIMENT_LOAD_M3A_TOTAL_LOAD,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_TOTAL_LOAD,
@@ -514,7 +574,9 @@
             if (res.hasTotalData()) {
                 newFacets.add(new SedimentLoadFacet(
                     idx,
-                    SEDIMENT_LOAD_TOTAL,
+                    (isUnitTA)
+                    ?SEDIMENT_LOAD_TA_TOTAL
+                    :SEDIMENT_LOAD_M3A_TOTAL,
                     Resources.getMsg(
                         meta,
                         I18N_FACET_SEDIMENTLOAD_TOTAL,
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceExporter.java	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDifferenceExporter.java	Mon Nov 04 11:26:02 2013 +0100
@@ -182,6 +182,5 @@
             logger.warn("Error generating PDF Report!", je);
         }
     }
-
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadLSGenerator.java	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadLSGenerator.java	Mon Nov 04 11:26:02 2013 +0100
@@ -53,6 +53,7 @@
             idx = c;
         }
     }
+
     /** The logger that is used in this generator. */
     private static Logger logger = Logger.getLogger(SedimentLoadLSGenerator.class);
 
@@ -133,7 +134,7 @@
             context.putContextValue("startkm", bounds.getLower());
             context.putContextValue("endkm", bounds.getUpper());
         }
-        if (FacetTypes.IS.SEDIMENT_LOAD(name)) {
+        if (FacetTypes.IS.SEDIMENT_LOAD_TA(name)||FacetTypes.IS.SEDIMENT_LOAD_M3A(name)){
             doSedimentLoadOut(
                 (double[][]) bundle.getData(context),
                 bundle,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadM3AProcessor.java	Mon Nov 04 11:26:02 2013 +0100
@@ -0,0 +1,83 @@
+/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.exports.process;
+
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.themes.ThemeDocument;
+
+import org.dive4elements.river.artifacts.model.minfo.SedimentLoad;
+import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction;
+
+public class SedimentLoadM3AProcessor extends DefaultProcessor {
+
+    private final static Logger logger =
+            Logger.getLogger(SedimentLoadM3AProcessor.class);
+
+    public static final String I18N_YAXIS_LABEL =
+        "chart.sedimentload.ls.yaxis.label.m3pera";
+    public static final String I18N_YAXIS_LABEL_DEFAULT = "[m\u00b3/a]";
+
+    @Override
+    public void doOut(
+            DiagramGenerator generator,
+            ArtifactAndFacet bundle,
+            ThemeDocument    theme,
+            boolean          visible) {
+        logger.debug("doOut " + bundle.getFacetName());
+        CallContext context = generator.getCallContext();
+        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+                theme);
+        Object data = bundle.getData(context);
+        String facetName = bundle.getFacetName();
+        double [][] points;
+
+        if (FacetTypes.IS.SEDIMENT_LOAD_M3A(facetName)) {
+            points = (double[][]) data;
+        } else if (FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facetName)) {
+            SedimentLoad load = (SedimentLoad) data;
+            Set<Double> kms = load.getKms();
+            points = new double[2][kms.size()];
+            int counter = 0;
+            for (Double km: kms) {
+                SedimentLoadFraction fraction = load.getFraction(km);
+                points[0][counter] = km;
+                points[1][counter] = fraction.getUnknown();
+                counter++;
+            }
+        } else {
+            logger.error("Unknown facet name: " + facetName);
+            return;
+        }
+
+        StyledSeriesBuilder.addPoints(series, points, true);
+
+        generator.addAxisSeries(series, axisName, visible);
+    }
+
+    @Override
+    public boolean canHandle(String facettype) {
+        return FacetTypes.IS.SEDIMENT_LOAD_M3A(facettype) ||
+            FacetTypes.SEDIMENT_LOAD_M3A_UNKNOWN.equals(facettype);
+    }
+
+    @Override
+    public String getAxisLabel(DiagramGenerator generator) {
+        return generator.msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
+    }
+}
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadProcessor.java	Mon Nov 04 11:24:30 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde
- * Software engineering by Intevation GmbH
- *
- * This file is Free Software under the GNU AGPL (>=v3)
- * and comes with ABSOLUTELY NO WARRANTY! Check out the
- * documentation coming with Dive4Elements River for details.
- */
-
-package org.dive4elements.river.exports.process;
-
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-import org.jfree.data.xy.XYSeries;
-import org.dive4elements.river.artifacts.D4EArtifact;
-
-import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
-import org.dive4elements.artifacts.CallContext;
-import org.dive4elements.river.artifacts.access.SedimentLoadAccess;
-import org.dive4elements.river.artifacts.model.FacetTypes;
-import org.dive4elements.river.exports.DiagramGenerator;
-import org.dive4elements.river.exports.StyledSeriesBuilder;
-import org.dive4elements.river.jfree.StyledXYSeries;
-import org.dive4elements.river.themes.ThemeDocument;
-
-import org.dive4elements.river.artifacts.model.minfo.SedimentLoad;
-import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction;
-
-public class SedimentLoadProcessor extends DefaultProcessor {
-
-    private final static Logger logger =
-            Logger.getLogger(SedimentLoadProcessor.class);
-
-    public static final String I18N_YAXIS_LABEL_1 =
-        "chart.sedimentload.ls.yaxis.label.tpera";
-    public static final String I18N_YAXIS_LABEL_2 =
-        "chart.sedimentload.ls.yaxis.label.m3pera";
-    public static final String I18N_YAXIS_LABEL_DEFAULT_1 = "[t/a]";
-    public static final String I18N_YAXIS_LABEL_DEFAULT_2 = "[m\u00b3/a]";
-
-    @Override
-    public void doOut(
-            DiagramGenerator generator,
-            ArtifactAndFacet bundle,
-            ThemeDocument    theme,
-            boolean          visible) {
-        logger.debug("doOut " + bundle.getFacetName());
-        CallContext context = generator.getCallContext();
-        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
-                theme);
-        Object data = bundle.getData(context);
-        String facetName = bundle.getFacetName();
-        double [][] points;
-
-        if (FacetTypes.IS.SEDIMENT_LOAD(facetName)) {
-            points = (double[][]) data;
-        } else if (FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facetName)) {
-            SedimentLoad load = (SedimentLoad) data;
-            Set<Double> kms = load.getKms();
-            points = new double[2][kms.size()];
-            int counter = 0;
-            for (Double km: kms) {
-                SedimentLoadFraction fraction = load.getFraction(km);
-                points[0][counter] = km;
-                points[1][counter] = fraction.getUnknown();
-                counter++;
-            }
-        } else {
-            logger.error("Unknown facet name: " + facetName);
-            return;
-        }
-        StyledSeriesBuilder.addPoints(series, points, true);
-
-        generator.addAxisSeries(series, axisName, visible);
-    }
-
-    @Override
-    public boolean canHandle(String facettype) {
-        return FacetTypes.IS.SEDIMENT_LOAD(facettype) ||
-            FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facettype);
-    }
-
-    @Override
-    public String getAxisLabel(DiagramGenerator generator) {
-        SedimentLoadAccess slaccess =
-            new SedimentLoadAccess((D4EArtifact) generator.getMaster());
-        String unit = slaccess.getUnit();
-        if (unit != null && unit.equals("m3_per_a")) {
-            return generator.msg(I18N_YAXIS_LABEL_2, I18N_YAXIS_LABEL_DEFAULT_2);
-        }
-        else {
-            return generator.msg(I18N_YAXIS_LABEL_1, I18N_YAXIS_LABEL_DEFAULT_1);
-        }
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/SedimentLoadTAProcessor.java	Mon Nov 04 11:26:02 2013 +0100
@@ -0,0 +1,83 @@
+/* Copyright (C) 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.exports.process;
+
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+import org.jfree.data.xy.XYSeries;
+
+import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.river.artifacts.model.FacetTypes;
+import org.dive4elements.river.exports.DiagramGenerator;
+import org.dive4elements.river.exports.StyledSeriesBuilder;
+import org.dive4elements.river.jfree.StyledXYSeries;
+import org.dive4elements.river.themes.ThemeDocument;
+
+import org.dive4elements.river.artifacts.model.minfo.SedimentLoad;
+import org.dive4elements.river.artifacts.model.minfo.SedimentLoadFraction;
+
+public class SedimentLoadTAProcessor extends DefaultProcessor {
+
+    private final static Logger logger =
+            Logger.getLogger(SedimentLoadTAProcessor.class);
+
+    public static final String I18N_YAXIS_LABEL =
+        "chart.sedimentload.ls.yaxis.label.tpera";
+    public static final String I18N_YAXIS_LABEL_DEFAULT = "[t/a]";
+
+    @Override
+    public void doOut(
+            DiagramGenerator generator,
+            ArtifactAndFacet bundle,
+            ThemeDocument    theme,
+            boolean          visible) {
+        logger.debug("doOut " + bundle.getFacetName());
+        CallContext context = generator.getCallContext();
+        XYSeries series = new StyledXYSeries(bundle.getFacetDescription(),
+                theme);
+        Object data = bundle.getData(context);
+        String facetName = bundle.getFacetName();
+        double [][] points;
+
+        if (FacetTypes.IS.SEDIMENT_LOAD_TA(facetName)) {
+            points = (double[][]) data;
+        } else if (FacetTypes.IS.SEDIMENT_LOAD_UNKNOWN(facetName)) {
+            SedimentLoad load = (SedimentLoad) data;
+            Set<Double> kms = load.getKms();
+            points = new double[2][kms.size()];
+            int counter = 0;
+            for (Double km: kms) {
+                SedimentLoadFraction fraction = load.getFraction(km);
+                points[0][counter] = km;
+                points[1][counter] = fraction.getUnknown();
+                counter++;
+            }
+        } else {
+            logger.error("Unknown facet name: " + facetName);
+            return;
+        }
+
+        StyledSeriesBuilder.addPoints(series, points, true);
+
+        generator.addAxisSeries(series, axisName, visible);
+    }
+
+    @Override
+    public boolean canHandle(String facettype) {
+        return FacetTypes.IS.SEDIMENT_LOAD_TA(facettype) ||
+            FacetTypes.SEDIMENT_LOAD_TA_UNKNOWN.equals(facettype);
+    }
+
+    @Override
+    public String getAxisLabel(DiagramGenerator generator) {
+        return generator.msg(I18N_YAXIS_LABEL, I18N_YAXIS_LABEL_DEFAULT);
+    }
+}
--- a/artifacts/src/main/java/org/dive4elements/river/exports/process/WOutProcessor.java	Mon Nov 04 11:24:30 2013 +0100
+++ b/artifacts/src/main/java/org/dive4elements/river/exports/process/WOutProcessor.java	Mon Nov 04 11:26:02 2013 +0100
@@ -116,13 +116,14 @@
             boolean          visible,
             int              index)
     {
-        CallContext context = generator.getCallContext();
-        WKms wkms = (WKms) bundle.getData(context);
-
         logger.debug("doOut");
 
+        CallContext context = generator.getCallContext();
+
         XYSeries series = new StyledXYSeries(bundle.getFacetDescription(), theme);
 
+        WKms wkms = (WKms) bundle.getData(context);
+
         StyledSeriesBuilder.addPoints(series, wkms);
         generator.addAxisSeries(series, index, visible);
 

http://dive4elements.wald.intevation.org