1
|
package cz.zcu.kiv.backendapi.catalog;
|
2
|
|
3
|
import cz.zcu.kiv.backendapi.alternativename.CatalogItemName;
|
4
|
import cz.zcu.kiv.backendapi.bibliography.Bibliography;
|
5
|
import cz.zcu.kiv.backendapi.country.Country;
|
6
|
import cz.zcu.kiv.backendapi.type.Type;
|
7
|
import cz.zcu.kiv.backendapi.writtenform.WrittenForm;
|
8
|
import lombok.EqualsAndHashCode;
|
9
|
import lombok.Getter;
|
10
|
import lombok.NoArgsConstructor;
|
11
|
import lombok.Setter;
|
12
|
import org.hibernate.annotations.Fetch;
|
13
|
import org.hibernate.annotations.FetchMode;
|
14
|
import org.hibernate.annotations.LazyCollection;
|
15
|
import org.hibernate.annotations.LazyCollectionOption;
|
16
|
|
17
|
import javax.persistence.*;
|
18
|
import java.util.LinkedHashSet;
|
19
|
import java.util.Set;
|
20
|
import java.util.UUID;
|
21
|
|
22
|
/**
|
23
|
* Catalog item entity representing catalog item
|
24
|
*/
|
25
|
@Getter
|
26
|
@Setter
|
27
|
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
|
28
|
@NoArgsConstructor
|
29
|
@Entity
|
30
|
@Table(name = "catalog_items")
|
31
|
public class CatalogItem {
|
32
|
/**
|
33
|
* Catalog item id
|
34
|
*/
|
35
|
@Id
|
36
|
@EqualsAndHashCode.Include
|
37
|
private UUID id = UUID.randomUUID();
|
38
|
|
39
|
/**
|
40
|
* Name of geographic item
|
41
|
*/
|
42
|
private String name = "";
|
43
|
|
44
|
/**
|
45
|
* Certainty
|
46
|
*/
|
47
|
private Integer certainty;
|
48
|
|
49
|
/**
|
50
|
* Longitude
|
51
|
*/
|
52
|
private Double longitude;
|
53
|
|
54
|
/**
|
55
|
* Latitude
|
56
|
*/
|
57
|
private Double latitude;
|
58
|
|
59
|
/**
|
60
|
* Description
|
61
|
*/
|
62
|
@Column(length = 100000)
|
63
|
private String description = "";
|
64
|
|
65
|
/**
|
66
|
* Set of bibliography
|
67
|
*/
|
68
|
@OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
69
|
@LazyCollection(LazyCollectionOption.FALSE)
|
70
|
@Fetch(FetchMode.SUBSELECT)
|
71
|
@OrderBy("entryOrder")
|
72
|
private Set<Bibliography> bibliography = new LinkedHashSet<>(0);
|
73
|
|
74
|
/**
|
75
|
* Set of countries
|
76
|
*/
|
77
|
@OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
78
|
@LazyCollection(LazyCollectionOption.FALSE)
|
79
|
@Fetch(FetchMode.SUBSELECT)
|
80
|
@OrderBy("entryOrder")
|
81
|
private Set<Country> countries = new LinkedHashSet<>(0);
|
82
|
|
83
|
/**
|
84
|
* Set of written forms
|
85
|
*/
|
86
|
@OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
87
|
@LazyCollection(LazyCollectionOption.FALSE)
|
88
|
@Fetch(FetchMode.SUBSELECT)
|
89
|
@OrderBy("entryOrder")
|
90
|
private Set<WrittenForm> writtenForms = new LinkedHashSet<>(0);
|
91
|
|
92
|
/**
|
93
|
* Set of all names
|
94
|
*/
|
95
|
@OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
96
|
@LazyCollection(LazyCollectionOption.FALSE)
|
97
|
@Fetch(FetchMode.SUBSELECT)
|
98
|
@OrderBy("entryOrder")
|
99
|
private Set<CatalogItemName> allNames = new LinkedHashSet<>(0);
|
100
|
|
101
|
/**
|
102
|
* Set of types - many-to-many relationship
|
103
|
*/
|
104
|
@ManyToMany(fetch = FetchType.EAGER)
|
105
|
@Fetch(FetchMode.SUBSELECT)
|
106
|
@JoinTable(
|
107
|
name = "catalog_item_type",
|
108
|
joinColumns = {
|
109
|
@JoinColumn(name = "catalog_item_id", referencedColumnName = "id")
|
110
|
},
|
111
|
inverseJoinColumns = {
|
112
|
@JoinColumn(name = "type", referencedColumnName = "type")
|
113
|
}
|
114
|
)
|
115
|
private Set<Type> types = new LinkedHashSet<>(0);
|
116
|
}
|