more updates to handle date ranges with my custom range language
This commit is contained in:
@@ -3,6 +3,8 @@ package org.lucares.pdbui;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.text.Collator;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -26,6 +28,9 @@ import org.lucares.pdb.api.DateTimeRange;
|
||||
import org.lucares.pdb.api.QueryWithCaretMarker;
|
||||
import org.lucares.pdb.api.QueryWithCaretMarker.ResultMode;
|
||||
import org.lucares.pdb.datastore.Proposal;
|
||||
import org.lucares.pdb.plot.api.DateTimeRangeParser;
|
||||
import org.lucares.pdb.plot.api.DateValue;
|
||||
import org.lucares.pdb.plot.api.DateValue.DateType;
|
||||
import org.lucares.pdb.plot.api.PlotSettings;
|
||||
import org.lucares.pdbui.domain.AutocompleteProposal;
|
||||
import org.lucares.pdbui.domain.AutocompleteProposalByValue;
|
||||
@@ -345,6 +350,22 @@ public class PdbController implements HardcodedValues, PropertyKeys {
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/dates", //
|
||||
method = RequestMethod.POST, //
|
||||
consumes = MediaType.APPLICATION_JSON_VALUE, //
|
||||
produces = MediaType.APPLICATION_JSON_VALUE //
|
||||
)
|
||||
@ResponseBody
|
||||
public DateTimeRange dates(@RequestBody final DateValue dateValue) {
|
||||
final DateType type = dateValue.getType();
|
||||
final DateTimeRange result = switch (type) {
|
||||
case RELATIVE -> DateTimeRangeParser.parse(OffsetDateTime.now(ZoneId.of("UTC")), dateValue.getValue());
|
||||
case QUICK -> DateTimeRangeParser.parse(OffsetDateTime.now(ZoneId.of("UTC")), dateValue.getValue());
|
||||
case ABSOLUTE -> DateTimeRangeParser.parseAbsolute(dateValue.getValue());
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping(path = "/data", consumes = MediaType.MULTIPART_MIXED_VALUE)
|
||||
@ResponseBody
|
||||
@ResponseStatus(code = HttpStatus.CREATED)
|
||||
|
||||
Reference in New Issue
Block a user