changeset 8713:6b68777aaeab

(issue1448) Remove obsolete code for OfficalEpoch "Calculation" This is handled through datacage recommendations as this was never an actual calculation.
author Andre Heinecke <andre.heinecke@intevation.de>
date Fri, 24 Apr 2015 17:54:12 +0200
parents 582e970115b6
children 4e8c80ff07e3
files artifacts/doc/conf/artifacts/minfo.xml artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadOffEpochSelect.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadOffEpochPanel.java
diffstat 5 files changed, 1 insertions(+), 297 deletions(-) [+]
line wrap: on
line diff
--- a/artifacts/doc/conf/artifacts/minfo.xml	Fri Apr 24 17:18:48 2015 +0200
+++ b/artifacts/doc/conf/artifacts/minfo.xml	Fri Apr 24 17:54:12 2015 +0200
@@ -527,12 +527,6 @@
 
         <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
             <from state="state.minfo.sediment.load.location"/>
-            <to state="state.minfo.sediment.load.off_epochs"/>
-            <condition data="ye_select" value="off_epoch" operator="equal"/>
-        </transition>
-
-        <transition transition="org.dive4elements.river.artifacts.transitions.ValueCompareTransition">
-            <from state="state.minfo.sediment.load.location"/>
             <to state="state.minfo.sediment.load.sq_interval"/>
             <condition data="ye_select" value="year" operator="equal"/>
         </transition>
@@ -578,11 +572,6 @@
             <data name="epochs" type="String"/>
         </state>
 
-        <state id="state.minfo.sediment.load.off_epochs" description="state.minfo.bed.off_epochs" state="org.dive4elements.river.artifacts.states.minfo.SedimentLoadOffEpochSelect"
-				helpText="help.state.minfo.sediment.load.off_epochs">
-            <data name="epochs" type="String"/>
-        </state>
-
         <transition transition="org.dive4elements.river.artifacts.transitions.DefaultTransition">
             <from state="state.minfo.sediment.load.period"/>
             <to state="state.minfo.sediment.load.unit"/>
@@ -593,11 +582,6 @@
             <to state="state.minfo.sediment.load.unit"/>
         </transition>
 
-        <transition transition="org.dive4elements.river.artifacts.transitions.DefaultTransition">
-            <from state="state.minfo.sediment.load.off_epochs"/>
-            <to state="state.minfo.sediment.load.unit"/>
-        </transition>
-
         <state id="state.minfo.sediment.load.unit" description="state.minfo.sediment.load.unit" state="org.dive4elements.river.artifacts.states.minfo.SedimentLoadUnit"
 				helpText="help.state.minfo.sediment.load.unit">
             <data name="unit" type="String"/>
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Fri Apr 24 17:18:48 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadDataCalculation.java	Fri Apr 24 17:54:12 2015 +0200
@@ -22,7 +22,6 @@
 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadData.Station;
 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.And;
 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsEpoch;
-import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.IsOfficial;
 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.Not;
 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.SQTimeInterval;
 import org.dive4elements.river.artifacts.model.minfo.SedimentLoadDataValueFilter.TimeRangeIntersects;
@@ -178,7 +177,7 @@
         if (yearEpoch.equals("year")) {
             years = access.getYears();
         }
