1
|
/**
|
2
|
* Copyright (C) 2019 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.model.common;
|
10
|
|
11
|
import java.io.Serializable;
|
12
|
import java.net.URI;
|
13
|
|
14
|
import javax.persistence.Basic;
|
15
|
import javax.persistence.Column;
|
16
|
import javax.persistence.Embeddable;
|
17
|
import javax.persistence.FetchType;
|
18
|
import javax.validation.constraints.NotNull;
|
19
|
import javax.xml.bind.annotation.XmlAccessType;
|
20
|
import javax.xml.bind.annotation.XmlAccessorType;
|
21
|
import javax.xml.bind.annotation.XmlAttribute;
|
22
|
import javax.xml.bind.annotation.XmlElement;
|
23
|
import javax.xml.bind.annotation.XmlRootElement;
|
24
|
import javax.xml.bind.annotation.XmlType;
|
25
|
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
26
|
|
27
|
import org.hibernate.annotations.Type;
|
28
|
import org.hibernate.search.annotations.Analyze;
|
29
|
import org.hibernate.search.annotations.Field;
|
30
|
import org.joda.time.DateTime;
|
31
|
|
32
|
import eu.etaxonomy.cdm.jaxb.DateTimeAdapter;
|
33
|
import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty;
|
34
|
|
35
|
/**
|
36
|
* Embedabble class to embed attributes to use externally managed data
|
37
|
* @author a.mueller
|
38
|
* @since 12.08.2019
|
39
|
*/
|
40
|
@XmlAccessorType(XmlAccessType.FIELD)
|
41
|
@XmlType(name = "ExternallyManaged", propOrder = {
|
42
|
"lastRetrieved",
|
43
|
"externalId",
|
44
|
"externalLink",
|
45
|
"authorityType",
|
46
|
"importMethod"
|
47
|
})
|
48
|
@XmlRootElement(name = "ExternallyManaged")
|
49
|
@Embeddable
|
50
|
public class ExternallyManaged implements Cloneable, Serializable{
|
51
|
|
52
|
private static final long serialVersionUID = -2254347420863435872L;
|
53
|
|
54
|
|
55
|
//attributes for externally managed
|
56
|
|
57
|
// @XmlElement (name = "LastRetrieved", type= String.class)
|
58
|
@XmlJavaTypeAdapter(DateTimeAdapter.class)
|
59
|
@Type(type="dateTimeUserType")
|
60
|
//TODO needed??
|
61
|
@Basic(fetch = FetchType.LAZY)
|
62
|
@Column(name="lastRetrieved")
|
63
|
private DateTime lastRetrieved;
|
64
|
|
65
|
@XmlElement(name ="ExternalId" )
|
66
|
// @Field
|
67
|
// @Match(MatchMode.EQUAL) //TODO check if this is correct
|
68
|
@NullOrNotEmpty
|
69
|
@Column(name="externalId", length=255)
|
70
|
private String externalId;
|
71
|
|
72
|
//Actionable link on e.g. on a webservice
|
73
|
@XmlElement(name = "ExternalLink")
|
74
|
@Field(analyze = Analyze.NO)
|
75
|
@Type(type="uriUserType")
|
76
|
@Column(name="externalLink")
|
77
|
private URI externalLink;
|
78
|
|
79
|
@XmlAttribute(name ="authority")
|
80
|
@Column(name="authorityType", length=10)
|
81
|
@Type(type = "eu.etaxonomy.cdm.hibernate.EnumUserType",
|
82
|
parameters = {@org.hibernate.annotations.Parameter(name = "enumClass", value = "eu.etaxonomy.cdm.model.common.AuthorityType")}
|
83
|
)
|
84
|
@NotNull
|
85
|
private AuthorityType authorityType;
|
86
|
|
87
|
@XmlAttribute(name ="importMethod")
|
88
|
@Column(name="importMethod", length=30)
|
89
|
@Type(type = "eu.etaxonomy.cdm.hibernate.EnumUserType",
|
90
|
parameters = {@org.hibernate.annotations.Parameter(name = "enumClass", value = "eu.etaxonomy.cdm.model.common.ExternallyManagedImport")}
|
91
|
)
|
92
|
@NotNull
|
93
|
private ExternallyManagedImport importMethod;
|
94
|
|
95
|
// ************************ CLONE ***********************/
|
96
|
|
97
|
@Override
|
98
|
protected Object clone() throws CloneNotSupportedException {
|
99
|
ExternallyManaged result = (ExternallyManaged)super.clone();
|
100
|
|
101
|
return result;
|
102
|
}
|
103
|
}
|