1
|
/**
|
2
|
* Copyright (C) 2007 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.Collection;
|
13
|
import java.util.List;
|
14
|
import java.util.Map;
|
15
|
import java.util.Set;
|
16
|
import java.util.UUID;
|
17
|
|
18
|
import org.apache.log4j.Logger;
|
19
|
import org.springframework.beans.factory.annotation.Autowired;
|
20
|
import org.springframework.stereotype.Service;
|
21
|
import org.springframework.transaction.annotation.Transactional;
|
22
|
|
23
|
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
|
24
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
25
|
import eu.etaxonomy.cdm.persistence.dao.common.IDefinedTermDao;
|
26
|
import eu.etaxonomy.cdm.persistence.dao.common.ITermVocabularyDao;
|
27
|
|
28
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
29
|
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
30
|
|
31
|
@Service
|
32
|
@Transactional(readOnly = true)
|
33
|
public class TermServiceImpl extends ServiceBase<DefinedTermBase> implements ITermService{
|
34
|
static Logger logger = Logger.getLogger(TermServiceImpl.class);
|
35
|
|
36
|
protected ITermVocabularyDao vocabularyDao;
|
37
|
|
38
|
@Autowired
|
39
|
protected void setVocabularyDao(ITermVocabularyDao vocabularyDao) {
|
40
|
this.vocabularyDao = vocabularyDao;
|
41
|
}
|
42
|
|
43
|
@Autowired
|
44
|
protected void setDao(IDefinedTermDao dao) {
|
45
|
this.dao = dao;
|
46
|
}
|
47
|
|
48
|
/* (non-Javadoc)
|
49
|
* @see eu.etaxonomy.cdm.api.service.ITermService#getTermByUri(java.lang.String)
|
50
|
*/
|
51
|
public DefinedTermBase getTermByUri(String uri) {
|
52
|
//FIXME transformation from URI to UUID
|
53
|
return DefinedTermBase.findByUuid(UUID.fromString(uri));
|
54
|
}
|
55
|
|
56
|
/* (non-Javadoc)
|
57
|
* @see eu.etaxonomy.cdm.api.service.ITermService#getTermByUuid(java.util.UUID)
|
58
|
*/
|
59
|
public DefinedTermBase getTermByUuid(UUID uuid) {
|
60
|
return DefinedTermBase.findByUuid(uuid);
|
61
|
}
|
62
|
|
63
|
public List<DefinedTermBase> getAllDefinedTerms(int limit, int start){
|
64
|
return dao.list(limit, start);
|
65
|
}
|
66
|
|
67
|
@Transactional(readOnly = false)
|
68
|
public UUID saveTerm(DefinedTermBase termBase) {
|
69
|
return super.saveCdmObject(termBase);
|
70
|
}
|
71
|
|
72
|
@Transactional(readOnly = false)
|
73
|
public Map<UUID, DefinedTermBase> saveTermsAll(Collection<DefinedTermBase> termBaseCollection){
|
74
|
return saveCdmObjectAll(termBaseCollection);
|
75
|
}
|
76
|
|
77
|
/* (non-Javadoc)
|
78
|
* @see eu.etaxonomy.cdm.api.service.ITermService#getVocabulary(java.util.UUID)
|
79
|
*/
|
80
|
public TermVocabulary getVocabulary(UUID vocabularyUuid) {
|
81
|
TermVocabulary vocabulary = (OrderedTermVocabulary)vocabularyDao.findByUuid(vocabularyUuid);
|
82
|
return vocabulary;
|
83
|
}
|
84
|
|
85
|
/* (non-Javadoc)
|
86
|
* @see eu.etaxonomy.cdm.api.service.ITermService#listVocabularies(java.lang.Class)
|
87
|
*/
|
88
|
public Set<TermVocabulary> listVocabularies(Class termClass) {
|
89
|
logger.error("Method not implemented yet");
|
90
|
return null;
|
91
|
}
|
92
|
|
93
|
|
94
|
}
|