annotate src/main/java/de/intevation/lada/model/stammdaten/Query.java @ 1255:c0db68c9a87d

enable new-line in sql text of queries
author Michael Stanko <mstanko@bfs.de>
date Wed, 04 Jan 2017 15:36:47 +0100
parents 186d602e031a
children
rev   line source
1097
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
1 package de.intevation.lada.model.stammdaten;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
2
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
3 import java.io.Serializable;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
4 import java.util.List;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
5
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
6 import javax.persistence.Column;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
7 import javax.persistence.Entity;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
8 import javax.persistence.FetchType;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
9 import javax.persistence.Id;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
10 import javax.persistence.JoinColumn;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
11 import javax.persistence.ManyToOne;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
12 import javax.persistence.OneToMany;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
13 import javax.persistence.OrderBy;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
14 import javax.persistence.Transient;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
15
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
16 import com.fasterxml.jackson.annotation.JsonIgnore;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
17
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
18
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
19 /**
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
20 * The persistent class for the query database table.
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
21 *
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
22 */
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
23 @Entity
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
24 public class Query implements Serializable {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
25 private static final long serialVersionUID = 1L;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
26
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
27 @Id
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
28 private Integer id;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
29
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
30 private String description;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
31
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
32 private String name;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
33
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
34 private String sql;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
35
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
36 @ManyToOne
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
37 @JoinColumn(name="type", insertable=false, updatable=false)
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
38 private QueryType type;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
39
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
40 @Column(name="type")
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
41 private Integer typeId;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
42
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
43 @Transient
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
44 private Boolean favorite;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
45
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
46 //bi-directional many-to-one association to Filter
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
47 @OneToMany(fetch=FetchType.EAGER, mappedBy="query")
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
48 private List<Filter> filters;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
49
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
50 //bi-directional many-to-one association to Result
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
51 @OneToMany(fetch=FetchType.EAGER, mappedBy="query")
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
52 @OrderBy("index")
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
53 private List<Result> results;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
54
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
55 public Query() {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
56 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
57
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
58 public Integer getId() {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
59 return this.id;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
60 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
61
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
62 public void setId(Integer id) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
63 this.id = id;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
64 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
65
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
66 public String getDescription() {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
67 return this.description;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
68 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
69
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
70 public void setDescription(String description) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
71 this.description = description;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
72 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
73
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
74 public String getName() {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
75 return this.name;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
76 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
77
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
78 public void setName(String name) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
79 this.name = name;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
80 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
81
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
82 public String getSql() {
1255
c0db68c9a87d enable new-line in sql text of queries
Michael Stanko <mstanko@bfs.de>
parents: 1097
diff changeset
83 // remove \r and \n from sql text
c0db68c9a87d enable new-line in sql text of queries
Michael Stanko <mstanko@bfs.de>
parents: 1097
diff changeset
84 return this.sql.replaceAll("(\r\n|\n)", " ");
1097
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
85 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
86
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
87 public void setSql(String sql) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
88 this.sql = sql;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
89 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
90
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
91 public String getType() {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
92 return this.type.getType();
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
93 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
94
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
95 /**
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
96 * @return the typeId
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
97 */
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
98 @JsonIgnore
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
99 public Integer getTypeId() {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
100 return typeId;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
101 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
102
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
103 /**
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
104 * @param typeId the typeId to set
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
105 */
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
106 @JsonIgnore
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
107 public void setTypeId(Integer typeId) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
108 this.typeId = typeId;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
109 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
110
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
111 /**
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
112 * @return the favorite
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
113 */
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
114 public Boolean getFavorite() {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
115 return favorite;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
116 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
117
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
118 /**
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
119 * @param favorite the favorite to set
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
120 */
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
121 public void setFavorite(Boolean favorite) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
122 this.favorite = favorite;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
123 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
124
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
125 public List<Filter> getFilters() {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
126 return this.filters;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
127 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
128
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
129 public void setFilters(List<Filter> filters) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
130 this.filters = filters;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
131 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
132
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
133 public Filter addFilter(Filter filter) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
134 getFilters().add(filter);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
135 filter.setQuery(this);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
136
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
137 return filter;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
138 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
139
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
140 public Filter removeFilter(Filter filter) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
141 getFilters().remove(filter);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
142 filter.setQuery(null);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
143
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
144 return filter;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
145 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
146
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
147 public List<Result> getResults() {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
148 return this.results;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
149 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
150
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
151 public void setResults(List<Result> results) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
152 this.results = results;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
153 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
154
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
155 public Result addResult(Result result) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
156 getResults().add(result);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
157 result.setQuery(this);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
158
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
159 return result;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
160 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
161
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
162 public Result removeResult(Result result) {
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
163 getResults().remove(result);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
164 result.setQuery(null);
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
165
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
166 return result;
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
167 }
186d602e031a Merged branch schema-update into default.
Tom Gottfried <tom@intevation.de>
parents:
diff changeset
168 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)