Mercurial > dive4elements > river
view flys-backend/src/main/java/de/intevation/flys/model/River.java @ 466:8bd50b41dea6
Moved the SessionHolder from flys-artifacts to flys-backend.
flys-backend/trunk@1700 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 15 Apr 2011 09:49:21 +0000 |
parents | c2c3ad4fda58 |
children | 1e196c75563b |
line wrap: on
line source
package de.intevation.flys.model; 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.OneToMany; import javax.persistence.JoinColumn; import javax.persistence.GenerationType; import java.util.List; @Entity @Table(name = "rivers") public class River implements Serializable { private Integer id; private String name; private List<Gauge> gauges; @Id @SequenceGenerator( name = "SEQUENCE_RIVERS_ID_SEQ", sequenceName = "RIVERS_ID_SEQ", allocationSize = 1) @GeneratedValue( strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_RIVERS_ID_SEQ") @Column(name = "id") public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @Column(name = "name") public String getName() { return name; } public void setName(String name) { this.name = name; } public River() { } public River(String name) { this.name = name; } @OneToMany @JoinColumn(name="river_id") public List<Gauge> getGauges() { return gauges; } public void setGauges(List<Gauge> gauges) { this.gauges = gauges; } public String toString() { return name != null ? name : ""; } /** * Returns the min and max distance of this river. The first position in the * resulting array contains the min distance, the second position the max * distance. * * @return the min and max distance of this river. */ public double[] determineMinMaxDistance() { if (gauges == null) { return null; } double minmax[] = new double[] { Double.MAX_VALUE, Double.MIN_VALUE }; for (Gauge g: gauges) { Range r = g.getRange(); double a = r.getA().doubleValue(); minmax[0] = minmax[0] < a ? minmax[0] : a; BigDecimal bigB = r.getB(); if (bigB != null) { double b = bigB.doubleValue(); minmax[1] = minmax[1] > b ? minmax[1] : b; } } return minmax; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :