org.opennms.web.map.db
Class ManagerDefaultImpl

java.lang.Object
  extended by org.opennms.web.map.db.ManagerDefaultImpl
All Implemented Interfaces:
Manager

public class ManagerDefaultImpl
extends Object
implements Manager

Author:
maurizio

Constructor Summary
ManagerDefaultImpl()
          Manage Maps using default implementation of Factory and Manager
 
Method Summary
 void clearMap()
           
 void closeMap()
          Close a VMap previusly opened.
 void deleteAllMapElements()
          delete all defined sub maps in existent maps
 void deleteAllNodeElements()
          delete all defined node elements in existent maps
 void deleteElementsOfMap(int mapId)
           
 void deleteMap()
           
 void deleteMap(int mapId)
          delete the map with identifier id
 void deleteMap(VMap map)
          delete the map in input
 void deleteMaps(int[] maps)
          delete the maps with the identifiers in input
 void deleteMaps(VMap[] maps)
          delete the maps in input
 boolean foundLoopOnMaps(VMap parentMap, int mapId)
           
 VElementInfo[] getAllElementInfo()
           
 VMapInfo[] getAllMapMenus()
          Get all defined maps.
 VMap[] getAllMaps(boolean refreshElems)
          Get all defined maps.
 HashMap<Integer,Integer> getAllNodesOccursOnMap(VMap map)
          Gets all nodes on the passed map (and its submaps) with theirs occurrences
 List<String> getCategories()
           
 Manager getDataAccessManager()
           
 DataSourceInterface getDataSource()
           
 Manager getDbManager()
           
 VElementInfo[] getElementInfoLike(String like)
           
 String getFilter()
           
 GroupDao getGroupDao()
           
 List<VLink> getLinks(Collection<VElement> elems)
           
 List<VLink> getLinks(VElement[] elems)
           
 List<VLink> getLinksOnElem(VElement[] elems, VElement elem)
           
 VMap[] getMap(String mapname, String maptype, boolean refreshElems)
          Take the map label and type in input and return it in VMap form.
 VMapInfo getMapMenu(int mapId)
           
 VMap[] getMapsByName(String mapName, boolean refreshElems)
          Take the maps with name in input and return them in VMap[] form.
 VMap[] getMapsLike(String likeLabel, boolean refreshElems)
          Take the maps with label like the pattern in input and return them in VMap[] form.
 VMapInfo[] getMapsMenuByName(String mapName)
          Take the maps with name in input and return them in MapMenu[] form.
 List<VMapInfo> getMapsMenuTreeByName(String mapName)
          Take all the maps in the tree of maps considering the with name in input as the root of the tree.
 MapPropertiesFactory getMapsPropertiesFactory()
           
 Set<Integer> getNodeidsOnElement(VElement velem)
          recursively gets all nodes contained by elem and its submaps (if elem is a map)
 List<VMapInfo> getVisibleMapsMenu(String user)
          gets all visible maps for user and userRole in input
 VElement newElement(int mapId, int elementId, String type)
          Create a new element child of the map with mapId (this map must be the sessionMap)
 VElement newElement(int mapId, int elementId, String type, int x, int y)
          Create a new VElement with the identifier setted to id.
 VElement newElement(int mapId, int elementId, String type, String iconname)
          Create a new (not child) empty Submap with the identifier setted to id.
 VElement newElement(int mapId, int elementId, String type, String iconname, int x, int y)
          Create a new element child of the map with mapId (this map must be the sessionMap).
 VElement newElement(int elementId, String type)
          Create a new element child of the map with mapId (this map must be the sessionMap)
 VElement newElement(int elementId, String type, int x, int y)
           
 VElement newElement(int elementId, String type, String iconname, int x, int y)
           
 VMap newMap()
          Create a new empty VMap and return it.
 VMap newMap(String name, String accessMode, String owner, String userModifies, int width, int height)
          Create a new VMap and return it
 VMap openMap()
           
 VMap openMap(int id, boolean refreshElems)
          Take the map with id in input and return it in VMap form.
 VMap openMap(int id, String user, boolean refreshElems)
          Take the map with id in input and return it in VMap form.
 VElement refreshElement(VElement mapElement)
           
 List<VElement> refreshElements(VElement[] mapElements)
          Refreshes of avail,severity and status of the elements in input.
 List<VLink> refreshLinks(VLink[] mapLinks)
          TODO write this method simil way to refreshElement Not Yet Implemented
 List<VElement> refreshMap()
           
 VMap reloadMap(VMap map)
          Reloads elements of map and theirs avail,severity and status
 void save(VMap map)
          save the map in input
 void save(VMap[] maps)
          save the maps in input
 void setDataSource(DataSourceInterface dataSource)
           
 void setDbManager(Manager dbManager)
           
 void setFilter(String filter)
           
 void setGroupDao(GroupDao groupDao)
           
 void setMapsPropertiesFactory(MapPropertiesFactory mapsPropertiesFactory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagerDefaultImpl

public ManagerDefaultImpl()
                   throws MapsException
Manage Maps using default implementation of Factory and Manager

Throws:
MapsException
Method Detail

getFilter

public String getFilter()

setFilter

public void setFilter(String filter)

getDataSource

public DataSourceInterface getDataSource()

setDataSource

public void setDataSource(DataSourceInterface dataSource)

getDbManager

public Manager getDbManager()

setDbManager

public void setDbManager(Manager dbManager)

getMapsPropertiesFactory

public MapPropertiesFactory getMapsPropertiesFactory()

setMapsPropertiesFactory

public void setMapsPropertiesFactory(MapPropertiesFactory mapsPropertiesFactory)

getCategories

public List<String> getCategories()
                           throws MapsException
Specified by:
getCategories in interface Manager
Throws:
MapsException

getLinks

public List<VLink> getLinks(Collection<VElement> elems)
                     throws MapsException
Specified by:
getLinks in interface Manager
Throws:
MapsException

openMap

public VMap openMap()
             throws MapNotFoundException
Specified by:
openMap in interface Manager
Returns:
the default VMap, if exists
Throws:
MapNotFoundException

clearMap

public void clearMap()
              throws MapNotFoundException,
                     MapsException
Specified by:
clearMap in interface Manager
Throws:
MapNotFoundException
MapsException

deleteMap

public void deleteMap()
               throws MapNotFoundException,
                      MapsException
Specified by:
deleteMap in interface Manager
Throws:
MapNotFoundException
MapsException

closeMap

public void closeMap()
Description copied from interface: Manager
Close a VMap previusly opened.

Specified by:
closeMap in interface Manager

openMap

public VMap openMap(int id,
                    String user,
                    boolean refreshElems)
             throws MapsManagementException,
                    MapNotFoundException,
                    MapsException
Description copied from interface: Manager
Take the map with id in input and return it in VMap form.

Specified by:
openMap in interface Manager
refreshElems - says if refresh the map's elements
Returns:
the VMap with identifier id
Throws:
MapsException
MapsManagementException
MapNotFoundException

newMap

public VMap newMap()
Create a new empty VMap and return it.

Specified by:
newMap in interface Manager
Returns:
the new VMap created.

newMap

public VMap newMap(String name,
                   String accessMode,
                   String owner,
                   String userModifies,
                   int width,
                   int height)
Create a new VMap and return it

Specified by:
newMap in interface Manager
Parameters:
name -
accessMode -
owner -
userModifies -
width -
height -
Returns:
the new VMap

openMap

public VMap openMap(int id,
                    boolean refreshElems)
             throws MapsManagementException,
                    MapNotFoundException,
                    MapsException
Take the map with id in input and return it in VMap form.

Specified by:
openMap in interface Manager
Parameters:
id -
refreshElems - says if refresh the map's elements
Returns:
the VMap with identifier id
Throws:
MapsException
MapsManagementException
MapNotFoundException

deleteElementsOfMap

public void deleteElementsOfMap(int mapId)
                         throws MapsException
Specified by:
deleteElementsOfMap in interface Manager
Throws:
MapsException

getMap

public VMap[] getMap(String mapname,
                     String maptype,
                     boolean refreshElems)
              throws MapsManagementException,
                     MapNotFoundException,
                     MapsException
Take the map label and type in input and return it in VMap form.

Specified by:
getMap in interface Manager
Parameters:
mapname -
maptype -
refreshElems - says if refresh map's elements
Returns:
the VMap[] with corresponding mapname and maptype
Throws:
MapsException
MapsManagementException
MapNotFoundException

getMapMenu

public VMapInfo getMapMenu(int mapId)
                    throws MapNotFoundException,
                           MapsException
Specified by:
getMapMenu in interface Manager
Throws:
MapNotFoundException
MapsException

getLinks

public List<VLink> getLinks(VElement[] elems)
                     throws MapsException
Specified by:
getLinks in interface Manager
Throws:
MapsException

getLinksOnElem

public List<VLink> getLinksOnElem(VElement[] elems,
                                  VElement elem)
                           throws MapsException
Specified by:
getLinksOnElem in interface Manager
Throws:
MapsException

getMapsLike

public VMap[] getMapsLike(String likeLabel,
                          boolean refreshElems)
                   throws MapsException
Take the maps with label like the pattern in input and return them in VMap[] form.

Specified by:
getMapsLike in interface Manager
Parameters:
label -
refreshElems - says if refresh map's elements
Returns:
the VMaps array if any label matches the pattern in input, null otherwise
Throws:
MapsException

getMapsByName

public VMap[] getMapsByName(String mapName,
                            boolean refreshElems)
                     throws MapNotFoundException,
                            MapsException
Take the maps with name in input and return them in VMap[] form.

Specified by:
getMapsByName in interface Manager
Parameters:
mapName -
refhresElems - says if refresh maps' elements
Returns:
the VMaps array if any map has name in input, null otherwise
Throws:
MapsException
MapNotFoundException

getAllMaps

public VMap[] getAllMaps(boolean refreshElems)
                  throws MapNotFoundException,
                         MapsException
Get all defined maps.

Specified by:
getAllMaps in interface Manager
Parameters:
refreshElems - says if refresh maps' elements
Returns:
the VMaps array containing all maps defined
Throws:
MapsException
MapNotFoundException

getAllMapMenus

public VMapInfo[] getAllMapMenus()
                          throws MapsException
Get all defined maps.

Specified by:
getAllMapMenus in interface Manager
Returns:
the MapMenu array containing all maps defined
Throws:
MapsException

getMapsMenuByName

public VMapInfo[] getMapsMenuByName(String mapName)
                             throws MapNotFoundException,
                                    MapsException
Take the maps with name in input and return them in MapMenu[] form.

Specified by:
getMapsMenuByName in interface Manager
Parameters:
mapName -
Returns:
the MapMenu array if any map has name in input, null otherwise
Throws:
MapsException
MapNotFoundException

getVisibleMapsMenu

public List<VMapInfo> getVisibleMapsMenu(String user)
                                  throws MapsException
gets all visible maps for user and userRole in input

Specified by:
getVisibleMapsMenu in interface Manager
Parameters:
user -
userRole -
Returns:
a List of MapMenu objects.
Throws:
MapsException

getMapsMenuTreeByName

public List<VMapInfo> getMapsMenuTreeByName(String mapName)
                                     throws MapNotFoundException,
                                            MapsException
Take all the maps in the tree of maps considering the with name in input as the root of the tree. If there are more maps with mapName (case insensitive) all trees with these maps as root are considered and returned.

Specified by:
getMapsMenuTreeByName in interface Manager
Parameters:
mapName -
Returns:
a List with the MapMenu objects.
Throws:
MapsException
MapNotFoundException

newElement

public VElement newElement(int mapId,
                           int elementId,
                           String type,
                           int x,
                           int y)
                    throws MapsException
Create a new VElement with the identifier setted to id.

Specified by:
newElement in interface Manager
Parameters:
mapId -
elementId -
type - the node type
x -
y -
Returns:
the new VElement
Throws:
MapsException

newElement

public VElement newElement(int elementId,
                           String type,
                           int x,
                           int y)
                    throws MapsException
Specified by:
newElement in interface Manager
Throws:
MapsException

newElement

public VElement newElement(int mapId,
                           int elementId,
                           String type)
                    throws MapsException
Create a new element child of the map with mapId (this map must be the sessionMap)

Specified by:
newElement in interface Manager
Parameters:
mapId -
elementId -
type - the node type
Returns:
the new VElement
Throws:
MapsException

newElement

public VElement newElement(int elementId,
                           String type)
                    throws MapsException
Create a new element child of the map with mapId (this map must be the sessionMap)

Specified by:
newElement in interface Manager
Throws:
MapsException

newElement

public VElement newElement(int mapId,
                           int elementId,
                           String type,
                           String iconname,
                           int x,
                           int y)
                    throws MapsException
Create a new element child of the map with mapId (this map must be the sessionMap).

Specified by:
newElement in interface Manager
Parameters:
mapId -
elementId -
type - the node type
Returns:
the new VElement
Throws:
MapsException

newElement

public VElement newElement(int elementId,
                           String type,
                           String iconname,
                           int x,
                           int y)
                    throws MapsException
Specified by:
newElement in interface Manager
Throws:
MapsException

newElement

public VElement newElement(int mapId,
                           int elementId,
                           String type,
                           String iconname)
                    throws MapsException
Create a new (not child) empty Submap with the identifier setted to id.

Specified by:
newElement in interface Manager
Parameters:
mapId -
elementId -
type - the node type
Returns:
the new VElement
Throws:
MapsException

deleteMap

public void deleteMap(VMap map)
               throws MapsException,
                      MapNotFoundException
delete the map in input

Specified by:
deleteMap in interface Manager
Parameters:
map - to delete
Throws:
MapsException - if an error occour deleting map, MapNotFoundException if the map to delete doesn't exist.
MapNotFoundException

deleteMap

public void deleteMap(int mapId)
               throws MapsException
delete the map with identifier id

Specified by:
deleteMap in interface Manager
Parameters:
id - of the map to delete
Throws:
MapsException

deleteMaps

public void deleteMaps(VMap[] maps)
                throws MapsException
delete the maps in input

Specified by:
deleteMaps in interface Manager
Parameters:
maps - to delete
Throws:
MapsException

deleteMaps

public void deleteMaps(int[] maps)
                throws MapsException
delete the maps with the identifiers in input

Specified by:
deleteMaps in interface Manager
Parameters:
identifiers - of the maps to delete
Throws:
MapsException

save

public void save(VMap map)
          throws MapsException
save the map in input

Specified by:
save in interface Manager
Parameters:
map - to save
Throws:
MapsException

save

public void save(VMap[] maps)
          throws MapsException
save the maps in input

Specified by:
save in interface Manager
Parameters:
maps - to save
Throws:
MapsException

deleteAllNodeElements

public void deleteAllNodeElements()
                           throws MapsException
delete all defined node elements in existent maps

Specified by:
deleteAllNodeElements in interface Manager
Throws:
MapsException

deleteAllMapElements

public void deleteAllMapElements()
                          throws MapsException
delete all defined sub maps in existent maps

Specified by:
deleteAllMapElements in interface Manager
Throws:
MapsException

refreshElements

public List<VElement> refreshElements(VElement[] mapElements)
                               throws MapsException
Refreshes of avail,severity and status of the elements in input. The refresh is performed as follows: - default factory is used if no others defined; - if in the using factory is defined a source, the system will use this one else, the system will use default source (OpenNMS)

Specified by:
refreshElements in interface Manager
Parameters:
mapElements - the elements to refresh
incremental - return only changed elements, if the refresh implementation is capable of this operation
Returns:
List of VElement
Throws:
MapsException

refreshElement

public VElement refreshElement(VElement mapElement)
                        throws MapsException
Specified by:
refreshElement in interface Manager
Throws:
MapsException

reloadMap

public VMap reloadMap(VMap map)
               throws MapsException
Reloads elements of map and theirs avail,severity and status

Specified by:
reloadMap in interface Manager
Parameters:
map -
Returns:
the map refreshed
Throws:
MapsException

refreshMap

public List<VElement> refreshMap()
                          throws MapsException
Specified by:
refreshMap in interface Manager
Throws:
MapsException

refreshLinks

public List<VLink> refreshLinks(VLink[] mapLinks)
                         throws MapsException
Description copied from interface: Manager
TODO write this method simil way to refreshElement Not Yet Implemented

Specified by:
refreshLinks in interface Manager
Throws:
MapsException

foundLoopOnMaps

public boolean foundLoopOnMaps(VMap parentMap,
                               int mapId)
                        throws MapsException
Specified by:
foundLoopOnMaps in interface Manager
Throws:
MapsException

getNodeidsOnElement

public Set<Integer> getNodeidsOnElement(VElement velem)
                                 throws MapsException
recursively gets all nodes contained by elem and its submaps (if elem is a map)

Specified by:
getNodeidsOnElement in interface Manager
Throws:
MapsException

getAllElementInfo

public VElementInfo[] getAllElementInfo()
                                 throws MapsException
Specified by:
getAllElementInfo in interface Manager
Throws:
MapsException

getElementInfoLike

public VElementInfo[] getElementInfoLike(String like)
                                  throws MapsException
Specified by:
getElementInfoLike in interface Manager
Throws:
MapsException

getDataAccessManager

public Manager getDataAccessManager()

getAllNodesOccursOnMap

public HashMap<Integer,Integer> getAllNodesOccursOnMap(VMap map)
                                                throws MapsException
Gets all nodes on the passed map (and its submaps) with theirs occurrences

Specified by:
getAllNodesOccursOnMap in interface Manager
Parameters:
map -
Returns:
HashMap (nodeid, occurrences) containing all nodes on the passed map (and its submaps) with theirs occourrences
Throws:
MapsException

getGroupDao

public GroupDao getGroupDao()

setGroupDao

public void setGroupDao(GroupDao groupDao)


Copyright © 2009. All Rights Reserved.