Revision c6a0721d
Added by Andreas Müller almost 8 years ago
- ID c6a0721db1da86894a25afad447639cf60cb78a0
- Parent ed77d49a
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/DescriptionElementBase.java | ||
---|---|---|
46 | 46 |
import org.hibernate.search.annotations.IndexedEmbedded; |
47 | 47 |
|
48 | 48 |
import eu.etaxonomy.cdm.jaxb.MultilanguageTextAdapter; |
49 |
import eu.etaxonomy.cdm.model.common.AnnotatableEntity; |
|
50 | 49 |
import eu.etaxonomy.cdm.model.common.DefinedTerm; |
51 | 50 |
import eu.etaxonomy.cdm.model.common.IMultiLanguageTextHolder; |
52 | 51 |
import eu.etaxonomy.cdm.model.common.IOriginalSource; |
... | ... | |
55 | 54 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
56 | 55 |
import eu.etaxonomy.cdm.model.common.MultilanguageText; |
57 | 56 |
import eu.etaxonomy.cdm.model.common.OriginalSourceType; |
57 |
import eu.etaxonomy.cdm.model.common.SourceableEntity; |
|
58 | 58 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
59 | 59 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
60 | 60 |
import eu.etaxonomy.cdm.model.media.Media; |
... | ... | |
62 | 62 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; |
63 | 63 |
import eu.etaxonomy.cdm.model.reference.Reference; |
64 | 64 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
65 |
import eu.etaxonomy.cdm.strategy.merge.Merge; |
|
66 |
import eu.etaxonomy.cdm.strategy.merge.MergeMode; |
|
67 | 65 |
|
68 | 66 |
/** |
69 | 67 |
* The upmost (abstract) class for a piece of information) about |
... | ... | |
95 | 93 |
@Entity |
96 | 94 |
@Audited |
97 | 95 |
@Inheritance(strategy=InheritanceType.SINGLE_TABLE) |
98 |
public abstract class DescriptionElementBase extends AnnotatableEntity implements ISourceable<DescriptionElementSource>, IModifiable, IMultiLanguageTextHolder{ |
|
96 |
public abstract class DescriptionElementBase |
|
97 |
extends SourceableEntity<DescriptionElementSource> |
|
98 |
implements ISourceable<DescriptionElementSource>, IModifiable, IMultiLanguageTextHolder{ |
|
99 |
|
|
99 | 100 |
private static final long serialVersionUID = 5000910777835755905L; |
100 | 101 |
@SuppressWarnings("unused") |
101 | 102 |
private static final Logger logger = Logger.getLogger(DescriptionElementBase.class); |
... | ... | |
149 | 150 |
@XmlElement(name = "TimePeriod") |
150 | 151 |
private TimePeriod timeperiod = TimePeriod.NewInstance(); |
151 | 152 |
|
152 |
@XmlElementWrapper(name = "Sources") |
|
153 |
@XmlElement(name = "DescriptionElementSource") |
|
154 |
@OneToMany(fetch = FetchType.LAZY, orphanRemoval=true) |
|
155 |
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE}) |
|
156 |
@Merge(MergeMode.ADD_CLONE) |
|
157 |
private Set<DescriptionElementSource> sources = new HashSet<DescriptionElementSource>(); |
|
153 |
// @XmlElementWrapper(name = "Sources")
|
|
154 |
// @XmlElement(name = "DescriptionElementSource")
|
|
155 |
// @OneToMany(fetch = FetchType.LAZY, orphanRemoval=true)
|
|
156 |
// @Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE})
|
|
157 |
// @Merge(MergeMode.ADD_CLONE)
|
|
158 |
// private Set<DescriptionElementSource> sources = new HashSet<DescriptionElementSource>();
|
|
158 | 159 |
|
159 | 160 |
|
160 | 161 |
|
... | ... | |
387 | 388 |
return this.modifyingText.remove(language); |
388 | 389 |
} |
389 | 390 |
|
390 |
/* (non-Javadoc) |
|
391 |
* @see eu.etaxonomy.cdm.model.common.ISourceable#getSources() |
|
392 |
*/ |
|
393 |
@Override |
|
394 |
public Set<DescriptionElementSource> getSources() { |
|
395 |
return this.sources; |
|
396 |
} |
|
397 |
|
|
398 |
/* (non-Javadoc) |
|
399 |
* @see eu.etaxonomy.cdm.model.common.ISourceable#addSource(eu.etaxonomy.cdm.model.common.IOriginalSource) |
|
400 |
*/ |
|
401 |
@Override |
|
402 |
public void addSource(DescriptionElementSource source) { |
|
403 |
if (source != null){ |
|
404 |
DescriptionElementBase oldSourcedObj = source.getSourcedObj(); |
|
405 |
if (oldSourcedObj != null && oldSourcedObj != this){ |
|
406 |
oldSourcedObj.getSources().remove(source); |
|
407 |
} |
|
408 |
this.sources.add(source); |
|
409 |
source.setSourcedObj(this); |
|
410 |
} |
|
411 |
} |
|
412 |
|
|
413 |
/* (non-Javadoc) |
|
414 |
* @see eu.etaxonomy.cdm.model.common.ISourceable#addSource(eu.etaxonomy.cdm.model.common.OriginalSourceType, java.lang.String, java.lang.String, eu.etaxonomy.cdm.model.reference.Reference, java.lang.String) |
|
415 |
*/ |
|
416 |
@Override |
|
417 |
public DescriptionElementSource addSource(OriginalSourceType type, String id, String idNamespace, Reference citation, String microCitation) { |
|
418 |
if (id == null && idNamespace == null && citation == null && microCitation == null){ |
|
419 |
return null; |
|
420 |
} |
|
421 |
DescriptionElementSource source = DescriptionElementSource.NewInstance(type, id, idNamespace, citation, microCitation); |
|
422 |
addSource(source); |
|
423 |
return source; |
|
424 |
} |
|
425 |
@Override |
|
426 |
public void addSources(Set<DescriptionElementSource> sources){ |
|
427 |
for (DescriptionElementSource source:sources){ |
|
428 |
addSource(source); |
|
429 |
} |
|
430 |
} |
|
431 |
|
|
432 |
|
|
433 |
/* (non-Javadoc) |
|
434 |
* @see eu.etaxonomy.cdm.model.common.ISourceable#addImportSource(java.lang.String, java.lang.String, eu.etaxonomy.cdm.model.reference.Reference, java.lang.String) |
|
435 |
*/ |
|
436 |
@Override |
|
437 |
public DescriptionElementSource addImportSource(String id, String idNamespace, Reference<?> citation, String microCitation) { |
|
438 |
if (id == null && idNamespace == null && citation == null && microCitation == null){ |
|
439 |
return null; |
|
440 |
} |
|
441 |
DescriptionElementSource source = DescriptionElementSource.NewInstance(OriginalSourceType.Import, id, idNamespace, citation, microCitation); |
|
442 |
addSource(source); |
|
443 |
return source; |
|
444 |
} |
|
445 |
|
|
391 |
// @Override |
|
392 |
// public Set<DescriptionElementSource> getSources() { |
|
393 |
// return this.sources; |
|
394 |
// } |
|
395 |
// |
|
396 |
// @Override |
|
397 |
// public void addSource(DescriptionElementSource source) { |
|
398 |
// if (source != null){ |
|
399 |
// DescriptionElementBase oldSourcedObj = source.getSourcedObj(); |
|
400 |
// if (oldSourcedObj != null && oldSourcedObj != this){ |
|
401 |
// oldSourcedObj.getSources().remove(source); |
|
402 |
// } |
|
403 |
// this.sources.add(source); |
|
404 |
// source.setSourcedObj(this); |
|
405 |
// } |
|
406 |
// } |
|
407 |
// |
|
408 |
// @Override |
|
409 |
// public DescriptionElementSource addSource(OriginalSourceType type, String id, String idNamespace, Reference citation, String microCitation) { |
|
410 |
// if (id == null && idNamespace == null && citation == null && microCitation == null){ |
|
411 |
// return null; |
|
412 |
// } |
|
413 |
// DescriptionElementSource source = DescriptionElementSource.NewInstance(type, id, idNamespace, citation, microCitation); |
|
414 |
// addSource(source); |
|
415 |
// return source; |
|
416 |
// } |
|
417 |
// @Override |
|
418 |
// public void addSources(Set<DescriptionElementSource> sources){ |
|
419 |
// for (DescriptionElementSource source:sources){ |
|
420 |
// addSource(source); |
|
421 |
// } |
|
422 |
// } |
|
423 |
// |
|
424 |
// |
|
425 |
// @Override |
|
426 |
// public DescriptionElementSource addImportSource(String id, String idNamespace, Reference<?> citation, String microCitation) { |
|
427 |
// if (id == null && idNamespace == null && citation == null && microCitation == null){ |
|
428 |
// return null; |
|
429 |
// } |
|
430 |
// DescriptionElementSource source = DescriptionElementSource.NewInstance(OriginalSourceType.Import, id, idNamespace, citation, microCitation); |
|
431 |
// addSource(source); |
|
432 |
// return source; |
|
433 |
// } |
|
434 |
// |
|
446 | 435 |
/** |
447 | 436 |
* Adds a {@link IOriginalSource source} to this description element. |
448 | 437 |
* @param type the type of the source |
... | ... | |
453 | 442 |
* @param nameUsedInSource the taxon name used in the source |
454 | 443 |
* @param originalNameString the name as text used in the source |
455 | 444 |
*/ |
445 |
// @Override |
|
456 | 446 |
public void addSource(OriginalSourceType type, String idInSource, String idNamespace, Reference citation, String microReference, TaxonNameBase nameUsedInSource, String originalNameString){ |
457 | 447 |
DescriptionElementSource newSource = DescriptionElementSource.NewInstance(type, idInSource, idNamespace, citation, microReference, nameUsedInSource, originalNameString); |
458 | 448 |
addSource(newSource); |
459 | 449 |
} |
450 |
// |
|
451 |
// @Override |
|
452 |
// public void removeSource(DescriptionElementSource source) { |
|
453 |
// this.sources.remove(source); |
|
454 |
// } |
|
455 |
|
|
456 |
|
|
460 | 457 |
|
461 |
/* (non-Javadoc) |
|
462 |
* @see eu.etaxonomy.cdm.model.common.ISourceable#removeSource(eu.etaxonomy.cdm.model.common.IOriginalSource) |
|
463 |
*/ |
|
464 | 458 |
@Override |
465 |
public void removeSource(DescriptionElementSource source) { |
|
466 |
this.sources.remove(source); |
|
459 |
protected DescriptionElementSource sourceInstance(OriginalSourceType type, String idInSource, String idNamespace, |
|
460 |
Reference<?> citation, String microCitation) { |
|
461 |
return DescriptionElementSource.NewInstance(type, idInSource, idNamespace, citation, microCitation); |
|
467 | 462 |
} |
468 | 463 |
|
469 | 464 |
// ******************* METHODS *************************************************************/ |
... | ... | |
480 | 475 |
return result; |
481 | 476 |
} |
482 | 477 |
|
478 |
|
|
483 | 479 |
public List<DefinedTerm> getModifiers(TermVocabulary voc){ |
484 | 480 |
List<DefinedTerm> result = makeModifierMap().get(voc); |
485 | 481 |
if (result == null){ |
Also available in: Unified diff
Preliminary changes for FK problem on sourcedObj_id using common base
class #5534, later reverted due to #5743