Skip to content

Commit

Permalink
Merge pull request #138 from aodn/feature/5854-differenciate-link-by-…
Browse files Browse the repository at this point in the history
…protocol

Feature/5854 differenciate link by protocol
  • Loading branch information
HavierD authored Sep 16, 2024
2 parents 934c5ab + ed100fe commit 959d819
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,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(
"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

0 comments on commit 959d819

Please sign in to comment.