1 |
78c2bf74
|
Katja Luther
|
/**
|
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 |
c4e812bc
|
ben.clark
|
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 |
2a56d8c1
|
ben.clark
|
import org.springframework.transaction.annotation.Propagation;
|
19 |
c4e812bc
|
ben.clark
|
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 |
79c0eaa0
|
Andreas Müller
|
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
|
24 |
c4e812bc
|
ben.clark
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
25 |
|
|
import eu.etaxonomy.cdm.model.common.Language;
|
26 |
40368de1
|
Cherian Mathew
|
import eu.etaxonomy.cdm.model.common.TermType;
|
27 |
c4e812bc
|
ben.clark
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
28 |
|
|
import eu.etaxonomy.cdm.model.common.VocabularyEnum;
|
29 |
|
|
import eu.etaxonomy.cdm.persistence.dao.common.ITermVocabularyDao;
|
30 |
|
|
import eu.etaxonomy.cdm.persistence.query.OrderHint;
|
31 |
f197a589
|
Andreas Müller
|
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
|
32 |
c4e812bc
|
ben.clark
|
|
33 |
|
|
@Service
|
34 |
77b4a247
|
Andreas Kohlbecker
|
@Transactional(readOnly = true)
|
35 |
c4e812bc
|
ben.clark
|
public class VocabularyServiceImpl extends IdentifiableServiceBase<TermVocabulary,ITermVocabularyDao> implements IVocabularyService {
|
36 |
|
|
|
37 |
|
|
@Autowired
|
38 |
|
|
protected void setDao(ITermVocabularyDao dao) {
|
39 |
|
|
this.dao = dao;
|
40 |
|
|
}
|
41 |
|
|
|
42 |
f197a589
|
Andreas Müller
|
|
43 |
b17d9121
|
Andreas Müller
|
@Override
|
44 |
8c1dd618
|
Andreas Müller
|
@Transactional(readOnly = false)
|
45 |
|
|
public void updateTitleCache(Class<? extends TermVocabulary> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<TermVocabulary> cacheStrategy, IProgressMonitor monitor) {
|
46 |
f197a589
|
Andreas Müller
|
if (clazz == null){
|
47 |
|
|
clazz = TermVocabulary.class;
|
48 |
|
|
}
|
49 |
|
|
super.updateTitleCacheImpl(clazz, stepSize, cacheStrategy, monitor);
|
50 |
c4e812bc
|
ben.clark
|
}
|
51 |
f197a589
|
Andreas Müller
|
|
52 |
888e5bec
|
Andreas Müller
|
@Override
|
53 |
49f9271a
|
ben.clark
|
public <TERM extends DefinedTermBase> List<TermVocabulary<TERM>> listByTermClass(Class<TERM> clazz, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
|
54 |
888e5bec
|
Andreas Müller
|
boolean includeSubclasses = false;
|
55 |
8fe5f6d5
|
Andreas Müller
|
boolean includeEmptyVocs = false;
|
56 |
|
|
return (List)listByTermClass(clazz, includeSubclasses, includeEmptyVocs, limit, start, orderHints, propertyPaths);
|
57 |
c4e812bc
|
ben.clark
|
}
|
58 |
888e5bec
|
Andreas Müller
|
|
59 |
c0a772b3
|
Andreas Müller
|
@Override
|
60 |
8fe5f6d5
|
Andreas Müller
|
public <TERM extends DefinedTermBase> List<TermVocabulary<? extends TERM>> listByTermClass(Class<TERM> clazz, boolean includeSubclasses, boolean includeEmptyVocs, Integer limit, Integer start, List<OrderHint> orderHints, List<String> propertyPaths) {
|
61 |
|
|
return dao.listByTermClass(clazz, includeSubclasses, includeEmptyVocs,limit, start, orderHints, propertyPaths);
|
62 |
888e5bec
|
Andreas Müller
|
}
|
63 |
c4e812bc
|
ben.clark
|
|
64 |
c0a772b3
|
Andreas Müller
|
@Override
|
65 |
40368de1
|
Cherian Mathew
|
public <T extends DefinedTermBase> List<TermVocabulary<T>> findByTermType(TermType termType) {
|
66 |
|
|
return dao.findByTermType(termType);
|
67 |
|
|
}
|
68 |
c4e812bc
|
ben.clark
|
/**
|
69 |
|
|
* (non-Javadoc)
|
70 |
|
|
* @see eu.etaxonomy.cdm.api.service.ITermService#getLanguageVocabulary()
|
71 |
|
|
* FIXME candidate for harmonization
|
72 |
|
|
* is this the same as getVocabulary(VocabularyEnum.Language)
|
73 |
|
|
*/
|
74 |
c0a772b3
|
Andreas Müller
|
@Override
|
75 |
c4e812bc
|
ben.clark
|
public TermVocabulary<Language> getLanguageVocabulary() {
|
76 |
|
|
String uuidString = "45ac7043-7f5e-4f37-92f2-3874aaaef2de";
|
77 |
|
|
UUID uuid = UUID.fromString(uuidString);
|
78 |
|
|
TermVocabulary<Language> languageVocabulary = (TermVocabulary)dao.findByUuid(uuid);
|
79 |
|
|
return languageVocabulary;
|
80 |
|
|
}
|
81 |
|
|
|
82 |
c0a772b3
|
Andreas Müller
|
@Override
|
83 |
c4e812bc
|
ben.clark
|
public Pager<DefinedTermBase> getTerms(TermVocabulary vocabulary, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
|
84 |
|
|
Integer numberOfResults = dao.countTerms(vocabulary);
|
85 |
|
|
|
86 |
|
|
List<DefinedTermBase> results = new ArrayList<DefinedTermBase>();
|
87 |
76de813f
|
Andreas Kohlbecker
|
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
|
88 |
c4e812bc
|
ben.clark
|
results = dao.getTerms(vocabulary, pageSize, pageNumber,orderHints,propertyPaths);
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
return new DefaultPagerImpl<DefinedTermBase>(pageNumber, numberOfResults, pageSize, results);
|
92 |
|
|
}
|
93 |
|
|
|
94 |
|
|
}
|