import org.codehaus.jackson.map.type.TypeFactory;\r
\r
import eu.etaxonomy.cdm.api.service.ITermService;\r
+import eu.etaxonomy.cdm.api.service.dto.CondensedDistribution;\r
import eu.etaxonomy.cdm.api.utility.DescriptionUtility;\r
import eu.etaxonomy.cdm.common.CdmUtils;\r
import eu.etaxonomy.cdm.model.common.Language;\r
-import eu.etaxonomy.cdm.model.common.Marker;\r
-import eu.etaxonomy.cdm.model.common.MarkerType;\r
import eu.etaxonomy.cdm.model.common.Representation;\r
import eu.etaxonomy.cdm.model.common.TermVocabulary;\r
import eu.etaxonomy.cdm.model.description.Distribution;\r
static final String VALUE_SUPER_LIST_ENTRY_SEPARATOR = "||";\r
\r
\r
-\r
- //preliminary implementation for TDWG areas\r
/**\r
* Returns the parameter String for the EDIT geo webservice to create a\r
- * dsitribution map.\r
+ * distribution map.\r
*\r
* @param distributions\r
* A set of distributions that should be shown on the map\r
- * @param subAreaPreference\r
- * enables the <b>Sub area preference rule</b> if set to true,\r
- * see {@link DescriptionUtility#filterDistributions(Collection,\r
- * boolean, boolean}\r
+ * The {@link DescriptionUtility} class provides a method for\r
+ * filtering a set of Distributions :\r
*\r
- * @param statusOrderPreference\r
- * enables the <b>Status order preference rule</b> if set to\r
- * true, see {@link\r
- * DescriptionUtility#filterDistributions(Collection, boolean,\r
- * boolean}\r
- * @param hideMarkedAreas\r
- * distributions where the area has a {@link Marker} with one of\r
- * the specified {@link MarkerType}s will be skipped, see\r
- * {@link DescriptionUtility#filterDistributions(Collection, boolean, boolean, Set)}\r
+ * {@code\r
+ * Collection<Distribution> filteredDistributions =\r
+ * DescriptionUtility.filterDistributions(distributions,\r
+ * subAreaPreference, statusOrderPreference, hideMarkedAreas);\r
+ * }\r
+ * @param mapping\r
+ * Data regarding the mapping of NamedAreas to shape file\r
+ * attribute tables\r
* @param presenceAbsenceTermColors\r
* A map that defines the colors of PresenceAbsenceTerms. The\r
* PresenceAbsenceTerms are defined by their uuid. If a\r
* PresenceAbsenceTerm is not included in this map, it's default\r
* color is taken instead. If the map == null all terms are\r
* colored by their default color.\r
- * @param width\r
- * The maps width\r
- * @param height\r
- * The maps height\r
- * @param bbox\r
- * The maps bounding box (e.g. "-180,-90,180,90" for the whole\r
- * world)\r
* @param projectToLayer\r
* name of a layer which is representing a specific\r
* {@link NamedAreaLevel} Supply this parameter if you to project\r
* all other distribution area levels to this layer.\r
- * @param layer\r
- * The layer that is responsible for background borders and\r
- * colors. Use the name for the layer. If null 'earth' is taken\r
- * as default.\r
+ * @param languages\r
+ *\r
* @return the parameter string or an empty string if the\r
* <code>distributions</code> set was null or empty.\r
*/\r
@Transient\r
public static String getDistributionServiceRequestParameterString(\r
- Set<Distribution> distributions,\r
- boolean subAreaPreference,\r
- boolean statusOrderPreference,\r
- Set<MarkerType> hideMarkedAreas,\r
+ Collection<Distribution> filteredDistributions,\r
IGeoServiceAreaMapping mapping,\r
Map<PresenceAbsenceTerm,Color> presenceAbsenceTermColors,\r
- String projectToLayer, List<Language> languages){\r
+ String projectToLayer,\r
+ List<Language> languages){\r
\r
\r
/*\r
\r
\r
//handle empty set\r
- if(distributions == null || distributions.size() == 0){\r
+ if(filteredDistributions == null || filteredDistributions.size() == 0){\r
return "";\r
}\r
\r
presenceAbsenceTermColors = mergeMaps(getDefaultPresenceAbsenceTermBaseColors(), presenceAbsenceTermColors);\r
\r
- Collection<Distribution> filteredDistributions = DescriptionUtility.filterDistributions(distributions, subAreaPreference, statusOrderPreference, hideMarkedAreas);\r
-\r
Map<String, Map<Integer, Set<Distribution>>> layerMap = new HashMap<String, Map<Integer, Set<Distribution>>>();\r
List<PresenceAbsenceTerm> statusList = new ArrayList<PresenceAbsenceTerm>();\r
\r
* &od=1%3A44.29481%2C6.82161|44.29252%2C6.822873|44.29247%2C6.82346|44.29279%2C6.823678|44.29269%2C6.82394|44.28482%2C6.887252|44.11469%2C7.287144|44.11468%2C7.289168\r
* &os=1%3Ac%2FFFD700%2F10%2FAporrectodea caliginosa\r
*/\r
- public static String getOccurrenceServiceRequestParameterString(\r
- List<Point> fieldUnitPoints,\r
- List<Point> derivedUnitPoints,\r
- Map<SpecimenOrObservationType, Color> specimenOrObservationTypeColors) {\r
+ public static OccurrenceServiceRequestParameterDto getOccurrenceServiceRequestParameterString(\r
+ List<Point> fieldUnitPoints,\r
+ List<Point> derivedUnitPoints,\r
+ Map<SpecimenOrObservationType, Color> specimenOrObservationTypeColors) {\r
+ OccurrenceServiceRequestParameterDto dto = new OccurrenceServiceRequestParameterDto();\r
\r
- specimenOrObservationTypeColors = mergeMaps(getDefaultSpecimenOrObservationTypeColors(), specimenOrObservationTypeColors);\r
\r
- Map<String, String> parameters = new HashMap<String, String>();\r
- parameters.put("legend", "0");\r
+ specimenOrObservationTypeColors = mergeMaps(getDefaultSpecimenOrObservationTypeColors(), specimenOrObservationTypeColors);\r
\r
- Map<String, String> styleAndData = new HashMap<String, String>();\r
+ Map<String, String> parameters = new HashMap<String, String>();\r
+ parameters.put("legend", "0");\r
\r
- addToStyleAndData(fieldUnitPoints, SpecimenOrObservationType.FieldUnit, specimenOrObservationTypeColors, styleAndData);\r
- addToStyleAndData(derivedUnitPoints, SpecimenOrObservationType.DerivedUnit, specimenOrObservationTypeColors, styleAndData);\r
+ Map<String, String> styleAndData = new HashMap<String, String>();\r
\r
- parameters.put("os", StringUtils.join(styleAndData.keySet().iterator(), "||"));\r
- parameters.put("od", StringUtils.join(styleAndData.values().iterator(), "||"));\r
+ addToStyleAndData(fieldUnitPoints, SpecimenOrObservationType.FieldUnit, specimenOrObservationTypeColors, styleAndData);\r
+ addToStyleAndData(derivedUnitPoints, SpecimenOrObservationType.DerivedUnit, specimenOrObservationTypeColors, styleAndData);\r
\r
- String queryString = makeQueryString(parameters);\r
+ parameters.put("os", StringUtils.join(styleAndData.keySet().iterator(), "||"));\r
+ parameters.put("od", StringUtils.join(styleAndData.values().iterator(), "||"));\r
\r
- logger.info(queryString);\r
+ String queryString = makeQueryString(parameters);\r
\r
- return queryString;\r
+ dto.setFieldUnitPoints(fieldUnitPoints);\r
+ dto.setDerivedUnitPoints(derivedUnitPoints);\r
+ dto.setOccurrenceQuery(queryString);\r
+\r
+ logger.info(queryString);\r
+\r
+ return dto;\r
}\r
\r
/**\r
return presenceAbsenceTermColors;\r
}\r
\r
+\r
+ /**\r
+ * @param filteredDistributions\r
+ * @param recipe\r
+ * @param hideMarkedAreas\r
+ * @param langs\r
+ * @return\r
+ */\r
+ public static CondensedDistribution getCondensedDistribution(Collection<Distribution> filteredDistributions,\r
+ CondensedDistributionRecipe recipe, List<Language> langs) {\r
+ ICondensedDistributionComposer composer;\r
+ if(recipe == null) {\r
+ throw new NullPointerException("parameter recipe must not be null");\r
+ }\r
+ try {\r
+ composer = recipe.newCondensedDistributionComposerInstance();\r
+ } catch (InstantiationException e) {\r
+ throw new RuntimeException(e);\r
+ } catch (IllegalAccessException e) {\r
+ throw new RuntimeException(e);\r
+ }\r
+ CondensedDistribution condensedDistribution = composer.createCondensedDistribution(\r
+ filteredDistributions, langs);\r
+ return condensedDistribution;\r
+ }\r
+\r
}\r