1
|
package eu.dnetlib.enabling.is.hib.objects;
|
2
|
|
3
|
import java.io.Serializable;
|
4
|
import java.util.Date;
|
5
|
import java.util.Set;
|
6
|
|
7
|
import javax.persistence.CascadeType;
|
8
|
import javax.persistence.Column;
|
9
|
import javax.persistence.Entity;
|
10
|
import javax.persistence.FetchType;
|
11
|
import javax.persistence.Id;
|
12
|
import javax.persistence.Inheritance;
|
13
|
import javax.persistence.InheritanceType;
|
14
|
import javax.persistence.OneToMany;
|
15
|
import javax.persistence.Table;
|
16
|
import javax.persistence.Transient;
|
17
|
|
18
|
import org.apache.commons.lang.builder.EqualsBuilder;
|
19
|
|
20
|
import com.google.common.collect.Sets;
|
21
|
|
22
|
@Entity(name = "resources")
|
23
|
@Table(name = "resources")
|
24
|
@Inheritance(strategy = InheritanceType.JOINED)
|
25
|
public class HibDnetResource extends HibDnetObject implements Serializable {
|
26
|
|
27
|
@Transient
|
28
|
private static final long serialVersionUID = 8408338809280479191L;
|
29
|
|
30
|
@Id
|
31
|
@Column(name = "id")
|
32
|
private String id;
|
33
|
|
34
|
@Column(name = "valid", nullable = false)
|
35
|
private boolean valid = true;
|
36
|
|
37
|
@Column(name = "date", nullable = false, insertable = false, updatable = false)
|
38
|
private Date date;
|
39
|
|
40
|
@OneToMany(mappedBy = "id.service", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
41
|
private Set<HibDnetResourceProperty> properties = Sets.newLinkedHashSet();
|
42
|
|
43
|
public HibDnetResource() {}
|
44
|
|
45
|
public HibDnetResource(final String id, final boolean valid) {
|
46
|
this(id, valid, new Date());
|
47
|
}
|
48
|
|
49
|
public HibDnetResource(final String id, final boolean valid, final Date date) {
|
50
|
this.id = id;
|
51
|
this.valid = valid;
|
52
|
this.date = date;
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
public String toString() {
|
57
|
return "[ id = " + id + ", class = " + getClass().getName() + " ]";
|
58
|
}
|
59
|
|
60
|
public String getId() {
|
61
|
return id;
|
62
|
}
|
63
|
|
64
|
public void setId(final String id) {
|
65
|
this.id = id;
|
66
|
}
|
67
|
|
68
|
public boolean isValid() {
|
69
|
return valid;
|
70
|
}
|
71
|
|
72
|
public void setValid(final boolean valid) {
|
73
|
this.valid = valid;
|
74
|
}
|
75
|
|
76
|
public Date getDate() {
|
77
|
return date;
|
78
|
}
|
79
|
|
80
|
public void setDate(final Date date) {
|
81
|
this.date = date;
|
82
|
}
|
83
|
|
84
|
public Set<HibDnetResourceProperty> getProperties() {
|
85
|
return properties;
|
86
|
}
|
87
|
|
88
|
public void setProperties(final Set<HibDnetResourceProperty> properties) {
|
89
|
this.properties = properties;
|
90
|
}
|
91
|
|
92
|
@Override
|
93
|
public boolean equals(final Object obj) {
|
94
|
if (obj == this) {
|
95
|
return true;
|
96
|
} else if (obj instanceof HibDnetResource) {
|
97
|
return new EqualsBuilder().append(id, ((HibDnetResource) obj).id).isEquals();
|
98
|
} else {
|
99
|
return false;
|
100
|
}
|
101
|
}
|
102
|
|
103
|
@Override
|
104
|
public int hashCode() {
|
105
|
return id.hashCode();
|
106
|
}
|
107
|
}
|