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.ArrayList;
|
13
|
import java.util.Collection;
|
14
|
import java.util.List;
|
15
|
import java.util.Map;
|
16
|
import java.util.Set;
|
17
|
import java.util.UUID;
|
18
|
|
19
|
import org.apache.log4j.Logger;
|
20
|
import org.springframework.beans.factory.annotation.Autowired;
|
21
|
import org.springframework.beans.factory.annotation.Qualifier;
|
22
|
import org.springframework.stereotype.Service;
|
23
|
import org.springframework.transaction.annotation.Transactional;
|
24
|
|
25
|
import eu.etaxonomy.cdm.model.common.Language;
|
26
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
27
|
import eu.etaxonomy.cdm.model.common.LanguageStringBase;
|
28
|
import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary;
|
29
|
import eu.etaxonomy.cdm.model.common.Representation;
|
30
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
31
|
import eu.etaxonomy.cdm.model.common.VersionableEntity;
|
32
|
import eu.etaxonomy.cdm.persistence.dao.common.IDefinedTermDao;
|
33
|
import eu.etaxonomy.cdm.persistence.dao.common.ILanguageStringBaseDao;
|
34
|
import eu.etaxonomy.cdm.persistence.dao.common.ILanguageStringDao;
|
35
|
import eu.etaxonomy.cdm.persistence.dao.common.IRepresentationDao;
|
36
|
import eu.etaxonomy.cdm.persistence.dao.common.ITermVocabularyDao;
|
37
|
|
38
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
39
|
|
40
|
@Service
|
41
|
@Transactional(readOnly = true)
|
42
|
public class TermServiceImpl extends ServiceBase<DefinedTermBase> implements ITermService{
|
43
|
static Logger logger = Logger.getLogger(TermServiceImpl.class);
|
44
|
|
45
|
protected ITermVocabularyDao vocabularyDao;
|
46
|
@Autowired
|
47
|
@Qualifier("langStrBaseDao")
|
48
|
private ILanguageStringBaseDao languageStringBaseDao;
|
49
|
@Autowired
|
50
|
private IRepresentationDao representationDao;
|
51
|
@Autowired
|
52
|
private ILanguageStringDao languageStringDao;
|
53
|
@Autowired
|
54
|
private IDefinedTermDao definedTermDao;
|
55
|
|
56
|
@Autowired
|
57
|
protected void setVocabularyDao(ITermVocabularyDao vocabularyDao) {
|
58
|
this.vocabularyDao = vocabularyDao;
|
59
|
}
|
60
|
|
61
|
@Autowired
|
62
|
protected void setDao(IDefinedTermDao dao) {
|
63
|
this.dao = dao;
|
64
|
this.definedTermDao = dao;
|
65
|
}
|
66
|
|
67
|
/* (non-Javadoc)
|
68
|
* @see eu.etaxonomy.cdm.api.service.ITermService#getTermByUri(java.lang.String)
|
69
|
*/
|
70
|
public DefinedTermBase getTermByUri(String uri) {
|
71
|
//FIXME transformation from URI to UUID
|
72
|
return DefinedTermBase.findByUuid(UUID.fromString(uri));
|
73
|
}
|
74
|
|
75
|
/* (non-Javadoc)
|
76
|
* @see eu.etaxonomy.cdm.api.service.ITermService#getTermByUuid(java.util.UUID)
|
77
|
*/
|
78
|
public DefinedTermBase getTermByUuid(UUID uuid) {
|
79
|
return DefinedTermBase.findByUuid(uuid);
|
80
|
}
|
81
|
|
82
|
public List<DefinedTermBase> getAllDefinedTerms(int limit, int start){
|
83
|
return dao.list(limit, start);
|
84
|
}
|
85
|
|
86
|
@Transactional(readOnly = false)
|
87
|
public UUID saveTerm(DefinedTermBase termBase) {
|
88
|
return super.saveCdmObject(termBase);
|
89
|
}
|
90
|
|
91
|
@Transactional(readOnly = false)
|
92
|
public Map<UUID, DefinedTermBase> saveTermsAll(Collection<DefinedTermBase> termBaseCollection){
|
93
|
return saveCdmObjectAll(termBaseCollection);
|
94
|
}
|
95
|
|
96
|
/* (non-Javadoc)
|
97
|
* @see eu.etaxonomy.cdm.api.service.ITermService#getVocabulary(java.util.UUID)
|
98
|
*/
|
99
|
public TermVocabulary getVocabulary(UUID vocabularyUuid) {
|
100
|
TermVocabulary vocabulary = (OrderedTermVocabulary)vocabularyDao.findByUuid(vocabularyUuid);
|
101
|
return vocabulary;
|
102
|
}
|
103
|
|
104
|
/* (non-Javadoc)
|
105
|
* @see eu.etaxonomy.cdm.api.service.ITermService#listVocabularies(java.lang.Class)
|
106
|
*/
|
107
|
public Set<TermVocabulary> listVocabularies(Class termClass) {
|
108
|
logger.error("Method not implemented yet");
|
109
|
return null;
|
110
|
}
|
111
|
|
112
|
public List<TermVocabulary<DefinedTermBase>> getAllTermVocabularies(int limit, int start) {
|
113
|
return vocabularyDao.list(limit, start);
|
114
|
}
|
115
|
|
116
|
public Map<UUID, TermVocabulary<DefinedTermBase>>
|
117
|
saveTermVocabulariesAll(Collection<TermVocabulary<DefinedTermBase>> termVocabularies) {
|
118
|
return vocabularyDao.saveAll(termVocabularies);
|
119
|
}
|
120
|
|
121
|
// @Transactional(readOnly = false)
|
122
|
// public Map<UUID, Representation> saveRepresentationsAll(Collection<Representation> representations){
|
123
|
// return representationDao.saveAll(representations);
|
124
|
// }
|
125
|
|
126
|
@Transactional(readOnly = false)
|
127
|
public Map<UUID, LanguageStringBase> saveLanguageDataAll(Collection<LanguageStringBase> languageData) {
|
128
|
return languageStringBaseDao.saveAll(languageData);
|
129
|
}
|
130
|
|
131
|
@Transactional(readOnly = false)
|
132
|
public Map<UUID, Representation> saveRepresentationAll(Collection<Representation> representations) {
|
133
|
return representationDao.saveAll(representations);
|
134
|
}
|
135
|
|
136
|
public List<Representation> getAllRepresentations(int limit, int start){
|
137
|
return representationDao.list(limit, start);
|
138
|
}
|
139
|
|
140
|
public List<LanguageString> getAllLanguageStrings(int limit, int start) {
|
141
|
return languageStringDao.list(limit, start);
|
142
|
}
|
143
|
|
144
|
public Map<UUID, LanguageStringBase>
|
145
|
saveLanguageStringBasesAll(Collection<LanguageStringBase> languageStringBases) {
|
146
|
return languageStringBaseDao.saveAll(languageStringBases);
|
147
|
}
|
148
|
|
149
|
public Language getLanguageByIso(String iso639) {
|
150
|
return definedTermDao.getLanguageByIso(iso639);
|
151
|
}
|
152
|
|
153
|
@Transactional(readOnly = false)
|
154
|
public UUID saveLanguageData(
|
155
|
LanguageStringBase languageData) {
|
156
|
return languageStringBaseDao.save(languageData);
|
157
|
}
|
158
|
|
159
|
}
|