Project

General

Profile

« Previous | Next » 

Revision dfd8da23

Added by Katja Luther over 2 years ago

ref #9814: add vocDto to termDto

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermDto.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.location.NamedArea;
22 23
import eu.etaxonomy.cdm.model.location.NamedAreaLevel;
23 24
import eu.etaxonomy.cdm.model.media.Media;
......
57 58
//        this(uuid, representations, termType, partOfUuid, kindOfUuid, vocabularyUuid, orderIndex, idInVocabulary, titleCache);
58 59
//    }
59 60

  
60
    protected TermDto(UUID uuid, Set<Representation> representations, TermType termType, UUID partOfUuid, UUID kindOfUuid,
61
            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary, String titleCache) {
61
    public TermDto(UUID uuid, Set<Representation> representations, TermType termType, UUID partOfUuid, UUID kindOfUuid,
62
            UUID vocabularyUuid, Integer orderIndex, String idInVocabulary,  String titleCache) {
62 63
        super(uuid, representations, titleCache);
63 64
        this.partOfUuid = partOfUuid;
64 65
        this.kindOfUuid = kindOfUuid;
65 66
        this.vocabularyUuid = vocabularyUuid;
66 67
        this.orderIndex = orderIndex;
67 68
        this.idInVocabulary = idInVocabulary;
68
//        this.vocRepresentations = vocRepresentations;
69
//        this.vocabularyDto = vocDto;
69 70
        setTermType(termType);
70 71
    }
71 72

  
......
88 89
        DefinedTermBase<?> partOf = term.getPartOf();
89 90
        DefinedTermBase<?> kindOf = term.getKindOf();
90 91
        TermVocabulary<?> vocabulary = term.getVocabulary();
92
        if (representations == null){
93
            term = HibernateProxyHelper.deproxy(term, DefinedTermBase.class);
94
            representations = term.getRepresentations();
95
        }
91 96

  
92 97
        TermDto dto = new TermDto(
93 98
                        term.getUuid(),
......
97 102
                        (kindOf!=null?kindOf.getUuid():null),
98 103
                        (vocabulary!=null?vocabulary.getUuid():null),
99 104
                        (term instanceof OrderedTermBase)?((OrderedTermBase<?>) term).getOrderIndex():null,
100
                         term.getIdInVocabulary(), term.getTitleCache());
105
                         term.getIdInVocabulary(),
106
                         term.getTitleCache());
101 107
        dto.setUri(term.getUri());
102 108
        if(initializeToTop){
103 109
            if(partOf!=null){
......
113 119
        if(term.getMedia()!=null){
114 120
            Collection<UUID> mediaUuids = new HashSet<>();
115 121
            Set<Media> media = term.getMedia();
116
            for (Media medium : media) {
117
                mediaUuids.add(medium.getUuid());
118
            }
119
            dto.setMedia(mediaUuids);
122

  
123
                for (Media medium : media) {
124
                    mediaUuids.add(medium.getUuid());
125
                }
126
                dto.setMedia(mediaUuids);
127

  
120 128
        }
121 129
        if (term instanceof NamedArea && ((NamedArea)term).getLevel() != null){
122 130
            dto.setLevel(((NamedArea)term).getLevel());
......
270 278
                + "v.uuid, "
271 279
                + "a.orderIndex, "
272 280
                + "a.idInVocabulary, "
273
//                + "voc_rep,  "
274 281
                + "a.termType,  "
275 282
                + "a.uri,  "
276 283
                + "m,  "
277 284
                + "a.titleCache ";
285

  
278 286
        String sqlFromString =   " FROM "+fromTable+" as a ";
279 287

  
280 288
        String sqlJoinString =  "LEFT JOIN a.partOf as p "
......
282 290
                + "LEFT JOIN a.media as m "
283 291
                + "LEFT JOIN a.representations AS r "
284 292
                + "LEFT JOIN a.vocabulary as v "
285
//                + "LEFT JOIN v.representations as voc_rep "
293

  
286 294
                ;
287 295

  
288 296
        String[] result = new String[3];
......
308 316
                if(elements[1]!=null){
309 317
                    dtoMap.get(uuid).addRepresentation((Representation)elements[1]);
310 318
                }
311
//                if(elements[7]!=null){
312
//                    dtoMap.get(uuid).addVocRepresentation((Representation)elements[7]);
313
//                }
319

  
314 320
                if(elements[9]!=null){
315 321
                    dtoMap.get(uuid).addMedia(((Media) elements[9]).getUuid());
316 322
                }
......
326 332
                if(elements[9] instanceof Media) {
327 333
                    mediaUuids.add(((Media) elements[9]).getUuid());
328 334
                }
329
                // voc representation
330
//                Set<Representation> vocRepresentations = new HashSet<>();
331
//                if(elements[7] instanceof Representation) {
332
//                    vocRepresentations = new HashSet<>(7);
333
//                    vocRepresentations.add((Representation)elements[7]);
334
//                }
335

  
336

  
335 337
                TermDto termDto = new TermDto(
336 338
                        uuid,
337 339
                        representations,
......
341 343
                        (UUID)elements[4],
342 344
                        (Integer)elements[5],
343 345
                        (String)elements[6],
344
//                        vocRepresentations,
345 346
                        (String)elements[10]);
346 347
                termDto.setUri((URI)elements[8]);
347 348
                termDto.setMedia(mediaUuids);

Also available in: Unified diff