Class ServiceContext
java.lang.Object
com.aquima.interactions.portal.model.session.PortalContextDelegate
com.aquima.interactions.portal.model.session.ServiceContext
- All Implemented Interfaces:
IEventContext
,IPortalContext
,IServiceContext
,IInternalPortalContext
,Serializable
Implementation of the context interface for services.
- Since:
- 5.0
- Author:
- O. Kerpershoek
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ServiceContext
(IInternalPortalContext context, IServiceFactory serviceFactory, String serviceCallName, String serviceTypeName, ITypedParameters parameters, EventErrors errors) -
Method Summary
Modifier and TypeMethodDescriptionboolean
addErrorMessage
(ValueReference attributeReference, String key, String[] parameters) This method may be used to add an error to the current context.boolean
addErrorText
(ValueReference attributeReference, IMultilingualText text) This method may be used to add an error to the current context.boolean
addWarningMessage
(ValueReference attributeReference, String key, String[] parameters) This method may be used to add a warning to the current context.boolean
addWarningText
(ValueReference attributeReference, IMultilingualText text) This method may be used to add a warning to the current context.boolean
This method will remove all the errors that might have been added.This method returns an element factory that may be used to expand pre-defined elements from the composer using the current container context.getErrors
(boolean onlyGenericErrors) Returns the error messages (never null) that have been set in the request scope.getErrors
(ValueReference attributeReference) Retrieves the errors for a specific ValueReference (never null) When no error messages have been set for the specified attribute, an empty array will be returned.getEvent()
Returns the event for which this context is working.This method returns an element factory that may be used to expand pre-defined elements from the composer using the mapping context.getParameter
(String name) This method returns the value for the specified parameter key.This method returns an object containing all the parameters that are defined for this service.This method returns the service call name as defined in studio.This method will return the service factory of the current application.This method returns a service manager for the current context.This method returns the type name of the service.boolean
This method returns the boolean indicating if errors should abort the current flow.boolean
Indicator if the request scope contains generic errors or errors on attribute values.boolean
This method returns a boolean indicating if the flow should be aborted.protected boolean
void
setFlowBlocked
(boolean rollback) This method may be used to block the current flow regardless if any errors are present.void
setFocus
(ValueReference reference) This method sets the focus for a specific ValueReference (never null).void
setStopOnErrors
(boolean stopOnErrors) This method may be used to change the behavior when an error is encountered after the component using the context has completed.Methods inherited from class com.aquima.interactions.portal.model.session.PortalContextDelegate
forModule, forModule, getActiveInstance, getApplication, getApplicationMode, getApplicationModel, getAuditEngine, getCaseEngineClient, getCommentsManager, getCommunicationEngine, getComposer, getConfiguration, getConnectionManager, getContentManagerFactory, getContentManagerFactory, getContext, getCurrentFlow, getCurrentLanguage, getDebugger, getDocumentEngine, getExpressionParser, getFactoryManager, getFlowEngine, getFlowScope, getFunctionCallDefinitionManager, getId, getMappingManager, getMaskManager, getMatchEngine, getMetaModel, getPageScope, getProcessScope, getProfile, getProject, getRequestScope, getResourceManager, getRuleEngine, getSessionId, getSessionScope, getState, getTraceEngine, getTreeEngine, getUserProfile, getUserScope, getWebServices, pushActiveInstance, restore
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.aquima.interactions.portal.IPortalContext
forModule, forModule, getActiveInstance, getApplicationMode, getAuditEngine, getCaseEngineClient, getCommentsManager, getCommunicationEngine, getConnectionManager, getContentManagerFactory, getContentManagerFactory, getCurrentFlow, getCurrentLanguage, getDebugger, getDocumentEngine, getExpressionParser, getFlowEngine, getFlowScope, getFunctionCallDefinitionManager, getMappingManager, getMaskManager, getMatchEngine, getMetaModel, getPageScope, getProcessScope, getProfile, getProject, getRequestScope, getResourceManager, getRuleEngine, getSessionId, getSessionScope, getState, getTraceEngine, getTreeEngine, getUserProfile, getUserScope, getWebServices, pushActiveInstance, restore
-
Constructor Details
-
ServiceContext
protected ServiceContext(IInternalPortalContext context, IServiceFactory serviceFactory, String serviceCallName, String serviceTypeName, ITypedParameters parameters, EventErrors errors)
-
-
Method Details
-
getElementComposer
Description copied from interface:IPortalContext
This method returns an element factory that may be used to expand pre-defined elements from the composer using the current container context.- Specified by:
getElementComposer
in interfaceIPortalContext
- Overrides:
getElementComposer
in classPortalContextDelegate
- Returns:
- An element factory that can be used to expand elements from the composer.
-
getMappingComposer
Description copied from interface:IPortalContext
This method returns an element factory that may be used to expand pre-defined elements from the composer using the mapping context.- Specified by:
getMappingComposer
in interfaceIPortalContext
- Overrides:
getMappingComposer
in classPortalContextDelegate
- Returns:
- An element factory that can be used to expand elements from the composer.
-
getServiceCallName
Description copied from interface:IServiceContext
This method returns the service call name as defined in studio. A single service might be specified multiple times with different parameters under different call names. Use the service type name to uniquely identify the service.- Specified by:
getServiceCallName
in interfaceIServiceContext
- Returns:
- The call name of the service as defined in studio.
-
getServiceTypeName
Description copied from interface:IServiceContext
This method returns the type name of the service. The type name is used to uniquely identify the service. Multiple definitions of the same service may exist, sharing the same type, but with different call names.- Specified by:
getServiceTypeName
in interfaceIServiceContext
- Returns:
- The type name of the service.
-
getParameter
Description copied from interface:IServiceContext
This method returns the value for the specified parameter key. When no value is defined for the given key, a null value will be returned. The parameter name is not case sensitive.- Specified by:
getParameter
in interfaceIServiceContext
- Parameters:
name
- The name of the parameter for which the value is requested.- Returns:
- The value of the specified parameter.
-
getParameters
Description copied from interface:IServiceContext
This method returns an object containing all the parameters that are defined for this service.- Specified by:
getParameters
in interfaceIServiceContext
- Returns:
- Object containing the service parameters.
-
getEvent
Description copied from interface:IEventContext
Returns the event for which this context is working.- Specified by:
getEvent
in interfaceIEventContext
- Returns:
- The fired even object which is never null.
-
hasErrors
public boolean hasErrors()Description copied from interface:IEventContext
Indicator if the request scope contains generic errors or errors on attribute values.- Specified by:
hasErrors
in interfaceIEventContext
- Returns:
- boolean indicating if errors are present in the request scope.
-
clearErrors
public boolean clearErrors()Description copied from interface:IEventContext
This method will remove all the errors that might have been added. The method returns a boolean indicating if any errors were actually discarded.
Warning: Use this method with care, as clearing errors might result in a state that is not consistent with the rules defined in the model.- Specified by:
clearErrors
in interfaceIEventContext
- Returns:
- a boolean indicating if any errors were actually discarded.
-
addErrorMessage
Description copied from interface:IEventContext
This method may be used to add an error to the current context. The error may be linked to a value by specifying a value reference, or the value reference may be left empty (null) to indicate that the error is generic. The message of the error is retrieved from the meta model for the specified the key.- Specified by:
addErrorMessage
in interfaceIEventContext
- Parameters:
attributeReference
- Optional parameter that specifies the value the error belongs to.key
- The id of the message from the meta model.parameters
- Optional parameters for the message.- Returns:
- boolean indicating if the error was actually added (duplicate messages are ignored).
-
addErrorText
Description copied from interface:IEventContext
This method may be used to add an error to the current context. The error may be linked to a value by specifying a value reference, or the value reference may be left empty (null) to indicate that the error is generic.- Specified by:
addErrorText
in interfaceIEventContext
- Parameters:
attributeReference
- Optional parameter that specifies the value the error belongs to.text
- The error message that should be added to the context.- Returns:
- boolean indicating if the error was actually added (duplicate messages are ignored).
-
addWarningMessage
public boolean addWarningMessage(ValueReference attributeReference, String key, String[] parameters) Description copied from interface:IEventContext
This method may be used to add a warning to the current context. The warning may be linked to a value by specifying a value reference, or the value reference may be left empty (null) to indicate that the warning is generic. The message of the warning is retrieved from the meta model for the specified the key.- Specified by:
addWarningMessage
in interfaceIEventContext
- Parameters:
attributeReference
- Optional parameter that specifies the value the warning belongs to.key
- The id of the message from the meta model.parameters
- Optional parameters for the message.- Returns:
- boolean indicating if the error was actually added (duplicate messages are ignored).
-
addWarningText
Description copied from interface:IEventContext
This method may be used to add a warning to the current context. The warning may be linked to a value by specifying a value reference, or the value reference may be left empty (null) to indicate that the warning is generic.- Specified by:
addWarningText
in interfaceIEventContext
- Parameters:
attributeReference
- Optional parameter that specifies the value the warning belongs to.text
- The warning message that should be added to the context.- Returns:
- boolean indicating if the error was actually added (duplicate messages are ignored).
-
getErrors
Description copied from interface:IEventContext
Returns the error messages (never null) that have been set in the request scope. When no errors have been an empty array will be returned.- Specified by:
getErrors
in interfaceIEventContext
- Parameters:
onlyGenericErrors
- Boolean indicating if only generic error messages should be returned.- Returns:
- Array containing the errors that have been set on the request scope.
-
getErrors
Description copied from interface:IEventContext
Retrieves the errors for a specific ValueReference (never null) When no error messages have been set for the specified attribute, an empty array will be returned.- Specified by:
getErrors
in interfaceIEventContext
- Parameters:
attributeReference
- Reference to the attribute for which the error messages are requested.- Returns:
- Array containing the error messages for the specified attribute (may be empty).
-
getStopOnErrors
public boolean getStopOnErrors()Description copied from interface:IEventContext
This method returns the boolean indicating if errors should abort the current flow.- Specified by:
getStopOnErrors
in interfaceIEventContext
- Returns:
- boolean indicating if errors should abort the current flow.
-
isFlowBlocked
public boolean isFlowBlocked()Description copied from interface:IEventContext
This method returns a boolean indicating if the flow should be aborted. The flow is aborted under the following conditions:- StopOnErrors = true AND hasErrors = true
- SetFlowBlocked was invoked.
- Specified by:
isFlowBlocked
in interfaceIEventContext
- Returns:
- boolean indicating if the flow should be aborted.
-
setFlowBlocked
public void setFlowBlocked(boolean rollback) Description copied from interface:IEventContext
This method may be used to block the current flow regardless if any errors are present. The rollback parameter may be used to indicate if changes so far should be discarded.- Specified by:
setFlowBlocked
in interfaceIEventContext
- Parameters:
rollback
- boolean to indicate if changes so far should be discarded.
-
setStopOnErrors
public void setStopOnErrors(boolean stopOnErrors) Description copied from interface:IEventContext
This method may be used to change the behavior when an error is encountered after the component using the context has completed. The default behavior is to stop any flow processing when the component using the context added an error. When this method is invoked with the value false, any errors from the component will be ignored, and the flow will continue normally. This setting has only effect on the current component using the flow. If another component is invoked after, that does have the stopOnErrors set to true, the flow will still be aborted.
Warning: Use this method with care, as it can result in errors being ignored or not shown if the result page does not contain the fields the errors are defined for.- Specified by:
setStopOnErrors
in interfaceIEventContext
- Parameters:
stopOnErrors
- Boolean indicating if the flow should be aborted when an error is encountered.
-
rollbackTransaction
protected boolean rollbackTransaction() -
getServiceFactory
Description copied from interface:IServiceContext
This method will return the service factory of the current application. The service factory may be used to request implementations of other services to allow the current service to combine the logic of several services.- Specified by:
getServiceFactory
in interfaceIServiceContext
- Returns:
- The service factory of the current application.
-
getServiceManager
Description copied from interface:IPortalContext
This method returns a service manager for the current context. Never returns null- Specified by:
getServiceManager
in interfaceIPortalContext
- Overrides:
getServiceManager
in classPortalContextDelegate
- Returns:
- A service manager for the current session.
-
setFocus
Description copied from interface:IEventContext
This method sets the focus for a specific ValueReference (never null).- Specified by:
setFocus
in interfaceIEventContext
- Parameters:
reference
- Reference to the attribute for which the focus has to be set.
-