+// $Id$\r
/**\r
-* Copyright (C) 2007 EDIT\r
-* European Distributed Institute of Taxonomy \r
-* http://www.e-taxonomy.eu\r
-* \r
-* The contents of this file are subject to the Mozilla Public License Version 1.1\r
-* See LICENSE.TXT at the top of this package for the full license terms.\r
-*/\r
+ * Copyright (C) 2007 EDIT\r
+ * European Distributed Institute of Taxonomy\r
+ * http://www.e-taxonomy.eu\r
+ *\r
+ * The contents of this file are subject to the Mozilla Public License Version 1.1\r
+ * See LICENSE.TXT at the top of this package for the full license terms.\r
+ */\r
\r
package eu.etaxonomy.cdm.api.service;\r
\r
-import java.util.Collection;\r
import java.util.List;\r
-import java.util.Map;\r
import java.util.UUID;\r
\r
import org.apache.log4j.Logger;\r
import org.springframework.stereotype.Service;\r
import org.springframework.transaction.annotation.Transactional;\r
\r
-import eu.etaxonomy.cdm.model.reference.ReferenceBase;\r
-import eu.etaxonomy.cdm.persistence.dao.common.ICdmEntityDao;\r
+import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;\r
+import eu.etaxonomy.cdm.model.reference.Reference;\r
+import eu.etaxonomy.cdm.model.taxon.TaxonBase;\r
+import eu.etaxonomy.cdm.persistence.dao.common.ICdmGenericDao;\r
import eu.etaxonomy.cdm.persistence.dao.reference.IReferenceDao;\r
+import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;\r
+import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;\r
\r
\r
@Service\r
@Transactional(readOnly = true)\r
-public class ReferenceServiceImpl<T extends ReferenceBase> extends IdentifiableServiceBase<T> implements IReferenceService<T> {\r
-//public class ReferenceServiceImpl extends ServiceBase<ReferenceBase> implements IReferenceService {\r
- static Logger logger = Logger.getLogger(ReferenceServiceImpl.class);\r
- \r
- private IReferenceDao referenceDao;\r
- \r
- @Autowired\r
- protected void setDao(IReferenceDao dao) {\r
- this.dao = (ICdmEntityDao)dao;\r
- this.referenceDao = dao;\r
- }\r
-\r
- public ReferenceBase getReferenceByUuid(UUID uuid) {\r
- return super.getCdmObjectByUuid(uuid); \r
- }\r
-\r
- public List<T> getReferencesByTitle(String title) {\r
- return super.findCdmObjectsByTitle(title);\r
- }\r
- \r
- public List<T> getReferencesByTitle(String title, Class<T> clazz) {\r
- return super.findCdmObjectsByTitle(title, clazz);\r
- }\r
- \r
- @Transactional(readOnly = false)\r
- public UUID saveReference(T reference) {\r
- return super.saveCdmObject(reference);\r
- }\r
-\r
- @Transactional(readOnly = false)\r
- public Map<UUID, T> saveReferenceAll(Collection<T> referenceCollection){\r
- return saveCdmObjectAll(referenceCollection);\r
- }\r
-\r
- public List<ReferenceBase> getAllReferences(int limit, int start){\r
- return referenceDao.list(limit, start);\r
- }\r
-\r
-\r
- public void generateTitleCache() {\r
- logger.warn("Not yet implemented");\r
- // TODO Auto-generated method stub\r
- \r
- }\r
+public class ReferenceServiceImpl extends IdentifiableServiceBase<Reference,IReferenceDao> implements IReferenceService {\r
\r
+ static Logger logger = Logger.getLogger(ReferenceServiceImpl.class);\r
\r
+ @Autowired\r
+ private ICdmGenericDao genericDao;\r
+ /**\r
+ * Constructor\r
+ */\r
+ public ReferenceServiceImpl(){\r
+ if (logger.isDebugEnabled()) { logger.debug("Load ReferenceService Bean"); }\r
+ }\r
+\r
+ @Override\r
+ @Transactional(readOnly = false)\r
+ public void updateTitleCache(Class<? extends Reference> clazz, Integer stepSize, IIdentifiableEntityCacheStrategy<Reference> cacheStrategy, IProgressMonitor monitor) {\r
+ if (clazz == null){\r
+ clazz = Reference.class;\r
+ }\r
+ super.updateTitleCacheImpl(clazz, stepSize, cacheStrategy, monitor);\r
+ }\r
+\r
+\r
+ @Override\r
+ protected void setOtherCachesNull(Reference ref) {\r
+ if (! ref.isProtectedAbbrevTitleCache()){\r
+ ref.setAbbrevTitleCache(null, false);\r
+ }\r
+ }\r
+\r
+\r
+ @Override\r
+ @Autowired\r
+ protected void setDao(IReferenceDao dao) {\r
+ this.dao = dao;\r
+ }\r
+\r
+ @Override\r
+ public List<UuidAndTitleCache<Reference>> getUuidAndTitle() {\r
+\r
+ return dao.getUuidAndTitle();\r
+ }\r
+\r
+ @Override\r
+ public List<Reference> getAllReferencesForPublishing(){\r
+ return dao.getAllNotNomenclaturalReferencesForPublishing();\r
+ }\r
+\r
+ @Override\r
+ public List<Reference> getAllNomenclaturalReferences() {\r
+\r
+ return dao.getAllNomenclaturalReferences();\r
+ }\r
+\r
+ @Override\r
+ public List<TaxonBase> listCoveredTaxa(Reference reference, boolean includeSubordinateReferences, List<String> propertyPaths) {\r
+\r
+ List<TaxonBase> taxonList = dao.listCoveredTaxa(reference, includeSubordinateReferences, null, propertyPaths);\r
+\r
+ return taxonList;\r
+ }\r
+\r
+ @Override\r
+ public DeleteResult delete(Reference reference) {\r
+ //check whether the reference is used somewhere\r
+ DeleteResult result = isDeletable(reference, null);\r
+\r
+ if (result.isOk()){\r
+ dao.delete(reference);\r
+ }\r
+\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ @Transactional(readOnly=false)\r
+ public DeleteResult delete(UUID referenceUuid) {\r
+ return delete(dao.load(referenceUuid));\r
+ }\r
}\r