Project

General

Profile

Revision b6ea6bbc

IDb6ea6bbc6bd1925a6a99c1c92658abdcca63c91c
Parent ff159227
Child bbd7e287

Added by Katja Luther over 1 year ago

ref #8385: methods for better voc selection pref pages

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/term/TermVocabularyDaoImpl.java
22 22
import org.hibernate.Criteria;
23 23
import org.hibernate.Query;
24 24
import org.hibernate.Session;
25
import org.hibernate.criterion.Disjunction;
25 26
import org.hibernate.criterion.Order;
26 27
import org.hibernate.criterion.Restrictions;
27 28
import org.hibernate.envers.query.AuditEntity;
......
399 400
        return dto;
400 401
    }
401 402

  
403
    @Override
404
    public List<TermVocabularyDto> findVocabularyDtoByUuids(List<UUID> vocUuids) {
405
        Session session = getSession();
406
        Criteria crit = session.createCriteria(type);
407
        Disjunction or = Restrictions.disjunction();
408
        for (UUID uuid: vocUuids){
409
            or.add(Restrictions.or(Restrictions.eq("uuid", uuid)));
410
        }
411
        crit.add(or);
412
        crit.addOrder(Order.desc("created"));
413
        List<TermVocabulary> result = crit.list();
414

  
415
        if (result.size() == 0){
416
            return null;
417
        }
418
        List<TermVocabularyDto> dtos = new ArrayList<>();
419
        for (TermVocabulary voc: result){
420
            TermVocabularyDto dto = new TermVocabularyDto(voc.getUuid(), voc.getRepresentations(), voc.getTermType());
421
            for (Object o: voc.getTerms()){
422
                DefinedTermBase term = (DefinedTermBase)o;
423
                dto.addTerm(TermDto.fromTerm(term));
424
            }
425
            dtos.add(dto);
426

  
427
        }
428
        return dtos;
429
    }
430

  
402 431
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/term/ITermVocabularyDao.java
163 163
    public TermVocabularyDto findVocabularyDtoByUuid(UUID vocUuid);
164 164

  
165 165
    /**
166
     * Returns list of term vocabularies for list of UUIDs
167
     *
168
     * @param vocUuids the {@link UUID} of the vocabularies
169
     * @return term vocabularies
170
     */
171
    public List<TermVocabularyDto> findVocabularyDtoByUuids(List<UUID> vocUuids);
172

  
173
    /**
166 174
     *
167 175
     * Like {@link #getUuidAndTitleCache(Class, Integer, String)} but filtering
168 176
     * the results by {@link TermType} of the vocabularies.
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dto/TermDto.java
88 88
                        term.getTermType(),
89 89
                        (partOf!=null?partOf.getUuid():null),
90 90
                        (kindOf!=null?kindOf.getUuid():null),
91
                        vocabulary.getUuid(),
91
                        (vocabulary!=null?vocabulary.getUuid():null),
92 92
                        (term instanceof OrderedTermBase)?((OrderedTermBase) term).getOrderIndex():null,
93 93
                         term.getIdInVocabulary());
94 94
        dto.setUri(term.getUri());
......
100 100
                dto.setKindOfDto(fromTerm(kindOf, initializeToTop));
101 101
            }
102 102
        }
103
        dto.setVocabularyDto(new TermVocabularyDto(vocabulary.getUuid(), vocabulary.getRepresentations(), term.getTermType()));
103
        if (vocabulary != null){
104
            dto.setVocabularyDto(new TermVocabularyDto(vocabulary.getUuid(), vocabulary.getRepresentations(), term.getTermType()));
105
        }
104 106
        if(term.getMedia()!=null){
105 107
            Collection<UUID> mediaUuids = new HashSet<>();
106 108
            Set<Media> media = term.getMedia();
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IVocabularyService.java
153 153
     * @param vocUuid
154 154
     * @return
155 155
     */
156
    TermVocabularyDto findVocabularyDtoByVocabularyUuid(UUID vocUuid);
156
    public TermVocabularyDto findVocabularyDtoByVocabularyUuid(UUID vocUuid);
157

  
158
    /**
159
     * @param vocUuid
160
     * @return
161
     */
162
    public List<TermVocabularyDto> findVocabularyDtoByVocabularyUuids(List<UUID> vocUuid);
157 163

  
158 164
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/VocabularyServiceImpl.java
172 172
            Integer limit, String pattern) {
173 173
        return dao.getUuidAndTitleCache(clazz, termType, limit, pattern);
174 174
    }
175

  
176

  
177
    @Override
178
    public List<TermVocabularyDto> findVocabularyDtoByVocabularyUuids(List<UUID> vocUuids) {
179
        return dao.findVocabularyDtoByUuids(vocUuids);
180
    }
175 181
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)