1 | package eu.clarin.cmdi.virtualcollectionregistry.model; |
---|
2 | |
---|
3 | import javax.persistence.Column; |
---|
4 | import javax.persistence.DiscriminatorValue; |
---|
5 | import javax.persistence.Embedded; |
---|
6 | import javax.persistence.Entity; |
---|
7 | import javax.xml.bind.annotation.XmlAccessType; |
---|
8 | import javax.xml.bind.annotation.XmlAccessorType; |
---|
9 | import javax.xml.bind.annotation.XmlElement; |
---|
10 | import javax.xml.bind.annotation.XmlRootElement; |
---|
11 | import javax.xml.bind.annotation.XmlSeeAlso; |
---|
12 | import javax.xml.bind.annotation.XmlType; |
---|
13 | |
---|
14 | import org.apache.commons.lang.builder.HashCodeBuilder; |
---|
15 | |
---|
16 | @Entity |
---|
17 | @DiscriminatorValue("M") |
---|
18 | @XmlRootElement(name = "ResourceMetadata") |
---|
19 | @XmlAccessorType(XmlAccessType.NONE) |
---|
20 | @XmlType(namespace = "urn:x-vcr:virtualcollection:resourcemetadata", |
---|
21 | propOrder = { "name", "description", "creator", "ref" }) |
---|
22 | @XmlSeeAlso({ Resource.class, Creator.class }) |
---|
23 | public class ResourceMetadata extends Resource { |
---|
24 | @Column(name = "name") |
---|
25 | private String name; |
---|
26 | @Column(name = "description") |
---|
27 | private String description; |
---|
28 | @Embedded |
---|
29 | private Creator creator; |
---|
30 | @Column(name = "ref", nullable = false) |
---|
31 | private String ref; |
---|
32 | @Column(name = "pid") |
---|
33 | private String pid; |
---|
34 | |
---|
35 | @SuppressWarnings("unused") |
---|
36 | private ResourceMetadata() { |
---|
37 | super(); |
---|
38 | } |
---|
39 | |
---|
40 | public ResourceMetadata(String title, String description, String ref) { |
---|
41 | super(); |
---|
42 | this.setName(title); |
---|
43 | this.setDescriptione(description); |
---|
44 | this.setRef(ref); |
---|
45 | } |
---|
46 | |
---|
47 | public ResourceType getType() { |
---|
48 | return ResourceType.METADATA; |
---|
49 | } |
---|
50 | |
---|
51 | public void setName(String name) { |
---|
52 | if (name == null) { |
---|
53 | throw new NullPointerException("name == null"); |
---|
54 | } |
---|
55 | this.name = name; |
---|
56 | } |
---|
57 | |
---|
58 | @XmlElement(name = "Name") |
---|
59 | public String getName() { |
---|
60 | return name; |
---|
61 | } |
---|
62 | |
---|
63 | public void setDescriptione(String description) { |
---|
64 | this.description = description; |
---|
65 | } |
---|
66 | |
---|
67 | @XmlElement(name = "Description") |
---|
68 | public String getDescription() { |
---|
69 | return description; |
---|
70 | } |
---|
71 | |
---|
72 | public void setCreator(Creator creator) { |
---|
73 | this.creator = creator; |
---|
74 | } |
---|
75 | |
---|
76 | @XmlElement(name = "Creator") |
---|
77 | public Creator getCreator() { |
---|
78 | return creator; |
---|
79 | } |
---|
80 | |
---|
81 | public void setRef(String ref) { |
---|
82 | if (ref == null) { |
---|
83 | throw new NullPointerException("ref == null"); |
---|
84 | } |
---|
85 | this.ref = ref; |
---|
86 | } |
---|
87 | |
---|
88 | @XmlElement(name = "ResourceRef") |
---|
89 | public String getRef() { |
---|
90 | return ref; |
---|
91 | } |
---|
92 | |
---|
93 | public void setPid(String pid) { |
---|
94 | if (pid == null) { |
---|
95 | throw new NullPointerException("pid == null"); |
---|
96 | } |
---|
97 | this.pid = pid.trim(); |
---|
98 | } |
---|
99 | |
---|
100 | public String getPid() { |
---|
101 | return pid; |
---|
102 | } |
---|
103 | |
---|
104 | int getSignature() { |
---|
105 | return new HashCodeBuilder(859, 83) |
---|
106 | .append(name) |
---|
107 | .append(description) |
---|
108 | .append((creator != null) ? creator.getSignature() : null) |
---|
109 | .append(ref) |
---|
110 | .toHashCode(); |
---|
111 | } |
---|
112 | |
---|
113 | } // class ResourceMetadata |
---|