X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/blobdiff_plain/b5b7a7b05ec528af9040c9ae458bf8141b531243..45546a913cf144912d383d54758aa51c81367ec9:/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/LocationServiceImpl.java diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/LocationServiceImpl.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/LocationServiceImpl.java index 67d141f239..9ddd10cd9d 100644 --- a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/LocationServiceImpl.java +++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/LocationServiceImpl.java @@ -1,9 +1,9 @@ // $Id$ /** * Copyright (C) 2007 EDIT -* European Distributed Institute of Taxonomy +* European Distributed Institute of Taxonomy * http://www.e-taxonomy.eu -* +* * The contents of this file are subject to the Mozilla Public License Version 1.1 * See LICENSE.TXT at the top of this package for the full license terms. */ @@ -24,8 +24,7 @@ import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper; import eu.etaxonomy.cdm.model.common.DefinedTermBase; import eu.etaxonomy.cdm.model.common.OrderedTermVocabulary; import eu.etaxonomy.cdm.model.common.TermVocabulary; -import eu.etaxonomy.cdm.model.description.AbsenceTerm; -import eu.etaxonomy.cdm.model.description.PresenceTerm; +import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; import eu.etaxonomy.cdm.model.location.NamedArea; import eu.etaxonomy.cdm.model.location.NamedAreaLevel; import eu.etaxonomy.cdm.model.location.NamedAreaType; @@ -34,139 +33,132 @@ import eu.etaxonomy.cdm.persistence.dao.common.IOrderedTermVocabularyDao; import eu.etaxonomy.cdm.persistence.dao.common.ITermVocabularyDao; /** - * Quick and dirty implementation of a location service as needed by the editor + * Quick and dirty implementation of a location service as needed by the editor. * + * NOTE: Current implementation does not support the IService methods like {@link #save(DefinedTermBase)} + * as no base dao is loaded by autowiring. + * * @author n.hoffman * @created 08.04.2009 * @version 1.0 */ @Service -@Transactional(readOnly=true) +@Transactional(readOnly = true) public class LocationServiceImpl extends ServiceBase implements ILocationService { - private static final Logger logger = Logger - .getLogger(LocationServiceImpl.class); - - @Autowired - protected ITermVocabularyDao vocabularyDao; - - @Autowired - protected IDefinedTermDao definedTermDao; - - @Autowired - protected IOrderedTermVocabularyDao orderedVocabularyDao; - - /* (non-Javadoc) - * @see eu.etaxonomy.cdm.api.service.ServiceBase#setDao(eu.etaxonomy.cdm.persistence.dao.common.ICdmEntityDao) - */ - @Override - protected void setDao(IDefinedTermDao dao) { - this.dao = dao; - } - - /** - * (non-Javadoc) - * @see eu.etaxonomy.cdm.api.service.ILocationService#getAbsenceTerms() - * FIXME Candidate for harmonization - * is this method a duplicate of termService.getVocabulary(VocabularyEnum.AbsenceTerm)? - */ - public OrderedTermVocabulary getAbsenceTermVocabulary() { - String uuidString = "5cd438c8-a8a1-4958-842e-169e83e2ceee"; - UUID uuid = UUID.fromString(uuidString); - OrderedTermVocabulary absenceTermVocabulary = - (OrderedTermVocabulary)orderedVocabularyDao.findByUuid(uuid); - return absenceTermVocabulary; - } - - - /** - * (non-Javadoc) - * @see eu.etaxonomy.cdm.api.service.ILocationService#getPresenceTermVocabulary() - * FIXME Candidate for harmonization - * is this method a duplicate of termService.getVocabulary(VocabularyEnum.PresenceTerm) - */ - public OrderedTermVocabulary getPresenceTermVocabulary() { - String uuidString = "adbbbe15-c4d3-47b7-80a8-c7d104e53a05"; - UUID uuid = UUID.fromString(uuidString); - OrderedTermVocabulary presenceTermVocabulary = - (OrderedTermVocabulary)orderedVocabularyDao.findByUuid(uuid); - return presenceTermVocabulary; - } - - /* (non-Javadoc) - * @see eu.etaxonomy.cdm.api.service.ILocationService#getNamedAreaVocabularyTypes() - */ - public List getNamedAreaVocabularyTypes() { - List result = new ArrayList(3); - result.add(NamedAreaVocabularyType.TDWG_AREA); - result.add(NamedAreaVocabularyType.WATERBODY_OR_COUNTRY); - result.add(NamedAreaVocabularyType.CONTINENT); - return result; - } - - /* (non-Javadoc) - * @see eu.etaxonomy.cdm.api.service.ILocationService#getNamedAreas(java.lang.Object) - */ - public OrderedTermVocabulary getNamedAreaVocabulary(NamedAreaVocabularyType vocabularyType) { - - UUID namedAreaVocabularyUuid = null; - - if(vocabularyType == NamedAreaVocabularyType.TDWG_AREA){ - namedAreaVocabularyUuid = UUID.fromString("1fb40504-d1d7-44b0-9731-374fbe6cac77"); - } - if(vocabularyType == NamedAreaVocabularyType.CONTINENT){ - namedAreaVocabularyUuid = UUID.fromString("e72cbcb6-58f8-4201-9774-15d0c6abc128"); - } - if(vocabularyType == NamedAreaVocabularyType.WATERBODY_OR_COUNTRY){ - namedAreaVocabularyUuid = UUID.fromString("006b1870-7347-4624-990f-e5ed78484a1a"); - } - - return (OrderedTermVocabulary)orderedVocabularyDao.findByUuid(namedAreaVocabularyUuid); - } - - /* (non-Javadoc) - * @see eu.etaxonomy.cdm.api.service.ILocationService#getNamedAreaLevelVocabulary() - */ - public OrderedTermVocabulary getNamedAreaLevelVocabulary() { - // TODO return namedAreaLevel filtered by NamedAreaVocabularyType - String uuidString = "49034253-27c8-4219-97e8-f8d987d3d122"; - UUID uuid = UUID.fromString(uuidString); - OrderedTermVocabulary namedAreaLevelVocabulary = - (OrderedTermVocabulary)orderedVocabularyDao.findByUuid(uuid); - return namedAreaLevelVocabulary; - } - - /** - * (non-Javadoc) - * @see eu.etaxonomy.cdm.api.service.ILocationService#getNamedAreaTypeVocabulary() - * FIXME Candidate for harmonization - * is this method a duplicate of termService.getVocabulary(VocabularyEnum.NamedAreaType) - */ - public TermVocabulary getNamedAreaTypeVocabulary() { - String uuidString = "e51d52d6-965b-4f7d-900f-4ba9c6f5dd33"; - UUID uuid = UUID.fromString(uuidString); - TermVocabulary namedAreaTypeVocabulary = - (OrderedTermVocabulary)orderedVocabularyDao.findByUuid(uuid); - return namedAreaTypeVocabulary; - } - - public List getTopLevelNamedAreasByVocabularyType(NamedAreaVocabularyType vocabularyType){ - - OrderedTermVocabulary vocabulary = getNamedAreaVocabulary(vocabularyType); - - List topLevelTerms = new ArrayList(); - -// for(NamedArea area : vocabulary){ - Iterator it = vocabulary.iterator(); - while(it.hasNext()){ - - NamedArea area = HibernateProxyHelper.deproxy(it.next(), NamedArea.class); - if(area.getPartOfWorkaround() == null){ - topLevelTerms.add(area); - } - } - - return topLevelTerms; - } + + @SuppressWarnings("unused") + private static final Logger logger = Logger.getLogger(LocationServiceImpl.class); + + @Autowired + protected ITermVocabularyDao vocabularyDao; + + @Autowired + protected IDefinedTermDao definedTermDao; + + @Autowired + protected IOrderedTermVocabularyDao orderedVocabularyDao; + + /* (non-Javadoc) + * @see eu.etaxonomy.cdm.api.service.ServiceBase#setDao(eu.etaxonomy.cdm.persistence.dao.common.ICdmEntityDao) + */ + @Override + protected void setDao(IDefinedTermDao dao) { + this.dao = dao; + } + + + /** + * (non-Javadoc) + * @see eu.etaxonomy.cdm.api.service.ILocationService#getPresenceTermVocabulary() + * FIXME Candidate for harmonization + * is this method a duplicate of termService.getVocabulary(VocabularyEnum.PresenceTerm) + */ + public OrderedTermVocabulary getPresenceAbsenceTermVocabulary() { + String uuidString = "adbbbe15-c4d3-47b7-80a8-c7d104e53a05"; + UUID uuid = UUID.fromString(uuidString); + OrderedTermVocabulary presenceTermVocabulary = + (OrderedTermVocabulary)orderedVocabularyDao.findByUuid(uuid); + return presenceTermVocabulary; + } + + /* (non-Javadoc) + * @see eu.etaxonomy.cdm.api.service.ILocationService#getNamedAreaVocabularyTypes() + */ + public List getNamedAreaVocabularyTypes() { + List result = new ArrayList(3); + result.add(NamedAreaVocabularyType.TDWG_AREA); + result.add(NamedAreaVocabularyType.COUNTRY); + result.add(NamedAreaVocabularyType.WATERBODY); + result.add(NamedAreaVocabularyType.CONTINENT); + return result; + } + + /* (non-Javadoc) + * @see eu.etaxonomy.cdm.api.service.ILocationService#getNamedAreas(java.lang.Object) + */ + public OrderedTermVocabulary getNamedAreaVocabulary(NamedAreaVocabularyType vocabularyType) { + + UUID namedAreaVocabularyUuid = null; + + if(vocabularyType == NamedAreaVocabularyType.TDWG_AREA){ + namedAreaVocabularyUuid = UUID.fromString("1fb40504-d1d7-44b0-9731-374fbe6cac77"); + } + if(vocabularyType == NamedAreaVocabularyType.CONTINENT){ + namedAreaVocabularyUuid = UUID.fromString("e72cbcb6-58f8-4201-9774-15d0c6abc128"); + } + if(vocabularyType == NamedAreaVocabularyType.COUNTRY){ + namedAreaVocabularyUuid = UUID.fromString("006b1870-7347-4624-990f-e5ed78484a1a"); + } + if(vocabularyType == NamedAreaVocabularyType.WATERBODY){ + namedAreaVocabularyUuid = UUID.fromString("35a62b25-f541-4f12-a7c7-17d90dec3e03"); + } + return (OrderedTermVocabulary)orderedVocabularyDao.findByUuid(namedAreaVocabularyUuid); + } + + /* (non-Javadoc) + * @see eu.etaxonomy.cdm.api.service.ILocationService#getNamedAreaLevelVocabulary() + */ + public OrderedTermVocabulary getNamedAreaLevelVocabulary() { + // TODO return namedAreaLevel filtered by NamedAreaVocabularyType + String uuidString = "49034253-27c8-4219-97e8-f8d987d3d122"; + UUID uuid = UUID.fromString(uuidString); + OrderedTermVocabulary namedAreaLevelVocabulary = + (OrderedTermVocabulary)orderedVocabularyDao.findByUuid(uuid); + return namedAreaLevelVocabulary; + } + + /** + * (non-Javadoc) + * @see eu.etaxonomy.cdm.api.service.ILocationService#getNamedAreaTypeVocabulary() + * FIXME Candidate for harmonization + * is this method a duplicate of termService.getVocabulary(VocabularyEnum.NamedAreaType) + */ + public TermVocabulary getNamedAreaTypeVocabulary() { + String uuidString = "e51d52d6-965b-4f7d-900f-4ba9c6f5dd33"; + UUID uuid = UUID.fromString(uuidString); + TermVocabulary namedAreaTypeVocabulary = + (OrderedTermVocabulary)orderedVocabularyDao.findByUuid(uuid); + return namedAreaTypeVocabulary; + } + + public List getTopLevelNamedAreasByVocabularyType(NamedAreaVocabularyType vocabularyType){ + + OrderedTermVocabulary vocabulary = getNamedAreaVocabulary(vocabularyType); + + List topLevelTerms = new ArrayList(); + +// for(NamedArea area : vocabulary){ + Iterator it = vocabulary.iterator(); + while(it.hasNext()){ + + NamedArea area = HibernateProxyHelper.deproxy(it.next(), NamedArea.class); + if(area.getPartOfWorkaround() == null){ + topLevelTerms.add(area); + } + } + + return topLevelTerms; + }