Project

General

Profile

Download (2.86 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.Set;
15
import java.util.UUID;
16

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

    
21
import eu.etaxonomy.cdm.api.service.pager.Pager;
22
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;
23
import eu.etaxonomy.cdm.model.agent.Address;
24
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
25
import eu.etaxonomy.cdm.model.common.Language;
26
import eu.etaxonomy.cdm.model.common.TermVocabulary;
27
import eu.etaxonomy.cdm.model.common.VocabularyEnum;
28
import eu.etaxonomy.cdm.persistence.dao.common.ITermVocabularyDao;
29
import eu.etaxonomy.cdm.persistence.query.OrderHint;
30

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

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

    
40
	public void generateTitleCache() {
41
		// TODO Auto-generated method stub
42
	}
43
	
44
	public TermVocabulary<DefinedTermBase> getVocabulary(VocabularyEnum vocabularyType){
45
		return dao.findByUuid(vocabularyType.getUuid());
46
	}
47
	
48
	public <TERM extends DefinedTermBase> List<TermVocabulary<TERM>> listByTermClass(Class<TERM> clazz, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
49
		return dao.listByTermClass(clazz, limit, start, orderHints, propertyPaths);
50
	}	
51
	
52
	/** 
53
	 * (non-Javadoc)
54
	 * @see eu.etaxonomy.cdm.api.service.ITermService#getLanguageVocabulary()
55
	 * FIXME candidate for harmonization
56
	 * is this the same as getVocabulary(VocabularyEnum.Language)
57
	 */
58
	public TermVocabulary<Language> getLanguageVocabulary() {
59
		String uuidString = "45ac7043-7f5e-4f37-92f2-3874aaaef2de";
60
		UUID uuid = UUID.fromString(uuidString);
61
		TermVocabulary<Language> languageVocabulary = (TermVocabulary)dao.findByUuid(uuid);
62
		return languageVocabulary;
63
	}
64

    
65
	public Pager<DefinedTermBase> getTerms(TermVocabulary vocabulary, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints,	List<String> propertyPaths) {
66
        Integer numberOfResults = dao.countTerms(vocabulary);
67
		
68
		List<DefinedTermBase> results = new ArrayList<DefinedTermBase>();
69
		if(numberOfResults > 0) { // no point checking again
70
			results = dao.getTerms(vocabulary, pageSize, pageNumber,orderHints,propertyPaths); 
71
		}
72
			
73
		return new DefaultPagerImpl<DefinedTermBase>(pageNumber, numberOfResults, pageSize, results);
74
	}
75

    
76
}
(48-48/48)