Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.org.aodn.ogcapi.server.core.model.enumeration;

import co.elastic.clients.elasticsearch._types.SortOptions;
import co.elastic.clients.elasticsearch._types
.SortOptions;
import co.elastic.clients.elasticsearch._types.SortOrder;
import co.elastic.clients.elasticsearch._types.TopLeftBottomRightGeoBounds;
import co.elastic.clients.elasticsearch._types.query_dsl.Query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public enum FeatureId {
wave_buoy_first_data_available("wave_buoy_first_data_available"),
wave_buoy_latest_date("wave_buoy_latest_date"),
wave_buoy_timeseries("wave_buoy_timeseries"),
wave_buoy_all("wave_buoy_all"),
wms_map_tile("wms_map_tile"),
wms_map_feature("wms_map_feature"),
wms_layers("wms_layers"), // Get all available layers from WMS GetCapabilities
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ public byte[] getWaveBuoyData(String from, String to, String buoy){
return httpClient.exchange(waveBuoyDataUrlTemplate, HttpMethod.GET,httpEntity,byte[].class,params).getBody();
}

public byte[] getLatestWaveBuoySites(){
String waveBuoysUrlTemplate = UriComponentsBuilder.fromUriString(dasConfig.host + "/api/v1/das/data/feature-collection/wave-buoy/all")
.encode()
.toUriString();

return httpClient.exchange(waveBuoysUrlTemplate, HttpMethod.GET,httpEntity,byte[].class).getBody();
}

public boolean isCollectionSupported(String collectionId){
final String waveBuoyRealtimeCollectionID = "b299cdcd-3dee-48aa-abdd-e0fcdbb9cadc";
return waveBuoyRealtimeCollectionID.contentEquals(collectionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ public ResponseEntity<?> getFeature(
case wave_buoy_timeseries -> {
return featuresService.getWaveBuoyData(collectionId, request.getDatetime(), request.getWaveBuoy());
}
case wave_buoy_all -> {
return featuresService.getLatestWaveBuoySites(collectionId);
}
case wfs_fields -> {
return featuresService.getWfsFields(collectionId, request);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,26 @@ public ResponseEntity<?> getWaveBuoyData(String collectionID, String datetime, S
return ResponseEntity.internalServerError().build();
}
}

/**
* This is to get all buoy sites with their latest available observation
*
* @param collectionID - uuid
* @return -
*/
public ResponseEntity<?> getLatestWaveBuoySites(String collectionID) {
if (!dasService.isCollectionSupported(collectionID)) {
return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).build();
}
try {
return ResponseEntity
.ok()
.header("Content-Type", MediaType.APPLICATION_JSON_VALUE)
.body(dasService.getLatestWaveBuoySites());

} catch (Exception e) {
log.error("Error fetching wave buoy all unique sites date: {}", e.getMessage());
return ResponseEntity.internalServerError().build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,37 @@ public void testGetWaveBuoysLatestDateServiceError() {
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
}

@Test
public void testGetLatestWaveBuoySitesSuccess() {
byte[] mockResponse = "[{\"site_code\":\"SITE1\"}]".getBytes();
when(dasService.isCollectionSupported(SUPPORTED_COLLECTION_ID)).thenReturn(true);
when(dasService.getLatestWaveBuoySites()).thenReturn(mockResponse);

ResponseEntity<?> response = restServices.getLatestWaveBuoySites(SUPPORTED_COLLECTION_ID);

assertEquals(HttpStatus.OK, response.getStatusCode());
assertEquals(mockResponse, response.getBody());
}

@Test
public void testGetLatestWaveBuoySitesUnsupportedCollection() {
when(dasService.isCollectionSupported("unsupported-id")).thenReturn(false);

ResponseEntity<?> response = restServices.getLatestWaveBuoySites("unsupported-id");

assertEquals(HttpStatus.NOT_IMPLEMENTED, response.getStatusCode());
}

@Test
public void testGetLatestWaveBuoySitesServiceError() {
when(dasService.isCollectionSupported(SUPPORTED_COLLECTION_ID)).thenReturn(true);
when(dasService.getLatestWaveBuoySites()).thenThrow(new RuntimeException("Connection refused"));

ResponseEntity<?> response = restServices.getLatestWaveBuoySites(SUPPORTED_COLLECTION_ID);

assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, response.getStatusCode());
}

@Test
public void testGetWfsTimeFieldWorks() {
when(wfsServer.getFieldValues(anyString(), any(WfsServer.WfsFeatureRequest.class), any(ParameterizedTypeReference.class)))
Expand Down
Loading