Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/5854 differenciate link by protocol #138

Merged
merged 10 commits into from
Sep 16, 2024
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 @@ -542,7 +542,18 @@ List<LinkModel> mapLinks(MDMetadataType source) {
linkModel.setType(Objects.equals(ciOnlineResource.getProtocol().getCharacterString().getValue().toString(), "WWW:LINK-1.0-http--link") ? "text/html" : "");
}
linkModel.setHref(ciOnlineResource.getLinkage().getCharacterString().getValue().toString());
linkModel.setRel(RelationType.RELATED.getValue());

// an empty string by default
linkModel.setRel("");

// WMS or WFS links shouldn't be displayed in the link panel)
safeGet(() -> ciOnlineResource.getProtocol().getCharacterString().getValue().toString())
.ifPresent(protocol -> {
if (!LinkUtils.isWmsOrWfs(protocol)) {
linkModel.setRel(RelationType.RELATED.getValue());
}
});

linkModel.setTitle(getOnlineResourceName(ciOnlineResource));
results.add(linkModel);
}
Expand Down
52 changes: 52 additions & 0 deletions indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package au.org.aodn.esindexer.utils;

import java.util.Arrays;
import java.util.List;

/**
* Protocols here are referenced from old portal project(Grails). Currently, didn't
* implement all of them. Others can be added if needed.
*/
@SuppressWarnings("unused")
public class LinkUtils {

// protocols as reference
private final static List<String> WMS = Arrays.asList(
HavierD marked this conversation as resolved.
Show resolved Hide resolved
"OGC:WMS-1.1.1-http-get-map",
"OGC:WMS-1.3.0-http-get-map",
"OGC:WMS",
"IMOS:NCWMS--proto"
) ;

private final static List<String> WFS = Arrays.asList(
"OGC:WFS-1.0.0-http-get-capabilities",
"OGC:WFS-1.0.0-http-get-feature--shapefile",
"OGC:WFS"
);

private final static List<String> DATA_FILE = Arrays.asList(
"WWW:DOWNLOAD-1.0-http--download",
"WWW:DOWNLOAD-1.0-http--downloadother",
"WWW:DOWNLOAD-1.0-http--downloaddata",
"WWW:LINK-1.0-http--downloaddata"
);

private final static List<String> SUPPLEMENTARY= Arrays.asList(
"WWW:LINK-1.0-http--link",
"WWW:LINK-1.0-http--downloaddata",
"WWW:LINK-1.0-http--related",
"WWW:DOWNLOAD-1.0-ftp--download"
);

private final static List<String> METADATA_RECORD = List.of(
"WWW:LINK-1.0-http--metadata-URL"
);

public static boolean isWmsOrWfs (String protocol) {
return protocol.startsWith("OGC:WMS")
|| protocol.startsWith("OGC:WFS")
|| protocol.startsWith("IMOS:NCWMS")
;
}

}
2 changes: 1 addition & 1 deletion indexer/src/test/resources/canned/sample10_stac.json
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@
},
{
"href": "http://geoserver-123.aodn.org.au/geoserver/wms",
"rel": "related",
"rel": "",
"type": "",
"title": "imos:anmn_velocity_timeseries_map"
},
Expand Down
4 changes: 2 additions & 2 deletions indexer/src/test/resources/canned/sample15_stac.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,13 @@
"links": [
{
"href": "https://geoserver.imas.utas.edu.au/geoserver/seamap/wfs?version=1.0.0&request=GetFeature&typeName=SeamapAus_QLD_GBRWHA_seagrass&outputFormat=SHAPE-ZIP",
"rel": "related",
"rel": "",
"type": "",
"title": "SHAPE-ZIP"
},
{
"href": "https://geoserver.imas.utas.edu.au/geoserver/seamap/wms",
"rel": "related",
"rel": "",
"type": "",
"title": "seamap:SeamapAus_QLD_GBRWHA_seagrass"
},
Expand Down
14 changes: 7 additions & 7 deletions indexer/src/test/resources/canned/sample4_stac.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,37 +206,37 @@
"title" : "NetCDF files via THREDDS catalog"
}, {
"href" : "http://geoserver-123.aodn.org.au/geoserver/ncwms",
"rel" : "related",
"rel" : "",
"type" : "",
"title" : "csiro_oa_reconstruction_url/SST"
}, {
"href" : "http://geoserver-123.aodn.org.au/geoserver/ncwms",
"rel" : "related",
"rel" : "",
"type" : "",
"title" : "csiro_oa_reconstruction_url/SSS"
}, {
"href" : "http://geoserver-123.aodn.org.au/geoserver/ncwms",
"rel" : "related",
"rel" : "",
"type" : "",
"title" : "csiro_oa_reconstruction_url/ALK"
}, {
"href" : "http://geoserver-123.aodn.org.au/geoserver/ncwms",
"rel" : "related",
"rel" : "",
"type" : "",
"title" : "csiro_oa_reconstruction_url/DIC"
}, {
"href" : "http://geoserver-123.aodn.org.au/geoserver/ncwms",
"rel" : "related",
"rel" : "",
"type" : "",
"title" : "csiro_oa_reconstruction_url/OMEGA_A"
}, {
"href" : "http://geoserver-123.aodn.org.au/geoserver/ncwms",
"rel" : "related",
"rel" : "",
"type" : "",
"title" : "csiro_oa_reconstruction_url/OMEGA_C"
}, {
"href" : "http://geoserver-123.aodn.org.au/geoserver/ncwms",
"rel" : "related",
"rel" : "",
"type" : "",
"title" : "csiro_oa_reconstruction_url/pH_T"
}, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@
},
{
"href": "https://geoserver.apps.aims.gov.au/aims/ows",
"rel": "related",
"rel": "",
"type": "",
"title": "aims:weather_data"
},
Expand All @@ -518,7 +518,7 @@
},
{
"href": "https://geoserver.apps.aims.gov.au/aims/wms",
"rel": "related",
"rel": "",
"type": "",
"title": "aims:weather_deployment"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@
},
{
"href": "https://geoserver.apps.aims.gov.au/aims/ows",
"rel": "related",
"rel": "",
"type": "",
"title": "aims:weather_data"
},
Expand All @@ -518,7 +518,7 @@
},
{
"href": "https://geoserver.apps.aims.gov.au/aims/wms",
"rel": "related",
"rel": "",
"type": "",
"title": "aims:weather_deployment"
},
Expand Down
Loading