-        else if (yearEpoch.equals("epoch") || yearEpoch.equals("off_epoch")) {
+        else if (yearEpoch.equals("epoch")) {
             epochs = access.getEpochs();
         }
         else {
@@ -217,7 +216,6 @@
     private CalculationResult internalCalculate() {
         if ("year".equals(yearEpoch))      return calculateYears();
         if ("epoch".equals(yearEpoch))     return calculateEpochs();
-        if ("off_epoch".equals(yearEpoch)) return calculateOffEpochs();
 
         // TODO: i18n
         return error("minfo.sedimentload.unknown.calc.mode");
@@ -339,51 +337,6 @@
         return new CalculationResult(sldr, this);
     }
 
-    private CalculationResult calculateOffEpochs() {
-        SedimentLoadData sld =
-            SedimentLoadDataFactory.INSTANCE.getSedimentLoadData(river);
-        if (sld == null) {
-            return error("minfo.sedimentload.no.data");
-        }
-
-        SedimentLoadDataResult sldr = new SedimentLoadDataResult();
-
-        SedimentDensity sd = getSedimentDensity();
-
-        Set<Integer> missingFractions = new TreeSet<Integer>();
-
-        for (int [] epoch: epochs) {
-            Value.Filter filter = new And(IsOfficial.INSTANCE)
-                .add(new TimeRangeIntersects(epoch[0], epoch[1]));
-
-            int year = Math.min(epoch[0], epoch[1]);
-
-            String period = Integer.toString(epoch[0]) + " - " +
-                Integer.toString(epoch[1]);
-
-            Sum sum = new Sum();
-
-            for (LoadSum ls: LOAD_SUMS) {
-                double [][] result = sum(
-                    sld, ls.getGrainFractions(), ls.getStationType(),
-                    filter, sum);
-
-                if (result[0].length == 0 || DoubleUtil.isNaN(result[1])) {
-                    addProblem("sedimentload.missing.fraction." +
-                               ls.getDescription(), period);
-                    continue;
-                }
-
-                transformT2M3(sd, year, result);
-                SedimentLoadDataResult.Fraction sldrf =
-                    new SedimentLoadDataResult.Fraction(ls.getDescription(), result, period);
-                sldr.addFraction(sldrf);
-            }
-        }
-        // TODO: Generate messages for missing fractions.
-        return new CalculationResult(sldr, this);
-    }
-
     private final boolean inM3() {
         return unit.equals("m3_per_a");
     }
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/minfo/SedimentLoadOffEpochSelect.java	Fri Apr 24 17:18:48 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/* Copyright (C) 2011, 2012, 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.artifacts.states.minfo;
-
-import org.apache.log4j.Logger;
-
-import org.dive4elements.river.artifacts.states.DefaultState;
-
-/** State in which official epoch is selected to calculate sediment load. */
-public class SedimentLoadOffEpochSelect
-extends DefaultState
-{
-   /** The log used in this class. */
-    private static Logger log = Logger.getLogger(SedimentLoadOffEpochSelect.class);
-
-
-    /**
-     * The default constructor that initializes an empty State object.
-     */
-    public SedimentLoadOffEpochSelect() {
-    }
-
-    @Override
-    protected String getUIProvider() {
-        return "minfo.sedimentload_offepoch_select";
-    }
-}
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java	Fri Apr 24 17:18:48 2015 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java	Fri Apr 24 17:54:12 2015 +0200
@@ -22,7 +22,6 @@
 import org.dive4elements.river.client.client.ui.minfo.CheckboxPanel;
 import org.dive4elements.river.client.client.ui.minfo.SedLoadDistancePanel;
 import org.dive4elements.river.client.client.ui.minfo.SedLoadEpochPanel;
-import org.dive4elements.river.client.client.ui.minfo.SedLoadOffEpochPanel;
 import org.dive4elements.river.client.client.ui.minfo.SedLoadPeriodPanel;
 import org.dive4elements.river.client.client.ui.minfo.SedLoadSQTiPanel;
 import org.dive4elements.river.client.client.ui.sq.SQPeriodPanel;
@@ -185,9 +184,6 @@
         else if (uiProvider.equals("minfo.sedimentload_epoch_select")) {
             return new SedLoadEpochPanel();
         }
-        else if (uiProvider.equals("minfo.sedimentload_offepoch_select")) {
-            return new SedLoadOffEpochPanel();
-        }
         else if (uiProvider.equals("minfo.sedimentload_sqti_select")) {
             return new SedLoadSQTiPanel();
         }
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/minfo/SedLoadOffEpochPanel.java	Fri Apr 24 17:18:48 2015 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,196 +0,0 @@
-/* Copyright (C) 2011, 2012, 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.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 org.dive4elements.river.client.client.Config;
-import org.dive4elements.river.client.client.services.SedimentLoadInfoService;
-import org.dive4elements.river.client.client.services.SedimentLoadInfoServiceAsync;
-import org.dive4elements.river.client.client.ui.PeriodPanel;
-import org.dive4elements.river.client.shared.model.ArtifactDescription;
-import org.dive4elements.river.client.shared.model.Data;
-import org.dive4elements.river.client.shared.model.DataItem;
-import org.dive4elements.river.client.shared.model.DataList;
-import org.dive4elements.river.client.shared.model.DefaultData;
-import org.dive4elements.river.client.shared.model.DefaultDataItem;
-import org.dive4elements.river.client.shared.model.SedimentLoadInfoObject;
-import org.dive4elements.river.client.shared.model.SedimentLoadInfoRecord;
-
-/** Show input to select an official epoch. */
-public class SedLoadOffEpochPanel
-extends PeriodPanel
-{
-    protected SedimentLoadInfoServiceAsync sedLoadInfoService =
-        GWT.create(SedimentLoadInfoService.class);
-
-    protected ListGrid sedLoadTable;
-
-    /** Creates layout with title. */
-    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;
-    }
-
-    /** Create layout for data entered previously. */
-    @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;
-    }
-
-    /** Creates the helper grid in which off epochs can be selected. */
-    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);
-
-        sedLoadTable.setFields(date);
-        return sedLoadTable;
-    }
-
-    /** Get data via listgrid selection. */
-    @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()]);
-    }
-
-    /** Fetch load info from service and populate table. */
-    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, "off_epoch", km[0], km[1], "",
-            new AsyncCallback<SedimentLoadInfoObject[]>() {
-                public void onFailure(Throwable caught) {
-                    GWT.log("Could not receive sediment load informations.");
-                    SC.warn(caught.getMessage());
-                }
-
-                public void onSuccess(SedimentLoadInfoObject[] sedLoad) {
-                    int num = sedLoad != null ? sedLoad.length :0;
-                    GWT.log("Received " + num + " sediment load informations.");
-
-                    if (num == 0) {
-                        return;
-                    }
-
-                    addSedimentLoadInfo(sedLoad);
-                }
-            }
-        );
-    }
-
-
-    /** Add record to input helper listgrid. */
-    protected void addSedimentLoadInfo (SedimentLoadInfoObject[] sedLoad) {
-        for(SedimentLoadInfoObject sl: sedLoad) {
-            SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl);
-            sedLoadTable.addData(rec);
-        }
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org