1
|
/**
|
2
|
* Copyright (C) 2020 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.HashSet;
|
12
|
import java.util.Set;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import eu.etaxonomy.cdm.model.description.Character;
|
16
|
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
|
17
|
import eu.etaxonomy.cdm.model.description.State;
|
18
|
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
|
19
|
import eu.etaxonomy.cdm.model.term.DefinedTerm;
|
20
|
import eu.etaxonomy.cdm.model.term.Representation;
|
21
|
import eu.etaxonomy.cdm.model.term.TermVocabulary;
|
22
|
/**
|
23
|
* @author k.luther
|
24
|
* @since Oct 6, 2020
|
25
|
*/
|
26
|
public class CharacterDto extends FeatureDto {
|
27
|
private static final long serialVersionUID = 1743178749047550590L;
|
28
|
|
29
|
private TermNodeDto structure;
|
30
|
private TermDto structureModifier;
|
31
|
private TermNodeDto property;
|
32
|
private TermDto propertyModifier;
|
33
|
|
34
|
|
35
|
/**
|
36
|
* @param uuid
|
37
|
* @param representations
|
38
|
* @param partOfUuid
|
39
|
* @param kindOfUuid
|
40
|
* @param vocabularyUuid
|
41
|
* @param orderIndex
|
42
|
* @param idInVocabulary
|
43
|
* @param vocRepresentations
|
44
|
* @param isAvailableForTaxon
|
45
|
* @param isAvailableForTaxonName
|
46
|
* @param isAvailableForOccurrence
|
47
|
* @param titleCache
|
48
|
* @param structure
|
49
|
* @param structureModifier
|
50
|
* @param property
|
51
|
* @param propertyModifier
|
52
|
*/
|
53
|
public CharacterDto(UUID uuid, Set<Representation> representations, UUID partOfUuid, UUID kindOfUuid,
|
54
|
UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, Set<Representation> vocRepresentations,
|
55
|
boolean isAvailableForTaxon, boolean isAvailableForTaxonName, boolean isAvailableForOccurrence,
|
56
|
String titleCache, TermNodeDto structure, TermDto structureModifier, TermNodeDto property,
|
57
|
TermDto propertyModifier, boolean isSupportCategoricalData, boolean isSupportsQuantitativeData, Set<TermVocabularyDto> supportedCategoricalEnumerations, Set<TermVocabularyDto> recommendedModifierEnumeration, Set<TermDto> recommendedMeasurementUnits, Set<TermDto> recommendedStatisticalMeasures) {
|
58
|
super(uuid, representations, partOfUuid, kindOfUuid, vocabularyUuid, orderIndex, idInVocabulary,
|
59
|
vocRepresentations, isAvailableForTaxon, isAvailableForTaxonName, isAvailableForOccurrence, titleCache, isSupportCategoricalData, isSupportsQuantitativeData, supportedCategoricalEnumerations, recommendedModifierEnumeration, recommendedMeasurementUnits, recommendedStatisticalMeasures);
|
60
|
this.structure = structure;
|
61
|
this.structureModifier = structureModifier;
|
62
|
this.property = property;
|
63
|
this.propertyModifier = propertyModifier;
|
64
|
}
|
65
|
|
66
|
/**
|
67
|
* @param character
|
68
|
*/
|
69
|
public static CharacterDto fromCharacter(Character character) {
|
70
|
TermVocabulary voc = character.getVocabulary();
|
71
|
|
72
|
Set<TermVocabularyDto> recommendedModifierDtos = new HashSet<>();
|
73
|
for (TermVocabulary<DefinedTerm> modVoc: character.getRecommendedModifierEnumeration()){
|
74
|
recommendedModifierDtos.add(TermVocabularyDto.fromVocabulary(modVoc));
|
75
|
}
|
76
|
|
77
|
|
78
|
Set<TermDto> recommendedStatisticalMeasuresDtos = new HashSet<>();
|
79
|
for (StatisticalMeasure term: character.getRecommendedStatisticalMeasures()){
|
80
|
recommendedStatisticalMeasuresDtos.add(TermDto.fromTerm(term));
|
81
|
}
|
82
|
|
83
|
|
84
|
Set<TermVocabularyDto> supportedCategoricalDtos = new HashSet<>();
|
85
|
for (TermVocabulary<State> catVoc: character.getSupportedCategoricalEnumerations()){
|
86
|
supportedCategoricalDtos.add(TermVocabularyDto.fromVocabulary(catVoc));
|
87
|
}
|
88
|
|
89
|
|
90
|
Set<TermDto> recommendedMeasurementUnitsDtos = new HashSet<>();
|
91
|
for (MeasurementUnit term: character.getRecommendedMeasurementUnits()){
|
92
|
recommendedMeasurementUnitsDtos.add(TermDto.fromTerm(term));
|
93
|
}
|
94
|
CharacterDto dto = new CharacterDto(character.getUuid(), character.getRepresentations(), character.getPartOf() != null? character.getPartOf().getUuid(): null, character.getKindOf() != null? character.getKindOf().getUuid(): null, voc != null? voc.getUuid(): null,
|
95
|
null, character.getIdInVocabulary(), voc != null? voc.getRepresentations(): null, character.isAvailableForTaxon(), character.isAvailableForTaxonName(), character.isAvailableForOccurrence(), character.getTitleCache(),
|
96
|
character.getStructure() !=null? TermNodeDto.fromNode(character.getStructure()): null, character.getStructureModifier() != null? TermDto.fromTerm(character.getStructureModifier()): null, character.getProperty() != null? TermNodeDto.fromNode(character.getProperty()): null,
|
97
|
character.getPropertyModifier() != null? TermDto.fromTerm(character.getPropertyModifier()): null, character.isSupportsCategoricalData(), character.isSupportsQuantitativeData(),supportedCategoricalDtos, recommendedModifierDtos, recommendedMeasurementUnitsDtos, recommendedStatisticalMeasuresDtos);
|
98
|
|
99
|
return dto;
|
100
|
}
|
101
|
|
102
|
|
103
|
|
104
|
public TermNodeDto getStructure() {
|
105
|
return structure;
|
106
|
}
|
107
|
|
108
|
public void setStructure(TermNodeDto structure) {
|
109
|
this.structure = structure;
|
110
|
}
|
111
|
|
112
|
public TermDto getStructureModifier() {
|
113
|
return structureModifier;
|
114
|
}
|
115
|
|
116
|
public void setStructureModifier(TermDto structureModifier) {
|
117
|
this.structureModifier = structureModifier;
|
118
|
}
|
119
|
|
120
|
public TermNodeDto getProperty() {
|
121
|
return property;
|
122
|
}
|
123
|
|
124
|
public void setProperty(TermNodeDto property) {
|
125
|
this.property = property;
|
126
|
}
|
127
|
|
128
|
public TermDto getPropertyModifier() {
|
129
|
return propertyModifier;
|
130
|
}
|
131
|
|
132
|
public void setPropertyModifier(TermDto propertyModifier) {
|
133
|
this.propertyModifier = propertyModifier;
|
134
|
}
|
135
|
|
136
|
|
137
|
}
|