Class GeoMapBean

java.lang.Object
io.goobi.viewer.managedbeans.GeoMapBean
All Implemented Interfaces:
IPolyglott, Serializable

@Named @ViewScoped public class GeoMapBean extends Object implements Serializable, IPolyglott
Bean for managing GeoMaps in the admin Backend.
Author:
Florian Alpers
See Also:
  • Constructor Details

    • GeoMapBean

      public GeoMapBean()
      Creates a new GeoMapBean instance.
  • Method Details

    • getCurrentMap

      public GeoMap getCurrentMap()
      Getter for the field currentMap.
      Returns:
      the GeoMap currently being edited, or null if none is selected
    • setCurrentMap

      public void setCurrentMap(GeoMap currentMap)
      Sets the current map to a clone of the given map.
      Parameters:
      currentMap - the GeoMap to clone and set as the currently edited map
    • setCurrentMapId

      public void setCurrentMapId(Long mapId) throws DAOException
      If a GeoMap of the given mapId exists in the database, set the current map to a clone of that map.
      Parameters:
      mapId - database ID of the map to load
      Throws:
      DAOException
    • getCurrentMapId

      public Long getCurrentMapId()
      getCurrentMapId.
      Returns:
      ID of the currently loaded map
    • saveCurrentMap

      public void saveCurrentMap() throws DAOException
      Saves the current map. Either add it to database if it has no id yet, or otherwise update it in the database.
      Throws:
      DAOException
    • deleteMap

      public void deleteMap(GeoMap map) throws DAOException
      deleteMap.
      Parameters:
      map - GeoMap to delete from the database
      Throws:
      DAOException
    • getEditMapUrl

      public String getEditMapUrl(GeoMap map)
      getEditMapUrl.
      Parameters:
      map - GeoMap whose edit URL to build
      Returns:
      Map edit URL
    • resetCurrentMap

      public void resetCurrentMap() throws DAOException
      If the current map has an id, restore the map from the database, removing all unsaved changes. If the current map exists but has no id, set the current map to a new empty map.
      Throws:
      DAOException
    • createEmptyCurrentMap

      public void createEmptyCurrentMap()
      Sets the currentMap to a new empty GeoMap.
    • getSelectedLanguage

      public Locale getSelectedLanguage()
      Getter for the field selectedLanguage.
      Returns:
      the locale representing the language currently selected for editing map translations
    • setSelectedLanguage

      public void setSelectedLanguage(Locale selectedLanguage)
      Setter for the field selectedLanguage.
      Parameters:
      selectedLanguage - the locale representing the language selected for editing map translations
    • getAllMaps

      public List<GeoMap> getAllMaps() throws DAOException
      Gets a list of all GeoMaps from the databse. Note that the databse is queries at each method call.
      Returns:
      a list of all stored GeoMaps
      Throws:
      DAOException
    • getPossibleMapTypes

      public Collection<GeoMap.GeoMapType> getPossibleMapTypes()
      getPossibleMapTypes.
      Returns:
      the collection of all available geo map type values
    • getPossibleMarkers

      public Collection<GeoMapMarker> getPossibleMarkers()
      getPossibleMarkers.
      Returns:
      the collection of all configured geo map marker definitions
    • hasCurrentFeature

      public boolean hasCurrentFeature()
      hasCurrentFeature.
      Returns:
      true if a current GeoJSON feature is selected in the editor, false otherwise
    • isInUse

      public boolean isInUse(GeoMap map) throws DAOException
      isInUse.
      Parameters:
      map - GeoMap to check for usage in CMS pages
      Returns:
      true if the given map is referenced by at least one CMS page, false otherwise
      Throws:
      DAOException - if any.
    • getEmbeddingCmsPages

      public List<CMSPage> getEmbeddingCmsPages(GeoMap map) throws DAOException
      getEmbeddingCmsPages.
      Parameters:
      map - GeoMap to find embedding CMS pages for
      Returns:
      a list of CMS pages that embed the given GeoMap
      Throws:
      DAOException - if any.
    • isHasMaps

      public boolean isHasMaps() throws DAOException
      isHasMaps.
      Returns:
      true if at least one geo map is stored in the database, false otherwise
      Throws:
      DAOException - if any.
    • getCoordinateSearchQuery

      public static String getCoordinateSearchQuery(SolrFeatureSet featureSet, String longLat)
    • getHeatmapUrl

      public String getHeatmapUrl()
      getHeatmapUrl.
      Returns:
      the URL to the spatial heatmap REST endpoint
    • getFeatureUrl

      public String getFeatureUrl()
      getFeatureUrl.
      Returns:
      the URL to the spatial search REST endpoint
    • addFeatureSet

      public void addFeatureSet(GeoMap map, String type)
      addFeatureSet.
      Parameters:
      map - GeoMap to add the feature set to
      type - feature set type identifier (MANUAL, SOLR_QUERY, SEARCH_RESULTS)
    • removeFeatureSet

      public void removeFeatureSet(GeoMap map, FeatureSet set)
      removeFeatureSet.
      Parameters:
      map - GeoMap to remove the feature set from
      set - feature set to remove
    • setCurrentGeoMapType

      public void setCurrentGeoMapType(GeoMap.GeoMapType type)
      setCurrentGeoMapType.
      Parameters:
      type - new map type to apply to the current map
    • getActiveFeatureSet

      public FeatureSet getActiveFeatureSet()
      Getter for the field activeFeatureSet.
      Returns:
      the currently active feature set, or null if none is selected
    • setActiveFeatureSet

      public void setActiveFeatureSet(ManualFeatureSet activeFeatureSet)
      Setter for the field activeFeatureSet.
      Parameters:
      activeFeatureSet - manual feature set to mark as active
    • getActiveFeatureSetAsString

      public String getActiveFeatureSetAsString() throws PresentationException
      getActiveFeatureSetAsString.
      Returns:
      the GeoJSON string representation of the active feature set, or an empty string if none is active
      Throws:
      PresentationException - if any.
    • setActiveFeatureSetAsString

      public void setActiveFeatureSetAsString(String features)
      setActiveFeatureSetAsString.
      Parameters:
      features - GeoJSON string representing the features to set
    • setActiveFeatureSet

      public void setActiveFeatureSet()
      Setter for the field activeFeatureSet.
    • isActiveFeatureSet

      public boolean isActiveFeatureSet(FeatureSet featureSet)
      isActiveFeatureSet.
      Parameters:
      featureSet - feature set to check against the active one
      Returns:
      true if the given feature set is the currently active feature set, false otherwise
    • getFromCache

      public GeoMap getFromCache(GeoMap geomap)
      getFromCache.
      Parameters:
      geomap - GeoMap to look up or store in cache
      Returns:
      the cached GeoMap if recently cached; otherwise the given GeoMap itself
    • isComplete

      public boolean isComplete(Locale locale)
      If this returns true, an associated language tab should have the 'already-translated' class, otherwise the '-partly-translated' class unless IPolyglott.isEmpty(Locale) also returns true.

      Return true if the the current geomap is not null and its title in the given locale is not empty and the description is either not empty for the current locale of the description for the default locale is empty. Otherwise return false

      Specified by:
      isComplete in interface IPolyglott
      Parameters:
      locale - the locale to check translation completeness for
      Returns:
      true if IPolyglott.isValid(Locale) returns true for the given locale and all fields contain a value which have a value in the default locale. For the default locale, IPolyglott.isComplete(Locale) and IPolyglott.isValid(Locale) are identical. For implementations with only one field, both methods are also always identical
    • isValid

      public boolean isValid(Locale locale)
      Only meaningful for the default language for which all required fields must be filled.

      Return true if the the current geomap is not null and its tile in the given locale is not empty Otherwise return false

      Specified by:
      isValid in interface IPolyglott
      Parameters:
      locale - the locale to validate required fields for
      Returns:
      true if all required fields contain a value in the given locale
    • isEmpty

      public boolean isEmpty(Locale locale)
      If this returns true, an associated language tab should have neither the 'already-translated' nor the '-partly-translated' class.

      return false if isValid(Locale) returns true and vice versa

      Specified by:
      isEmpty in interface IPolyglott
      Parameters:
      locale - the locale to check for empty fields
      Returns:
      true if no fields are filled for the given locale
    • getSelectedLocale

      public Locale getSelectedLocale()
      Specified by:
      getSelectedLocale in interface IPolyglott
      Returns:
      the locale currently set by IPolyglott.setSelectedLocale(Locale)
    • setSelectedLocale

      public void setSelectedLocale(Locale locale)
      Sets the locale to use for display and editing.
      Specified by:
      setSelectedLocale in interface IPolyglott
      Parameters:
      locale - the locale to select