[Lada-commits] [PATCH 1 of 5] Updated model for query, filter, result, etc
Wald Commits
scm-commit at wald.intevation.org
Tue Feb 2 15:33:14 CET 2016
# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1454423349 -3600
# Node ID 36b1104c3c22a57c7da399db69545fc19e2ae9b0
# Parent 2ce24e2baf204dfb9170bc68ce9b03edf9c05b1a
Updated model for query, filter, result, etc.
diff -r 2ce24e2baf20 -r 36b1104c3c22 src/main/java/de/intevation/lada/model/stamm/Favorite.java
--- a/src/main/java/de/intevation/lada/model/stamm/Favorite.java Thu Jan 28 12:16:23 2016 +0100
+++ b/src/main/java/de/intevation/lada/model/stamm/Favorite.java Tue Feb 02 15:29:09 2016 +0100
@@ -9,7 +9,10 @@
import java.io.Serializable;
+import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@@ -26,16 +29,16 @@
private static final long serialVersionUID = 1L;
@Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id", unique=true, nullable=false)
private Integer id;
//bi-directional many-to-one association to LadaUser
- @ManyToOne
- @JoinColumn(name="user_id")
- private LadaUser ladaUser;
+ @Column(name="user_id")
+ private Integer userId;
- //bi-directional many-to-one association to Query
- @ManyToOne
- private Query query;
+ @Column(name="query_id")
+ private Integer queryId;
public Favorite() {
}
@@ -48,20 +51,20 @@
this.id = id;
}
- public LadaUser getLadaUser() {
- return this.ladaUser;
+ public Integer getUserId() {
+ return this.userId;
}
- public void setLadaUser(LadaUser ladaUser) {
- this.ladaUser = ladaUser;
+ public void setUserId(Integer userId) {
+ this.userId = userId;
}
- public Query getQuery() {
- return this.query;
+ public Integer getQueryId() {
+ return this.queryId;
}
- public void setQuery(Query query) {
- this.query = query;
+ public void setQueryId(Integer queryId) {
+ this.queryId = queryId;
}
}
diff -r 2ce24e2baf20 -r 36b1104c3c22 src/main/java/de/intevation/lada/model/stamm/Filter.java
--- a/src/main/java/de/intevation/lada/model/stamm/Filter.java Thu Jan 28 12:16:23 2016 +0100
+++ b/src/main/java/de/intevation/lada/model/stamm/Filter.java Tue Feb 02 15:29:09 2016 +0100
@@ -11,8 +11,11 @@
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
+import javax.persistence.Transient;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -26,6 +29,8 @@
private static final long serialVersionUID = 1L;
@Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id", unique=true, nullable=false)
private Integer id;
@Column(name="data_index")
@@ -41,6 +46,9 @@
@ManyToOne
private Query query;
+ @Transient
+ private String value;
+
public Filter() {
}
@@ -93,4 +101,18 @@
public void setQuery(Query query) {
this.query = query;
}
+
+ /**
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
}
diff -r 2ce24e2baf20 -r 36b1104c3c22 src/main/java/de/intevation/lada/model/stamm/FilterValue.java
--- a/src/main/java/de/intevation/lada/model/stamm/FilterValue.java Thu Jan 28 12:16:23 2016 +0100
+++ b/src/main/java/de/intevation/lada/model/stamm/FilterValue.java Tue Feb 02 15:29:09 2016 +0100
@@ -11,6 +11,8 @@
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@@ -27,21 +29,22 @@
private static final long serialVersionUID = 1L;
@Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id", unique=true, nullable=false)
private Integer id;
private String value;
//bi-directional many-to-one association to Filter
- @ManyToOne
- private Filter filter;
+ @Column(name="filter_id")
+ private Integer filterId;
//bi-directional many-to-one association to LadaUser
- @ManyToOne
- @JoinColumn(name="user_id")
- private LadaUser ladaUser;
+ @Column(name="user_id")
+ private Integer userId;
@Column(name="query_id")
- private Integer query;
+ private Integer queryId;
public FilterValue() {
}
@@ -62,28 +65,27 @@
this.value = value;
}
- public Filter getFilter() {
- return this.filter;
+ public Integer getFilterId() {
+ return this.filterId;
}
- public void setFilter(Filter filter) {
- this.filter = filter;
+ public void setFilterId(Integer filterId) {
+ this.filterId = filterId;
}
- public LadaUser getLadaUser() {
- return this.ladaUser;
+ public Integer getUserId() {
+ return this.userId;
}
- public void setLadaUser(LadaUser ladaUser) {
- this.ladaUser = ladaUser;
+ public void setUserId(Integer userId) {
+ this.userId = userId;
}
- public Integer getQuery() {
- return this.query;
+ public Integer getQueryId() {
+ return this.queryId;
}
- public void setQuery(Integer query) {
- this.query = query;
+ public void setQueryId(Integer queryId) {
+ this.queryId = queryId;
}
-
}
diff -r 2ce24e2baf20 -r 36b1104c3c22 src/main/java/de/intevation/lada/model/stamm/LadaUser.java
--- a/src/main/java/de/intevation/lada/model/stamm/LadaUser.java Thu Jan 28 12:16:23 2016 +0100
+++ b/src/main/java/de/intevation/lada/model/stamm/LadaUser.java Tue Feb 02 15:29:09 2016 +0100
@@ -10,7 +10,11 @@
import java.io.Serializable;
import java.util.List;
+import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@@ -26,18 +30,12 @@
private static final long serialVersionUID = 1L;
@Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id", unique=true, nullable=false)
private Integer id;
private String name;
- //bi-directional many-to-one association to Favorite
- @OneToMany(mappedBy="ladaUser")
- private List<Favorite> favorites;
-
- //bi-directional many-to-one association to FilterValue
- @OneToMany(mappedBy="ladaUser")
- private List<FilterValue> filterValues;
-
public LadaUser() {
}
@@ -56,49 +54,4 @@
public void setName(String name) {
this.name = name;
}
-
- public List<Favorite> getFavorites() {
- return this.favorites;
- }
-
- public void setFavorites(List<Favorite> favorites) {
- this.favorites = favorites;
- }
-
- public Favorite addFavorite(Favorite favorite) {
- getFavorites().add(favorite);
- favorite.setLadaUser(this);
-
- return favorite;
- }
-
- public Favorite removeFavorite(Favorite favorite) {
- getFavorites().remove(favorite);
- favorite.setLadaUser(null);
-
- return favorite;
- }
-
- public List<FilterValue> getFilterValues() {
- return this.filterValues;
- }
-
- public void setFilterValues(List<FilterValue> filterValues) {
- this.filterValues = filterValues;
- }
-
- public FilterValue addFilterValue(FilterValue filterValue) {
- getFilterValues().add(filterValue);
- filterValue.setLadaUser(this);
-
- return filterValue;
- }
-
- public FilterValue removeFilterValue(FilterValue filterValue) {
- getFilterValues().remove(filterValue);
- filterValue.setLadaUser(null);
-
- return filterValue;
- }
-
}
diff -r 2ce24e2baf20 -r 36b1104c3c22 src/main/java/de/intevation/lada/model/stamm/Query.java
--- a/src/main/java/de/intevation/lada/model/stamm/Query.java Thu Jan 28 12:16:23 2016 +0100
+++ b/src/main/java/de/intevation/lada/model/stamm/Query.java Tue Feb 02 15:29:09 2016 +0100
@@ -10,10 +10,14 @@
import java.io.Serializable;
import java.util.List;
+import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
+import javax.persistence.Transient;
import com.fasterxml.jackson.annotation.JsonIgnore;
@@ -27,6 +31,8 @@
private static final long serialVersionUID = 1L;
@Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id", unique=true, nullable=false)
private Integer id;
private String description;
@@ -37,9 +43,8 @@
private String type;
- //bi-directional many-to-one association to Favorite
- @OneToMany(fetch=FetchType.EAGER, mappedBy="query")
- private List<Favorite> favorites;
+ @Transient
+ private Boolean favorite;
//bi-directional many-to-one association to Filter
@OneToMany(fetch=FetchType.EAGER, mappedBy="query")
@@ -92,28 +97,15 @@
this.type = type;
}
- @JsonIgnore
- public List<Favorite> getFavorites() {
- return this.favorites;
- }
-
- @JsonIgnore
- public void setFavorites(List<Favorite> favorites) {
- this.favorites = favorites;
- }
-
- public Favorite addFavorite(Favorite favorite) {
- getFavorites().add(favorite);
- favorite.setQuery(this);
-
+ public Boolean isFavorite() {
+ if (favorite == null) {
+ return false;
+ }
return favorite;
}
- public Favorite removeFavorite(Favorite favorite) {
- getFavorites().remove(favorite);
- favorite.setQuery(null);
-
- return favorite;
+ public void setFavorite(Boolean favorite) {
+ this.favorite = favorite;
}
public List<Filter> getFilters() {
diff -r 2ce24e2baf20 -r 36b1104c3c22 src/main/java/de/intevation/lada/model/stamm/Result.java
--- a/src/main/java/de/intevation/lada/model/stamm/Result.java Thu Jan 28 12:16:23 2016 +0100
+++ b/src/main/java/de/intevation/lada/model/stamm/Result.java Tue Feb 02 15:29:09 2016 +0100
@@ -11,6 +11,8 @@
import javax.persistence.Column;
import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
@@ -28,6 +30,8 @@
private static final long serialVersionUID = 1L;
@Id
+ @GeneratedValue(strategy=GenerationType.IDENTITY)
+ @Column(name="id", unique=true, nullable=false)
private Integer id;
@Column(name="data_index")
More information about the Lada-commits
mailing list