comparison backend/src/main/java/org/dive4elements/river/model/AnnotationType.java @ 8974:a275ddf7a3a1

Added some trim and lowercase in the where clauses of the selects of existing recordsets; added AnnotationType select
author mschaefer
date Tue, 03 Apr 2018 10:37:30 +0200
parents 4c3ccf2b0304
children
comparison
equal deleted inserted replaced
8973:35afa0349782 8974:a275ddf7a3a1
7 */ 7 */
8 8
9 package org.dive4elements.river.model; 9 package org.dive4elements.river.model;
10 10
11 import java.io.Serializable; 11 import java.io.Serializable;
12 import java.util.ArrayList;
13 import java.util.List;
12 14
15 import javax.persistence.Column;
13 import javax.persistence.Entity; 16 import javax.persistence.Entity;
17 import javax.persistence.GeneratedValue;
18 import javax.persistence.GenerationType;
14 import javax.persistence.Id; 19 import javax.persistence.Id;
20 import javax.persistence.SequenceGenerator;
15 import javax.persistence.Table; 21 import javax.persistence.Table;
16 import javax.persistence.GeneratedValue; 22
17 import javax.persistence.Column; 23 import org.dive4elements.river.backend.SessionHolder;
18 import javax.persistence.SequenceGenerator; 24 import org.hibernate.Query;
19 import javax.persistence.GenerationType; 25 import org.hibernate.Session;
20 26
21 @Entity 27 @Entity
22 @Table(name = "annotation_types") 28 @Table(name = "annotation_types")
23 public class AnnotationType 29 public class AnnotationType
24 implements Serializable 30 implements Serializable
27 private String name; 33 private String name;
28 34
29 public AnnotationType() { 35 public AnnotationType() {
30 } 36 }
31 37
32 public AnnotationType(String name) { 38 public AnnotationType(final String name) {
33 this.name = name; 39 this.name = name;
34 } 40 }
35 41
36 @Id 42 @Id
37 @SequenceGenerator( 43 @SequenceGenerator(
38 name = "SEQUENCE_ANNOTATION_TYPES_ID_SEQ", 44 name = "SEQUENCE_ANNOTATION_TYPES_ID_SEQ",
39 sequenceName = "ANNOTATION_TYPES_ID_SEQ", 45 sequenceName = "ANNOTATION_TYPES_ID_SEQ",
40 allocationSize = 1) 46 allocationSize = 1)
41 @GeneratedValue( 47 @GeneratedValue(
42 strategy = GenerationType.SEQUENCE, 48 strategy = GenerationType.SEQUENCE,
43 generator = "SEQUENCE_ANNOTATION_TYPES_ID_SEQ") 49 generator = "SEQUENCE_ANNOTATION_TYPES_ID_SEQ")
44 @Column(name = "id") 50 @Column(name = "id")
45 public Integer getId() { 51 public Integer getId() {
46 return id; 52 return this.id;
47 } 53 }
48 54
49 public void setId(Integer id) { 55 public void setId(final Integer id) {
50 this.id = id; 56 this.id = id;
51 } 57 }
52 58
53 @Column(name = "name") 59 @Column(name = "name")
54 public String getName() { 60 public String getName() {
55 return name; 61 return this.name;
56 } 62 }
57 63
58 public void setName(String name) { 64 public void setName(final String name) {
59 this.name = name; 65 this.name = name;
66 }
67
68 /**
69 * Queries all annotation types from the database, orders by name
70 */
71 public static List<AnnotationType> getTypes() {
72 final Session session = SessionHolder.HOLDER.get();
73 final Query query = session.createQuery("FROM AnnotationType ORDER BY name");
74 return new ArrayList<>(query.list());
60 } 75 }
61 } 76 }
62 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 77 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org