rsanchez
2017-03-21 45029ab3bc4f6c293f3a59af233f015b71cc0c09
securis/src/main/java/net/curisit/securis/db/Organization.java
....@@ -26,6 +26,7 @@
2626
2727 import com.fasterxml.jackson.annotation.JsonAutoDetect;
2828 import com.fasterxml.jackson.annotation.JsonIgnore;
29
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
2930 import com.fasterxml.jackson.annotation.JsonInclude;
3031 import com.fasterxml.jackson.annotation.JsonInclude.Include;
3132 import com.fasterxml.jackson.annotation.JsonProperty;
....@@ -36,164 +37,159 @@
3637 */
3738 @JsonAutoDetect
3839 @JsonInclude(Include.NON_NULL)
40
+@JsonIgnoreProperties(ignoreUnknown = true)
3941 @Entity
4042 @Table(name = "organization")
41
-@NamedQueries({
42
- @NamedQuery(name = "list-organizations", query = "SELECT o FROM Organization o"),
43
- @NamedQuery(name = "list-organizations-by-ids", query = "SELECT o FROM Organization o where id in :list_ids"),
44
- @NamedQuery(name = "find-children-org", query = "SELECT o FROM Organization o where o.parentOrganization = :parentOrganization")
45
-})
43
+@NamedQueries({ @NamedQuery(name = "list-organizations", query = "SELECT o FROM Organization o"),
44
+ @NamedQuery(name = "list-organizations-by-ids", query = "SELECT o FROM Organization o where id in :list_ids"),
45
+ @NamedQuery(name = "find-children-org", query = "SELECT o FROM Organization o where o.parentOrganization = :parentOrganization") })
4646 public class Organization implements Serializable {
4747
48
- @SuppressWarnings("unused")
49
- private static final Logger LOG = LogManager.getLogger(Organization.class);
48
+ @SuppressWarnings("unused")
49
+ private static final Logger LOG = LogManager.getLogger(Organization.class);
5050
51
- private static final long serialVersionUID = 1L;
51
+ private static final long serialVersionUID = 1L;
5252
53
- @Id
54
- @GeneratedValue
55
- private Integer id;
53
+ @Id
54
+ @GeneratedValue
55
+ private Integer id;
5656
57
- private String code;
58
- private String name;
59
- private String description;
57
+ private String code;
58
+ private String name;
59
+ private String description;
6060
61
- @Column(name = "creation_timestamp")
62
- @JsonProperty("creation_timestamp")
63
- private Date creationTimestamp;
61
+ @Column(name = "creation_timestamp")
62
+ @JsonProperty("creation_timestamp")
63
+ private Date creationTimestamp;
6464
65
- @JsonIgnore
66
- // We don't include the users to limit the size of each row a the listing
67
- @ManyToMany(cascade = CascadeType.REMOVE)
68
- @JoinTable(name = "user_organization", //
69
- joinColumns = {
70
- @JoinColumn(name = "organization_id", referencedColumnName = "id")
71
- }, //
72
- inverseJoinColumns = {
73
- @JoinColumn(name = "username", referencedColumnName = "username")
74
- })
75
- private Set<User> users;
65
+ @JsonIgnore
66
+ // We don't include the users to limit the size of each row a the listing
67
+ @ManyToMany(cascade = CascadeType.REMOVE)
68
+ @JoinTable(name = "user_organization", //
69
+ joinColumns = { @JoinColumn(name = "organization_id", referencedColumnName = "id") }, //
70
+ inverseJoinColumns = { @JoinColumn(name = "username", referencedColumnName = "username") })
71
+ private Set<User> users;
7672
77
- @JsonIgnore
78
- // We don't include the users to limit the size of each row a the listing
79
- @ManyToOne
80
- @JoinColumn(name = "org_parent_id")
81
- private Organization parentOrganization;
73
+ @JsonIgnore
74
+ // We don't include the users to limit the size of each row a the listing
75
+ @ManyToOne
76
+ @JoinColumn(name = "org_parent_id")
77
+ private Organization parentOrganization;
8278
83
- @JsonIgnore
84
- // We don't include the users to limit the size of each row a the listing
85
- @OneToMany(fetch = FetchType.LAZY, mappedBy = "parentOrganization")
86
- private Set<Organization> childOrganizations;
79
+ @JsonIgnore
80
+ // We don't include the users to limit the size of each row a the listing
81
+ @OneToMany(fetch = FetchType.LAZY, mappedBy = "parentOrganization")
82
+ private Set<Organization> childOrganizations;
8783
88
- public Integer getId() {
89
- return id;
90
- }
84
+ public Integer getId() {
85
+ return id;
86
+ }
9187
92
- public void setId(Integer id) {
93
- this.id = id;
94
- }
88
+ public void setId(Integer id) {
89
+ this.id = id;
90
+ }
9591
96
- public String getName() {
97
- return name;
98
- }
92
+ public String getName() {
93
+ return name;
94
+ }
9995
100
- public void setName(String name) {
101
- this.name = name;
102
- }
96
+ public void setName(String name) {
97
+ this.name = name;
98
+ }
10399
104
- public String getDescription() {
105
- return description;
106
- }
100
+ public String getDescription() {
101
+ return description;
102
+ }
107103
108
- public void setDescription(String description) {
109
- this.description = description;
110
- }
104
+ public void setDescription(String description) {
105
+ this.description = description;
106
+ }
111107
112
- public String getCode() {
113
- return code;
114
- }
108
+ public String getCode() {
109
+ return code;
110
+ }
115111
116
- public void setCode(String code) {
117
- this.code = code;
118
- }
112
+ public void setCode(String code) {
113
+ this.code = code;
114
+ }
119115
120
- public Date getCreationTimestamp() {
121
- return creationTimestamp;
122
- }
116
+ public Date getCreationTimestamp() {
117
+ return creationTimestamp;
118
+ }
123119
124
- public void setCreationTimestamp(Date creationTimestamp) {
125
- this.creationTimestamp = creationTimestamp;
126
- }
120
+ public void setCreationTimestamp(Date creationTimestamp) {
121
+ this.creationTimestamp = creationTimestamp;
122
+ }
127123
128
- public Set<User> getUsers() {
129
- return users;
130
- }
124
+ public Set<User> getUsers() {
125
+ return users;
126
+ }
131127
132
- public void setUsers(Set<User> users) {
133
- this.users = users;
134
- }
128
+ public void setUsers(Set<User> users) {
129
+ this.users = users;
130
+ }
135131
136
- public Organization getParentOrganization() {
137
- return parentOrganization;
138
- }
132
+ public Organization getParentOrganization() {
133
+ return parentOrganization;
134
+ }
139135
140
- public void setParentOrganization(Organization parentOrganization) {
141
- this.parentOrganization = parentOrganization;
142
- }
136
+ public void setParentOrganization(Organization parentOrganization) {
137
+ this.parentOrganization = parentOrganization;
138
+ }
143139
144
- // Roberto: Following methods are necessary to include in the REST list
145
- // response
146
- // information about the referenced entities.
147
- @JsonProperty("org_parent_id")
148
- public void setParentOrgId(Integer orgId) {
149
- if (orgId != null) {
150
- parentOrganization = new Organization();
151
- parentOrganization.setId(orgId);
152
- } else {
153
- parentOrganization = null;
154
- }
155
- }
140
+ // Roberto: Following methods are necessary to include in the REST list
141
+ // response
142
+ // information about the referenced entities.
143
+ @JsonProperty("org_parent_id")
144
+ public void setParentOrgId(Integer orgId) {
145
+ if (orgId != null) {
146
+ parentOrganization = new Organization();
147
+ parentOrganization.setId(orgId);
148
+ } else {
149
+ parentOrganization = null;
150
+ }
151
+ }
156152
157
- @JsonProperty("org_parent_id")
158
- public Integer getParentOrgId() {
159
- return parentOrganization == null ? null : parentOrganization.getId();
160
- }
153
+ @JsonProperty("org_parent_id")
154
+ public Integer getParentOrgId() {
155
+ return parentOrganization == null ? null : parentOrganization.getId();
156
+ }
161157
162
- @JsonProperty("org_parent_name")
163
- public String getParentOrgName() {
164
- return parentOrganization == null ? null : parentOrganization.getName();
165
- }
158
+ @JsonProperty("org_parent_name")
159
+ public String getParentOrgName() {
160
+ return parentOrganization == null ? null : parentOrganization.getName();
161
+ }
166162
167
- @JsonProperty("users_ids")
168
- public void setUsersIds(List<String> usersIds) {
169
- users = new HashSet<>();
170
- if (usersIds != null) {
171
- for (String userid : usersIds) {
172
- User u = new User();
173
- u.setUsername(userid);
174
- users.add(u);
175
- }
176
- }
177
- }
163
+ @JsonProperty("users_ids")
164
+ public void setUsersIds(List<String> usersIds) {
165
+ users = new HashSet<>();
166
+ if (usersIds != null) {
167
+ for (String userid : usersIds) {
168
+ User u = new User();
169
+ u.setUsername(userid);
170
+ users.add(u);
171
+ }
172
+ }
173
+ }
178174
179
- @JsonProperty("users_ids")
180
- public Set<String> getUsersIds() {
181
- if (users == null) {
182
- return null;
183
- }
184
- Set<String> ids = new HashSet<>();
185
- for (User user : users) {
186
- ids.add(user.getUsername());
187
- }
188
- return ids;
189
- }
175
+ @JsonProperty("users_ids")
176
+ public Set<String> getUsersIds() {
177
+ if (users == null) {
178
+ return null;
179
+ }
180
+ Set<String> ids = new HashSet<>();
181
+ for (User user : users) {
182
+ ids.add(user.getUsername());
183
+ }
184
+ return ids;
185
+ }
190186
191
- public Set<Organization> getChildOrganizations() {
192
- return childOrganizations;
193
- }
187
+ public Set<Organization> getChildOrganizations() {
188
+ return childOrganizations;
189
+ }
194190
195
- public void setChildOrganizations(Set<Organization> childOrganizations) {
196
- this.childOrganizations = childOrganizations;
197
- }
191
+ public void setChildOrganizations(Set<Organization> childOrganizations) {
192
+ this.childOrganizations = childOrganizations;
193
+ }
198194
199195 }