Project

General

Profile

« Previous | Next » 

Revision d09294f4

Added by Katja Luther over 2 years ago

ref #9802, #9843: fix display label in rowwrapper

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/FeatureDto.java
18 18
import java.util.UUID;
19 19

  
20 20
import eu.etaxonomy.cdm.common.URI;
21
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
21 22
import eu.etaxonomy.cdm.model.common.CdmClass;
22 23
import eu.etaxonomy.cdm.model.description.Feature;
23 24
import eu.etaxonomy.cdm.model.description.MeasurementUnit;
......
72 73
    static public FeatureDto fromFeature(Feature term) {
73 74
        UUID partOfUuid = term.getPartOf() != null? term.getPartOf().getUuid(): null;
74 75
        UUID kindOfUuid = term.getKindOf() != null? term.getKindOf().getUuid(): null;
75
        UUID vocUuid =  term.getVocabulary() != null? term.getVocabulary().getUuid(): null;
76
        TermVocabulary<?> vocabulary = HibernateProxyHelper.deproxy(term.getVocabulary());
77
        UUID vocUuid =  vocabulary != null? vocabulary.getUuid(): null;
76 78
        Set<TermVocabularyDto> supportedCategoricalEnumerations = new HashSet<>();
77 79
        for (TermVocabulary<State> stateVoc:term.getSupportedCategoricalEnumerations()){
78 80
            supportedCategoricalEnumerations.add(TermVocabularyDto.fromVocabulary(stateVoc));
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java
92 92
import eu.etaxonomy.cdm.persistence.dao.term.ITermNodeDao;
93 93
import eu.etaxonomy.cdm.persistence.dao.term.ITermTreeDao;
94 94
import eu.etaxonomy.cdm.persistence.dao.term.ITermVocabularyDao;
95
import eu.etaxonomy.cdm.persistence.dto.FeatureDto;
95 96
import eu.etaxonomy.cdm.persistence.dto.MergeResult;
96 97
import eu.etaxonomy.cdm.persistence.dto.TermDto;
97 98
import eu.etaxonomy.cdm.persistence.query.OrderHint;
......
123 124
    protected IOccurrenceDao occurrenceDao;
124 125
    protected ITaxonNodeDao taxonNodeDao;
125 126
    protected IDescriptiveDataSetDao dataSetDao;
127
    protected ITermService termService;
126 128

  
127 129
    //TODO change to Interface
128 130
    private NaturalLanguageGenerator naturalLanguageGenerator;
......
152 154
        this.definedTermDao = definedTermDao;
153 155
    }
154 156

  
157
    @Autowired
158
    protected void setTermService(ITermService definedTermService) {
159
        this.termService = definedTermService;
160
    }
161

  
162

  
155 163
    @Autowired
156 164
    protected void statisticalMeasurementValueDao(IStatisticalMeasurementValueDao statisticalMeasurementValueDao) {
157 165
        this.statisticalMeasurementValueDao = statisticalMeasurementValueDao;
......
1152 1160
            @SuppressWarnings("unchecked")
1153 1161
            List<Object[]>  resultCat = query.list();
1154 1162
            List<CategoricalDataDto> listCategorical = CategoricalDataDto.categoricalDataDtoListFrom(resultCat);
1163

  
1164
            List<UUID> featureUuids = new ArrayList<>();
1165
            for (CategoricalDataDto catDto: listCategorical){
1166
                featureUuids.add(catDto.getFeatureUuid());
1167
            }
1168
            Map<UUID, TermDto> featureDtos = termService.findFeatureByUUIDsAsDtos(featureUuids);
1169
            for (CategoricalDataDto catDto: listCategorical){
1170
                FeatureDto featuredto = (FeatureDto)featureDtos.get(catDto.getFeatureUuid());
1171
                catDto.setFeatureDto(featuredto);
1172
            }
1155 1173
            dto.getElements().addAll(listCategorical);
1156 1174
            //get quantitative data
1157 1175
            sqlSelect = QuantitativeDataDto.getQuantitativeDataDtoSelect();
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/ITermService.java
282 282
    public Country getCountryByIso(String iso639);
283 283

  
284 284
    public List<Country> getCountryByName(String name);
285
    /**
286
     * Returns a map of {@link UUID} and {@link TermDto} of terms with uuid matches one of uuids in list
287
     * @param uuidList
288
     * @return
289
     */
290
    public Map<UUID, TermDto> findFeatureByUUIDsAsDtos(List<UUID> uuidList);
285 291

  
286 292
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TermServiceImpl.java
11 11
import java.util.ArrayList;
12 12
import java.util.Collection;
13 13
import java.util.Enumeration;
14
import java.util.HashMap;
14 15
import java.util.HashSet;
15 16
import java.util.List;
16 17
import java.util.Locale;
......
632 633
        return dao.findFeatureByUUIDsAsDto(uuidList);
633 634
    }
634 635

  
636
    @Override
637
    public Map<UUID, TermDto> findFeatureByUUIDsAsDtos(List<UUID> uuidList){
638
        Collection<TermDto> col = dao.findFeatureByUUIDsAsDto(uuidList);
639
        Map<UUID, TermDto> result = new HashMap<>();
640
        for (TermDto dto: col){
641
            result.put(dto.getUuid(), dto);
642
        }
643
        return result;
644
    }
645

  
646

  
635 647
    @Override
636 648
    public Collection<TermDto> findFeatureByTitleAsDto(String title){
637 649
        return dao.findFeatureByTitleAsDto(title);
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DescriptionBaseDto.java
237 237
        for (Object element: desc.getElements()){
238 238
            if (element instanceof CategoricalData){
239 239
                Feature feature = ((CategoricalData) element).getFeature();
240
                FeatureDto featureDto = FeatureDto.fromFeature(feature);
240
//                FeatureDto featureDto = FeatureDto.fromFeature(feature);
241 241
                CategoricalDataDto dto = CategoricalDataDto.fromCategoricalData((CategoricalData)element);
242 242
                elements.add(dto);
243 243
            }
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/QuantitativeDataDto.java
142 142
            }
143 143
            StatisticalMeasurementValueDto statVal = new StatisticalMeasurementValueDto(TermDto.fromTerm((DefinedTermBase)o[4]),(BigDecimal)o[3], (UUID)o[2]) ;
144 144
            dto.addValue(statVal);
145
            if (o[5] != null) {
146
                dto.setMeasurementUnit(TermDto.fromTerm((DefinedTermBase)o[5]));
147
            }
145 148
        }
146 149

  
147 150

  
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/RowWrapperDTO.java
180 180
        displayData = "";
181 181
        BigDecimal min = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.MIN().getUuid());
