From 71a8d1933b06c1957723efd738f8cc0065733e4c Mon Sep 17 00:00:00 2001 From: HuaizhiDai Date: Fri, 13 Sep 2024 11:13:50 +1000 Subject: [PATCH 1/9] add link protocols --- .../org/aodn/esindexer/utils/LinkUtils.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java diff --git a/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java b/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java new file mode 100644 index 00000000..14beaf86 --- /dev/null +++ b/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java @@ -0,0 +1,48 @@ +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 + private final static List 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 WFS = Arrays.asList( + "OGC:WFS-1.0.0-http-get-capabilities", + "OGC:WFS" + ); + + private final static List 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 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 METADATA_RECORD = List.of( + "WWW:LINK-1.0-http--metadata-URL" + ); + + public static boolean isSupplementaryLink (String protocol) { + return SUPPLEMENTARY.contains(protocol); + } + +} From fca3bbed2b8bb9da393a70f722d5da80e615360b Mon Sep 17 00:00:00 2001 From: HuaizhiDai Date: Fri, 13 Sep 2024 11:19:55 +1000 Subject: [PATCH 2/9] set related rel for supplementary links only --- .../service/StacCollectionMapperService.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java b/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java index a222207e..ad1bfd03 100644 --- a/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java +++ b/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java @@ -542,7 +542,16 @@ List 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()); + safeGet(() -> ciOnlineResource.getProtocol().getCharacterString().getValue().toString()) + .ifPresent(protocol -> { + + // only supplementary links are related (need to be displayed + // in the link panel) + if (LinkUtils.isSupplementaryLink(protocol)) { + linkModel.setRel(RelationType.RELATED.getValue()); + } + }); + linkModel.setTitle(getOnlineResourceName(ciOnlineResource)); results.add(linkModel); } From 40c89277023d95b036bf0319f4412992e76e5279 Mon Sep 17 00:00:00 2001 From: HuaizhiDai Date: Fri, 13 Sep 2024 13:38:14 +1000 Subject: [PATCH 3/9] change the algorithm --- .../aodn/esindexer/service/StacCollectionMapperService.java | 5 ++--- .../src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java b/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java index ad1bfd03..c7ead250 100644 --- a/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java +++ b/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java @@ -545,9 +545,8 @@ List mapLinks(MDMetadataType source) { safeGet(() -> ciOnlineResource.getProtocol().getCharacterString().getValue().toString()) .ifPresent(protocol -> { - // only supplementary links are related (need to be displayed - // in the link panel) - if (LinkUtils.isSupplementaryLink(protocol)) { + // WMS or WFS links shouldn't be displayed in the link panel) + if (!LinkUtils.isWmsOrWfs(protocol)) { linkModel.setRel(RelationType.RELATED.getValue()); } }); diff --git a/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java b/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java index 14beaf86..2daf3d5a 100644 --- a/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java +++ b/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java @@ -41,8 +41,8 @@ public class LinkUtils { "WWW:LINK-1.0-http--metadata-URL" ); - public static boolean isSupplementaryLink (String protocol) { - return SUPPLEMENTARY.contains(protocol); + public static boolean isWmsOrWfs (String protocol) { + return WMS.contains(protocol) || WFS.contains(protocol); } } From 093c1d1946f5adf5d1f6844d5fd63d7920665d92 Mon Sep 17 00:00:00 2001 From: HuaizhiDai Date: Fri, 13 Sep 2024 14:08:15 +1000 Subject: [PATCH 4/9] test fixing --- .../service/StacCollectionMapperService.java | 7 +++++-- .../src/test/resources/canned/sample10_stac.json | 2 +- .../src/test/resources/canned/sample15_stac.json | 2 +- .../src/test/resources/canned/sample4_stac.json | 14 +++++++------- .../canned/sample_multiple_temporal1_stac.json | 4 ++-- .../canned/sample_multiple_temporal2_stac.json | 4 ++-- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java b/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java index c7ead250..547569f6 100644 --- a/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java +++ b/indexer/src/main/java/au/org/aodn/esindexer/service/StacCollectionMapperService.java @@ -542,10 +542,13 @@ List 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()); + + // 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 -> { - - // WMS or WFS links shouldn't be displayed in the link panel) if (!LinkUtils.isWmsOrWfs(protocol)) { linkModel.setRel(RelationType.RELATED.getValue()); } diff --git a/indexer/src/test/resources/canned/sample10_stac.json b/indexer/src/test/resources/canned/sample10_stac.json index 9f71b1f3..06c3838a 100644 --- a/indexer/src/test/resources/canned/sample10_stac.json +++ b/indexer/src/test/resources/canned/sample10_stac.json @@ -1068,7 +1068,7 @@ }, { "href": "http://geoserver-123.aodn.org.au/geoserver/wms", - "rel": "related", + "rel": "", "type": "", "title": "imos:anmn_velocity_timeseries_map" }, diff --git a/indexer/src/test/resources/canned/sample15_stac.json b/indexer/src/test/resources/canned/sample15_stac.json index 7172fcdb..3aed609d 100644 --- a/indexer/src/test/resources/canned/sample15_stac.json +++ b/indexer/src/test/resources/canned/sample15_stac.json @@ -372,7 +372,7 @@ }, { "href": "https://geoserver.imas.utas.edu.au/geoserver/seamap/wms", - "rel": "related", + "rel": "", "type": "", "title": "seamap:SeamapAus_QLD_GBRWHA_seagrass" }, diff --git a/indexer/src/test/resources/canned/sample4_stac.json b/indexer/src/test/resources/canned/sample4_stac.json index 2dabd783..7f520fc6 100644 --- a/indexer/src/test/resources/canned/sample4_stac.json +++ b/indexer/src/test/resources/canned/sample4_stac.json @@ -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" }, { diff --git a/indexer/src/test/resources/canned/sample_multiple_temporal1_stac.json b/indexer/src/test/resources/canned/sample_multiple_temporal1_stac.json index 2fa2091c..87aead52 100644 --- a/indexer/src/test/resources/canned/sample_multiple_temporal1_stac.json +++ b/indexer/src/test/resources/canned/sample_multiple_temporal1_stac.json @@ -506,7 +506,7 @@ }, { "href": "https://geoserver.apps.aims.gov.au/aims/ows", - "rel": "related", + "rel": "", "type": "", "title": "aims:weather_data" }, @@ -518,7 +518,7 @@ }, { "href": "https://geoserver.apps.aims.gov.au/aims/wms", - "rel": "related", + "rel": "", "type": "", "title": "aims:weather_deployment" }, diff --git a/indexer/src/test/resources/canned/sample_multiple_temporal2_stac.json b/indexer/src/test/resources/canned/sample_multiple_temporal2_stac.json index 935928be..60897eee 100644 --- a/indexer/src/test/resources/canned/sample_multiple_temporal2_stac.json +++ b/indexer/src/test/resources/canned/sample_multiple_temporal2_stac.json @@ -506,7 +506,7 @@ }, { "href": "https://geoserver.apps.aims.gov.au/aims/ows", - "rel": "related", + "rel": "", "type": "", "title": "aims:weather_data" }, @@ -518,7 +518,7 @@ }, { "href": "https://geoserver.apps.aims.gov.au/aims/wms", - "rel": "related", + "rel": "", "type": "", "title": "aims:weather_deployment" }, From cbfe193aa7ed308a0b5c5d7aee9b0adadd42fea2 Mon Sep 17 00:00:00 2001 From: HuaizhiDai Date: Fri, 13 Sep 2024 14:12:04 +1000 Subject: [PATCH 5/9] format fixing --- indexer/src/test/resources/canned/sample10_stac.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indexer/src/test/resources/canned/sample10_stac.json b/indexer/src/test/resources/canned/sample10_stac.json index 06c3838a..a4493faa 100644 --- a/indexer/src/test/resources/canned/sample10_stac.json +++ b/indexer/src/test/resources/canned/sample10_stac.json @@ -1068,7 +1068,7 @@ }, { "href": "http://geoserver-123.aodn.org.au/geoserver/wms", - "rel": "", + "rel": "", "type": "", "title": "imos:anmn_velocity_timeseries_map" }, From 4991b6db5a45b4c73b65e561895949bc2050aaab Mon Sep 17 00:00:00 2001 From: HuaizhiDai Date: Mon, 16 Sep 2024 11:22:11 +1000 Subject: [PATCH 6/9] update link protocol check --- .../main/java/au/org/aodn/esindexer/utils/LinkUtils.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java b/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java index 2daf3d5a..bc895ad3 100644 --- a/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java +++ b/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java @@ -10,7 +10,7 @@ @SuppressWarnings("unused") public class LinkUtils { - // protocols + // protocols as reference private final static List WMS = Arrays.asList( "OGC:WMS-1.1.1-http-get-map", "OGC:WMS-1.3.0-http-get-map", @@ -42,7 +42,10 @@ public class LinkUtils { ); public static boolean isWmsOrWfs (String protocol) { - return WMS.contains(protocol) || WFS.contains(protocol); + return protocol.contains("OGC:WMS") + || protocol.contains("OGC:WFS") + || protocol.contains("IMOS:NCWMS") + ; } } From 811d892878a96b600c84808a0c7ebe3ef6600b4b Mon Sep 17 00:00:00 2001 From: HuaizhiDai Date: Mon, 16 Sep 2024 11:48:21 +1000 Subject: [PATCH 7/9] test fixing --- indexer/src/test/resources/canned/sample15_stac.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indexer/src/test/resources/canned/sample15_stac.json b/indexer/src/test/resources/canned/sample15_stac.json index 3aed609d..84a02772 100644 --- a/indexer/src/test/resources/canned/sample15_stac.json +++ b/indexer/src/test/resources/canned/sample15_stac.json @@ -366,7 +366,7 @@ "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" }, From 085a9cefcaed2ce55c281a6a1a99cfea48e432fa Mon Sep 17 00:00:00 2001 From: HuaizhiDai Date: Mon, 16 Sep 2024 11:48:53 +1000 Subject: [PATCH 8/9] a new protocol --- indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java b/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java index bc895ad3..618b2be6 100644 --- a/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java +++ b/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java @@ -20,6 +20,7 @@ public class LinkUtils { private final static List WFS = Arrays.asList( "OGC:WFS-1.0.0-http-get-capabilities", + "OGC:WFS-1.0.0-http-get-feature--shapefile", "OGC:WFS" ); From ed100fe4eb0ba05f20632eb817eb5965321a92e4 Mon Sep 17 00:00:00 2001 From: HuaizhiDai Date: Mon, 16 Sep 2024 14:00:18 +1000 Subject: [PATCH 9/9] use startWith --- .../main/java/au/org/aodn/esindexer/utils/LinkUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java b/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java index 618b2be6..ebfcac7f 100644 --- a/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java +++ b/indexer/src/main/java/au/org/aodn/esindexer/utils/LinkUtils.java @@ -43,9 +43,9 @@ public class LinkUtils { ); public static boolean isWmsOrWfs (String protocol) { - return protocol.contains("OGC:WMS") - || protocol.contains("OGC:WFS") - || protocol.contains("IMOS:NCWMS") + return protocol.startsWith("OGC:WMS") + || protocol.startsWith("OGC:WFS") + || protocol.startsWith("IMOS:NCWMS") ; }