From 05dd124a47d406b7af8ecb54f38eccbd6b66e9b4 Mon Sep 17 00:00:00 2001 From: Emmanuel Mathot Date: Thu, 13 Jun 2024 11:50:49 +0200 Subject: [PATCH] post collection with OnCollection --- .../ThirdParty/Publication/GeosquarePublicationModel.cs | 2 ++ src/Stars.Data/ThirdParty/Publication/GeosquareService.cs | 8 ++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Stars.Data/ThirdParty/Publication/GeosquarePublicationModel.cs b/src/Stars.Data/ThirdParty/Publication/GeosquarePublicationModel.cs index f78f45da..2a3f0d1e 100644 --- a/src/Stars.Data/ThirdParty/Publication/GeosquarePublicationModel.cs +++ b/src/Stars.Data/ThirdParty/Publication/GeosquarePublicationModel.cs @@ -118,6 +118,8 @@ internal void UpdateLink(SyndicationLink link, AtomItem item, IAssetsContainer a public string CatalogId { get; set; } public List AssetsFilters { get; set; } + + public bool PublishCollections { get; set; } = false; } } diff --git a/src/Stars.Data/ThirdParty/Publication/GeosquareService.cs b/src/Stars.Data/ThirdParty/Publication/GeosquareService.cs index 5563a8c2..f053dc46 100644 --- a/src/Stars.Data/ThirdParty/Publication/GeosquareService.cs +++ b/src/Stars.Data/ThirdParty/Publication/GeosquareService.cs @@ -129,6 +129,8 @@ private void InitRoutingTask(GeosquarePublicationModel geosquareModel) // routingService.OnRoutingException((route, router, exception, state) => PrintRouteInfo(route, router, exception, state)); routingService.OnBeforeBranching((node, router, state, subroutes, ct) => OnBeforeBranching(node, router, state, subroutes, ct)); routingService.OnItem((node, router, state, ct) => PostItemToCatalog(node, router, state, ct)); + if (geosquareModel.PublishCollections) + routingService.OnCollection((node, router, state, ct) => PostCollectionToCatalog(node, router, state, ct)); // routingService.OnBranching((parentRoute, route, siblings, state) => PrepareNewRoute(parentRoute, route, siblings, state)); } @@ -139,12 +141,6 @@ private async Task OnBeforeBranching(ICatalog node, IRouter router, obje return state; } - // If Collection has assets, we consider it as a single item - if (collection.Assets.Count > 0) - { - await PostCollectionToCatalog(new StacCollectionNode(collection, node.Uri), router, state, ct); - } - return state; }