Interface AutomationService

All Known Implementing Classes:
OperationServiceImpl

public interface AutomationService
Service providing an operation registry and operation execution methods. The operation registry is thread-safe and optimized for lookups. Progress monitor for asynchronous executions is not yet implemented.
Author:
Bogdan Stefanescu, Guillaume
  • Method Details

    • putOperation

      void putOperation(Class<?> type) throws OperationException
      Registers an operation given its class. The operation class MUST be annotated using Operation annotation. If an operation having the same ID exists an exception will be thrown.
      Throws:
      OperationException
    • putOperation

      void putOperation(Class<?> type, boolean replace) throws OperationException
      Registers an operation given its class. The operation class MUST be annotated using Operation annotation. If the replace argument is true then any existing operation having the same ID will replaced with this one.
      Throws:
      OperationException
    • putOperation

      void putOperation(Class<?> type, boolean replace, String contributingComponent) throws OperationException
      Registers an operation given its class. The operation class MUST be annotated using Operation annotation. If the replace argument is true then any existing operation having the same ID will replaced with this one. Third argument represents the name of the component registring the operation
      Throws:
      OperationException
    • putOperation

      void putOperation(OperationType op, boolean replace) throws OperationException
      Registers an operation given it's type.
      Throws:
      OperationException
      Since:
      5.9.2
    • removeOperation

      void removeOperation(Class<?> key)
      Removes an operation given its class. If the operation was not registered does nothing.
    • removeOperation

      void removeOperation(OperationType type)
      Removes an operation given it's type. If the operation was not registered does nothing.
      Since:
      5.9.2
    • getOperations

      OperationType[] getOperations()
      Gets all operation types that was registered.
    • getOperation

      Gets an operation type given its ID. Throws an exception if the operation is not found.
      Throws:
      OperationNotFoundException
    • compileChain

      CompiledChain compileChain(Class<?> inputType, OperationChain chain) throws OperationException
      Builds the operation chain given a context. If the context input object or the chain cannot be resolved (no path can be found through all the operation in the chain) then InvalidChainException is thrown. The returned object can be used to run the chain.
      Throws:
      OperationException
    • compileChain

      CompiledChain compileChain(Class<?> inputType, OperationParameters... chain) throws OperationException
      Same as previous but takes an array of operation parameters
      Throws:
      OperationException
    • run

      Builds and runs the operation chain given a context. If the context input object or the chain cannot be resolved (no path can be found through all the operation in the chain) then InvalidChainException is thrown.
      Throws:
      OperationException
    • run

      Object run(OperationContext ctx, String chainId) throws OperationException
      Same as previous but for managed chains identified by an ID. For managed chains always use this method since the compiled chain is cached and run will be faster
      Throws:
      OperationException
    • run

      Object run(OperationContext ctx, String id, Map<String,?> params) throws OperationException
      Shortcut to execute a single operation described by the given ID and map of parameters
      Throws:
      OperationException
    • putTypeAdapter

      void putTypeAdapter(Class<?> accept, Class<?> produce, TypeAdapter adapter)
      Registers a new type adapter that can adapt an instance of the accepted type into one of the produced type.
    • removeTypeAdapter

      void removeTypeAdapter(Class<?> accept, Class<?> produce)
      Removes a type adapter
    • getTypeAdapter

      TypeAdapter getTypeAdapter(Class<?> accept, Class<?> produce)
      Gets a type adapter for the input type accept and the output type produce. Returns null if no adapter was registered for these types.
    • getAdaptedValue

      <T> T getAdaptedValue(OperationContext ctx, Object toAdapt, Class<?> targetType) throws OperationException
      Adapts an object to a target type if possible otherwise throws an exception. The method must be called in an operation execution with a valid operation context.
      Throws:
      OperationException
    • isTypeAdaptable

      boolean isTypeAdaptable(Class<?> typeToAdapt, Class<?> targetType)
      Checks whether or not the given type is adaptable into the target type. An instance of an adaptable type can be converted into an instance of the target type.

      This is a shortcut to getTypeAdapter(typeToAdapt, targetType) != null

    • getDocumentation

      List<OperationDocumentation> getDocumentation() throws OperationException
      Generates a documentation model for all registered operations. The documentation model is generated from operation annotations and can be used in UI tools to describe operations. The returned list is sorted using operation ID. Optional method.
      Throws:
      OperationException
    • hasOperation

      boolean hasOperation(String id)
      Parameters:
      id - operation ID
      Returns:
      true if operation registry contains the given operation
      Since:
      5.7.2
    • putChainException

      void putChainException(ChainException exceptionChain)
      Since:
      5.7.3
    • removeExceptionChain

      void removeExceptionChain(ChainException exceptionChain)
      Since:
      5.7.3
    • getChainExceptions

      ChainException[] getChainExceptions()
      Since:
      5.7.3
    • getChainException

      ChainException getChainException(String onChainId)
      Since:
      5.7.3
    • putAutomationFilter

      void putAutomationFilter(AutomationFilter automationFilter)
      Since:
      5.7.3
    • removeAutomationFilter

      void removeAutomationFilter(AutomationFilter automationFilter)
      Since:
      5.7.3
    • getAutomationFilter

      AutomationFilter getAutomationFilter(String id)
      Since:
      5.7.3
    • getAutomationFilters

      AutomationFilter[] getAutomationFilters()
      Since:
      5.7.3
    • hasChainException

      boolean hasChainException(String onChainId)
      Since:
      5.7.3
    • putOperation

      void putOperation(Class<?> type, boolean replace, String contributingComponent, List<WidgetDefinition> widgetDefinitionList) throws OperationException
      Throws:
      OperationException
      Since:
      5.9.5
    • runInNewTx

      Object runInNewTx(OperationContext ctx, String chainId, Map<String,?> chainParameters, Integer timeout, boolean rollbackGlobalOnError) throws OperationException
      This running method execute operation process through a new transaction.
      Parameters:
      ctx - the operation context.
      chainId - the chain Id.
      chainParameters - chain parameters.
      timeout - Transaction timeout.
      rollbackGlobalOnError - Rollback or not transaction after failing.
      Throws:
      OperationException
      Since:
      6.0