Project

General

Profile

« Previous | Next » 

Revision 71559ffe

Added by Katja Luther over 2 years ago

ref #9710: switch to dtos for descriptive data set and descriptions for character matrix

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/FeatureDto.java
49 49
    Set<TermVocabularyDto> recommendedModifierEnumeration = new HashSet<>();
50 50

  
51 51
    public FeatureDto(UUID uuid, Set<Representation> representations, UUID partOfUuid, UUID kindOfUuid,
52
            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, Set<Representation> vocRepresentations, boolean isAvailableForTaxon,
53
            boolean isAvailableForTaxonName, boolean isAvailableForOccurrence, String titleCache, boolean isSupportsCategoricalData, boolean isSupportsQuantitativeData,
52
            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, //Set<Representation> vocRepresentations,
53
            boolean isAvailableForTaxon, boolean isAvailableForTaxonName, boolean isAvailableForOccurrence, String titleCache, boolean isSupportsCategoricalData, boolean isSupportsQuantitativeData,
54 54
            Set<TermVocabularyDto> supportedCategoricalEnumerations, Set<TermVocabularyDto> recommendedModifierEnumeration,  Set<TermDto> recommendedMeasurementUnits,  Set<TermDto> recommendedStatisticalMeasures){
55 55
        super(uuid, representations, TermType.Feature, partOfUuid, kindOfUuid,
56
                vocabularyUuid, orderIndex, idInVocabulary, vocRepresentations, titleCache);
56
                vocabularyUuid, orderIndex, idInVocabulary, titleCache);
57 57
        this.isAvailableForOccurrence = isAvailableForOccurrence;
58 58
        this.isAvailableForTaxon = isAvailableForTaxon;
59 59
        this.isAvailableForTaxonName = isAvailableForTaxonName;
......
67 67
        this.recommendedModifierEnumeration = recommendedModifierEnumeration;
68 68
    }
