[PATCH 1 of 5] Removed bed height epoch in importer

Wald Commits scm-commit at wald.intevation.org
Fri Jun 6 17:02:16 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1402066068 -7200
# Node ID 5813c206ff64e854cb93bb5c3968be067ef7bd23
# Parent  9ec6def1a7dd36dff632b9ef0df340b4eac5e956
Removed bed height epoch in importer.

diff -r 9ec6def1a7dd -r 5813c206ff64 backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java
--- a/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java	Thu Jun 05 15:32:52 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/backend/FLYSCredentials.java	Fri Jun 06 16:47:48 2014 +0200
@@ -14,8 +14,6 @@
 import org.dive4elements.river.model.AnnotationType;
 import org.dive4elements.river.model.Attribute;
 import org.dive4elements.river.model.AxisKind;
-import org.dive4elements.river.model.BedHeightEpoch;
-import org.dive4elements.river.model.BedHeightEpochValue;
 import org.dive4elements.river.model.BedHeightSingle;
 import org.dive4elements.river.model.BedHeightSingleValue;
 import org.dive4elements.river.model.BedHeightType;
@@ -139,8 +137,6 @@
         AnnotationType.class,
         Attribute.class,
         AxisKind.class,
-        BedHeightEpoch.class,
-        BedHeightEpochValue.class,
         BedHeightSingle.class,
         BedHeightSingleValue.class,
         BedHeightType.class,
