Class ActionUtil


  • public class ActionUtil
    extends Object
    • Constructor Detail

      • ActionUtil

        public ActionUtil()
    • Method Detail

      • removeKeyFromMap

        public static void removeKeyFromMap​(Map<String,​?> params,
                                            String key)
        Removes the provided key from the params Map , if it exists, as well as its "equivalent", as defined within the KEY_MAP. If the provided key is a key within the KEY_MAP, its "equivalent" is the value. If the provided key is a value within the KEY_MAP, its "equivalent" is the key.

        Example: Given a KEY_MAP that looks like this:
        • firstName=first.name
        • lastName=last.name
        • addr=address
        • person.age=age
        a call to removeKeyFromMap( map, "firstName") will attempt to remove the "firstName" and "first.name" keys from the provided map. Likewise, a call to removeKeyFromMap( map, "last.name") will attempt to remove the "last.name" and "lastName" keys from the provided map.
        Parameters:
        params - the Map from which keys are being removed
        key - the String key being removed from the map
      • prepareMap

        public static void prepareMap​(Map<String,​Serializable> params)
        Prepares the params Map for action invocation, adding appropriate keys that are not scheduler specific, so that the action invocation code can operate on these mapped non-scheduler specific keys, rather than any keys defined within the scheduler. The corresponding entries that use the scheduler related keys are removed.
        Parameters:
        params - the Map or parameters needed to invoke the IAction
      • extractName

        public static String extractName​(Map<String,​Serializable> params)
        Looks up the work item name within the Map. If available, the value is returned, otherwise a new name is generated and returned.
        Parameters:
        params - a Map that may contain the name
        Returns:
        work item name from the Map or a new one, or null in the absence of the IWorkItemLifecycleEventPublisher bean
      • generateWorkItemName

        public static String generateWorkItemName​(Map<String,​Serializable> params)
        Parameters:
        params - a Map containing action/work item related attributes, in particular inputFile and actionUser, which are both used for the purpose of generating the uid.
        Returns:
        a name for the work item
      • isInlinePassingOfInputOnStreamProvider

        public static boolean isInlinePassingOfInputOnStreamProvider​(Map<String,​Serializable> params)
      • generateWorkItemName

        public static String generateWorkItemName​(String inputFilePath,
                                                  String userName)
        Returns a name for a work item which includes the input file name (derived from inputFilePath) and user that executed it, in the following format: %input file name%-%user%, stripping any invalid characters. This workItemName will be used for logging only
        Parameters:
        inputFilePath - the path of the input file of the action being invoked - optional
        userName - the user executing the action
        Returns:
        a name for the work item
      • createActionBean

        public static org.pentaho.platform.api.action.IAction createActionBean​(String actionClassName,
                                                                               String actionId)
                                                                        throws org.pentaho.platform.api.action.ActionInvocationException
        Returns an instance of IAction created from the provided parameters.
        Parameters:
        actionClassName - the name of the class being resolved
        actionId - the is of the action which corresponds to some bean id
        Returns:
        IAction created from the provided parameters.
        Throws:
        Exception - when the IAction cannot be created for some reason
        org.pentaho.platform.api.action.ActionInvocationException
      • createActionBean

        public static org.pentaho.platform.api.action.IAction createActionBean​(String actionClassName,
                                                                               String actionId,
                                                                               boolean retryBeanInstantiationIfFailed)
                                                                        throws org.pentaho.platform.api.action.ActionInvocationException
        Returns an instance of IAction created from the provided parameters.
        Parameters:
        actionClassName - the name of the class being resolved
        actionId - the is of the action which corresponds to some bean id
        Returns:
        IAction created from the provided parameters.
        Throws:
        Exception - when the IAction cannot be created for some reason
        org.pentaho.platform.api.action.ActionInvocationException
      • sendEmail

        public static void sendEmail​(Map<String,​Object> actionParams,
                                     Map<String,​Serializable> params,
                                     String filePath)
        Sends an email with the file representing the provided filePath as an attachment. All information needed to send the email (to, from, cc, bcc etc) is expected to be proviced in the actionParams Map.
        Parameters:
        actionParams - a Map of parameters needed to send the email
        params - a Map of parameter used to invoke the action
        filePath - the path of the repository file that was generated when the action was invoked