1
|
package cz.zcu.kiv.backendapi.catalog;
|
2
|
|
3
|
import cz.zcu.kiv.backendapi.alternativename.AlternativeName;
|
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.Getter;
|
9
|
import lombok.NoArgsConstructor;
|
10
|
import lombok.Setter;
|
11
|
import org.hibernate.annotations.Fetch;
|
12
|
import org.hibernate.annotations.FetchMode;
|
13
|
import org.hibernate.annotations.LazyCollection;
|
14
|
import org.hibernate.annotations.LazyCollectionOption;
|
15
|
|
16
|
import javax.persistence.*;
|
17
|
import java.util.HashSet;
|
18
|
import java.util.Set;
|
19
|
import java.util.UUID;
|
20
|
|
21
|
/**
|
22
|
* Catalog entity representing catalog item
|
23
|
*/
|
24
|
@Getter
|
25
|
@Setter
|
26
|
@NoArgsConstructor
|
27
|
@Entity
|
28
|
@Table(name = "catalog_items")
|
29
|
public class CatalogItem {
|
30
|
/**
|
31
|
* Catalog item id
|
32
|
*/
|
33
|
@Id
|
34
|
@GeneratedValue
|
35
|
private UUID id;
|
36
|
|
37
|
/**
|
38
|
* Name of geographic item
|
39
|
*/
|
40
|
private String name;
|
41
|
|
42
|
/**
|
43
|
* Certainty
|
44
|
*/
|
45
|
private int certainty;
|
46
|
|
47
|
/**
|
48
|
* Longitude
|
49
|
*/
|
50
|
private double longitude;
|
51
|
|
52
|
/**
|
53
|
* Latitude
|
54
|
*/
|
55
|
private double latitude;
|
56
|
|
57
|
/**
|
58
|
* Bibliography
|
59
|
*/
|
60
|
@OneToMany(mappedBy = "catalogItem", orphanRemoval = true, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
61
|
@LazyCollection(LazyCollectionOption.FALSE)
|
62
|
@Fetch(FetchMode.SUBSELECT)
|
63
|
private Set<Bibliography> bibliography = new HashSet<>();
|
64
|
|
65
|
/**
|
66
|
* Countries
|
67
|
*/
|
68
|
@OneToMany(mappedBy = "catalogItem", orphanRemoval = true, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
69
|
@LazyCollection(LazyCollectionOption.FALSE)
|
70
|
@Fetch(FetchMode.SUBSELECT)
|
71
|
private Set<Country> countries = new HashSet<>();
|
72
|
|
73
|
/**
|
74
|
* Written forms
|
75
|
*/
|
76
|
@OneToMany(mappedBy = "catalogItem", orphanRemoval = true, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
77
|
@LazyCollection(LazyCollectionOption.FALSE)
|
78
|
@Fetch(FetchMode.SUBSELECT)
|
79
|
private Set<WrittenForm> writtenForms = new HashSet<>();
|
80
|
|
81
|
/**
|
82
|
* Alternative names
|
83
|
*/
|
84
|
@OneToMany(mappedBy = "catalogItem", orphanRemoval = true, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
85
|
@LazyCollection(LazyCollectionOption.FALSE)
|
86
|
@Fetch(FetchMode.SUBSELECT)
|
87
|
private Set<AlternativeName> alternativeNames = new HashSet<>();
|
88
|
/**
|
89
|
* Set of user roles - many-to-many relationship
|
90
|
*/
|
91
|
@ManyToMany(fetch = FetchType.EAGER)
|
92
|
@Fetch(FetchMode.SUBSELECT)
|
93
|
@JoinTable(
|
94
|
name = "catalog_item_type",
|
95
|
joinColumns = {
|
96
|
@JoinColumn(name = "catalog_item_id", referencedColumnName = "id")
|
97
|
},
|
98
|
inverseJoinColumns = {
|
99
|
@JoinColumn(name = "type", referencedColumnName = "type")
|
100
|
}
|
101
|
)
|
102
|
private Set<Type> types = new HashSet<>();
|
103
|
}
|