diff -r 9ec6def1a7dd -r 5813c206ff64 backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightEpoch.java
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightEpoch.java	Thu Jun 05 15:32:52 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,206 +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.importer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-import org.hibernate.Query;
-import org.hibernate.Session;
-
-import org.dive4elements.river.model.BedHeightEpoch;
-import org.dive4elements.river.model.ElevationModel;
-import org.dive4elements.river.model.Range;
-import org.dive4elements.river.model.River;
-import org.dive4elements.river.model.TimeInterval;
-
-
-/** Import Bed Height Data, 'epoch' type from csv file. */
-public class ImportBedHeightEpoch implements ImportBedHeight {
-
-    /** Private logger. */
-    private static Logger log = Logger.getLogger(ImportBedHeightEpoch.class);
-
-    protected String evaluationBy;
-
-    /** De facto the file name. */
-    protected String description;
-
-    protected ImportTimeInterval timeInterval;
-    protected ImportRange range;
-    protected ImportElevationModel curElevationModel;
-    protected ImportElevationModel oldElevationModel;
-
-    protected List<ImportBedHeightEpochValue> values;
-
-    protected BedHeightEpoch peer;
-
-    public ImportBedHeightEpoch(String description) {
-        this.description = description;
-        this.values = new ArrayList<ImportBedHeightEpochValue>();
-    }
-
-    public String getDescription() {
-        return description;
-    }
-
-    public int getValueCount() {
-        return values.size();
-    }
-
-    public void setTimeInterval(ImportTimeInterval timeInterval) {
-        this.timeInterval = timeInterval;
-    }
-
-    public void setEvaluationBy(String evaluationBy) {
-        this.evaluationBy = evaluationBy;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    public void setRange(ImportRange range) {
-        this.range = range;
-    }
-
-    public void setCurElevationModel(ImportElevationModel curElevationModel) {
-        this.curElevationModel = curElevationModel;
-    }
-
-    public void setOldElevationModel(ImportElevationModel oldElevationModel) {
-        this.oldElevationModel = oldElevationModel;
-    }
-
-    /** Does nothing. */
-    public void setYear(int year) {
-        // do nothing
-    }
-
-    /** Does nothing. */
-    public void setSoundingWidth(int soundingWidth) {
-        // do nothing
-    }
-
-
-    /** Does nothing. */
-    public void setLocationSystem(ImportLocationSystem locationSystem) {
-        // do nothing
-    }
-
-
-    /** Does nothing. */
-    public void setType(ImportBedHeightType type) {
-        // do nothing
-    }
-
-    @Override
-    public void addValue(ImportBedHeightValue value) {
-        values.add((ImportBedHeightEpochValue) value);
-    }
-
-    @Override
-    public void storeDependencies(River river) {
-        log.info("Store dependencies for epoch: '" + getDescription() + "'");
-
-        BedHeightEpoch peer = getPeer(river);
-
-        if (curElevationModel != null) {
-            curElevationModel.storeDependencies();
-        }
-
-        if (oldElevationModel != null) {
-            oldElevationModel.storeDependencies();
-        }
-
-        if (peer != null) {
-            log.debug("store values now...");
-
-            for (ImportBedHeightEpochValue value : values) {
-                value.storeDependencies(peer);
-            }
-        }
-
-        Session session = ImporterSession.getInstance().getDatabaseSession();
-        session.flush();
-    }
-
-    /**
-     * Asserts all dependent entities (ElevationModel, TimeInterval, Range,
-     * BedHeighEpoch) are in db and returns bound (either newly created or
-     * freshly fetched) BedHeightEpoch.
-     */
-    @Override
-    public BedHeightEpoch getPeer(River river) {
-        if (peer == null) {
-            ElevationModel theCurModel = null;
-            if (curElevationModel != null) {
-                curElevationModel.storeDependencies();
-                theCurModel = curElevationModel.getPeer();
-            }
-
-            if (theCurModel == null) {
-                log.warn("BHE: Skip file - invalid current elevation model.");
-                return null;
-            }
-
-            TimeInterval theTime = null;
-            if (timeInterval != null) {
-                theTime = timeInterval.getPeer();
-            }
-
-            if (theTime == null) {
-                log.warn("BHE: Skip file - invalid time range.");
-                return null;
-            }
-
-            Range theRange = range != null ? range.getPeer(river) : null;
-
-            if (theRange == null) {
-                log.warn("BHE: invalid km range.");
-            }
-
-            Session session = ImporterSession.getInstance()
-                .getDatabaseSession();
-
-            Query query = session.createQuery("from BedHeightEpoch where "
-                + "   river=:river and " + "   timeInterval=:timeInterval and "
-                + "   curElevationModel=:curElevationModel and "
-                + "   range=:range and " + "   evaluationBy=:evaluationBy and "
-                + "   description=:description");
-
-            query.setParameter("river", river);
-            query.setParameter("timeInterval", theTime);
-            query.setParameter("curElevationModel", theCurModel);
-            query.setParameter("range", theRange);
-            query.setParameter("evaluationBy", evaluationBy);
-            query.setParameter("description", description);
-
-            List<BedHeightEpoch> bedHeights = query.list();
-
-            if (bedHeights.isEmpty()) {
-                log.info("Create new BedHeightEpoch DB instance.");
-
-                peer = new BedHeightEpoch(river, theTime, theRange,
-                    theCurModel,
-                    oldElevationModel != null ? oldElevationModel.getPeer()
-                        : null, evaluationBy, description);
-
-                session.save(peer);
-            }
-            else {
-                peer = bedHeights.get(0);
-            }
-        }
-
-        return peer;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 9ec6def1a7dd -r 5813c206ff64 backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightEpochValue.java
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportBedHeightEpochValue.java	Thu Jun 05 15:32:52 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +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.importer;
-
-import java.util.List;
-
-import java.math.BigDecimal;
-
-import org.apache.log4j.Logger;
-
-import org.hibernate.Session;
-import org.hibernate.Query;
-
-import org.dive4elements.river.model.BedHeightEpoch;
-import org.dive4elements.river.model.BedHeightEpochValue;
-
-
-public class ImportBedHeightEpochValue implements ImportBedHeightValue {
-
-    private static final Logger log =
-        Logger.getLogger(ImportBedHeightEpochValue.class);
-
-
-    private BigDecimal station;
-    private BigDecimal height;
-
-    private BedHeightEpochValue peer;
-
-
-    public ImportBedHeightEpochValue() {
-    }
-
-
-    public ImportBedHeightEpochValue(BigDecimal station, BigDecimal height) {
-        this.station = station;
-        this.height  = height;
-    }
-
-
-    public void storeDependencies(BedHeightEpoch bedHeight) {
-        getPeer(bedHeight);
-    }
-
-
-    public BedHeightEpochValue getPeer(BedHeightEpoch bedHeight) {
-        if (peer == null) {
-            Session session = ImporterSession.getInstance().getDatabaseSession();
-
-            Query query = session.createQuery(
-                "from BedHeightEpochValue where " +
-                "   bedHeight=:bedHeight and " +
-                "   station=:station and " +
-                "   height=:height");
-
-            query.setParameter("bedHeight", bedHeight);
-            query.setParameter("station", station);
-            query.setParameter("height", height);
-
-            List<BedHeightEpochValue> values = query.list();
-
-            if (values.isEmpty()) {
-                peer = new BedHeightEpochValue(
-                    bedHeight,
-                    station,
-                    height
-                );
-                session.save(peer);
-            }
-            else {
-                peer = values.get(0);
-            }
-        }
-
-        return peer;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 9ec6def1a7dd -r 5813c206ff64 backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java
--- a/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Thu Jun 05 15:32:52 2014 +0200
+++ b/backend/src/main/java/org/dive4elements/river/importer/ImportRiver.java	Fri Jun 06 16:47:48 2014 +0200
@@ -14,7 +14,6 @@
 
 import org.dive4elements.river.importer.parsers.AnnotationClassifier;
 import org.dive4elements.river.importer.parsers.AnnotationsParser;
-import org.dive4elements.river.importer.parsers.BedHeightEpochParser;
 import org.dive4elements.river.importer.parsers.BedHeightSingleParser;
 import org.dive4elements.river.importer.parsers.CrossSectionParser;
 import org.dive4elements.river.importer.parsers.DA50Parser;
@@ -93,8 +92,6 @@
 
     public static final String BED_HEIGHT_SINGLE_DIR = "Einzeljahre";
 
-    public static final String BED_HEIGHT_EPOCH_DIR = "Epochen";
-
     public static final String SEDIMENT_DENSITY_DIR = "Sedimentdichte";
 
     public static final String POROSITY_DIR = "Porositaet";
@@ -450,7 +447,6 @@
         File minfoDir     = getMinfoDir();
         File bedHeightDir = new File(minfoDir, BED_HEIGHT_DIR);
         File singlesDir   = new File(bedHeightDir, BED_HEIGHT_SINGLE_DIR);
-        File epochDir     = new File(bedHeightDir, BED_HEIGHT_EPOCH_DIR);
 
         if (Config.INSTANCE.skipBedHeightSingle()) {
             log.info("skip parsing bed height single.");
@@ -459,14 +455,6 @@
             log.info("Parse bed height single.");
             parseBedHeightSingles(singlesDir);
         }
-
-        if (Config.INSTANCE.skipBedHeightEpoch()) {
-            log.info("skip parsing bed height epochs.");
-        }
-        else {
-            log.info("Parse bed height epochs.");
-            parseBedHeightEpochs(epochDir);
-        }
     }
 
 
@@ -815,27 +803,6 @@
         bedHeightSingles = parser.getBedHeights();
     }
 
-
-    protected void parseBedHeightEpochs(File dir) throws IOException {
-        log.debug("Parse bed height epochs");
-
-        File[] files = dir.listFiles();
-
-        if (files == null) {
-            log.warn("Cannot read directory '" + dir + "'");
-            return;
-        }
-
-        BedHeightEpochParser parser = new BedHeightEpochParser();
-
-        for (File file: files) {
-            parser.parse(file);
-        }
-
-        bedHeightEpochs = parser.getBedHeights();
-    }
-
-
     public void parseFloodWater() throws IOException {
         if (Config.INSTANCE.skipFloodWater()) {
             log.info("skip parsing flod water");
@@ -1444,11 +1411,6 @@
             log.info("store bed heights single");
             storeBedHeightSingle();
         }
-
-        if (!Config.INSTANCE.skipBedHeightEpoch()) {
-            log.info("store bed height epoch.");
-            storeBedHeightEpoch();
-        }
     }
 
 
@@ -1472,25 +1434,6 @@
     }
 
 
-    private void storeBedHeightEpoch() {
-        River river = getPeer();
-
-        if (bedHeightEpochs != null) {
-            for (ImportBedHeight tmp: bedHeightEpochs) {
-                ImportBedHeightEpoch epoch = (ImportBedHeightEpoch) tmp;
-
-                String desc = epoch.getDescription();
-
-                log.debug("name: " + desc);
-
-                epoch.storeDependencies(river);
-            }
-        }
-        else {
-            log.info("No epoch bed heights to store.");
-        }
-    }
-
     public void storeSedimentDensity() {
         if (!Config.INSTANCE.skipSedimentDensity()) {
             log.info("store sediment density");
diff -r 9ec6def1a7dd -r 5813c206ff64 backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightEpochParser.java
--- a/backend/src/main/java/org/dive4elements/river/importer/parsers/BedHeightEpochParser.java	Thu Jun 05 15:32:52 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +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.importer.parsers;
-
-import java.math.BigDecimal;
-
-import java.text.ParseException;
-
-import org.apache.log4j.Logger;
-
-import org.dive4elements.river.importer.ImportBedHeight;
-import org.dive4elements.river.importer.ImportBedHeightEpoch;
-import org.dive4elements.river.importer.ImportBedHeightEpochValue;
-
-
-/** Parses BedHeightEpochs from csv file. */
-public class BedHeightEpochParser extends BedHeightParser {
-
-    /** Our own logger. */
-    private static final Logger log =
-        Logger.getLogger(BedHeightEpochParser.class);
-
-
-    @Override
-    protected ImportBedHeight newImportBedHeight(String description) {
-        return new ImportBedHeightEpoch(description);
-    }
-
-
-    /**
-     * Handle a non-comment, none-Metadata line of csv file, adding
-     * ImportBedHeightEpochValues to the given ImportBedHeight object.
-     */
-    @Override
-    protected void handleDataLine(ImportBedHeight obj, String line) {
-        String[] values = line.split(SEPERATOR_CHAR);
-
-        if (values == null || values.length == 0 || values[0].length() == 0) {
-            // There might be quite some ";" found.
-            //log.warn("Skip invalid data line: " + line);
-            return;
-        }
-
-        BigDecimal km;
-
-        try {
-            km = new BigDecimal(nf.parse(values[0]).doubleValue());
-        }
-        catch (ParseException e) {
-            log.warn("Unparseable number in data row: " + line);
-            return;
-        }
-
-
-        // Handle "gap" lines like '255,0;'
-        if (values.length < 2) {
-            ImportBedHeightEpochValue value = new ImportBedHeightEpochValue(
-                km,
-                null
-            );
-
-            obj.addValue(value);
-            return;
-        }
-
-        try {
-            ImportBedHeightEpochValue value = new ImportBedHeightEpochValue(
-                km,
-                new BigDecimal(nf.parse(values[1]).doubleValue())
-            );
-
-            obj.addValue(value);
-        }
-        catch (ParseException e) {
-            log.warn("Unparseable number in data row: " + line);
-        }
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 9ec6def1a7dd -r 5813c206ff64 backend/src/main/java/org/dive4elements/river/model/BedHeightEpoch.java
--- a/backend/src/main/java/org/dive4elements/river/model/BedHeightEpoch.java	Thu Jun 05 15:32:52 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,219 +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.model;
-
-import java.io.Serializable;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Column;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.GenerationType;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToOne;
-import javax.persistence.OneToMany;
-
-import org.hibernate.Session;
-import org.hibernate.Query;
-
-import org.dive4elements.river.backend.SessionHolder;
-
-
- at Entity
- at Table(name = "bed_height_epoch")
-public class BedHeightEpoch implements Serializable {
-
-    private Integer id;
-
-    private River river;
-
-    private TimeInterval timeInterval;
-
-    private ElevationModel curElevationModel;
-    private ElevationModel oldElevationModel;
-
-    private Range range;
-
-    private String evaluationBy;
-    private String description;
-
-    private List<BedHeightEpochValue> values;
-
-
-    public BedHeightEpoch() {
-    }
-
-
-    public BedHeightEpoch(
-        River          river,
-        TimeInterval   timeInterval,
-        Range          range,
-        ElevationModel curElevationModel,
-        ElevationModel oldElevationModel,
-        String         evaluationBy,
-        String         description
-    ) {
-        this.river             = river;
-        this.timeInterval      = timeInterval;
-        this.range             = range;
-        this.curElevationModel = curElevationModel;
-        this.oldElevationModel = oldElevationModel;
-        this.evaluationBy      = evaluationBy;
-        this.description       = description;
-        this.values            = new ArrayList<BedHeightEpochValue>();
-    }
-
-
-    @Id
-    @SequenceGenerator(
-        name           = "SEQUENCE_BED_HEIGHT_EPOCH_ID_SEQ",
-        sequenceName   = "BED_HEIGHT_EPOCH_ID_SEQ",
-        allocationSize = 1)
-    @GeneratedValue(
-        strategy  = GenerationType.SEQUENCE,
-        generator = "SEQUENCE_BED_HEIGHT_EPOCH_ID_SEQ")
-    @Column(name = "id")
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    @OneToOne
-    @JoinColumn(name = "river_id" )
-    public River getRiver() {
-        return river;
-    }
-
-    public void setRiver(River river) {
-        this.river = river;
-    }
-
-    @OneToOne
-    @JoinColumn(name = "time_interval_id")
-    public TimeInterval getTimeInterval() {
-        return timeInterval;
-    }
-
-    public void setTimeInterval(TimeInterval timeInterval) {
-        this.timeInterval = timeInterval;
-    }
-
-    @OneToOne
-    @JoinColumn(name = "cur_elevation_model_id")
-    public ElevationModel getCurElevationModel() {
-        return curElevationModel;
-    }
-
-    public void setCurElevationModel(ElevationModel curElevationModel) {
-        this.curElevationModel = curElevationModel;
-    }
-
-    @OneToOne
-    @JoinColumn(name = "old_elevation_model_id")
-    public ElevationModel getOldElevationModel() {
-        return oldElevationModel;
-    }
-
-    public void setOldElevationModel(ElevationModel oldElevationModel) {
-        this.oldElevationModel = oldElevationModel;
-    }
-
-    @OneToOne
-    @JoinColumn(name = "range_id")
-    public Range getRange() {
-        return range;
-    }
-
-    public void setRange(Range range) {
-        this.range = range;
-    }
-
-    @Column(name = "evaluation_by")
-    public String getEvaluationBy() {
-        return evaluationBy;
-    }
-
-    public void setEvaluationBy(String evaluationBy) {
-        this.evaluationBy = evaluationBy;
-    }
-
-    @Column(name = "description")
-    public String getDescription() {
-        return description;
-    }
-
-    public void setDescription(String description) {
-        this.description = description;
-    }
-
-    @OneToMany
-    @JoinColumn(name = "bed_height_epoch_id")
-    public List<BedHeightEpochValue> getValues() {
-        return values;
-    }
-
-    public void setValues(List<BedHeightEpochValue> values) {
-        this.values = values;
-    }
-
-
-    public static List<BedHeightEpoch> getBedHeightEpochs(
-        River  river,
-        double kmLo,
-        double kmHi
-    ) {
-        Session session = SessionHolder.HOLDER.get();
-
-        Query query = session.createQuery(
-            "from BedHeightEpoch where river=:river");
-
-        query.setParameter("river", river);
-
-        // TODO Do km range filtering in SQL statement
-
-        List<BedHeightEpoch> epochs = query.list();
-        List<BedHeightEpoch> good   = new ArrayList<BedHeightEpoch>();
-
-        OUTER: for (BedHeightEpoch e: epochs) {
-            for (BedHeightEpochValue value: e.getValues()) {
-                double station = value.getStation().doubleValue();
-
-                if (station >= kmLo && station <= kmHi) {
-                    good.add(e);
-                    continue OUTER;
-                }
-            }
-        }
-
-        return good;
-    }
-
-
-    public static BedHeightEpoch getBedHeightEpochById(int id) {
-        Session session = SessionHolder.HOLDER.get();
-
-        Query query = session.createQuery(
-            "from BedHeightEpoch where id=:id");
-
-        query.setParameter("id", id);
-
-        List<BedHeightEpoch> singles = query.list();
-
-        return singles != null ? singles.get(0) : null;
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 9ec6def1a7dd -r 5813c206ff64 backend/src/main/java/org/dive4elements/river/model/BedHeightEpochValue.java
--- a/backend/src/main/java/org/dive4elements/river/model/BedHeightEpochValue.java	Thu Jun 05 15:32:52 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +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.model;
-
-import java.util.List;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Column;
-import javax.persistence.SequenceGenerator;
-import javax.persistence.GenerationType;
-import javax.persistence.JoinColumn;
-import javax.persistence.OneToOne;
-
-import org.apache.log4j.Logger;
-
-import org.hibernate.Session;
-import org.hibernate.Query;
-
-import org.dive4elements.river.backend.SessionHolder;
-
-
- at Entity
- at Table(name = "bed_height_epoch_values")
-public class BedHeightEpochValue
-implements   Serializable
-{
-    private static Logger logger =
-        Logger.getLogger(BedHeightEpochValue.class);
-
-    private Integer id;
-
-    private BedHeightEpoch bedHeight;
-
-    private BigDecimal station;
-    private BigDecimal height;
-
-
-    public BedHeightEpochValue() {
-    }
-
-    public BedHeightEpochValue(
-        BedHeightEpoch bedHeight,
-        BigDecimal station,
-        BigDecimal height
-    ) {
-        this.bedHeight = bedHeight;
-        this.station   = station;
-        this.height    = height;
-    }
-
-    @Id
-    @SequenceGenerator(
-        name           = "SEQUENCE_BED_EPOCH_VALUE_ID_SEQ",
-        sequenceName   = "BED_EPOCH_VALUES_ID_SEQ",
-        allocationSize = 1)
-    @GeneratedValue(
-        strategy  = GenerationType.SEQUENCE,
-        generator = "SEQUENCE_BED_EPOCH_VALUE_ID_SEQ")
-    @Column(name = "id")
-    public Integer getId() {
-        return id;
-    }
-
-    public void setId(Integer id) {
-        this.id = id;
-    }
-
-    @OneToOne
-    @JoinColumn(name = "bed_height_epoch_id" )
-    public BedHeightEpoch getBedHeight() {
-        return bedHeight;
-    }
-
-    public void setBedHeight(BedHeightEpoch bedHeight) {
-        this.bedHeight = bedHeight;
-    }
-
-    @Column(name = "station")
-    public BigDecimal getStation() {
-        return station;
-    }
-
-    public void setStation(BigDecimal station) {
-        this.station = station;
-    }
-
-    @Column(name = "height")
-    public BigDecimal getHeight() {
-        return height;
-    }
-
-    public void setHeight(BigDecimal height) {
-        this.height = height;
-    }
-
-
-    public static List<BedHeightEpochValue> getBedHeightEpochValues(
-        BedHeightEpoch epoch,
-        double kmLo,
-        double kmHi
-    ) {
-        Session session = SessionHolder.HOLDER.get();
-
-        Query query = session.createQuery(
-            "from BedHeightEpochValue where bedHeight=:epoch " +
-            "   and station >= :kmLo and station <= :kmHi");
-
-        query.setParameter("epoch", epoch);
-        query.setParameter("kmLo", new BigDecimal(kmLo));
-        query.setParameter("kmHi", new BigDecimal(kmHi));
-
-        return query.list();
-    }
-}
-// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :


More information about the Dive4Elements-commits mailing list