Project

General

Profile

« Previous | Next » 

Revision b5c5e6fc

Added by Andreas Müller about 5 years ago

ref #8017 add sources to TypeDesignationBase

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TypeDesignationBase.java
33 33
import org.hibernate.envers.Audited;
34 34
import org.hibernate.search.annotations.IndexedEmbedded;
35 35

  
36
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
36
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
37
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
38
import eu.etaxonomy.cdm.model.common.SourcedEntityBase;
37 39
import eu.etaxonomy.cdm.model.reference.Reference;
38 40
import eu.etaxonomy.cdm.validation.Level2;
39 41
import eu.etaxonomy.cdm.validation.annotation.ValidTypeDesignation;
......
60 62
})
61 63
@XmlSeeAlso({
62 64
    NameTypeDesignation.class,
63
    SpecimenTypeDesignation.class
65
    SpecimenTypeDesignation.class,
66
    TextTypeDesignation.class
64 67
})
65 68
@Entity
66 69
@Audited
67 70
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
68 71
@ValidTypeDesignation(groups=Level2.class)
69 72
public abstract class TypeDesignationBase<T extends TypeDesignationStatusBase<T>>
70
        extends ReferencedEntityBase
73
        extends SourcedEntityBase<IdentifiableSource>
71 74
        implements ITypeDesignation {
72 75

  
73
    private static final long serialVersionUID = 8622351017235131355L;
76
    private static final long serialVersionUID = 4838214337140859787L;
74 77

  
75 78
    @SuppressWarnings("unused")
76 79
    private static final Logger logger = Logger.getLogger(TypeDesignationBase.class);
......
78 81
    @XmlElement(name = "IsNotDesignated")
79 82
    private boolean notDesignated;
80 83

  
84
    @XmlElement(name = "TypeStatus")
85
    @XmlIDREF
86
    @XmlSchemaType(name = "IDREF")
87
    @ManyToOne(fetch = FetchType.LAZY, targetEntity = TypeDesignationStatusBase.class)
88
    private T typeStatus;
89

  
90
    //the lectotype (or similar) reference
91
    @XmlElement(name = "Citation")
92
    @XmlIDREF
93
    @XmlSchemaType(name = "IDREF")
94
    @ManyToOne(fetch = FetchType.LAZY)
95
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
96
    private Reference citation;
97

  
98
    //Details of the lectotype reference.
99
    @XmlElement(name = "CitationMicroReference")
100
    private String citationMicroReference;
101

  
81 102
    @XmlElementWrapper(name = "TypifiedNames")
82 103
    @XmlElement(name = "TypifiedName")
83 104
    @XmlIDREF
......
86 107
    @Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
87 108
    private Set<TaxonName> typifiedNames = new HashSet<>();
88 109

  
89
    @XmlElement(name = "TypeStatus")
90
    @XmlIDREF
91
    @XmlSchemaType(name = "IDREF")
92
    @ManyToOne(fetch = FetchType.LAZY, targetEntity = TypeDesignationStatusBase.class)
93
    private T typeStatus;
94

  
95 110
    //******* REGISTRATION *****************/
96 111

  
97 112
    @XmlElementWrapper(name = "Registrations")
......
107 122

  
108 123
// **************** CONSTRUCTOR *************************************/
109 124

  
110
    /**
111
     * Class constructor: creates a new empty type designation.
112
     *
113
     * @see	#TypeDesignationBase(Reference, String, String, Boolean)
114
     */
115 125
    protected TypeDesignationBase(){
116 126
        super();
117 127
    }
......
149 159
     * @see							TaxonName#getTypeDesignations()
150 160
     */
151 161
    protected TypeDesignationBase(Reference citation, String citationMicroReference, String originalNameString, boolean notDesignated){
152
        super(citation, citationMicroReference, originalNameString);
162
        super();
153 163
        this.notDesignated = notDesignated;
164
        this.citationMicroReference = citationMicroReference;
165
        this.citation = citation;
154 166
    }
155 167

  
156 168

  
......
173 185
        this.typeStatus = typeStatus;
174 186
    }
