1 package com.germinus.merlin.model;
2
3
4
5 import java.util.HashSet;
6 import java.util.Set;
7 import javax.persistence.CascadeType;
8 import javax.persistence.Column;
9 import javax.persistence.Entity;
10 import javax.persistence.FetchType;
11 import javax.persistence.GeneratedValue;
12 import javax.persistence.Id;
13 import javax.persistence.JoinColumn;
14 import javax.persistence.ManyToOne;
15 import javax.persistence.OneToMany;
16 import javax.persistence.Table;
17
18 import org.hibernate.annotations.GenericGenerator;
19
20 import com.germinus.merlin.model.assignment.Assignment;
21
22
23
24
25 @Entity
26 @Table(name = "ResourceContainers")
27 public class ResourceContainer implements java.io.Serializable, Comparable<Object> {
28
29
30
31
32
33 private static final long serialVersionUID = -7554091158557691971L;
34 private long idResourceContainer;
35 private Course course;
36 private String name;
37 private Integer position;
38 private Set<ForumTopic> forumTopic = new HashSet<ForumTopic>(0);
39 private Set<Label> labels = new HashSet<Label>(0);
40 private Set<Assignment> assignments = new HashSet<Assignment>(0);
41 private Set<Advise> advise = new HashSet<Advise>(0);
42
43 public ResourceContainer() {
44 }
45
46 public ResourceContainer(long idResourceContainer, Course course) {
47 this.idResourceContainer = idResourceContainer;
48 this.course = course;
49 }
50
51 public ResourceContainer(long idResourceContainer, Course course,
52 String name, Integer position,
53 Set<ForumTopic> forumTopic, Set<Label> labels,
54 Set<Assignment> assignments, Set<Advise> advise) {
55 this.idResourceContainer = idResourceContainer;
56 this.course = course;
57 this.name = name;
58 this.position = position;
59 this.forumTopic = forumTopic;
60 this.labels = labels;
61 this.assignments = assignments;
62 this.advise = advise;
63 }
64
65 @Id @GeneratedValue(generator="system-increment")
66 @GenericGenerator(name="system-increment", strategy = "increment")
67 @Column(name = "idResourceContainer", unique = true, nullable = false)
68 public long getIdResourceContainer() {
69 return this.idResourceContainer;
70 }
71
72 public void setIdResourceContainer(long idResourceContainer) {
73 this.idResourceContainer = idResourceContainer;
74 }
75
76 @ManyToOne(fetch = FetchType.LAZY)
77 @JoinColumn(name = "courseid", nullable = false)
78 public Course getCourse() {
79 return this.course;
80 }
81
82 public void setCourse(Course course) {
83 this.course = course;
84 }
85
86 @Column(name = "name", length = 75)
87 public String getName() {
88 return this.name;
89 }
90
91 public void setName(String name) {
92 this.name = name;
93 }
94
95 @Column(name = "resourceposition")
96 public Integer getPosition() {
97 return this.position;
98 }
99
100 public void setPosition(Integer position) {
101 this.position = position;
102 }
103
104 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "resourceContainer")
105 public Set<ForumTopic> getForumTopics() {
106 return this.forumTopic;
107 }
108
109 public void setForumTopics(Set<ForumTopic> forumTopic) {
110 this.forumTopic = forumTopic;
111 }
112
113 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "resourceContainer")
114 public Set<Label> getLabels() {
115 return this.labels;
116 }
117
118 public void setLabels(Set<Label> labels) {
119 this.labels = labels;
120 }
121
122 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "resourceContainer")
123 public Set<Assignment> getAssignments() {
124 return this.assignments;
125 }
126
127 public void setAssignments(Set<Assignment> assignments) {
128 this.assignments = assignments;
129 }
130
131 @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "resourceContainer")
132 public Set<Advise> getAdvises() {
133 return this.advise;
134 }
135
136 public void setAdvises(Set<Advise> advise) {
137 this.advise = advise;
138 }
139
140 public int compareTo(Object o) {
141
142 int rvi = ((ResourceContainer)o).position;
143
144 return (position < rvi ? -1 : (position == rvi ? 0 : 1));
145
146 }
147
148 }