Project

General

Profile

Revision cf6aefdd

IDcf6aefdd59a49f7aaf3274f3b3ef9c2b35367037
Parent b806219d
Child fdf36f4e

Added by Andreas Müller 2 months ago

ref #6581 ,ref #9004 fix preliminary SingleSourcedEntityBase class hierarchy

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IdentifiableSource.java
133 133

  
134 134

  
135 135
	@Override
136
	public Object clone() throws CloneNotSupportedException{
136
	public IdentifiableSource clone() throws CloneNotSupportedException{
137 137
		IdentifiableSource result = (IdentifiableSource)super.clone();
138 138

  
139 139
		//no changes
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/SingleSourcedEntityBase.java
21 21
import javax.xml.bind.annotation.XmlSchemaType;
22 22
import javax.xml.bind.annotation.XmlType;
23 23

  
24
import org.apache.commons.lang.StringUtils;
25 24
import org.apache.log4j.Logger;
26 25
import org.hibernate.annotations.Cascade;
27 26
import org.hibernate.annotations.CascadeType;
28 27
import org.hibernate.envers.Audited;
29 28

  
30
import eu.etaxonomy.cdm.model.reference.Reference;
31

  
32 29
/**
33 30
 * Abstract class for all objects that may have a reference
34 31
 * @author m.doering
......
36 33
 */
37 34
@XmlAccessorType(XmlAccessType.FIELD)
38 35
@XmlType(name = "SingleSourcedEntityBase", propOrder = {
39
    "source",
40
    "originalNameString",
41
    "citation",
42
    "citationMicroReference"
36
    "source"
43 37
})
44 38
@XmlRootElement(name = "SingleSourcedEntityBase")
45 39
@MappedSuperclass
46 40
@Audited
47 41
public abstract class SingleSourcedEntityBase
48
        extends AnnotatableEntity
49
        implements IReferencedEntity {
42
        //TODO move to AnnotatableEntity once als ReferencedEntityBase attributes are removed from subclasses
43
        extends ReferencedEntityBase {
50 44

  
51 45
    static final long serialVersionUID = 2035568689268762760L;
52 46
    @SuppressWarnings("unused")
53 47
	private static final Logger logger = Logger.getLogger(SingleSourcedEntityBase.class);
54 48

  
55
	@XmlElement(name = "Citation")
56
    @XmlIDREF
57
    @XmlSchemaType(name = "IDREF")
58
    @ManyToOne(fetch = FetchType.LAZY)
59
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
60
	@Deprecated
61
	private Reference citation;
62

  
63
	//Details of the reference. These are mostly (implicitly) pages but can also be tables or any other element of a
64
    //publication. {if the citationMicroReference exists then there must be also a reference}
65
    @XmlElement(name = "CitationMicroReference")
66
    @Deprecated
67
    private String citationMicroReference;
68

  
69
    @XmlElement(name = "OriginalNameString")
70
    @Deprecated
71
    private String originalNameString;
72

  
73 49
    //the source for this single sourced entity
74 50
    @XmlElement(name = "source")
75 51
    @XmlIDREF
......
85 61
		super();
86 62
	}
87 63

  
88
	public SingleSourcedEntityBase(Reference citation, String citationMicroReference,
89
			String originalNameString) {
90
		this.citationMicroReference = citationMicroReference;
91
		this.originalNameString = originalNameString;
92
		this.citation = citation;
64
	public SingleSourcedEntityBase(IdentifiableSource source) {
65
		this.source = source;
93 66
	}
94 67

  
95 68
//********************* GETTER / SETTER *******************************/
96 69

  
97
	public String getCitationMicroReference(){
98
		return this.citationMicroReference;
99
	}
100
	public void setCitationMicroReference(String citationMicroReference){
101
		this.citationMicroReference = citationMicroReference;
102
	}
103

  
104

  
105
	public String getOriginalNameString(){
106
		return this.originalNameString;
107
	}
108
	public void setOriginalNameString(String originalNameString){
109
		this.originalNameString = originalNameString;
110
	}
111

  
112
	@Override
113
    public Reference getCitation(){
114
		return this.citation;
115
	}
116
	public void setCitation(Reference citation) {
117
		this.citation = citation;
118
	}
70
	//TODO source
119 71

  
120 72
// **************** EMPTY ************************/
121 73

  
122 74
    @Override
123 75
    protected boolean isEmpty(){
124 76
       return super.isEmpty()
125
            && this.getCitation() == null
126
            && this.getCitationMicroReference() == null
127
            && isBlank(this.getOriginalNameString())
77
            && this.source == null
128 78
           ;
129 79
    }
130 80

  
......
134 84
	public Object clone() throws CloneNotSupportedException{
135 85
		SingleSourcedEntityBase result = (SingleSourcedEntityBase)super.clone();
136 86

  
137
		//no changes to: citation, citationMicroReference, originalNameString
87
		if (this.source != null){
88
		    result.source = source.clone();
89
		}
90

  
91
		//no changes to: --
138 92
		return result;
139 93
	}
140 94

  
141 95
//*********************************** EQUALS *********************************************************/
142 96

  
143
	/**
144
	 * Indicates whether some other object is "equal to" this one.
145
	 *
146
	 * Uses a content based compare strategy which avoids bean initialization. This is achieved by
147
	 * comparing the cdm entity ids.
148
	 */
149
	public boolean equalsByShallowCompare(SingleSourcedEntityBase other) {
150

  
151
	    int thisCitationId = -1;
152
	    int otherCitationId = -1;
153
	    if(this.getCitation() != null) {
154
	        thisCitationId = this.getCitation().getId();
155
	    }
156
	    if(other.getCitation() != null) {
157
	        otherCitationId = other.getCitation().getId();
158
        }
159

  
160
        if(thisCitationId != otherCitationId
161
                || !StringUtils.equals(this.getCitationMicroReference(), other.getCitationMicroReference())
162
                || !StringUtils.equals(this.getOriginalNameString(), other.getOriginalNameString())
163
                        ){
164
            return false;
165
        }
166

  
167
        return true;
168
    }
97

  
169 98

  
170 99

  
171 100
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)