Class CoreActionsRegistry


  • @Service
    public class CoreActionsRegistry
    extends Object
    All general purpose, inventory object-dependent actions (e.g. new object or delete object) in all modules (but most likely in the Navigation module) considered as core actions and must be registered here at module startup. Relevant menus (Such as Basic Actions in the Navigation module) will be dynamically built using the actions in this registry as well as the classes they are applicable to. There are two types of core actions: Delete Actions, which are the actions intended to remove objects. from the system. Most objects will use the default implementation, however, some might require a special procedure -such as for physical or logical connections-). Regular Actions are basically the rest of them, actions such as move/copy objects or launch reports.
    Author:
    Charles Edward Bedon Cortazar <charles.bedon@kuwaiba.org>
    • Constructor Detail

      • CoreActionsRegistry

        public CoreActionsRegistry()
    • Method Detail

      • getRegularActionsApplicableTo

        public List<AbstractVisualInventoryAction> getRegularActionsApplicableTo​(String filter)
        Checks what misc actions are associated to a given inventory class. For example, NewCustomer and ShowReports are part of the returned list if filter is GenericCustomer. Note that the difference between this method and #getMiscActionsApplicableToRecursive(java.lang.String) is that this method will return the actions whose appliesTo matches exactly with the provided filter, while the latter might match even subclasses of the appliesTo return value.
        Parameters:
        filter - The class to be evaluated.
        Returns:
        The actions that can be executed from an instance of the given class or superclass.
      • getActionsApplicableToRecursive

        public List<AbstractVisualInventoryAction> getActionsApplicableToRecursive​(String filter)
        Checks what misc actions are associated to a given inventory class. For example, NewCustomer and ShowReports are part of the returned list if filter is CorporateCustomer.
        Parameters:
        filter - The class to be evaluated.
        Returns:
        The actions that can be executed from an instance of the given class or superclass.
      • getDeleteActionsApplicableTo

        public List<AbstractVisualInventoryAction> getDeleteActionsApplicableTo​(String filter)
        Checks what delete actions (there might be more than one, if several delete action implementations are provided) are associated to a given inventory class. See #getMiscActionsApplicableTo(java.lang.String) for more details on its behavior.
        Parameters:
        filter - The class to be evaluated.
        Returns:
        The delete actions that can be executed from an instance of the given class or superclass.
      • getDeleteActionsApplicableToRecursive

        public List<AbstractVisualInventoryAction> getDeleteActionsApplicableToRecursive​(String filter)
        Checks recursively in the class hierarchy what delete actions are associated to a given inventory class. See getActionsApplicableToRecursive(java.lang.String) for more details on its behavior.
        Parameters:
        filter - The class to be evaluated.
        Returns:
        The delete actions that can be executed from an instance of the given class or superclass.
      • registerRegularAction

        public void registerRegularAction​(String moduleId,
                                          AbstractVisualInventoryAction action)
                                   throws IllegalArgumentException
        Adds an action to the registry.This method also feeds the action map cache structure, which is a hash map which keys are all the possible super classes the actions are applicable to and the keys are the corresponding actions.
        Parameters:
        moduleId - The id of the module this action is provided by. The id is returned by AbstractModule.getId().
        action - The action to be added. Duplicated action ids are allowed, as long as the duplicate can be used to overwrite default behaviors, for example, if an object (say a connection) has a specific delete routine that should be executed instead of the general purpose delete action, both actions should have the same id, and the renderer should override the default action with the specific one.
        Throws:
        IllegalArgumentException - If a delete action (a subclass of AbstractDeleteAction) is provided as argument.
      • registerDeleteAction

        public void registerDeleteAction​(String moduleId,
                                         AbstractVisualInventoryAction action)
        Registers a custom delete action.
        Parameters:
        moduleId - The id of the module the action belongs to.
        action - The action itself.
      • getRegularActions

        public List<AbstractVisualInventoryAction> getRegularActions()
        Returns all registered regular actions.
        Returns:
        All registered regular actions.
      • getDeleteActionForClass

        public AbstractVisualInventoryAction getDeleteActionForClass​(String className)
        Gets the appropriate delete action for a given class, if explicitly registered, and the default implementation otherwise.
        Parameters:
        className - The name of the class to evaluate.
        Returns:
        The delete action applicable to the given class. If there isn't one explicitly set, it will return the default implementation.
      • getActionsForModule

        public List<AbstractVisualInventoryAction> getActionsForModule​(String moduleId)
        Returns all actions registered by a particular module.
        Parameters:
        moduleId - The id of the module. Usually the strings that comes from calling AbstractModule.getId().
        Returns:
        The list of actions, even if none registered for the given module (in that case, an empty array will be returned).