Mercurial > dive4elements > river
comparison backend/src/main/java/org/dive4elements/river/model/sinfo/CollisionType.java @ 8971:50416a0df385
Importer for the Schifffahrt (S-INFO) and Oekologie (U-INFO) files
author | mschaefer |
---|---|
date | Tue, 03 Apr 2018 10:18:30 +0200 |
parents | |
children | 3dfcb6e1c4d6 |
comparison
equal
deleted
inserted
replaced
8970:da5dc7446652 | 8971:50416a0df385 |
---|---|
1 /* Copyright (C) 2017 by Bundesanstalt für Gewässerkunde | |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 | |
11 package org.dive4elements.river.model.sinfo; | |
12 | |
13 import java.io.Serializable; | |
14 import java.util.ArrayList; | |
15 import java.util.List; | |
16 | |
17 import javax.persistence.Column; | |
18 import javax.persistence.Entity; | |
19 import javax.persistence.GeneratedValue; | |
20 import javax.persistence.GenerationType; | |
21 import javax.persistence.Id; | |
22 import javax.persistence.SequenceGenerator; | |
23 import javax.persistence.Table; | |
24 | |
25 import org.dive4elements.river.backend.SessionHolder; | |
26 import org.hibernate.Query; | |
27 import org.hibernate.Session; | |
28 | |
29 @Entity | |
30 @Table(name = "collision_type") | |
31 public class CollisionType implements Serializable { | |
32 | |
33 /***** FIELDS *****/ | |
34 | |
35 private static final long serialVersionUID = -865783384903507910L; | |
36 | |
37 private Integer id; | |
38 | |
39 private String name; | |
40 | |
41 | |
42 /***** CONSTRUCTORS *****/ | |
43 | |
44 public CollisionType() { | |
45 } | |
46 | |
47 public CollisionType(final String name) { | |
48 this.name = name; | |
49 } | |
50 | |
51 /***** METHODS *****/ | |
52 | |
53 @Id | |
54 @SequenceGenerator(name = "SEQUENCE_COLLISION_TYPE_ID_SEQ", sequenceName = "COLLISION_TYPE_ID_SEQ", allocationSize = 1) | |
55 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQUENCE_COLLISION_TYPE_ID_SEQ") | |
56 @Column(name = "id") | |
57 public Integer getId() { | |
58 return this.id; | |
59 } | |
60 | |
61 public void setId(final Integer id) { | |
62 this.id = id; | |
63 } | |
64 | |
65 @Column(name = "name") | |
66 public String getName() { | |
67 return this.name; | |
68 } | |
69 | |
70 public void setName(final String name) { | |
71 this.name = name; | |
72 } | |
73 | |
74 /** | |
75 * Queries all collision types from the database, orders by name | |
76 */ | |
77 public static List<CollisionType> getTypes() { | |
78 final Session session = SessionHolder.HOLDER.get(); | |
79 final Query query = session.createQuery("FROM CollisionType ORDER BY name"); | |
80 return new ArrayList<>(query.list()); | |
81 } | |
82 } |