+
+ @Override
+ public Collection<TermDto> getTopLevelTerms(UUID vocabularyUuid) {
+ return dao.getTopLevelTerms(vocabularyUuid);
+ }
+
+ @Override
+ public Collection<TermDto> getTerms(UUID vocabularyUuid) {
+ return dao.getTerms(vocabularyUuid);
+ }
+
+ @Override
+ public Collection<TermDto> getTerms(List<UUID> vocabularyUuids) {
+ return dao.getTerms(vocabularyUuids);
+ }
+
+ @Override
+ public Collection<TermDto> getNamedAreaTerms(List<UUID> vocabularyUuids) {
+ return dao.getNamedAreaTerms(vocabularyUuids);
+ }
+
+ @Override
+ public List<TermDto> getCompleteTermHierarchy(TermVocabularyDto vocabularyDto) {
+ List<TermDto> topLevelTerms = dao.getTopLevelTerms(vocabularyDto.getUuid(), vocabularyDto.getTermType());
+ for (TermDto termDto : topLevelTerms) {
+ termDto.setVocabularyDto(vocabularyDto);
+ initializeIncludes(termDto);
+ initializeGeneralizationOf(termDto);
+ }
+
+ return topLevelTerms;
+ }
+
+ private void initializeGeneralizationOf(TermDto parentTerm){
+ Collection<TermDto> generalizationOf = termService.getKindOfsAsDto(parentTerm);
+ parentTerm.setGeneralizationOf(generalizationOf);
+ generalizationOf.forEach(generalization->{
+ generalization.setVocabularyDto(parentTerm.getVocabularyDto());
+ generalization.setKindOfDto(parentTerm);
+ initializeGeneralizationOf(generalization);
+ });
+ }
+
+ private void initializeIncludes(TermDto parentTerm){
+ Collection<TermDto> includes = termService.getIncludesAsDto(parentTerm);
+ parentTerm.setIncludes(includes);
+ includes.forEach(include->{
+ include.setVocabularyDto(parentTerm.getVocabularyDto());
+ initializeIncludes(include);
+ include.setPartOfDto(parentTerm);
+ });
+ }
+
+ @Override
+ public List<TermVocabularyDto> findVocabularyDtoByTermType(TermType termType) {
+ return findVocabularyDtoByTermTypes(Collections.singleton(termType), true);
+ }
+
+ @Override
+ public List<TermVocabularyDto> findVocabularyDtoByTermTypeAndPattern(String pattern, TermType termType) {
+ return dao.findVocabularyDtoByTermTypes(Collections.singleton(termType), pattern, true);
+ }
+
+ @Override
+ public List<TermVocabularyDto> findVocabularyDtoByTermTypes(Set<TermType> termTypes) {
+ return findVocabularyDtoByTermTypes(termTypes, true);
+ }
+
+ @Override
+ public List<TermVocabularyDto> findVocabularyDtoByTermType(TermType termType, boolean includeSubtypes) {
+ return findVocabularyDtoByTermTypes(Collections.singleton(termType), includeSubtypes);
+ }
+
+ @Override
+ public List<TermVocabularyDto> findVocabularyDtoByTermTypes(Set<TermType> termTypes, boolean includeSubtypes) {
+ return dao.findVocabularyDtoByTermTypes(termTypes, includeSubtypes);
+ }
+
+ @Override
+ public List<TermVocabularyDto> findFeatureVocabularyDtoByTermTypes(Set<CdmClass> availableFor) {
+ return dao.findVocabularyDtoByAvailableFor(availableFor);
+ }
+
+ @Override
+ public TermVocabularyDto findVocabularyDtoByVocabularyUuid(UUID vocUuid) {
+ return dao.findVocabularyDtoByUuid(vocUuid);
+ }
+
+ @Transactional(readOnly = false)
+ @Override
+ public TermDto addNewTerm(TermType termType, UUID vocabularyUUID) {
+ DefinedTermBase<?> term = termType.getEmptyDefinedTermBase();
+ termService.save(term);
+ TermVocabulary vocabulary = dao.load(vocabularyUUID);
+ vocabulary.addTerm(term);
+ dao.saveOrUpdate(vocabulary);
+ return TermDto.fromTerm(term, true);
+ }
+
+ @Override
+ public <S extends TermVocabulary> List<UuidAndTitleCache<S>> getUuidAndTitleCache(Class<S> clazz, TermType termType,
+ Integer limit, String pattern) {
+ return dao.getUuidAndTitleCache(clazz, termType, limit, pattern);
+ }
+
+ @Override
+ public List<TermVocabularyDto> findVocabularyDtoByVocabularyUuids(List<UUID> vocUuids) {
+ return dao.findVocabularyDtoByUuids(vocUuids);
+ }