175 187

  
176
    /**
177
     * Returns the set of {@link TaxonName taxon names} typified in <i>this</i>
178
     * type designation. This is a subset of the taxon names belonging to the
179
     * corresponding {@link #getHomotypicalGroup() homotypical group}.
180
     */
181
    @Override
182
    public Set<TaxonName> getTypifiedNames() {
183
        return typifiedNames;
184
    }
185

  
186 188
    /**
187 189
     * Returns the boolean value "true" if it is known that a type does not
188 190
     * exist and therefore the {@link TaxonName taxon name} to which <i>this</i>
......
201 203
    public boolean isNotDesignated() {
202 204
        return notDesignated;
203 205
    }
204

  
205 206
    /**
206 207
     * @see   #isNotDesignated()
207 208
     */
......
209 210
        this.notDesignated = notDesignated;
210 211
    }
211 212

  
213
    public String getCitationMicroReference(){
214
        return this.citationMicroReference;
215
    }
216
    public void setCitationMicroReference(String citationMicroReference){
217
        this.citationMicroReference = citationMicroReference;
218
    }
219

  
220
    public Reference getCitation(){
221
        return this.citation;
222
    }
223
    public void setCitation(Reference citation) {
224
        this.citation = citation;
225
    }
226

  
227
    /**
228
     * Returns the {@link Registration registrations} available for this
229
     * type designation.
230
     */
231
    public Set<Registration> getRegistrations() {
232
        return this.registrations;
233
    }
234

  
235
    /**
236
     * Remove the type (specimen or name) from this type designation
237
     */
238
    public abstract void removeType();
239

  
240
    /**
241
     * Returns the set of {@link TaxonName taxon names} typified in <i>this</i>
242
     * type designation. This is a subset of the taxon names belonging to the
243
     * corresponding {@link #getHomotypicalGroup() homotypical group}.
244
     */
245
    @Override
246
    public Set<TaxonName> getTypifiedNames() {
247
        return typifiedNames;
248
    }
249

  
212 250
    /**
213 251
     * @deprecated for bidirectional use only
214 252
     */
......
228 266
        }
229 267
    }
230 268

  
269

  
231 270
    /**
232
     * Returns the {@link Registration registrations} available for this
233
     * type designation.
271
     * {@inheritDoc}
234 272
     */
235
    public Set<Registration> getRegistrations() {
236
        return this.registrations;
273
    @Override
274
    protected IdentifiableSource createNewInstance(OriginalSourceType type, String idInSource, String idNamespace,
275
            Reference reference, String microReference, String originalInfo) {
276
        return IdentifiableSource.NewInstance(type, idInSource, idNamespace, reference, microReference, originalInfo);
237 277
    }
238 278

  
239
    public abstract void removeType();
240

  
241 279
//*********************** CLONE ********************************************************/
242 280

  
243 281
    /**
......
261 299
    public Object clone() throws CloneNotSupportedException {
262 300
        TypeDesignationBase<?> result = (TypeDesignationBase<?>)super.clone();
263 301

  
264
        //typified names
265
        result.typifiedNames = new HashSet<>();
266
		for (TaxonName taxonName : getTypifiedNames()){
267
		    taxonName.addTypeDesignation(result, false);
268
		}
269 302
		//registrations
270 303
		result.registrations = new HashSet<>();
271 304
		for (Registration registration : registrations){
272 305
		    registration.addTypeDesignation(result);
273 306
		}
274 307

  
308
        //typified names
309
        result.typifiedNames = new HashSet<>();
310
        for (TaxonName taxonName : getTypifiedNames()){
311
            taxonName.addTypeDesignation(result, false);
312
        }
313

  
275 314
        //no changes to: notDesignated, typeStatus, homotypicalGroup
276 315
        return result;
277 316
    }

Also available in: Unified diff