2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.api
.service
;
12 import java
.util
.ArrayList
;
13 import java
.util
.List
;
15 import org
.apache
.log4j
.Logger
;
17 import eu
.etaxonomy
.cdm
.api
.service
.pager
.Pager
;
18 import eu
.etaxonomy
.cdm
.api
.service
.pager
.impl
.DefaultPagerImpl
;
19 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
20 import eu
.etaxonomy
.cdm
.model
.common
.ISourceable
;
21 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
22 import eu
.etaxonomy
.cdm
.model
.common
.OriginalSource
;
23 import eu
.etaxonomy
.cdm
.model
.media
.Rights
;
24 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.IIdentifiableDao
;
26 public abstract class IdentifiableServiceBase
<T
extends IdentifiableEntity
,DAO
extends IIdentifiableDao
<T
>> extends AnnotatableServiceBase
<T
,DAO
>
27 implements IIdentifiableEntityService
<T
>{
28 @SuppressWarnings("unused")
29 private static final Logger logger
= Logger
.getLogger(IdentifiableServiceBase
.class);
32 public Pager
<Rights
> getRights(T t
, Integer pageSize
, Integer pageNumber
) {
33 Integer numberOfResults
= dao
.countRights(t
);
35 List
<Rights
> results
= new ArrayList
<Rights
>();
36 if(numberOfResults
> 0) { // no point checking again
37 results
= dao
.getRights(t
, pageSize
, pageNumber
);
40 return new DefaultPagerImpl
<Rights
>(pageNumber
, numberOfResults
, pageSize
, results
);
43 public Pager
<OriginalSource
> getSources(T t
, Integer pageSize
, Integer pageNumber
) {
44 Integer numberOfResults
= dao
.countSources(t
);
46 List
<OriginalSource
> results
= new ArrayList
<OriginalSource
>();
47 if(numberOfResults
> 0) { // no point checking again
48 results
= dao
.getSources(t
, pageSize
, pageNumber
);
51 return new DefaultPagerImpl
<OriginalSource
>(pageNumber
, numberOfResults
, pageSize
, results
);
54 protected List
<T
> findCdmObjectsByTitle(String title
){
55 return ((IIdentifiableDao
)dao
).findByTitle(title
);
58 protected List
<T
> findCdmObjectsByTitle(String title
, Class
<T
> clazz
){
59 return ((IIdentifiableDao
)dao
).findByTitleAndClass(title
, clazz
);
61 protected List
<T
> findCdmObjectsByTitle(String title
, CdmBase sessionObject
){
62 return ((IIdentifiableDao
)dao
).findByTitle(title
, sessionObject
);
66 * TODO - Migrated from CommonServiceBase
68 * @see eu.etaxonomy.cdm.api.service.ICommonService#getSourcedObjectById(java.lang.String, java.lang.String)
70 public ISourceable
getSourcedObjectByIdInSource(Class clazz
, String idInSource
, String idNamespace
) {
71 ISourceable result
= null;
73 List
<T
> list
= dao
.findOriginalSourceByIdInSource(idInSource
, idNamespace
);
74 if (! list
.isEmpty()){