Class ForecastRatingProposalUpdate

java.lang.Object
energy.trolie.client.impl.request.AbstractStreamingUpdate<ForecastRatingProposalStatus>
energy.trolie.client.request.ratingproposals.ForecastRatingProposalUpdate
All Implemented Interfaces:
StreamingUpdate<ForecastRatingProposalStatus>, AutoCloseable

public class ForecastRatingProposalUpdate extends energy.trolie.client.impl.request.AbstractStreamingUpdate<ForecastRatingProposalStatus>

Streaming update for forecast rating proposals. Users stream out proposals by invoking methods in the following sequence:

  1. begin(ForecastProposalHeader) with a completely populated header.
  2. beginResource(String) for each resource. Then, within that resource,
  3. periodBuilder() for each period in the forecast window.
  4. endResource() before calling beginResource(String) again for a new resource.
  5. complete() to synchronously finish the request.
  • Constructor Details

    • ForecastRatingProposalUpdate

      public ForecastRatingProposalUpdate(org.apache.hc.client5.http.classic.HttpClient httpClient, TrolieHost host, org.apache.hc.client5.http.config.RequestConfig requestConfig, int bufferSize, com.fasterxml.jackson.databind.ObjectMapper objectMapper, Map<String,String> httpHeaders, int defaultIntervalMinutes)
      Constructs a new update. Should not be called by application code.
      Parameters:
      httpClient - client
      host - host
      requestConfig - HTTP client request config
      bufferSize - configure buffer size
      objectMapper - Jackson object mapper
      httpHeaders - passed headers
      defaultIntervalMinutes - forecast interval minutes
  • Method Details

    • getRequest

      protected org.apache.hc.client5.http.classic.methods.HttpUriRequestBase getRequest()
      Specified by:
      getRequest in class energy.trolie.client.impl.request.AbstractStreamingUpdate<ForecastRatingProposalStatus>
      Returns:
      Apache HTTP client request associated with this request.
    • getContentType

      protected org.apache.hc.core5.http.ContentType getContentType()
      Specified by:
      getContentType in class energy.trolie.client.impl.request.AbstractStreamingUpdate<ForecastRatingProposalStatus>
      Returns:
      content type associated with this update
    • getPath

      protected String getPath()
      Specified by:
      getPath in class energy.trolie.client.impl.request.AbstractStreamingUpdate<ForecastRatingProposalStatus>
      Returns:
      HTTP path associated with this update
    • getResponseHandler

      protected Function<org.apache.hc.core5.http.HttpEntity,ForecastRatingProposalStatus> getResponseHandler()
      Specified by:
      getResponseHandler in class energy.trolie.client.impl.request.AbstractStreamingUpdate<ForecastRatingProposalStatus>
      Returns:
      handler associated with this update.
    • begin

      public void begin(ForecastProposalHeader header)
      Begin the stream, sending a populated header
      Parameters:
      header - populated header. Must include at least emergency rating durations and power system resources
    • beginResource

      public void beginResource(String resourceId)
      Begin writing a new group of ratings for a particular resource.
      Parameters:
      resourceId - resource ID to write
    • periodBuilder

      public ForecastPeriodBuilder periodBuilder()
      Fluent way of constructing valid forecast periods. Use of these builders is the recommended way to send ratings for a given period.
      Returns:
      instance of a ForecastPeriodBuilder to create a new period.
    • period

      public void period(ForecastRatingPeriod forecastRatingPeriod)

      Write out a rating set, using the JSON format in a relatively raw way.

      NOTE: this method is only intended for advanced users with a low-level understanding of the schema. periodBuilder() is preferred for most users.

      Parameters:
      forecastRatingPeriod - per-period rating set applying to the last resource set in beginResource(String).
    • endResource

      public void endResource()
      Finish the resource set started with beginResource(String).
    • complete

      public ForecastRatingProposalStatus complete()
      Finalize the request.
      Returns:
      status of the proposal retrieved from the TROLIE server. NOTE: TROLIE allows for partial proposal updates. Be sure to check and appropriately log any validation errors returned with this status, as they will indicate that ratings were not sent successfully for those resources.
    • close

      public void close()
      Close underlying resources
      Specified by:
      close in interface AutoCloseable
      Overrides:
      close in class energy.trolie.client.impl.request.AbstractStreamingUpdate<ForecastRatingProposalStatus>