Class ExternalComponentMessageHelper


  • public class ExternalComponentMessageHelper
    extends Object
    Helper to deal with External Component Messages.
    • Field Detail

      • FUNCTION_NOT_FOUND

        public static final String FUNCTION_NOT_FOUND
        Message when a requested function is not found
        See Also:
        Constant Field Values
      • FUNCTION_CALL_SUCESS

        public static final String FUNCTION_CALL_SUCESS
        Message when a function is executed with success
        See Also:
        Constant Field Values
      • FUNCTION_CALL_REQUEST_NOT_FOUND

        public static final String FUNCTION_CALL_REQUEST_NOT_FOUND
        Message when a message is of type FUNCTION_CALL, but the request to call the function is not found.
        See Also:
        Constant Field Values
      • FUNCTION_EXECUTION_ERROR_FOUND

        public static final String FUNCTION_EXECUTION_ERROR_FOUND
        Default message when there was an error executing the function.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ExternalComponentMessageHelper

        public ExternalComponentMessageHelper()
    • Method Detail

      • filterRequest

        public Optional<ExternalFilterRequest> filterRequest​(ExternalComponentMessage message)
        Extract filter request from messages coming from the component.
        Parameters:
        message - The message sent by the component.
        Returns:
        An optional containing the filter extracted from the message.
      • newDataSetMessage

        public ExternalComponentMessage newDataSetMessage​(ExternalDataSet ds,
                                                          Map<String,​Object> componentProperties)
        Builds a message that contains dataset and component properties.
        Parameters:
        ds - The dataset that will be sent to client
        componentProperties - All the component properties
        Returns:
        The message ready to be sent to the user.
      • newInitMessage

        public ExternalComponentMessage newInitMessage​(Map<String,​Object> componentProperties)
        Creates a message of type INIT, which is the first message sent to the component.
        Parameters:
        componentProperties - The initial properties.
        Returns:
        The message ready to be sent.
      • newFunctionNotFound

        public ExternalComponentMessage newFunctionNotFound​(FunctionCallRequest functionCallRequest)
        Produces a message to respond function call requests here the function could not be found.
        Parameters:
        functionCallRequest -
        Returns:
      • newFunctionRequestNotFound

        public ExternalComponentMessage newFunctionRequestNotFound()
        Generate messages for function call message types that does not specify a function call request.
        Returns:
      • newFunctionSuccess

        public ExternalComponentMessage newFunctionSuccess​(FunctionCallRequest functionCallRequest,
                                                           Object result)
        Messages to sent when a function is called with success
        Parameters:
        functionCallRequest -
        result - The function execution result.
        Returns:
      • withId

        public void withId​(ExternalComponentMessage message,
                           String componentId)
        Add the component runtime ID to a message
        Parameters:
        message - The message which the ID should be set
        componentId - The component unique ID. It should be used by components to send messages to DB.
      • getComponentId

        public Optional<String> getComponentId​(ExternalComponentMessage message)
        Extract the component Id from a message.
        Parameters:
        message - The target message to have the component id removed.
        Returns:
        An optional containing the component id.
      • isInit

        public boolean isInit​(ExternalComponentMessage message)
        Check if the given message is an INIT message.
        Parameters:
        message - The message to be checked.
        Returns:
        true if it is a message of type INIT.