3 * Copyright (C) 2009 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.ext
;
12 import java
.awt
.Color
;
13 import java
.util
.ArrayList
;
14 import java
.util
.HashSet
;
15 import java
.util
.List
;
19 import org
.apache
.log4j
.Logger
;
20 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
21 import org
.springframework
.stereotype
.Service
;
22 import org
.springframework
.transaction
.annotation
.Transactional
;
24 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
25 import eu
.etaxonomy
.cdm
.model
.description
.Distribution
;
26 import eu
.etaxonomy
.cdm
.model
.description
.Feature
;
27 import eu
.etaxonomy
.cdm
.model
.description
.PresenceAbsenceTermBase
;
28 import eu
.etaxonomy
.cdm
.model
.description
.TaxonDescription
;
29 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
30 import eu
.etaxonomy
.cdm
.persistence
.dao
.common
.IDefinedTermDao
;
31 import eu
.etaxonomy
.cdm
.persistence
.dao
.description
.IDescriptionDao
;
34 * @author a.kohlbecker
39 @Transactional(readOnly
=true)
40 public class EditGeoService
implements IEditGeoService
{
41 public static final Logger logger
= Logger
.getLogger(EditGeoService
.class);
43 private static final String DEFAULT_BACK_LAYER
= "tdwg4";
46 private IDescriptionDao dao
;
48 private IDefinedTermDao termDao
;
50 private Set
<Feature
> getDistributionFeatures() {
51 Set
<Feature
> distributionFeature
= new HashSet
<Feature
>();
52 Feature feature
= (Feature
) termDao
.findByUuid(Feature
.DISTRIBUTION().getUuid());
53 distributionFeature
.add(feature
);
54 return distributionFeature
;
58 * @see eu.etaxonomy.cdm.ext.IEditGeoService#getEditGeoServiceUrlParameterString(java.util.List, java.util.Map, int, int, java.lang.String, java.lang.String, java.util.List)
60 public String
getEditGeoServiceUrlParameterString(
61 List
<TaxonDescription
> taxonDescriptions
,
62 Map
<PresenceAbsenceTermBase
<?
>, Color
> presenceAbsenceTermColors
,
63 int width
, int height
, String bbox
, String backLayer
,
64 List
<Language
> langs
) {
65 Set
<Distribution
> distributions
= new HashSet
<Distribution
>();
66 for(TaxonDescription taxonDescription
: taxonDescriptions
){
67 List
<Distribution
> result
= (List
)dao
.getDescriptionElements(taxonDescription
, getDistributionFeatures(), Distribution
.class, null, null, null);
68 distributions
.addAll(result
);
71 if(backLayer
== null){
72 backLayer
= DEFAULT_BACK_LAYER
;
74 String uriParams
= EditGeoServiceUtilities
.getEditGeoServiceUrlParameterString(distributions
, presenceAbsenceTermColors
, width
, height
, bbox
, backLayer
, langs
);
80 * @see eu.etaxonomy.cdm.ext.IEditGeoService#getEditGeoServiceUrlParameterString(eu.etaxonomy.cdm.model.description.TaxonDescription, java.util.Map, int, int, java.lang.String, java.lang.String)
82 public String
getEditGeoServiceUrlParameterString(
83 TaxonDescription taxonDescription
,
84 Map
<PresenceAbsenceTermBase
<?
>, Color
> presenceAbsenceTermColors
,
85 int width
, int height
, String bbox
, String backLayer
,
86 List
<Language
> langs
) {
88 List
<TaxonDescription
> taxonDescriptions
= new ArrayList
<TaxonDescription
>();
89 taxonDescriptions
.add(taxonDescription
);
91 return getEditGeoServiceUrlParameterString(taxonDescriptions
, presenceAbsenceTermColors
, width
, height
, bbox
, backLayer
, langs
);
95 * @see eu.etaxonomy.cdm.api.service.IEditGeoService#getEditGeoServiceUrlParameterString(eu.etaxonomy.cdm.model.taxon.Taxon, java.util.Map, int, int, java.lang.String, java.lang.String)
97 public String
getEditGeoServiceUrlParameterString(Taxon taxon
,
98 Map
<PresenceAbsenceTermBase
<?
>, Color
> presenceAbsenceTermColors
, int width
, int height
, String bbox
,
100 List
<Language
> langs
) {
102 List
<TaxonDescription
> taxonDescriptions
= dao
.getTaxonDescriptions(taxon
, null, null, null, null, null);
104 Set
<Distribution
> distCollection
= new HashSet
<Distribution
>();
105 // get descriptions elements for each description
106 for (TaxonDescription td
: taxonDescriptions
) {
107 List
<Distribution
> dists
= (List
)dao
.getDescriptionElements(td
, getDistributionFeatures(), Distribution
.class, null, null, null);
108 distCollection
.addAll(dists
);
110 // generate the uri parameter string
111 if(backLayer
== null){
112 backLayer
= DEFAULT_BACK_LAYER
;
114 String uriParams
= EditGeoServiceUtilities
.getEditGeoServiceUrlParameterString(distCollection
,
115 presenceAbsenceTermColors
, width
, height
, bbox
, backLayer
, langs
);