Revision 37f2b410
Added by Katja Luther almost 3 years ago
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/AbstractTermDto.java | ||
---|---|---|
111 | 111 |
this.representation_L10n_text = representation_L10n_text; |
112 | 112 |
} |
113 | 113 |
|
114 |
|
|
114 | 115 |
public UUID getUuid() { |
115 | 116 |
return uuid; |
116 | 117 |
} |
... | ... | |
154 | 155 |
return null; |
155 | 156 |
} |
156 | 157 |
|
158 |
|
|
157 | 159 |
public String getTitleCache() { |
158 | 160 |
return titleCache; |
159 | 161 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/CharacterDtoLabelBuilder.java | ||
---|---|---|
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 eu.etaxonomy.cdm.model.common.Language; |
|
12 |
import eu.etaxonomy.cdm.model.term.Representation; |
|
13 |
|
|
14 |
/** |
|
15 |
* @author k.luther |
|
16 |
* @since Apr 20, 2021 |
|
17 |
*/ |
|
18 |
public class CharacterDtoLabelBuilder { |
|
19 |
|
|
20 |
public static final CharacterDtoLabelBuilder NewDefaultInstance(){ |
|
21 |
return new CharacterDtoLabelBuilder(); |
|
22 |
} |
|
23 |
|
|
24 |
private CharacterDtoLabelBuilder(){} |
|
25 |
|
|
26 |
public static String buildAbbrevLabel(CharacterDto character, Language lang){ |
|
27 |
TermNodeDto propertyNode = character.getProperty(); |
|
28 |
TermNodeDto structureNode = character.getStructure(); |
|
29 |
TermNodeDto ratioToNode = character.getRatioTo(); |
|
30 |
Representation structureRepresentation = structureNode.getTerm().getRepresentation(lang); |
|
31 |
if(structureRepresentation==null){ |
|
32 |
structureRepresentation = structureNode.getTerm().getRepresentation(Language.DEFAULT()); |
|
33 |
} |
|
34 |
Representation propertyRepresentation = propertyNode.getTerm().getRepresentation(lang); |
|
35 |
if(propertyRepresentation==null){ |
|
36 |
propertyRepresentation = propertyNode.getTerm().getRepresentation(Language.DEFAULT()); |
|
37 |
} |
|
38 |
|
|
39 |
String abbrevLabel = null; |
|
40 |
if(structureRepresentation!=null && propertyRepresentation!=null){ |
|
41 |
if(structureRepresentation.getAbbreviatedLabel()!=null && propertyRepresentation.getAbbreviatedLabel()!=null){ |
|
42 |
abbrevLabel = structureRepresentation.getAbbreviatedLabel()+" "+propertyRepresentation.getAbbreviatedLabel(); |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
if (character.getRatioTo() != null){ |
|
47 |
Representation ratioToRepresentation = ratioToNode.getTerm().getRepresentation(lang); |
|
48 |
if(ratioToRepresentation==null){ |
|
49 |
ratioToRepresentation = ratioToNode.getTerm().getRepresentation(Language.DEFAULT()); |
|
50 |
} |
|
51 |
if(structureRepresentation!=null && propertyRepresentation!=null){ |
|
52 |
|
|
53 |
if(structureRepresentation.getAbbreviatedLabel()!=null && propertyRepresentation.getAbbreviatedLabel()!=null && ratioToRepresentation.getAbbreviatedLabel() != null){ |
|
54 |
abbrevLabel = propertyRepresentation.getAbbreviatedLabel() + " ratio " +structureRepresentation.getAbbreviatedLabel()+ " to " + ratioToRepresentation.getAbbreviatedLabel(); |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
} |
|
59 |
|
|
60 |
return abbrevLabel; |
|
61 |
} |
|
62 |
public static String buildLabel(CharacterDto character, Language lang){ |
|
63 |
TermNodeDto propertyNode = character.getProperty(); |
|
64 |
TermNodeDto structureNode = character.getStructure(); |
|
65 |
TermNodeDto ratioToNode = character.getRatioTo(); |
|
66 |
Representation structureRepresentation = structureNode.getTerm().getRepresentation(lang); |
|
67 |
if(structureRepresentation==null){ |
|
68 |
structureRepresentation = structureNode.getTerm().getRepresentation(Language.DEFAULT()); |
|
69 |
} |
|
70 |
Representation propertyRepresentation = propertyNode.getTerm().getRepresentation(lang); |
|
71 |
if(propertyRepresentation==null){ |
|
72 |
propertyRepresentation = propertyNode.getTerm().getRepresentation(Language.DEFAULT()); |
|
73 |
} |
|
74 |
String label = null; |
|
75 |
|
|
76 |
if(structureRepresentation!=null && propertyRepresentation!=null){ |
|
77 |
if(structureRepresentation.getLabel()!=null && propertyRepresentation.getLabel()!=null){ |
|
78 |
label = structureRepresentation.getLabel()+" "+propertyRepresentation.getLabel(); |
|
79 |
} |
|
80 |
|
|
81 |
} |
|
82 |
if(label!=null){ |
|
83 |
//default label |
|
84 |
label = structureNode.getTerm().getRepresentation_L10n()+" "+propertyNode.getTerm().getRepresentation_L10n(); |
|
85 |
} |
|
86 |
if (character.getRatioTo() != null){ |
|
87 |
Representation ratioToRepresentation = ratioToNode.getTerm().getRepresentation(lang); |
|
88 |
if(ratioToRepresentation==null){ |
|
89 |
ratioToRepresentation = ratioToNode.getTerm().getRepresentation(Language.DEFAULT()); |
|
90 |
} |
|
91 |
if(structureRepresentation!=null && propertyRepresentation!=null){ |
|
92 |
if(structureRepresentation.getLabel() != null && propertyRepresentation.getLabel() != null && ratioToRepresentation.getLabel() != null){ |
|
93 |
label = propertyRepresentation.getLabel() + " ratio " +structureRepresentation.getLabel()+" to " +ratioToRepresentation.getLabel() ; |
|
94 |
} |
|
95 |
|
|
96 |
} |
|
97 |
if(label==null){ |
|
98 |
//default label |
|
99 |
label = propertyNode.getTerm().getRepresentation_L10n()+ " ratio " +structureNode.getTerm().getRepresentation_L10n()+ " to " + ratioToNode.getTerm().getRepresentation_L10n() ; |
|
100 |
} |
|
101 |
} |
|
102 |
|
|
103 |
return label; |
|
104 |
} |
|
105 |
|
|
106 |
} |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermCollectionDto.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.cdm.persistence.dto; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
12 | 13 |
import java.util.HashSet; |
14 |
import java.util.List; |
|
13 | 15 |
import java.util.Set; |
14 | 16 |
import java.util.UUID; |
15 | 17 |
|
... | ... | |
25 | 27 |
|
26 | 28 |
private static final long serialVersionUID = 6053392236860675874L; |
27 | 29 |
|
28 |
private Set<TermDto> terms;
|
|
30 |
private List<TermDto> terms;
|
|
29 | 31 |
|
30 | 32 |
private boolean isAllowDuplicate; |
31 | 33 |
private boolean containsDuplicates = false; |
... | ... | |
34 | 36 |
|
35 | 37 |
public TermCollectionDto(UUID uuid, Set<Representation> representations, TermType termType, String titleCache, boolean isAllowDuplicate, boolean isOrderRelevant, boolean isFlat) { |
36 | 38 |
super(uuid, representations, titleCache); |
37 |
terms = new HashSet<>();
|
|
39 |
terms = new ArrayList<>();
|
|
38 | 40 |
setTermType(termType); |
39 | 41 |
this.isAllowDuplicate = isAllowDuplicate; |
40 | 42 |
this.isOrderRelevant = isOrderRelevant; |
41 | 43 |
this.isFlat = isFlat; |
42 | 44 |
} |
43 | 45 |
|
44 |
public Set<TermDto> getTerms() {
|
|
46 |
public List<TermDto> getTerms() {
|
|
45 | 47 |
if (terms.isEmpty()){ |
46 | 48 |
|
47 | 49 |
} |
... | ... | |
49 | 51 |
} |
50 | 52 |
|
51 | 53 |
public void addTerm(TermDto term){ |
54 |
if (term == null){ |
|
55 |
return; |
|
56 |
} |
|
52 | 57 |
if (terms == null){ |
53 |
terms = new HashSet<>();
|
|
58 |
terms = new ArrayList<>();
|
|
54 | 59 |
} |
55 | 60 |
if (terms.contains(term)){ |
56 | 61 |
containsDuplicates = true; |
... | ... | |
79 | 84 |
} |
80 | 85 |
|
81 | 86 |
public boolean isContainsDuplicates() { |
87 |
Set<TermDto> dtoSet = new HashSet<>(terms); |
|
88 |
if (dtoSet.size() == terms.size()){ |
|
89 |
containsDuplicates = false; |
|
90 |
} |
|
91 |
|
|
82 | 92 |
return containsDuplicates; |
83 | 93 |
} |
84 | 94 |
|
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermDto.java | ||
---|---|---|
271 | 271 |
+ "a.uri, " |
272 | 272 |
+ "m, " |
273 | 273 |
+ "a.titleCache "; |
274 |
String sqlFromString = " from "+fromTable+" as a ";
|
|
274 |
String sqlFromString = " FROM "+fromTable+" as a ";
|
|
275 | 275 |
|
276 | 276 |
String sqlJoinString = "LEFT JOIN a.partOf as p " |
277 | 277 |
+ "LEFT JOIN a.kindOf as k " |
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermNodeDto.java | ||
---|---|---|
219 | 219 |
int index = this.getIndex(nodeDto); |
220 | 220 |
if (index > -1){ |
221 | 221 |
this.getChildren().remove(index); |
222 |
this.tree.removeTerm(nodeDto.term); |
|
222 | 223 |
return true; |
223 | 224 |
}else if (doRecursive && this.getChildren() != null && !this.getChildren().isEmpty()){ |
224 | 225 |
for (TermNodeDto child: children){ |
Also available in: Unified diff
ref #8776: fix contains duplicates in dto