1
2
3
4
5 package org.directdemocracyportal.democracy.model.world;
6
7 import java.util.HashSet;
8 import java.util.Set;
9
10 import javax.persistence.CascadeType;
11 import javax.persistence.Entity;
12 import javax.persistence.FetchType;
13 import javax.persistence.JoinColumn;
14 import javax.persistence.ManyToOne;
15 import javax.persistence.OneToMany;
16
17 import org.directdemocracyportal.democracy.model.core.Environment;
18 import org.hibernate.annotations.Cache;
19 import org.hibernate.annotations.CacheConcurrencyStrategy;
20
21 /***
22 * The Class Region.
23 */
24 @Entity
25 @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
26 public class Region extends Environment
27 {
28
29 /*** The Constant serialVersionUID. */
30 private static final long serialVersionUID = 614889376820015758L;
31
32 /*** The parent. */
33 private Region parent;
34
35 /*** The region type. */
36 private RegionType regionType;
37
38 /*** The parts. */
39 private Set<Region> parts = new HashSet<Region>();
40
41 /***
42 * Instantiates a new region.
43 */
44 public Region() {
45 }
46
47 /***
48 * Gets the parent.
49 *
50 * @return the parent
51 */
52 @ManyToOne
53 @JoinColumn
54 public Region getParent() {
55 return parent;
56 }
57
58 /***
59 * Sets the parent.
60 *
61 * @param parent the new parent
62 */
63 public void setParent(Region parent) {
64 this.parent = parent;
65 }
66
67 /***
68 * Gets the parts.
69 *
70 * @return the parts
71 */
72 @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
73 public Set<Region> getParts() {
74 return parts;
75 }
76
77 /***
78 * Sets the parts.
79 *
80 * @param parts the new parts
81 */
82 public void setParts(Set<Region> parts) {
83 this.parts = parts;
84 }
85
86 /***
87 * Gets the region type.
88 *
89 * @return the region type
90 */
91 public RegionType getRegionType() {
92 return regionType;
93 }
94
95 /***
96 * Sets the region type.
97 *
98 * @param regionType the new region type
99 */
100 public void setRegionType(RegionType regionType) {
101 this.regionType = regionType;
102 }
103 }