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
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,35 @@ default <D extends StacCollectionModel> Collection getCollection(D m, Filter fil
collection.setExtent(extent);
}

if(m.getLinks() != null) {
if(m.getLinks() != null || (m.getUuid() != null && uuidToNotebookName.containsKey(m.getUuid())) || m.getAssets() != null) {
collection.setLinks(new ArrayList<>());

// Convert object type.
collection.getLinks().addAll(
m.getLinks()
.stream()
.map(l -> new Link()
.href(l.getHref())
.type(l.getType())
.rel(l.getRel())
.title(l.getTitle())
)
.toList()
);
if(m.getLinks() != null) {
collection.getLinks().addAll(
m.getLinks()
.stream()
.map(l -> new Link()
.href(l.getHref())
.type(l.getType())
.rel(l.getRel())
.title(l.getTitle())
)
.toList()
);
}

if(m.getAssets() != null) {
m.getAssets().values().forEach(i -> collection.getLinks().add(new Link()
.title(i.getTitle())
.href(host + "/api/v1/ogc" + i.getHref())
.type(i.getType())
.rel(i.getRole().toString().toLowerCase())
));
}

// TODO: This is temp workaround for demo purpose, we need a way to map the notebook name to uuid
if(uuidToNotebookName.containsKey(m.getUuid())) {
if(m.getUuid() != null) {
collection.getLinks().add(new Link()
.href("https://github.com/aodn/aodn_cloud_optimised/blob/main/notebooks/" + uuidToNotebookName.get(m.getUuid()))
.type(MediaType.APPLICATION_JSON_VALUE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package au.org.aodn.ogcapi.server.core.model;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AssetModel {
// https://github.com/radiantearth/stac-spec/blob/master/best-practices.md#list-of-asset-roles
public enum Role {
DATA("data"),
METADATA("metadata"),
THUMBNAIL("thumbnail"),
SUMMARY("summary"),
OVERVIEW("overview"),
VISUAL("visual"),
DATE("date"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.*;

import java.util.List;
import java.util.Map;

/**
* This is used to map the json from Elastic search to object
Expand All @@ -22,6 +23,7 @@ public class StacCollectionModel {
protected List<ContactModel> contacts;
protected List<ThemeModel> themes;
protected String license;
protected Map<String, AssetModel> assets;

@JsonProperty("sci:citation")
protected String citation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ public enum CQLFields implements CQLFieldsInterface {
.query(literal))._toQuery(),
null
),
// Contains cloud-optimized data
assets_summary(
StacBasicField.AssetsSummary.searchField,
StacBasicField.AssetsSummary.displayField,
null,
null
),
;
private final String searchField;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum StacBasicField {
),
Links("links", "links"),
Collection("collection", "collection", "collection.keyword"),
AssetsSummary("assets.summary", "assets.summary")
;

// Field that use to do sort, elastic search treat FieldData (searchField) differently, a searchField is not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,4 +616,34 @@ public void verifySortByTemporalCorrect() throws IOException {
assertEquals("bb3599d5-ab12-4278-a68b-42cac8e7a746", Objects.requireNonNull(collections.getBody()).getCollections().get(6).getId(), "bb3599d5-ab12-4278-a68b-42cac8e7a746");
assertEquals("5c418118-2581-4936-b6fd-d6bedfe74f62", Objects.requireNonNull(collections.getBody()).getCollections().get(7).getId(), "5c418118-2581-4936-b6fd-d6bedfe74f62");
}
/**
* If this field exist, then
*/
@Test
public void verifyAssetSummarySearchWorks() throws IOException {
super.insertJsonToElasticRecordIndex(
"073fde5a-bff3-1c1f-e053-08114f8c5588.json",
"5c418118-2581-4936-b6fd-d6bedfe74f62.json",
"19da2ce7-138f-4427-89de-a50c724f5f54.json",
"516811d7-cd1e-207a-e0440003ba8c79dd.json",
"35234913-aa3c-48ec-b9a4-77f822f66ef8.json" // This one have cloud optimized index, that is assets.summary value
);

ResponseEntity<Collections> collections = testRestTemplate.exchange(
getBasePath() + "/collections?filter=(assets_summary IS NULL)&sortby=-temporal",
HttpMethod.GET,
null,
new ParameterizedTypeReference<>() {});

assertEquals(4, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 4");

collections = testRestTemplate.exchange(
getBasePath() + "/collections?filter=(assets_summary IS NOT NULL)&sortby=-temporal",
HttpMethod.GET,
null,
new ParameterizedTypeReference<>() {});

assertEquals(1, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 1");
assertEquals("35234913-aa3c-48ec-b9a4-77f822f66ef8", Objects.requireNonNull(collections.getBody()).getCollections().get(0).getId(), "asset.summary exist 35234913-aa3c-48ec-b9a4-77f822f66ef8");
}
}
Loading
Loading