1
|
/**
|
2
|
* Copyright (C) 2021 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.persistence.dto;
|
10
|
|
11
|
import java.util.HashMap;
|
12
|
import java.util.HashSet;
|
13
|
import java.util.Map;
|
14
|
import java.util.Set;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.name.HomotypicalGroup;
|
18
|
import eu.etaxonomy.cdm.model.name.TaxonName;
|
19
|
import eu.etaxonomy.cdm.model.taxon.Synonym;
|
20
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
21
|
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
22
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
23
|
|
24
|
/**
|
25
|
* @author k.luther
|
26
|
* @since Mar 19, 2021
|
27
|
*/
|
28
|
public class HomotypicGroupDto extends UuidAndTitleCache<HomotypicalGroup> {
|
29
|
|
30
|
private static final long serialVersionUID = 5016285663369538997L;
|
31
|
|
32
|
private Set<UUID> uuidsOfSecundumReferences = new HashSet<>();
|
33
|
private Map<UUID, Boolean> publishFlagsForSynonyms = new HashMap<>();
|
34
|
private Set<UUID> uuidsOfTaxonBases = new HashSet<>();
|
35
|
|
36
|
public HomotypicGroupDto(HomotypicalGroup group, UUID nodeUuid) {
|
37
|
super(group.getUuid(), group.getId(), group.getUserFriendlyDescription());
|
38
|
for (TaxonName name: group.getTypifiedNames()){
|
39
|
TaxonBase<?> tbInHomotypicGroup = null;
|
40
|
for (TaxonBase<?> tb:name.getTaxonBases()){
|
41
|
if (tb instanceof Taxon){
|
42
|
for (TaxonNode node: ((Taxon)tb).getTaxonNodes()){
|
43
|
if (node.getUuid().equals(nodeUuid)){
|
44
|
tbInHomotypicGroup = tb;
|
45
|
break;
|
46
|
}
|
47
|
}
|
48
|
}else {
|
49
|
for (TaxonNode node: ((Synonym)tb).getAcceptedTaxon().getTaxonNodes()){
|
50
|
if (node.getUuid().equals(nodeUuid)){
|
51
|
tbInHomotypicGroup = tb;
|
52
|
break;
|
53
|
}
|
54
|
}
|
55
|
}
|
56
|
}
|
57
|
if (tbInHomotypicGroup != null){
|
58
|
uuidsOfTaxonBases.add(tbInHomotypicGroup.getUuid());
|
59
|
uuidsOfSecundumReferences.add(tbInHomotypicGroup.getSec()!= null?tbInHomotypicGroup.getSec().getUuid(): null);
|
60
|
publishFlagsForSynonyms.put(tbInHomotypicGroup.getUuid(), tbInHomotypicGroup.isPublish());
|
61
|
}
|
62
|
}
|
63
|
}
|
64
|
|
65
|
public Set<UUID> getUuidsOfSecundumReferences() {
|
66
|
return uuidsOfSecundumReferences;
|
67
|
}
|
68
|
public void setUuidsOfSecundumReferences(Set<UUID> uuidsOfSecundumReferences) {
|
69
|
this.uuidsOfSecundumReferences = uuidsOfSecundumReferences;
|
70
|
}
|
71
|
|
72
|
public Map<UUID, Boolean> getPublishFlagsForSynonyms() {
|
73
|
return publishFlagsForSynonyms;
|
74
|
}
|
75
|
public void setPublishFlagsForSynonyms(Map<UUID, Boolean> publishFlagsForSynonyms) {
|
76
|
this.publishFlagsForSynonyms = publishFlagsForSynonyms;
|
77
|
}
|
78
|
|
79
|
public Set<UUID> getUuidsOfTaxonBases() {
|
80
|
return uuidsOfTaxonBases;
|
81
|
}
|
82
|
public void setUuidsOfTaxonBases(Set<UUID> uuidsOfTaxonBases) {
|
83
|
this.uuidsOfTaxonBases = uuidsOfTaxonBases;
|
84
|
}
|
85
|
}
|