2022-03-17 18:47:34 -03:00
|
|
|
/*
|
|
|
|
* Copyright [2022] [wisemapping]
|
|
|
|
*
|
|
|
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
|
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
|
|
* "powered by wisemapping" text requirement on every single page;
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the license at
|
|
|
|
*
|
|
|
|
* http://www.wisemapping.org/license
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2014-01-25 23:21:17 -03:00
|
|
|
package com.wisemapping.model;
|
|
|
|
|
|
|
|
|
2022-01-18 13:16:39 -08:00
|
|
|
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
2014-01-25 23:21:17 -03:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
2023-07-28 22:46:38 -07:00
|
|
|
import jakarta.persistence.*;
|
2022-01-16 20:01:56 -08:00
|
|
|
import java.io.Serializable;
|
2022-10-21 23:06:04 -07:00
|
|
|
import java.util.Objects;
|
2022-01-16 20:01:56 -08:00
|
|
|
|
|
|
|
@Entity
|
|
|
|
@Table(name = "LABEL")
|
2022-01-18 13:16:39 -08:00
|
|
|
@Cacheable
|
|
|
|
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
|
2022-01-16 20:01:56 -08:00
|
|
|
public class Label implements Serializable {
|
|
|
|
@Id
|
|
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
2014-01-25 23:21:17 -03:00
|
|
|
private int id;
|
2022-01-16 20:01:56 -08:00
|
|
|
|
2022-10-21 23:06:04 -07:00
|
|
|
@NotNull
|
|
|
|
private String title;
|
|
|
|
@NotNull
|
|
|
|
private String color;
|
|
|
|
@Nullable
|
|
|
|
private String iconName;
|
2014-01-25 23:21:17 -03:00
|
|
|
|
2022-01-16 20:01:56 -08:00
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
2022-10-21 23:06:04 -07:00
|
|
|
@JoinColumn(name = "creator_id", nullable = true, unique = true)
|
|
|
|
@NotNull
|
|
|
|
private User creator;
|
2022-01-16 20:01:56 -08:00
|
|
|
|
|
|
|
@ManyToOne(fetch = FetchType.LAZY)
|
2022-10-21 23:06:04 -07:00
|
|
|
@JoinColumn(name = "parent_label_id", nullable = true)
|
|
|
|
@Nullable
|
|
|
|
private Label parent;
|
2022-01-16 20:01:56 -08:00
|
|
|
|
2014-01-25 23:21:17 -03:00
|
|
|
public void setParent(@Nullable Label parent) {
|
|
|
|
this.parent = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
public Label getParent() {
|
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCreator(@NotNull User creator) {
|
|
|
|
this.creator = creator;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
public User getCreator() {
|
|
|
|
return creator;
|
|
|
|
}
|
|
|
|
|
2014-02-10 00:58:19 -03:00
|
|
|
@Nullable
|
2014-01-25 23:21:17 -03:00
|
|
|
public String getTitle() {
|
|
|
|
return title;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTitle(@NotNull String title) {
|
|
|
|
this.title = title;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setId(int id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
2014-01-28 00:13:29 -03:00
|
|
|
|
|
|
|
@NotNull
|
|
|
|
public String getColor() {
|
|
|
|
return color;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setColor(@NotNull String color) {
|
|
|
|
this.color = color;
|
|
|
|
}
|
2014-02-05 02:11:23 -03:00
|
|
|
|
2022-01-18 13:16:39 -08:00
|
|
|
@Nullable
|
2014-04-16 02:38:33 -03:00
|
|
|
public String getIconName() {
|
|
|
|
return iconName;
|
2014-04-14 18:09:34 -03:00
|
|
|
}
|
|
|
|
|
2014-04-16 02:38:33 -03:00
|
|
|
public void setIconName(@NotNull String iconName) {
|
|
|
|
this.iconName = iconName;
|
2014-04-14 18:09:34 -03:00
|
|
|
}
|
|
|
|
|
2014-02-05 02:11:23 -03:00
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (!(o instanceof Label)) return false;
|
|
|
|
|
2022-10-21 23:06:04 -07:00
|
|
|
final Label label = (Label) o;
|
2014-02-05 02:11:23 -03:00
|
|
|
return id == label.id && creator.getId() == label.creator.getId()
|
2022-10-21 23:06:04 -07:00
|
|
|
&& Objects.equals(parent, label.parent);
|
2014-02-05 02:11:23 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
2022-10-21 23:06:04 -07:00
|
|
|
long result = title.hashCode();
|
|
|
|
result = 31 * result + (creator != null ? creator.hashCode() : 0);
|
2014-02-05 02:11:23 -03:00
|
|
|
result = 31 * result + (parent != null ? parent.hashCode() : 0);
|
2022-01-16 20:01:56 -08:00
|
|
|
return (int) result;
|
2014-02-05 02:11:23 -03:00
|
|
|
}
|
2014-04-14 18:09:34 -03:00
|
|
|
|
2014-01-25 23:21:17 -03:00
|
|
|
}
|