Class ApiControllerUtil
java.lang.Object
com.bluebell.greenhouse.planter.controllers.util.ApiControllerUtil
Utility class for api controllers.
- Version:
- 3.0.6
- Author:
- Stephen Prizio
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.http.ResponseEntity<org.springframework.core.io.ByteArrayResource> buildDownloadResponse(File file, org.springframework.http.MediaType mediaType) Builds a file-download response and ensures the temporary file is deleted afterwards.static org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody> buildStreamingDownloadResponse(File file, org.springframework.http.MediaType mediaType) Builds a streaming file-download response and ensures the temporary file is deleted afterwards.static LocalDateParses an optional ISO date or date-time value as a local date.static AnalysisFilterresolveAnalysisFilter(String filter) Resolves an analysis filter.static ZoneIdresolveOptionalTimeZone(String timeZone) Resolves an optional timezone parameter.static PositionDurationFilterresolvePositionDurationFilter(String positionDurationFilter) Resolves a position-duration filter.static RecordTimeIntervalresolveRecordTimeInterval(String interval) Resolves a record interval.static ZoneIdresolveTimeZone(String timeZone) Resolves a required timezone parameter.static ZoneIdresolveTimeZoneOrUtc(String timeZone) Resolves a timezone parameter, defaulting to UTC when omitted.static DayOfWeekresolveWeekday(String weekday) Resolves a weekday.static voidvalidateDateTimeFormat(String date) Basic data integrity validation.static voidvalidateStartAndEndDateTimeFormats(String start, String end) Basic data integrity validation.static booleanvalidateSymbol(String symbol) Validates the given symbol is of the correct format.
-
Method Details
-
validateSymbol
Validates the given symbol is of the correct format.- Parameters:
symbol- symbol- Returns:
- true if no illegal characters are present
-
validateDateTimeFormat
Basic data integrity validation.- Parameters:
date- date of format yyyy-MM-dd
-
validateStartAndEndDateTimeFormats
-
resolveAnalysisFilter
Resolves an analysis filter.- Parameters:
filter- filter enum code- Returns:
AnalysisFilter
-
resolveWeekday
-
resolvePositionDurationFilter
Resolves a position-duration filter.- Parameters:
positionDurationFilter- position-duration filter code- Returns:
PositionDurationFilter
-
resolveRecordTimeInterval
Resolves a record interval.- Parameters:
interval- record interval code- Returns:
RecordTimeInterval
-
parseOptionalIsoDateOrDateTime
-
resolveOptionalTimeZone
-
resolveTimeZoneOrUtc
-
resolveTimeZone
-
buildDownloadResponse
public static org.springframework.http.ResponseEntity<org.springframework.core.io.ByteArrayResource> buildDownloadResponse(File file, org.springframework.http.MediaType mediaType) throws IOException Builds a file-download response and ensures the temporary file is deleted afterwards.- Parameters:
file-FilemediaType-MediaType- Returns:
ResponseEntity- Throws:
IOException- if the file cannot be read
-
buildStreamingDownloadResponse
public static org.springframework.http.ResponseEntity<org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody> buildStreamingDownloadResponse(File file, org.springframework.http.MediaType mediaType) Builds a streaming file-download response and ensures the temporary file is deleted afterwards.- Parameters:
file-FilemediaType-MediaType- Returns:
ResponseEntity
-