// $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.ArrayList;\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.api.service.pager.Pager;\r
-import eu.etaxonomy.cdm.api.service.pager.impl.DefaultPagerImpl;\r
-import eu.etaxonomy.cdm.model.name.BotanicalName;\r
-import eu.etaxonomy.cdm.model.name.HybridRelationship;\r
-import eu.etaxonomy.cdm.model.name.HybridRelationshipType;\r
-import eu.etaxonomy.cdm.model.reference.ReferenceBase;\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.query.OrderHint;\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<ReferenceBase,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
- /**\r
- * FIXME Candidate for harmonization\r
- * find\r
- */\r
- public ReferenceBase getReferenceByUuid(UUID uuid) {\r
- return super.getCdmObjectByUuid(uuid); \r
- }\r
-\r
- /**\r
- * FIXME Candidate for harmonization\r
- * getByTitle?\r
- */\r
- public List<ReferenceBase> getReferencesByTitle(String title) {\r
- return super.findCdmObjectsByTitle(title);\r
- }\r
- \r
- public List<ReferenceBase> getReferencesByTitle(String title, Class<ReferenceBase> clazz) {\r
- return super.findCdmObjectsByTitle(title, clazz);\r
- }\r
- \r
- /**\r
- * FIXME Candidate for harmonization\r
- * save\r
- */\r
- @Transactional(readOnly = false)\r
- public UUID saveReference(ReferenceBase reference) {\r
- return super.saveCdmObject(reference);\r
- }\r
-\r
- /**\r
- * FIXME Candidate for harmonization\r
- * save(Set<Reference> references)\r
- */\r
- @Transactional(readOnly = false)\r
- public Map<UUID, ReferenceBase> saveReferenceAll(Collection<ReferenceBase> referenceCollection){\r
- return saveCdmObjectAll(referenceCollection);\r
- }\r
-\r
- /**\r
- * FIXME Candidate for harmonization\r
- * list()\r
- * (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.api.service.IReferenceService#getAllReferences(int, int)\r
- */\r
- @Deprecated\r
- public List<ReferenceBase> getAllReferences(int limit, int start){\r
- return dao.list(limit, start);\r
- }\r
- \r
- /**\r
- * FIXME Candidate for harmonization\r
- * list\r
- * (non-Javadoc)\r
- * @see eu.etaxonomy.cdm.api.service.IReferenceService#getAllReferences(java.lang.Integer, java.lang.Integer)\r
- */\r
- public Pager<ReferenceBase> getAllReferences(Integer pageSize, Integer pageNumber, List<OrderHint> orderHints) {\r
- Integer numberOfResults = dao.count();\r
- \r
- List<ReferenceBase> results = new ArrayList<ReferenceBase>();\r
- if(numberOfResults > 0) { // no point checking again\r
- Integer start = pageSize == null ? 0 : pageSize * (pageNumber - 1);\r
- results = dao.list(pageSize, start, orderHints); //TODO implement pager like method in dao?\r
- }\r
- return new DefaultPagerImpl<ReferenceBase>(pageNumber, numberOfResults, pageSize, results);\r
- }\r
-\r
- /**\r
- * FIXME Candidate for harmonization\r
- * list\r
- */\r
- public Pager<ReferenceBase> getAllReferences(Integer pageSize, Integer pageNumber) {\r
- return getAllReferences(pageSize, pageNumber, null);\r
- }\r
-\r
- public void generateTitleCache() {\r
- logger.warn("Not yet implemented");\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- @Autowired\r
- protected void setDao(IReferenceDao dao) {\r
- this.dao = dao;\r
- }\r
- \r
- public Pager<ReferenceBase> search(Class<? extends ReferenceBase> clazz, String queryString, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {\r
- Integer numberOfResults = dao.count(clazz,queryString);\r
- \r
- List<ReferenceBase> results = new ArrayList<ReferenceBase>();\r
- if(numberOfResults > 0) { // no point checking again\r
- results = dao.search(clazz,queryString, pageSize, pageNumber, orderHints, propertyPaths); \r
- }\r
- \r
- return new DefaultPagerImpl<ReferenceBase>(pageNumber, numberOfResults, pageSize, results);\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