From 0f9035b9d5e61d45f0f122c4150996ef64faae0f Mon Sep 17 00:00:00 2001 From: Emmanuel Mathot Date: Mon, 17 Jun 2024 10:39:41 +0200 Subject: [PATCH] chore: Add option to skip collections with items in GeosquarePublicationModel --- .../ThirdParty/Publication/GeosquarePublicationModel.cs | 2 ++ src/Stars.Data/ThirdParty/Publication/GeosquareService.cs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/Stars.Data/ThirdParty/Publication/GeosquarePublicationModel.cs b/src/Stars.Data/ThirdParty/Publication/GeosquarePublicationModel.cs index 2a3f0d1e..e5c044ad 100644 --- a/src/Stars.Data/ThirdParty/Publication/GeosquarePublicationModel.cs +++ b/src/Stars.Data/ThirdParty/Publication/GeosquarePublicationModel.cs @@ -120,6 +120,8 @@ internal void UpdateLink(SyndicationLink link, AtomItem item, IAssetsContainer a public List AssetsFilters { get; set; } public bool PublishCollections { get; set; } = false; + + public bool SkipCollectionsWithItems { get; set; } = false; } } diff --git a/src/Stars.Data/ThirdParty/Publication/GeosquareService.cs b/src/Stars.Data/ThirdParty/Publication/GeosquareService.cs index f053dc46..01422f70 100644 --- a/src/Stars.Data/ThirdParty/Publication/GeosquareService.cs +++ b/src/Stars.Data/ThirdParty/Publication/GeosquareService.cs @@ -149,6 +149,14 @@ public async Task PostCollectionToCatalog(ICollection collectionNode, IR GeosquarePublicationState catalogPublicationState = state as GeosquarePublicationState; AtomItemNode atomItemNode = null; + // Get Item from the collection + var items = collectionNode.GetLinks().Where(l => l.Relationship == "item"); + if ( items.Any() && catalogPublicationState.GeosquarePublicationModel.SkipCollectionsWithItems == true) + { + logger.LogWarning("Skipping collection {0} because it has items", collectionNode); + return state; + } + // Filter assets // Create the asset filters based on the asset filters string from the catalog publication model AssetFilters assetFilters = AssetFilters.CreateAssetFilters(catalogPublicationState.GeosquarePublicationModel.AssetsFilters);