From 45029ab3bc4f6c293f3a59af233f015b71cc0c09 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Tue, 21 Mar 2017 09:30:03 +0000
Subject: [PATCH] #3527 fix - Ignoring unknown properties for unmarshall
---
securis/src/main/java/net/curisit/securis/db/Organization.java | 250 ++++++++++++++++++++++++-------------------------
1 files changed, 123 insertions(+), 127 deletions(-)
diff --git a/securis/src/main/java/net/curisit/securis/db/Organization.java b/securis/src/main/java/net/curisit/securis/db/Organization.java
index 78c8ced..4084245 100644
--- a/securis/src/main/java/net/curisit/securis/db/Organization.java
+++ b/securis/src/main/java/net/curisit/securis/db/Organization.java
@@ -26,6 +26,7 @@
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -36,164 +37,159 @@
*/
@JsonAutoDetect
@JsonInclude(Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
@Entity
@Table(name = "organization")
-@NamedQueries({
- @NamedQuery(name = "list-organizations", query = "SELECT o FROM Organization o"),
- @NamedQuery(name = "list-organizations-by-ids", query = "SELECT o FROM Organization o where id in :list_ids"),
- @NamedQuery(name = "find-children-org", query = "SELECT o FROM Organization o where o.parentOrganization = :parentOrganization")
-})
+@NamedQueries({ @NamedQuery(name = "list-organizations", query = "SELECT o FROM Organization o"),
+ @NamedQuery(name = "list-organizations-by-ids", query = "SELECT o FROM Organization o where id in :list_ids"),
+ @NamedQuery(name = "find-children-org", query = "SELECT o FROM Organization o where o.parentOrganization = :parentOrganization") })
public class Organization implements Serializable {
- @SuppressWarnings("unused")
- private static final Logger LOG = LogManager.getLogger(Organization.class);
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LogManager.getLogger(Organization.class);
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue
- private Integer id;
+ @Id
+ @GeneratedValue
+ private Integer id;
- private String code;
- private String name;
- private String description;
+ private String code;
+ private String name;
+ private String description;
- @Column(name = "creation_timestamp")
- @JsonProperty("creation_timestamp")
- private Date creationTimestamp;
+ @Column(name = "creation_timestamp")
+ @JsonProperty("creation_timestamp")
+ private Date creationTimestamp;
- @JsonIgnore
- // We don't include the users to limit the size of each row a the listing
- @ManyToMany(cascade = CascadeType.REMOVE)
- @JoinTable(name = "user_organization", //
- joinColumns = {
- @JoinColumn(name = "organization_id", referencedColumnName = "id")
- }, //
- inverseJoinColumns = {
- @JoinColumn(name = "username", referencedColumnName = "username")
- })
- private Set<User> users;
+ @JsonIgnore
+ // We don't include the users to limit the size of each row a the listing
+ @ManyToMany(cascade = CascadeType.REMOVE)
+ @JoinTable(name = "user_organization", //
+ joinColumns = { @JoinColumn(name = "organization_id", referencedColumnName = "id") }, //
+ inverseJoinColumns = { @JoinColumn(name = "username", referencedColumnName = "username") })
+ private Set<User> users;
- @JsonIgnore
- // We don't include the users to limit the size of each row a the listing
- @ManyToOne
- @JoinColumn(name = "org_parent_id")
- private Organization parentOrganization;
+ @JsonIgnore
+ // We don't include the users to limit the size of each row a the listing
+ @ManyToOne
+ @JoinColumn(name = "org_parent_id")
+ private Organization parentOrganization;
- @JsonIgnore
- // We don't include the users to limit the size of each row a the listing
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "parentOrganization")
- private Set<Organization> childOrganizations;
+ @JsonIgnore
+ // We don't include the users to limit the size of each row a the listing
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "parentOrganization")
+ private Set<Organization> childOrganizations;
- public Integer getId() {
- return id;
- }
+ public Integer getId() {
+ return id;
+ }
- public void setId(Integer id) {
- this.id = id;
- }
+ public void setId(Integer id) {
+ this.id = id;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
- public String getDescription() {
- return description;
- }
+ public String getDescription() {
+ return description;
+ }
- public void setDescription(String description) {
- this.description = description;
- }
+ public void setDescription(String description) {
+ this.description = description;
+ }
- public String getCode() {
- return code;
- }
+ public String getCode() {
+ return code;
+ }
- public void setCode(String code) {
- this.code = code;
- }
+ public void setCode(String code) {
+ this.code = code;
+ }
- public Date getCreationTimestamp() {
- return creationTimestamp;
- }
+ public Date getCreationTimestamp() {
+ return creationTimestamp;
+ }
- public void setCreationTimestamp(Date creationTimestamp) {
- this.creationTimestamp = creationTimestamp;
- }
+ public void setCreationTimestamp(Date creationTimestamp) {
+ this.creationTimestamp = creationTimestamp;
+ }
- public Set<User> getUsers() {
- return users;
- }
+ public Set<User> getUsers() {
+ return users;
+ }
- public void setUsers(Set<User> users) {
- this.users = users;
- }
+ public void setUsers(Set<User> users) {
+ this.users = users;
+ }
- public Organization getParentOrganization() {
- return parentOrganization;
- }
+ public Organization getParentOrganization() {
+ return parentOrganization;
+ }
- public void setParentOrganization(Organization parentOrganization) {
- this.parentOrganization = parentOrganization;
- }
+ public void setParentOrganization(Organization parentOrganization) {
+ this.parentOrganization = parentOrganization;
+ }
- // Roberto: Following methods are necessary to include in the REST list
- // response
- // information about the referenced entities.
- @JsonProperty("org_parent_id")
- public void setParentOrgId(Integer orgId) {
- if (orgId != null) {
- parentOrganization = new Organization();
- parentOrganization.setId(orgId);
- } else {
- parentOrganization = null;
- }
- }
+ // Roberto: Following methods are necessary to include in the REST list
+ // response
+ // information about the referenced entities.
+ @JsonProperty("org_parent_id")
+ public void setParentOrgId(Integer orgId) {
+ if (orgId != null) {
+ parentOrganization = new Organization();
+ parentOrganization.setId(orgId);
+ } else {
+ parentOrganization = null;
+ }
+ }
- @JsonProperty("org_parent_id")
- public Integer getParentOrgId() {
- return parentOrganization == null ? null : parentOrganization.getId();
- }
+ @JsonProperty("org_parent_id")
+ public Integer getParentOrgId() {
+ return parentOrganization == null ? null : parentOrganization.getId();
+ }
- @JsonProperty("org_parent_name")
- public String getParentOrgName() {
- return parentOrganization == null ? null : parentOrganization.getName();
- }
+ @JsonProperty("org_parent_name")
+ public String getParentOrgName() {
+ return parentOrganization == null ? null : parentOrganization.getName();
+ }
- @JsonProperty("users_ids")
- public void setUsersIds(List<String> usersIds) {
- users = new HashSet<>();
- if (usersIds != null) {
- for (String userid : usersIds) {
- User u = new User();
- u.setUsername(userid);
- users.add(u);
- }
- }
- }
+ @JsonProperty("users_ids")
+ public void setUsersIds(List<String> usersIds) {
+ users = new HashSet<>();
+ if (usersIds != null) {
+ for (String userid : usersIds) {
+ User u = new User();
+ u.setUsername(userid);
+ users.add(u);
+ }
+ }
+ }
- @JsonProperty("users_ids")
- public Set<String> getUsersIds() {
- if (users == null) {
- return null;
- }
- Set<String> ids = new HashSet<>();
- for (User user : users) {
- ids.add(user.getUsername());
- }
- return ids;
- }
+ @JsonProperty("users_ids")
+ public Set<String> getUsersIds() {
+ if (users == null) {
+ return null;
+ }
+ Set<String> ids = new HashSet<>();
+ for (User user : users) {
+ ids.add(user.getUsername());
+ }
+ return ids;
+ }
- public Set<Organization> getChildOrganizations() {
- return childOrganizations;
- }
+ public Set<Organization> getChildOrganizations() {
+ return childOrganizations;
+ }
- public void setChildOrganizations(Set<Organization> childOrganizations) {
- this.childOrganizations = childOrganizations;
- }
+ public void setChildOrganizations(Set<Organization> childOrganizations) {
+ this.childOrganizations = childOrganizations;
+ }
}
--
Gitblit v1.3.2