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.api.service.dto;
|
10
|
|
11
|
import java.util.EnumSet;
|
12
|
import java.util.HashSet;
|
13
|
import java.util.Set;
|
14
|
import java.util.UUID;
|
15
|
|
16
|
import eu.etaxonomy.cdm.model.common.CdmClass;
|
17
|
import eu.etaxonomy.cdm.model.description.Feature;
|
18
|
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
|
19
|
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
|
20
|
import eu.etaxonomy.cdm.model.term.Representation;
|
21
|
import eu.etaxonomy.cdm.model.term.TermType;
|
22
|
import eu.etaxonomy.cdm.model.term.TermVocabulary;
|
23
|
import eu.etaxonomy.cdm.persistence.dto.TermDto;
|
24
|
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto;
|
25
|
|
26
|
/**
|
27
|
* @author k.luther
|
28
|
* @since Aug 25, 2021
|
29
|
*/
|
30
|
public class FeatureDto_ extends TermDto {
|
31
|
|
32
|
private static final long serialVersionUID = -5138575401281727741L;
|
33
|
|
34
|
|
35
|
private EnumSet<CdmClass> supportedDataTypes = EnumSet.of(CdmClass.TEXT_DATA);
|
36
|
|
37
|
private Set<TermVocabularyDto> recommendedModifierEnumeration = new HashSet<>();
|
38
|
|
39
|
private Set<TermDto> recommendedStatisticalMeasures = new HashSet<>();
|
40
|
|
41
|
private Set<TermVocabularyDto> supportedCategoricalEnumerations = new HashSet<>();
|
42
|
|
43
|
private Set<TermDto> recommendedMeasurementUnits = new HashSet<>();
|
44
|
|
45
|
public FeatureDto_(UUID uuid, Set<Representation> representations, TermType termType, UUID partOfUuid, UUID kindOfUuid,
|
46
|
UUID vocabularyUuid, String idInVocabulary, String titleCache, EnumSet<CdmClass> supportedDataTypes,
|
47
|
Set<TermVocabularyDto> recommendedModifierEnumeration, Set<TermDto> recommendedStatisticalMeasures,
|
48
|
Set<TermVocabularyDto> supportedCategoricalEnumerations, Set<TermDto> recommendedMeasurementUnits) {
|
49
|
super(uuid, representations, termType, partOfUuid, kindOfUuid, vocabularyUuid, null, idInVocabulary, titleCache);
|
50
|
this.recommendedMeasurementUnits = recommendedMeasurementUnits;
|
51
|
this.recommendedModifierEnumeration = recommendedModifierEnumeration;
|
52
|
this.recommendedStatisticalMeasures = recommendedStatisticalMeasures;
|
53
|
this.supportedCategoricalEnumerations = supportedCategoricalEnumerations;
|
54
|
this.supportedDataTypes = supportedDataTypes;
|
55
|
}
|
56
|
|
57
|
public static FeatureDto_ fromFeature(Feature feature){
|
58
|
FeatureDto_ dto = (FeatureDto_) fromTerm(feature);
|
59
|
if (feature.isSupportsCategoricalData()){
|
60
|
dto.supportedDataTypes.add(CdmClass.CATEGORICAL_DATA);
|
61
|
}
|
62
|
if (feature.isSupportsCommonTaxonName()){
|
63
|
dto.supportedDataTypes.add(CdmClass.COMMON_TAXON_NAME);
|
64
|
}
|
65
|
if (feature.isSupportsDistribution()){
|
66
|
dto.supportedDataTypes.add(CdmClass.DISTRIBUTION);
|
67
|
}
|
68
|
if (feature.isSupportsIndividualAssociation()){
|
69
|
dto.supportedDataTypes.add(CdmClass.INDIVIDUALS_ASSOCIATION);
|
70
|
}
|
71
|
if (feature.isSupportsQuantitativeData()){
|
72
|
dto.supportedDataTypes.add(CdmClass.QUANTITATIVE_DATA);
|
73
|
}
|
74
|
if (feature.isSupportsTaxonInteraction()){
|
75
|
dto.supportedDataTypes.add(CdmClass.TAXON_INTERACTION);
|
76
|
}
|
77
|
if (feature.isSupportsTemporalData()){
|
78
|
dto.supportedDataTypes.add(CdmClass.TEMPORAL_DATA);
|
79
|
}
|
80
|
if (!feature.isSupportsTextData()){
|
81
|
dto.supportedDataTypes.remove(CdmClass.TEXT_DATA);
|
82
|
}
|
83
|
TermVocabularyDto vocDto;
|
84
|
for (TermVocabulary<?> voc: feature.getRecommendedModifierEnumeration()){
|
85
|
vocDto = TermVocabularyDto.fromVocabulary(voc);
|
86
|
dto.recommendedModifierEnumeration.add(vocDto);
|
87
|
}
|
88
|
TermDto termDto;
|
89
|
for (StatisticalMeasure term: feature.getRecommendedStatisticalMeasures()){
|
90
|
termDto = TermDto.fromTerm(term);
|
91
|
dto.recommendedStatisticalMeasures.add(termDto);
|
92
|
}
|
93
|
for (TermVocabulary<?> voc: feature.getSupportedCategoricalEnumerations()){
|
94
|
vocDto = TermVocabularyDto.fromVocabulary(voc);
|
95
|
dto.supportedCategoricalEnumerations.add(vocDto);
|
96
|
}
|
97
|
|
98
|
for (MeasurementUnit term: feature.getRecommendedMeasurementUnits()){
|
99
|
termDto = TermDto.fromTerm(term);
|
100
|
dto.recommendedMeasurementUnits.add(termDto);
|
101
|
}
|
102
|
|
103
|
return dto;
|
104
|
|
105
|
}
|
106
|
|
107
|
|
108
|
public EnumSet<CdmClass> getSupportedDataTypes() {
|
109
|
return supportedDataTypes;
|
110
|
}
|
111
|
public void setSupportedDataTypes(EnumSet<CdmClass> supportedDataTypes) {
|
112
|
this.supportedDataTypes = supportedDataTypes;
|
113
|
}
|
114
|
|
115
|
public Set<TermVocabularyDto> getRecommendedModifierEnumeration() {
|
116
|
return recommendedModifierEnumeration;
|
117
|
}
|
118
|
public void setRecommendedModifierEnumeration(Set<TermVocabularyDto> recommendedModifierEnumeration) {
|
119
|
this.recommendedModifierEnumeration = recommendedModifierEnumeration;
|
120
|
}
|
121
|
|
122
|
public Set<TermDto> getRecommendedStatisticalMeasures() {
|
123
|
return recommendedStatisticalMeasures;
|
124
|
}
|
125
|
public void setRecommendedStatisticalMeasures(Set<TermDto> recommendedStatisticalMeasures) {
|
126
|
this.recommendedStatisticalMeasures = recommendedStatisticalMeasures;
|
127
|
}
|
128
|
|
129
|
public Set<TermVocabularyDto> getSupportedCategoricalEnumerations() {
|
130
|
return supportedCategoricalEnumerations;
|
131
|
}
|
132
|
public void setSupportedCategoricalEnumerations(Set<TermVocabularyDto> supportedCategoricalEnumerations) {
|
133
|
this.supportedCategoricalEnumerations = supportedCategoricalEnumerations;
|
134
|
}
|
135
|
|
136
|
public Set<TermDto> getRecommendedMeasurementUnits() {
|
137
|
return recommendedMeasurementUnits;
|
138
|
}
|
139
|
public void setRecommendedMeasurementUnits(Set<TermDto> recommendedMeasurementUnits) {
|
140
|
this.recommendedMeasurementUnits = recommendedMeasurementUnits;
|
141
|
}
|
142
|
}
|