Project

General

Profile

Download (3.27 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

    
10
package eu.etaxonomy.cdm.api.service;
11

    
12
import java.util.ArrayList;
13
import java.util.List;
14
import java.util.UUID;
15

    
16
import org.springframework.beans.factory.annotation.Autowired;
17
import org.springframework.stereotype.Service;
18
import org.springframework.transaction.annotation.Transactional;
19

    
20
import eu.etaxonomy.cdm.api.service.pager.Pager;
21
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;
22
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
23
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
24
import eu.etaxonomy.cdm.model.common.Language;
25
import eu.etaxonomy.cdm.model.common.TermType;
26
import eu.etaxonomy.cdm.model.common.TermVocabulary;
27
import eu.etaxonomy.cdm.persistence.dao.common.ITermVocabularyDao;
28
import eu.etaxonomy.cdm.persistence.query.OrderHint;
29
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
30

    
31
@Service
32
@Transactional(readOnly = true)
33
public class VocabularyServiceImpl extends IdentifiableServiceBase<TermVocabulary,ITermVocabularyDao>  implements IVocabularyService {
34

    
35
	@Override
36
    @Autowired
37
	protected void setDao(ITermVocabularyDao dao) {
38
		this.dao = dao;
39
	}
40

    
41

    
42
	@Override
43
	@Transactional(readOnly = false)
44
    public void updateTitleCache(Class<? extends TermVocabulary> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<TermVocabulary> cacheStrategy, IProgressMonitor monitor) {
45
		if (clazz == null){
46
			clazz = TermVocabulary.class;
47
		}
48
		super.updateTitleCacheImpl(clazz, stepSize, cacheStrategy, monitor);
49
	}
50

    
51

    
52
    @Override
53
    public List<TermVocabulary> listByTermType(TermType termType, boolean includeSubTypes,
54
            Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
55
        return dao.listByTermType(termType, includeSubTypes, limit, start, orderHints, propertyPaths);
56
    }
57

    
58
    @Override
59
	public <T extends DefinedTermBase> List<TermVocabulary<T>> findByTermType(TermType termType) {
60
		return dao.findByTermType(termType);
61
	}
62
	/**
63
	 * (non-Javadoc)
64
	 * @see eu.etaxonomy.cdm.api.service.ITermService#getLanguageVocabulary()
65
	 * FIXME candidate for harmonization
66
	 * is this the same as getVocabulary(VocabularyEnum.Language)
67
	 */
68
	@Override
69
	public TermVocabulary<Language> getLanguageVocabulary() {
70
		String uuidString = "45ac7043-7f5e-4f37-92f2-3874aaaef2de";
71
		UUID uuid = UUID.fromString(uuidString);
72
		TermVocabulary<Language> languageVocabulary = dao.findByUuid(uuid);
73
		return languageVocabulary;
74
	}
75

    
76
	@Override
77
	public Pager<DefinedTermBase> getTerms(TermVocabulary vocabulary, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,	List<String> propertyPaths) {
78
        Integer numberOfResults = dao.countTerms(vocabulary);
79

    
80
		List<DefinedTermBase> results = new ArrayList<DefinedTermBase>();
81
		if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
82
			results = dao.getTerms(vocabulary, pageSize, pageNumber,orderHints,propertyPaths);
83
		}
84

    
85
		return new DefaultPagerImpl<DefinedTermBase>(pageNumber, numberOfResults, pageSize, results);
86
	}
87

    
88
}
(91-91/92)