// $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.List;\r
+import java.util.UUID;\r
\r
import org.apache.log4j.Logger;\r
import org.springframework.beans.factory.annotation.Autowired;\r
import org.springframework.stereotype.Service;\r
-import org.springframework.transaction.annotation.Propagation;\r
import org.springframework.transaction.annotation.Transactional;\r
\r
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;\r
-import eu.etaxonomy.cdm.model.common.UuidAndTitleCache;\r
-import eu.etaxonomy.cdm.model.description.PolytomousKey;\r
-import eu.etaxonomy.cdm.model.name.TaxonNameBase;\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 extends IdentifiableServiceBase<Reference,IReferenceDao> implements IReferenceService {\r
- \r
- static Logger logger = Logger.getLogger(ReferenceServiceImpl.class);\r
-\r
- /**\r
- * Constructor\r
- */\r
- public ReferenceServiceImpl(){\r
- if (logger.isDebugEnabled()) { logger.debug("Load ReferenceService Bean"); }\r
- }\r
-\r
- /* (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.api.service.IIdentifiableEntityService#updateTitleCache(java.lang.Integer, eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy)\r
- */\r
- @Override\r
- @Transactional(readOnly = false)\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
- @Autowired\r
- protected void setDao(IReferenceDao dao) {\r
- this.dao = dao;\r
- }\r
-\r
- public List<UuidAndTitleCache<Reference>> getUuidAndTitle() {\r
- \r
- return dao.getUuidAndTitle();\r
- }\r
- \r
- public List<Reference> getAllReferencesForPublishing(){\r
- return dao.getAllNotNomenclaturalReferencesForPublishing();\r
- }\r
-\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
+ 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