3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
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.
11 package eu
.etaxonomy
.cdm
.api
.service
;
13 import java
.util
.ArrayList
;
14 import java
.util
.List
;
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
;
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
.monitor
.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
;
34 @Transactional(readOnly
=true, propagation
= Propagation
.SUPPORTS
)
35 public class MediaServiceImpl
extends IdentifiableServiceBase
<Media
,IMediaDao
> implements IMediaService
{
38 protected void setDao(IMediaDao dao
) {
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
);
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
);
50 return new DefaultPagerImpl
<MediaKey
>(pageNumber
, numberOfResults
, pageSize
, results
);
53 public Pager
<Rights
> getRights(Media t
, Integer pageSize
, Integer pageNumber
, List
<String
> propertyPaths
) {
54 Integer numberOfResults
= dao
.countRights(t
);
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
);
61 return new DefaultPagerImpl
<Rights
>(pageNumber
, numberOfResults
, pageSize
, results
);
65 * @see eu.etaxonomy.cdm.api.service.IIdentifiableEntityService#updateTitleCache(java.lang.Integer, eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy)
68 @Transactional(readOnly
= false)
69 public void updateTitleCache(Class
<?
extends Media
> clazz
, Integer stepSize
, IIdentifiableEntityCacheStrategy
<Media
> cacheStrategy
, IProgressMonitor monitor
) {
70 //IIdentifiableEntityCacheStrategy<Media> cacheStrategy = MediaDefaultCacheStrategy();
74 super.updateTitleCacheImpl(clazz
, stepSize
, cacheStrategy
, monitor
);