182 182
        BigDecimal max = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.MAX().getUuid());
183
        BigDecimal mean = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.AVERAGE().getUuid());
184
        BigDecimal low = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.TYPICAL_LOWER_BOUNDARY().getUuid());
185
        BigDecimal high = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.TYPICAL_UPPER_BOUNDARY().getUuid());
186
        BigDecimal size = quantitativeData.getSpecificStatisticalValue(StatisticalMeasure.SAMPLE_SIZE().getUuid());
187
        String typicalValues = "";
188
        if (low != null || high != null){
189
            typicalValues += low!= null?low.toString():""+"-"+high!= null?high.toString():"";
190
        }
183 191
        if(min!=null||max!=null){
184
            displayData += "["+(min!=null?min.toString():"?")+"-"+(max!=null?max.toString():"?")+"] ";
192
            if (min!= null && max != null && min.intValue() == max.intValue()){
193
                displayData += "("+min.toString()+")"+typicalValues;
194
            }else{
195
                if (StringUtils.isBlank(typicalValues)){
196
                    displayData += "("+(min!=null?min.toString():"?")+"-"+(max!=null?max.toString():"?")+") ";
197
                }else{
198
                    displayData += "("+(min!=null?min.toString():"?")+typicalValues+(max!=null?max.toString():"?")+") ";
199
                }
200
            }
185 201
        }
186 202
        displayData += quantitativeData.getValues().stream()
187 203
                .filter(value->value.getType().getUuid().equals(StatisticalMeasure.EXACT_VALUE().getUuid()))
......
190 206
        if (quantitativeData.getMeasurementUnit() != null && StringUtils.isNotBlank(displayData)){
191 207
            displayData += " "+ quantitativeData.getMeasurementIdInVocabulary();
192 208
        }
209

  
193 210
        return displayData;
194 211
    }
195 212

  

Also available in: Unified diff