69 69

  
70
    static public FeatureDto fromTerm(Feature term) {
71
        FeatureDto result = (FeatureDto) fromTerm(term, null, false);
70

  
71

  
72
    static public FeatureDto fromFeature(Feature term) {
73
        UUID partOfUuid = term.getPartOf() != null? term.getPartOf().getUuid(): null;
74
        UUID kindOfUuid = term.getKindOf() != null? term.getKindOf().getUuid(): null;
75
        UUID vocUuid =  term.getVocabulary() != null? term.getVocabulary().getUuid(): null;
76
        Set<TermVocabularyDto> supportedCategoricalEnumerations = new HashSet<>();
77
        for (TermVocabulary<State> stateVoc:term.getSupportedCategoricalEnumerations()){
78
            supportedCategoricalEnumerations.add(TermVocabularyDto.fromVocabulary(stateVoc));
79
        }
80

  
81
        Set<TermVocabularyDto> recommendedModifiers = new HashSet<>();
82
        for (TermVocabulary<DefinedTerm> modifier:term.getRecommendedModifierEnumeration()){
83
            recommendedModifiers.add(TermVocabularyDto.fromVocabulary(modifier));
84
        }
85

  
86
        Set<TermDto> recommendedMeasurementUnits= new HashSet<>();
87
        for (MeasurementUnit measurementUnit:term.getRecommendedMeasurementUnits()){
88
            recommendedMeasurementUnits.add(TermDto.fromTerm(measurementUnit));
89
        }
90

  
91
        Set<TermDto> recommendedStatisticalMeasures = new HashSet<>();
92
        for (StatisticalMeasure statMeasure:term.getRecommendedStatisticalMeasures()){
93
            recommendedStatisticalMeasures.add(TermDto.fromTerm(statMeasure));
94
        }
95

  
96
        FeatureDto result =  new FeatureDto(term.getUuid(), term.getRepresentations(), partOfUuid, kindOfUuid, vocUuid, null, term.getIdInVocabulary(), term.isAvailableForTaxon(), term.isAvailableForTaxonName(), term.isAvailableForOccurrence(),
97
                term.getTitleCache(),term.isSupportsCategoricalData(), term.isSupportsQuantitativeData(), supportedCategoricalEnumerations, recommendedModifiers, recommendedMeasurementUnits, recommendedStatisticalMeasures);
72 98
        result.isAvailableForOccurrence = term.isAvailableForOccurrence();
73 99
        result.isAvailableForTaxon = term.isAvailableForTaxon();
74 100
        result.isAvailableForTaxonName = term.isAvailableForTaxonName();
......
245 271
                + "v.uuid, "
246 272
                + "a.orderIndex, "
247 273
                + "a.idInVocabulary, "
248
                + "voc_rep,  "
274
//                + "voc_rep,  "
249 275
                + "a.termType,  "
250 276
                + "a.uri,  "
251 277
                + "m,  "
......
264 290
                + "LEFT JOIN a.media as m "
265 291
                + "LEFT JOIN a.representations AS r "
266 292
                + "LEFT JOIN a.vocabulary as v "
267
                + "LEFT JOIN v.representations as voc_rep "
293
//                + "LEFT JOIN v.representations as voc_rep "
268 294
                + "LEFT JOIN a.recommendedModifierEnumeration as recommendedModifierEnumeration "
269 295
                + "LEFT JOIN a.recommendedStatisticalMeasures as recommendedStatisticalMeasures "
270 296
                + "LEFT JOIN a.supportedCategoricalEnumerations as supportedCategoricalEnumerations "
......
290 316
                if(elements[1]!=null){
291 317
                    dtoMap.get(uuid).addRepresentation((Representation)elements[1]);
292 318
                }
293
                if(elements[7]!=null){
294
                    dtoMap.get(uuid).addVocRepresentation((Representation)elements[7]);
295
                }
296
                if(elements[10]!=null){
297
                    dtoMap.get(uuid).addMedia(((Media) elements[10]).getUuid());
319
//                if(elements[7]!=null){
320
//                    dtoMap.get(uuid).addVocRepresentation((Representation)elements[7]);
321
//                }
322
                if(elements[9]!=null){
323
                    dtoMap.get(uuid).addMedia(((Media) elements[9]).getUuid());
298 324
                }
299 325
            } else {
300 326
                // term representation
......
305 331
                }
306 332
                // term media
307 333
                Set<UUID> mediaUuids = new HashSet<>();
308
                if(elements[10] instanceof Media) {
309
                    mediaUuids.add(((Media) elements[10]).getUuid());
334
                if(elements[9] instanceof Media) {
335
                    mediaUuids.add(((Media) elements[9]).getUuid());
310 336
                }
311 337
                // voc representation
312
                Set<Representation> vocRepresentations = new HashSet<>();
313
                if(elements[7] instanceof Representation) {
314
                    vocRepresentations = new HashSet<Representation>(7);
315
                    vocRepresentations.add((Representation)elements[7]);
316
                }
338
//                Set<Representation> vocRepresentations = new HashSet<>();
339
//                if(elements[7] instanceof Representation) {
340
//                    vocRepresentations = new HashSet<Representation>(7);
341
//                    vocRepresentations.add((Representation)elements[7]);
342
//                }
317 343
                boolean isAvailableForTaxon = false;
318 344
                boolean isAvailableForTaxonName = false;
319 345
                boolean isAvailableForOccurrence = false;
320 346

  
321
                EnumSet<CdmClass> availableForString = (EnumSet<CdmClass>)elements[11];
347
                EnumSet<CdmClass> availableForString = (EnumSet<CdmClass>)elements[10];
322 348

  
323 349
                if (availableForString.contains(CdmClass.TAXON)){
324 350
                    isAvailableForTaxon = true;
......
332 358
                boolean isSupportsCategoricalData = false;
333 359
                boolean isSupportsQuantitativeData = false;
334 360

  
335
                EnumSet<CdmClass> supportsString = (EnumSet<CdmClass>)elements[13];
361
                EnumSet<CdmClass> supportsString = (EnumSet<CdmClass>)elements[12];
336 362

  
337 363
                if (supportsString.contains(CdmClass.CATEGORICAL_DATA)){
338 364
                    isSupportsCategoricalData = true;
......
341 367
                    isSupportsQuantitativeData = true;
342 368
                }
343 369

  
344
                Object o = elements[14];
370
                Object o = elements[13];
345 371
                Set<TermVocabularyDto> recommendedModifierDtos = new HashSet<>();
346 372
                if (o instanceof TermVocabulary){
347 373
                    recommendedModifierDtos.add(TermVocabularyDto.fromVocabulary((TermVocabulary)o));
......
356 382

  
357 383

  
358 384

  
359
                o = elements[15];
385
                o = elements[14];
360 386
                Set<TermDto> recommendedStatisticalMeasuresDtos = new HashSet<>();
361 387
                if (o instanceof StatisticalMeasure){
362 388
                    recommendedStatisticalMeasuresDtos.add(TermDto.fromTerm((StatisticalMeasure)o));
......
368 394
                        }
369 395
                    }
370 396
                }
371
                o =  elements[16];
397
                o =  elements[15];
372 398
                Set<TermVocabularyDto> supportedCategoricalDtos = new HashSet<>();
373 399
                if (o instanceof TermVocabulary){
374 400
                    supportedCategoricalDtos.add(TermVocabularyDto.fromVocabulary((TermVocabulary)o));
......
384 410
//                        supportedCategoricalDtos.add(TermVocabularyDto.fromVocabulary(voc));
385 411
//                    }
386 412
//                }
387
                o = elements[17];
413
                o = elements[16];
388 414
                Set<TermDto> recommendedMeasurementUnitsDtos = new HashSet<>();
389 415
                if (o instanceof MeasurementUnit){
390 416
                    recommendedMeasurementUnitsDtos.add(TermDto.fromTerm((MeasurementUnit)o));
391 417
                }else if (o instanceof Set){
392
                    Set<MeasurementUnit> recommendedMeasurementUnits = (Set<MeasurementUnit>) elements[17];
418
                    Set<MeasurementUnit> recommendedMeasurementUnits = (Set<MeasurementUnit>) elements[16];
393 419
                    for (MeasurementUnit term: recommendedMeasurementUnits){
394 420
                        recommendedMeasurementUnitsDtos.add(TermDto.fromTerm(term));
395 421
                    }
......
409 435
                        (UUID)elements[4],
410 436
                        (Integer)elements[5],
411 437
                        (String)elements[6],
412
                        vocRepresentations,
438
//                        vocRepresentations,
413 439
                        isAvailableForTaxon,
414 440
                        isAvailableForTaxonName,
415 441
                        isAvailableForOccurrence,
416
                        (String)elements[12],
442
                        (String)elements[11],
417 443
                        isSupportsCategoricalData,
418 444
                        isSupportsQuantitativeData,
419 445
                        supportedCategoricalDtos,
......
421 447
                        recommendedMeasurementUnitsDtos,
422 448
                        recommendedStatisticalMeasuresDtos)
423 449
                        ;
424
                termDto.setUri((URI)elements[9]);
450
                termDto.setUri((URI)elements[8]);
425 451
                termDto.setMedia(mediaUuids);
426 452

  
427 453

  

Also available in: Unified diff