Class ExternalComponentMessageHelper
- java.lang.Object
-
- org.dashbuilder.displayer.external.ExternalComponentMessageHelper
-
public class ExternalComponentMessageHelper extends Object
Helper to deal with External Component Messages.
-
-
Field Summary
Fields Modifier and Type Field Description static StringFUNCTION_CALL_REQUEST_NOT_FOUNDMessage when a message is of type FUNCTION_CALL, but the request to call the function is not found.static StringFUNCTION_CALL_SUCESSMessage when a function is executed with successstatic StringFUNCTION_EXECUTION_ERROR_FOUNDDefault message when there was an error executing the function.static StringFUNCTION_NOT_FOUNDMessage when a requested function is not found
-
Constructor Summary
Constructors Constructor Description ExternalComponentMessageHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<ExternalFilterRequest>filterRequest(ExternalComponentMessage message)Extract filter request from messages coming from the component.Optional<FunctionCallRequest>functionCallRequest(ExternalComponentMessage message)Retrieves a function call object from a message.Optional<String>getComponentId(ExternalComponentMessage message)Extract the component Id from a message.Optional<String>getConfigurationIssue(ExternalComponentMessage message)booleanisInit(ExternalComponentMessage message)Check if the given message is an INIT message.ExternalComponentMessageTypemessageType(ExternalComponentMessage message)ExternalComponentMessagenewDataSetMessage(ExternalDataSet ds, Map<String,Object> componentProperties)Builds a message that contains dataset and component properties.ExternalComponentMessagenewFunctionError(FunctionCallRequest functionCallRequest, String errorMessage)ExternalComponentMessagenewFunctionNotFound(FunctionCallRequest functionCallRequest)Produces a message to respond function call requests here the function could not be found.ExternalComponentMessagenewFunctionRequestNotFound()Generate messages for function call message types that does not specify a function call request.ExternalComponentMessagenewFunctionSuccess(FunctionCallRequest functionCallRequest, Object result)Messages to sent when a function is called with successExternalComponentMessagenewInitMessage(Map<String,Object> componentProperties)Creates a message of type INIT, which is the first message sent to the component.voidwithId(ExternalComponentMessage message, String componentId)Add the component runtime ID to a message
-
-
-
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
-
-
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.
-
functionCallRequest
public Optional<FunctionCallRequest> functionCallRequest(ExternalComponentMessage message)
Retrieves a function call object from a message.- Parameters:
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 clientcomponentProperties- 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.
-
newFunctionError
public ExternalComponentMessage newFunctionError(FunctionCallRequest functionCallRequest, String errorMessage)
-
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 setcomponentId- 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.
-
getConfigurationIssue
public Optional<String> getConfigurationIssue(ExternalComponentMessage message)
-
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.
-
messageType
public ExternalComponentMessageType messageType(ExternalComponentMessage message)
-
-