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:
begin(ForecastProposalHeader)
with a completely populated header.beginResource(String)
for each resource. Then, within that resource,periodBuilder()
for each period in the forecast window.endResource()
before callingbeginResource(String)
again for a new resource.complete()
to synchronously finish the request.
-
Field Summary
Fields inherited from class energy.trolie.client.impl.request.AbstractStreamingUpdate
objectMapper
-
Constructor Summary
ConstructorsConstructorDescriptionForecastRatingProposalUpdate
(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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
begin
(ForecastProposalHeader header) Begin the stream, sending a populated headervoid
beginResource
(String resourceId) Begin writing a new group of ratings for a particular resource.void
close()
Close underlying resourcescomplete()
Finalize the request.void
Finish the resource set started withbeginResource(String)
.protected org.apache.hc.core5.http.ContentType
protected String
getPath()
protected org.apache.hc.client5.http.classic.methods.HttpUriRequestBase
protected Function<org.apache.hc.core5.http.HttpEntity,
ForecastRatingProposalStatus> void
period
(ForecastRatingPeriod forecastRatingPeriod) Write out a rating set, using the JSON format in a relatively raw way.Fluent way of constructing valid forecast periods.Methods inherited from class energy.trolie.client.impl.request.AbstractStreamingUpdate
checkCanWrite, completeRequest, createRequestOutputStream, getFullPath, handleWriteError
-
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
- clienthost
- hostrequestConfig
- HTTP client request configbufferSize
- configure buffer sizeobjectMapper
- Jackson object mapperhttpHeaders
- passed headersdefaultIntervalMinutes
- forecast interval minutes
-
-
Method Details
-
getRequest
protected org.apache.hc.client5.http.classic.methods.HttpUriRequestBase getRequest()- Specified by:
getRequest
in classenergy.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 classenergy.trolie.client.impl.request.AbstractStreamingUpdate<ForecastRatingProposalStatus>
- Returns:
- content type associated with this update
-
getPath
- Specified by:
getPath
in classenergy.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 classenergy.trolie.client.impl.request.AbstractStreamingUpdate<ForecastRatingProposalStatus>
- Returns:
- handler associated with this update.
-
begin
Begin the stream, sending a populated header- Parameters:
header
- populated header. Must include at least emergency rating durations and power system resources
-
beginResource
Begin writing a new group of ratings for a particular resource.- Parameters:
resourceId
- resource ID to write
-
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
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 inbeginResource(String)
.
-
endResource
public void endResource()Finish the resource set started withbeginResource(String)
. -
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 interfaceAutoCloseable
- Overrides:
close
in classenergy.trolie.client.impl.request.AbstractStreamingUpdate<ForecastRatingProposalStatus>
-