1
|
// $Id$
|
2
|
/**
|
3
|
* Copyright (C) 2007 EDIT
|
4
|
* European Distributed Institute of Taxonomy
|
5
|
* http://www.e-taxonomy.eu
|
6
|
*
|
7
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
8
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
9
|
*/
|
10
|
|
11
|
package eu.etaxonomy.cdm.api.service;
|
12
|
|
13
|
import java.util.ArrayList;
|
14
|
import java.util.List;
|
15
|
import java.util.Set;
|
16
|
|
17
|
import org.springframework.beans.factory.annotation.Autowired;
|
18
|
import org.springframework.stereotype.Service;
|
19
|
import org.springframework.transaction.annotation.Propagation;
|
20
|
import org.springframework.transaction.annotation.Transactional;
|
21
|
|
22
|
import eu.etaxonomy.cdm.api.service.pager.Pager;
|
23
|
import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;
|
24
|
import eu.etaxonomy.cdm.common.IProgressMonitor;
|
25
|
import eu.etaxonomy.cdm.model.description.MediaKey;
|
26
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
27
|
import eu.etaxonomy.cdm.model.media.Media;
|
28
|
import eu.etaxonomy.cdm.model.media.Rights;
|
29
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
30
|
import eu.etaxonomy.cdm.persistence.dao.media.IMediaDao;
|
31
|
import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
|
32
|
|
33
|
@Service
|
34
|
@Transactional(readOnly=true, propagation = Propagation.SUPPORTS)
|
35
|
public class MediaServiceImpl extends IdentifiableServiceBase<Media,IMediaDao> implements IMediaService {
|
36
|
|
37
|
@Autowired
|
38
|
protected void setDao(IMediaDao dao) {
|
39
|
this.dao = dao;
|
40
|
}
|
41
|
|
42
|
public Pager<MediaKey> getMediaKeys(Set<Taxon> taxonomicScope, Set<NamedArea> geoScopes, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
|
43
|
Integer numberOfResults = dao.countMediaKeys(taxonomicScope, geoScopes);
|
44
|
|
45
|
List<MediaKey> results = new ArrayList<MediaKey>();
|
46
|
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
|
47
|
results = dao.getMediaKeys(taxonomicScope, geoScopes, pageSize, pageNumber, propertyPaths);
|
48
|
}
|
49
|
|
50
|
return new DefaultPagerImpl<MediaKey>(pageNumber, numberOfResults, pageSize, results);
|
51
|
}
|
52
|
|
53
|
public Pager<Rights> getRights(Media t, Integer pageSize, Integer pageNumber, List<String> propertyPaths) {
|
54
|
Integer numberOfResults = dao.countRights(t);
|
55
|
|
56
|
List<Rights> results = new ArrayList<Rights>();
|
57
|
if(numberOfResults > 0) { // no point checking again //TODO use AbstractPagerImpl.hasResultsInRange(numberOfResults, pageNumber, pageSize)
|
58
|
results = dao.getRights(t, pageSize, pageNumber,propertyPaths);
|
59
|
}
|
60
|
|
61
|
return new DefaultPagerImpl<Rights>(pageNumber, numberOfResults, pageSize, results);
|
62
|
}
|
63
|
|
64
|
/* (non-Javadoc)
|
65
|
* @see eu.etaxonomy.cdm.api.service.IIdentifiableEntityService#updateTitleCache(java.lang.Integer, eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy)
|
66
|
*/
|
67
|
@Override
|
68
|
public void updateTitleCache(Class<? extends Media> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<Media> cacheStrategy, IProgressMonitor monitor) {
|
69
|
//IIdentifiableEntityCacheStrategy<Media> cacheStrategy = MediaDefaultCacheStrategy();
|
70
|
if (clazz == null){
|
71
|
clazz = Media.class;
|
72
|
}
|
73
|
super.updateTitleCacheImpl(clazz, stepSize, cacheStrategy, monitor);
|
74
|
}
|
75
|
}
|