1 package eu
.etaxonomy
.cdm
.api
.service
;
5 import org
.apache
.log4j
.Logger
;
6 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
7 import org
.springframework
.context
.ApplicationContext
;
8 import org
.springframework
.context
.ApplicationContextAware
;
9 import org
.springframework
.stereotype
.Service
;
10 import org
.springframework
.transaction
.annotation
.Transactional
;
12 import eu
.etaxonomy
.cdm
.model
.common
.CdmBase
;
13 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
14 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
15 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.ICdmEntityDao
;
16 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.IDefinedTermDao
;
19 public abstract class ServiceBase
<T
extends CdmBase
> implements IService
<T
>, ApplicationContextAware
{
20 static Logger logger
= Logger
.getLogger(ServiceBase
.class);
22 protected ApplicationContext appContext
;
23 protected ICdmEntityDao
<T
> dao
;
25 protected void setEntityDao(ICdmEntityDao
<T
> dao
){
29 public void setApplicationContext(ApplicationContext appContext
){
30 this.appContext
= appContext
;
33 protected T
getCdmObjectByUuid(String uuid
){
34 return dao
.findByUuid(uuid
);
37 @Transactional(readOnly
= false)
38 protected String
saveCdmObject(T cdmObj
){
39 if (logger
.isDebugEnabled()){logger
.debug("Save cdmObj: " + (cdmObj
== null?
null: cdmObj
.toString()));}
40 return dao
.saveOrUpdate(cdmObj
);
43 protected List
<T
> list(int limit
, int start
) {
44 return dao
.list(limit
, start
);