Project

General

Profile

1
package eu.dnetlib.enabling.is.hib.objects;
2

    
3
import javax.persistence.Column;
4
import javax.persistence.Entity;
5
import javax.persistence.JoinColumn;
6
import javax.persistence.ManyToOne;
7
import javax.persistence.PrimaryKeyJoinColumn;
8
import javax.persistence.Table;
9
import javax.persistence.Transient;
10

    
11
import eu.dnetlib.rmi.objects.is.DnetDataStructure;
12

    
13
@Entity(name = "datastructures")
14
@Table(name = "datastructures")
15
@PrimaryKeyJoinColumn(name = "id")
16
public class HibDatastructure extends HibDnetResource {
17

    
18
	/**
19
	 * 
20
	 */
21
	@Transient
22
	private static final long serialVersionUID = -7449480123747087335L;
23

    
24
	@Column(name = "code")
25
	private String code;
26

    
27
	@Column(name = "name")
28
	private String name;
29

    
30
	@Column(name = "description", columnDefinition = "text")
31
	private String description;
32

    
33
	@ManyToOne
34
	@JoinColumn(name = "type", nullable = false)
35
	private HibResourceType type;
36

    
37
	@Column(name = "content", columnDefinition = "text")
38
	private String content;
39

    
40
	@ManyToOne
41
	@JoinColumn(name = "service", nullable = true)
42
	private HibService service;
43

    
44
	public HibDatastructure() {}
45

    
46
	public HibDatastructure(final String code, final String name, final String description, final HibResourceType type, final String content,
47
			final HibService service) {
48
		this.code = code;
49
		this.name = name;
50
		this.description = description;
51
		this.type = type;
52
		this.content = content;
53
		this.service = service;
54
	}
55

    
56
	public String getCode() {
57
		return code;
58
	}
59

    
60
	public void setCode(final String code) {
61
		this.code = code;
62
	}
63

    
64
	public String getName() {
65
		return name;
66
	}
67

    
68
	public void setName(final String name) {
69
		this.name = name;
70
	}
71

    
72
	public String getDescription() {
73
		return description;
74
	}
75

    
76
	public void setDescription(final String description) {
77
		this.description = description;
78
	}
79

    
80
	public HibResourceType getType() {
81
		return type;
82
	}
83

    
84
	public void setType(final HibResourceType type) {
85
		this.type = type;
86
	}
87

    
88
	public String getContent() {
89
		return content;
90
	}
91

    
92
	public void setContent(final String content) {
93
		this.content = content;
94
	}
95

    
96
	public HibService getService() {
97
		return service;
98
	}
99

    
100
	public void setService(final HibService service) {
101
		this.service = service;
102
	}
103

    
104
	public DnetDataStructure asDnetDataStructure() {
105
		final DnetDataStructure ds = new DnetDataStructure();
106
		ds.setId(getId());
107
		ds.setCode(getCode());
108
		ds.setName(getName());
109
		ds.setDescription(getDescription());
110
		ds.setType(getType() != null ? getType().getId() : null);
111
		ds.setDate(getDate());
112
		ds.setServiceId(getService() != null ? getService().getId() : null);
113
		ds.setContent(getContent());
114
		return ds;
115
	}
116

    
117
	@Override
118
	public int hashCode() {
119
		return super.hashCode();
120
	}
121
}
(2-2/12)