Revision b5c5e6fc
Added by Andreas Müller about 5 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/IdentifiableEntity.java | ||
---|---|---|
88 | 88 |
@Audited |
89 | 89 |
@MappedSuperclass |
90 | 90 |
public abstract class IdentifiableEntity<S extends IIdentifiableEntityCacheStrategy> |
91 |
extends AnnotatableEntity
|
|
91 |
extends SourcedEntityBase<IdentifiableSource>
|
|
92 | 92 |
implements IIdentifiableEntity /*, ISourceable<IdentifiableSource> */ { |
93 | 93 |
|
94 | 94 |
private static final long serialVersionUID = 7912083412108359559L; |
... | ... | |
159 | 159 |
@NotNull |
160 | 160 |
private List<Identifier> identifiers = new ArrayList<>(); |
161 | 161 |
|
162 |
@XmlElementWrapper(name = "Sources", nillable = true) |
|
163 |
@XmlElement(name = "IdentifiableSource") |
|
164 |
@OneToMany(fetch = FetchType.LAZY) |
|
165 |
@Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE}) |
|
166 |
@Merge(MergeMode.ADD_CLONE) |
|
167 |
@NotNull |
|
168 |
private Set<IdentifiableSource> sources = new HashSet<>(); |
|
162 |
// @XmlElementWrapper(name = "Sources", nillable = true)
|
|
163 |
// @XmlElement(name = "IdentifiableSource")
|
|
164 |
// @OneToMany(fetch = FetchType.LAZY)
|
|
165 |
// @Cascade({CascadeType.SAVE_UPDATE, CascadeType.MERGE, CascadeType.DELETE})
|
|
166 |
// @Merge(MergeMode.ADD_CLONE)
|
|
167 |
// @NotNull
|
|
168 |
// private Set<IdentifiableSource> sources = new HashSet<>();
|
|
169 | 169 |
|
170 | 170 |
@XmlTransient |
171 | 171 |
@Transient |
... | ... | |
529 | 529 |
} |
530 | 530 |
} |
531 | 531 |
|
532 |
|
|
533 |
@Override |
|
534 |
public Set<IdentifiableSource> getSources() { |
|
535 |
if(sources == null) { |
|
536 |
this.sources = new HashSet<>(); |
|
537 |
} |
|
538 |
return this.sources; |
|
539 |
} |
|
540 |
|
|
541 | 532 |
@Override |
542 | 533 |
public void addSource(IdentifiableSource source) { |
543 | 534 |
if (source != null){ |
... | ... | |
554 | 545 |
} |
555 | 546 |
} |
556 | 547 |
|
557 |
@Override |
|
558 |
public void removeSources() { |
|
559 |
this.sources.clear(); |
|
560 |
} |
|
561 |
|
|
562 |
@Override |
|
563 |
public IdentifiableSource addSource(OriginalSourceType type, String id, String idNamespace, Reference citation, String microCitation) { |
|
564 |
if (id == null && idNamespace == null && citation == null && microCitation == null){ |
|
565 |
return null; |
|
566 |
} |
|
567 |
IdentifiableSource source = IdentifiableSource.NewInstance(type, id, idNamespace, citation, microCitation); |
|
568 |
addSource(source); |
|
569 |
return source; |
|
570 |
} |
|
571 |
|
|
572 |
|
|
573 |
@Override |
|
574 |
public IdentifiableSource addImportSource(String id, String idNamespace, Reference citation, String microCitation) { |
|
575 |
if (id == null && idNamespace == null && citation == null && microCitation == null){ |
|
576 |
return null; |
|
577 |
} |
|
578 |
IdentifiableSource source = IdentifiableSource.NewInstance(OriginalSourceType.Import, id, idNamespace, citation, microCitation); |
|
579 |
addSource(source); |
|
580 |
return source; |
|
581 |
} |
|
582 |
|
|
583 |
@Override |
|
584 |
public IdentifiableSource addPrimaryTaxonomicSource(Reference citation, String microCitation) { |
|
585 |
if (citation == null && microCitation == null){ |
|
586 |
return null; |
|
587 |
} |
|
588 |
IdentifiableSource source = IdentifiableSource.NewPrimarySourceInstance(citation, microCitation); |
|
589 |
addSource(source); |
|
590 |
return source; |
|
591 |
} |
|
592 |
|
|
593 |
@Override |
|
594 |
public IdentifiableSource addPrimaryTaxonomicSource(Reference citation) { |
|
595 |
return addPrimaryTaxonomicSource(citation, null); |
|
596 |
} |
|
597 |
|
|
598 | 548 |
|
549 |
/** |
|
550 |
* {@inheritDoc} |
|
551 |
*/ |
|
599 | 552 |
@Override |
600 |
public void removeSource(IdentifiableSource source) { |
|
601 |
getSources().remove(source); |
|
553 |
protected IdentifiableSource createNewInstance(OriginalSourceType type, String idInSource, String idNamespace, |
|
554 |
Reference reference, String microReference, String originalInfo) { |
|
555 |
return IdentifiableSource.NewInstance(type, idInSource, idNamespace, reference, microReference, originalInfo); |
|
602 | 556 |
} |
603 | 557 |
|
604 | 558 |
//******************************** TO STRING *****************************************************/ |
... | ... | |
664 | 618 |
result.addIdentifier(newIdentifier); |
665 | 619 |
} |
666 | 620 |
|
667 |
//OriginalSources |
|
668 |
result.sources = new HashSet<>(); |
|
669 |
for (IdentifiableSource source : getSources()){ |
|
670 |
IdentifiableSource newSource = (IdentifiableSource)source.clone(); |
|
671 |
result.addSource(newSource); |
|
672 |
} |
|
673 |
|
|
674 | 621 |
//Rights - reusable since #5762 |
675 | 622 |
result.rights = new HashSet<>(); |
676 | 623 |
for(Rights right : getRights()) { |
677 | 624 |
result.addRights(right); |
678 | 625 |
} |
679 | 626 |
|
680 |
|
|
681 | 627 |
//Credits |
682 | 628 |
result.credits = new ArrayList<>(); |
683 | 629 |
for(Credit credit : getCredits()) { |
Also available in: Unified diff
ref #8017 add sources to TypeDesignationBase