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

public class ServiceContext extends PortalContextDelegate implements IServiceContext
Implementation of the context interface for services.
Since:
5.0
Author:
O. Kerpershoek
See Also:
  • Constructor Details

  • Method Details

    • getElementComposer

      public IElementComposer 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 interface IPortalContext
      Overrides:
      getElementComposer in class PortalContextDelegate
      Returns:
      An element factory that can be used to expand elements from the composer.
    • getMappingComposer

      public IMappingComposer 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 interface IPortalContext
      Overrides:
      getMappingComposer in class PortalContextDelegate
      Returns:
      An element factory that can be used to expand elements from the composer.
    • getServiceCallName

      public String 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 interface IServiceContext
      Returns:
      The call name of the service as defined in studio.
    • getServiceTypeName

      public String 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 interface IServiceContext
      Returns:
      The type name of the service.
    • getParameter

      public String getParameter(String name)
      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 interface IServiceContext
      Parameters:
      name - The name of the parameter for which the value is requested.
      Returns:
      The value of the specified parameter.
    • getParameters

      public ITypedParameters 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 interface IServiceContext
      Returns:
      Object containing the service parameters.
    • getEvent

      public IFiredEvent getEvent()
      Description copied from interface: IEventContext
      Returns the event for which this context is working.
      Specified by:
      getEvent in interface IEventContext
      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 interface IEventContext
      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 interface IEventContext
      Returns:
      a boolean indicating if any errors were actually discarded.
    • addErrorMessage

      public boolean addErrorMessage(ValueReference attributeReference, String key, String[] parameters)
      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 interface IEventContext
      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

      public boolean addErrorText(ValueReference attributeReference, IMultilingualText text)
      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 interface IEventContext
      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 interface IEventContext
      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

      public boolean addWarningText(ValueReference attributeReference, IMultilingualText text)
      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 interface IEventContext
      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

      public IErrorMessage[] getErrors(boolean onlyGenericErrors)
      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 interface IEventContext
      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

      public IErrorMessage[] getErrors(ValueReference attributeReference)
      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 interface IEventContext
      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 interface IEventContext
      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 interface IEventContext
      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 interface IEventContext
      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 interface IEventContext
      Parameters:
      stopOnErrors - Boolean indicating if the flow should be aborted when an error is encountered.
    • rollbackTransaction

      protected boolean rollbackTransaction()
    • getServiceFactory

      public IServiceFactory 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 interface IServiceContext
      Returns:
      The service factory of the current application.
    • getServiceManager

      public IServiceManager getServiceManager()
      Description copied from interface: IPortalContext
      This method returns a service manager for the current context. Never returns null
      Specified by:
      getServiceManager in interface IPortalContext
      Overrides:
      getServiceManager in class PortalContextDelegate
      Returns:
      A service manager for the current session.
    • setFocus

      public void setFocus(ValueReference reference)
      Description copied from interface: IEventContext
      This method sets the focus for a specific ValueReference (never null).
      Specified by:
      setFocus in interface IEventContext
      Parameters:
      reference - Reference to the attribute for which the focus has to be set.