Class InsertService

java.lang.Object
com.invirgance.convirgance.web.service.InsertService
All Implemented Interfaces:
Processable, Service

@Wiring public class InsertService extends Object implements Service, Processable
Service implementation for receiving and persisting data from HTTP requests. InsertService processes data submission operations (typically POST requests) by extracting data from HTTP requests, applying transformations, and persisting the results.
 The service follows:
 - Extract parameters from the request
 - Obtain raw data using an Origin component
 - Parse the data with an Input processor
 - Apply optional transformations
 - Persist the data through a Consumer
 - Return any generated keys or results
 
Use this service when you need to create endpoints for data submission, form processing, or implementing POST/PUT operations in REST APIs.
Author:
jbanes
  • Constructor Details

    • InsertService

      public InsertService()
  • Method Details

    • getParameters

      public List<Parameter> getParameters()
      Gets the list of parameters to extract from the request.
      Returns:
      The parameters list
    • setParameters

      public void setParameters(List<Parameter> parameters)
      Sets the list of parameters to extract from the request.
      Parameters:
      parameters - The parameters list
    • getInput

      public com.invirgance.convirgance.input.Input getInput()
      Gets the input parser for the request data.
      Returns:
      The input parser
    • setInput

      public void setInput(com.invirgance.convirgance.input.Input input)
      Sets the input parser for the request data.
      Parameters:
      input - The input parser
    • getOrigin

      public Origin getOrigin()
      Gets the origin of the data to be processed.
      Returns:
      The data origin
    • setOrigin

      public void setOrigin(Origin origin)
      Sets the origin of the data to be processed.
      Parameters:
      origin - The data origin
    • getInjectParameters

      public List<String> getInjectParameters()
    • setInjectParameters

      public void setInjectParameters(List<String> injectParameters)
    • getTransformers

      public List<com.invirgance.convirgance.transform.Transformer> getTransformers()
      Gets the list of transformers to apply to the data.
      Returns:
      The transformers list
    • setTransformers

      public void setTransformers(List<com.invirgance.convirgance.transform.Transformer> transformers)
      Sets the list of transformers to apply to the data.
      Parameters:
      transformers - The transformers list
    • getConsumer

      public Consumer getConsumer()
      Gets the consumer that will persist the processed data.
      Returns:
      The consumer
    • setConsumer

      public void setConsumer(Consumer consumer)
      Sets the consumer that will persist the processed data.
      Parameters:
      consumer - The consumer
    • getOutput

      public com.invirgance.convirgance.output.Output getOutput()
    • setOutput

      public void setOutput(com.invirgance.convirgance.output.Output output)
    • process

      public Iterable<com.invirgance.convirgance.json.JSONObject> process(HttpRequest request)
      Description copied from interface: Processable
      Processes an HTTP request to retrieve data without generating a response.

      This method implements the core data retrieval pipeline and can be used by other components that need access to the data without writing to a response.

      1. Extract parameters from the HTTP request
      2. Store parameters in thread-local storage for access by other components
      3. Use the configured binding to retrieve data based on the parameters
      4. Apply any configured transformers to the data
      Specified by:
      process in interface Processable
      Parameters:
      request - The HTTP request containing the parameters
      Returns:
      An iterable of JSONObjects containing the retrieved and transformed data
    • execute

      public void execute(HttpRequest request, HttpResponse response)
      Executes the insert service, processing and persisting data from the HTTP request.
      Specified by:
      execute in interface Service
      Parameters:
      request - The HTTP request containing the data to process
      response - The HTTP response to write results to
      Throws:
      com.invirgance.convirgance.ConvirganceException - If an error occurs during processing