From 1d4893c4a51b5b331b2f14d8cdd603d32801fd25 Mon Sep 17 00:00:00 2001 From: Emmanuel Mathot Date: Mon, 30 Oct 2023 13:49:37 +0100 Subject: [PATCH] Better naming + cql fixes --- .../Extensions/Sort/SortModelExtensions.cs | 2 +- .../Extensions/Sort/SortStacApiExtension.cs | 2 +- .../Default/Extensions/Sort/Sortby.cs | 2 +- .../Extensions/StacWebApiExtensions.cs | 2 +- src/Stac.Api.Tests/CQL2FilteringTests.cs | 22 ++-- src/Stac.Api.Tests/CQL2Tests.cs | 65 ++++++---- .../Resources/CQL2/CQL2Tests_Example12.json | 16 +++ .../Filter/DefaultFilterController.cs | 2 +- .../DefaultTransactionController.cs | 2 +- .../Converters/IIsInListOperandConverter.cs | 44 +++++++ .../Converters/ScalarExpressionConverter.cs | 28 ++++- src/Stac.Api/Extensions/NTSExtensions.cs | 82 ++++++++++++ ...{ISearchFilter.cs => ISearchExpression.cs} | 2 +- src/Stac.Api/Models/Cql2/CQL2.cs | 118 +++++++++++++++--- src/Stac.Api/Models/Cql2/Cql2Linq.cs | 2 +- .../Extensions/Filters/CQL2expression.cs | 2 +- .../Extensions/Filters/GeometryExtensions.cs | 1 - .../Extensions/Filters/TemporalExtensions.cs | 1 - .../Extensions/Sort/Context/DefaultSortBy.cs | 2 +- .../Sort/Context/DefaultSortByItem.cs | 2 +- .../Extensions/Sort/Context/ISortByItem.cs | 2 +- .../Extensions/Sort/Context/ISortExtension.cs | 2 +- .../Sort/Context/ISortParameters.cs | 2 +- .../Sort/Context/SortContextFilter.cs | 2 +- .../Extensions/Sort/Context/SortDirection.cs | 2 +- .../Extensions/Sort/Context/SortExtensions.cs | 2 +- .../Transactions/TransactionsExtensions.cs | 2 +- src/Stac.Api/Stac.Api.csproj | 1 - 28 files changed, 339 insertions(+), 75 deletions(-) create mode 100644 src/Stac.Api.Tests/Resources/CQL2/CQL2Tests_Example12.json create mode 100644 src/Stac.Api/Converters/IIsInListOperandConverter.cs create mode 100644 src/Stac.Api/Extensions/NTSExtensions.cs rename src/Stac.Api/Interfaces/{ISearchFilter.cs => ISearchExpression.cs} (79%) rename src/Stac.Api/{ => Models}/Extensions/Sort/Context/DefaultSortBy.cs (87%) rename src/Stac.Api/{ => Models}/Extensions/Sort/Context/DefaultSortByItem.cs (96%) rename src/Stac.Api/{ => Models}/Extensions/Sort/Context/ISortByItem.cs (84%) rename src/Stac.Api/{ => Models}/Extensions/Sort/Context/ISortExtension.cs (87%) rename src/Stac.Api/{ => Models}/Extensions/Sort/Context/ISortParameters.cs (78%) rename src/Stac.Api/{ => Models}/Extensions/Sort/Context/SortContextFilter.cs (99%) rename src/Stac.Api/{ => Models}/Extensions/Sort/Context/SortDirection.cs (62%) rename src/Stac.Api/{ => Models}/Extensions/Sort/Context/SortExtensions.cs (97%) rename src/Stac.Api/{ => Models}/Extensions/Transactions/TransactionsExtensions.cs (96%) diff --git a/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/SortModelExtensions.cs b/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/SortModelExtensions.cs index 879f015..cb7b700 100644 --- a/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/SortModelExtensions.cs +++ b/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/SortModelExtensions.cs @@ -6,7 +6,7 @@ using Newtonsoft.Json.Linq; using Stac.Api.Attributes; using Stac.Api.Clients.ItemSearch; -using Stac.Api.Extensions.Sort.Context; +using Stac.Api.Models.Extensions.Sort.Context; using Stac.Api.Interfaces; namespace Stac.Api.Clients.Extensions.Sort diff --git a/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/SortStacApiExtension.cs b/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/SortStacApiExtension.cs index bd0ad87..9ad6dee 100644 --- a/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/SortStacApiExtension.cs +++ b/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/SortStacApiExtension.cs @@ -6,7 +6,7 @@ using Newtonsoft.Json.Linq; using Stac.Api.Attributes; using Stac.Api.Clients.ItemSearch; -using Stac.Api.Extensions.Sort.Context; +using Stac.Api.Models.Extensions.Sort.Context; using Stac.Api.Interfaces; namespace Stac.Api.Clients.Extensions.Sort diff --git a/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/Sortby.cs b/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/Sortby.cs index 47f3d04..be9cd66 100644 --- a/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/Sortby.cs +++ b/src/Stac.Api.Clients/Implementations/Default/Extensions/Sort/Sortby.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using Stac.Api.Extensions.Sort.Context; +using Stac.Api.Models.Extensions.Sort.Context; using Stac.Api.Services.Queryable; namespace Stac.Api.Clients.Extensions.Sort diff --git a/src/Stac.Api.FileSystem/Extensions/StacWebApiExtensions.cs b/src/Stac.Api.FileSystem/Extensions/StacWebApiExtensions.cs index a9b362e..f1e4d60 100644 --- a/src/Stac.Api.FileSystem/Extensions/StacWebApiExtensions.cs +++ b/src/Stac.Api.FileSystem/Extensions/StacWebApiExtensions.cs @@ -18,7 +18,7 @@ using Stac.Api.WebApi.Implementations.Default.Services; using Stac.Api.WebApi.Services.Context; using Stac.Api.Services.Default; -using Stac.Api.Extensions.Sort.Context; +using Stac.Api.Models.Extensions.Sort.Context; using Stac.Api.Services.Debugging; namespace Stac.Api.FileSystem.Extensions diff --git a/src/Stac.Api.Tests/CQL2FilteringTests.cs b/src/Stac.Api.Tests/CQL2FilteringTests.cs index 53742ca..6ba9b85 100644 --- a/src/Stac.Api.Tests/CQL2FilteringTests.cs +++ b/src/Stac.Api.Tests/CQL2FilteringTests.cs @@ -221,18 +221,18 @@ public async Task Example9Test() Assert.Equal(3, cql.AsAndOrExpression().Args.Count); Assert.Equal(ComparisonPredicateOp.Gt, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Op); - Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); Assert.Equal(50, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[1].AsNumericExpression().AsNumber().Num); Assert.Equal(ComparisonPredicateOp.Lt, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Op); - Assert.Equal("landsat:coverage_percent", cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("landsat:coverage_percent", cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); Assert.Equal(10, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[1].AsNumericExpression().AsNumber().Num); Assert.Equal(AndOrExpressionOp.And, cql.AsAndOrExpression().Args[2].AsAndOrExpression().Op); Assert.IsType(cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[0]); Assert.IsType(cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[1]); - Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[0].AsComparison().AsIsNullPredicate().Args.AsChar().AsPropertyRef().Property); - Assert.Equal("landsat:coverage_percent", cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[1].AsComparison().AsIsNullPredicate().Args.AsChar().AsPropertyRef().Property); + Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[0].AsComparison().AsIsNullPredicate().Args.AsCharExpression().AsPropertyRef().Property); + Assert.Equal("landsat:coverage_percent", cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[1].AsComparison().AsIsNullPredicate().Args.AsCharExpression().AsPropertyRef().Property); json = GetJson("CQL2", "SampleItem", "CQL2Tests"); StacItem item = JsonConvert.DeserializeObject(json); @@ -256,7 +256,7 @@ public async Task Example10Test() Assert.Equal(IsBetweenPredicateOp.Between, cql.AsComparison().AsIsBetweenPredicate().Op); Assert.Equal(3, cql.AsComparison().AsIsBetweenPredicate().Args.Count); - Assert.Equal("eo:cloud_cover", cql.AsComparison().AsIsBetweenPredicate().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("eo:cloud_cover", cql.AsComparison().AsIsBetweenPredicate().Args[0].AsCharExpression().AsPropertyRef().Property); Assert.Equal((double)0, cql.AsComparison().AsIsBetweenPredicate().Args[1].AsNumeric().Value); Assert.Equal((double)50, cql.AsComparison().AsIsBetweenPredicate().Args[2].AsNumeric().Value); @@ -278,13 +278,13 @@ public async Task Example11Test() JObject jObject = JObject.Parse(json); var cql = JsonConvert.DeserializeObject(jObject["filter"].ToString(), _settings); Assert.IsType(cql); - Assert.NotNull(cql.AsComparison().AsIsLike()); - Assert.Equal(IsLikePredicateOp.Like, cql.AsComparison().AsIsLike().Op); - Assert.Equal(2, cql.AsComparison().AsIsLike().Args.Count); + Assert.NotNull(cql.AsComparison().AsIsLikePredicate()); + Assert.Equal(IsLikePredicateOp.Like, cql.AsComparison().AsIsLikePredicate().Op); + Assert.Equal(2, cql.AsComparison().AsIsLikePredicate().Args.Count); - Assert.Equal("mission", cql.AsComparison().AsIsLike().Args[0].AsPropertyRef().Property); - Assert.IsType(cql.AsComparison().AsIsLike().Args[1]); - Assert.Equal("sentinel%", cql.AsComparison().AsIsLike().Args[1].ToString()); + Assert.Equal("mission", cql.AsComparison().AsIsLikePredicate().Args[0].AsPropertyRef().Property); + Assert.IsType(cql.AsComparison().AsIsLikePredicate().Args[1]); + Assert.Equal("sentinel%", cql.AsComparison().AsIsLikePredicate().Args[1].ToString()); json = GetJson("CQL2", "SampleItem", "CQL2Tests"); StacItem item = JsonConvert.DeserializeObject(json); diff --git a/src/Stac.Api.Tests/CQL2Tests.cs b/src/Stac.Api.Tests/CQL2Tests.cs index 63a7423..ac8ee62 100644 --- a/src/Stac.Api.Tests/CQL2Tests.cs +++ b/src/Stac.Api.Tests/CQL2Tests.cs @@ -8,6 +8,9 @@ using Stac.Api.Converters; using GeoJSON.Net.Geometry; using System.Globalization; +using System.Collections; +using System.Linq; +using System.Collections.Generic; namespace Stac.Api.Tests { @@ -36,8 +39,8 @@ public async Task Example1Test() Assert.Equal(ComparisonPredicateOp.Eq, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Op); Assert.Equal(2, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args.Count); Assert.IsType(cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0]); - Assert.Equal("id", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); - Assert.Equal("S2A_60HWB_20201111_0_L2A", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[1].AsChar().ToString()); + Assert.Equal("id", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); + Assert.Equal("S2A_60HWB_20201111_0_L2A", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[1].AsCharExpression().ToString()); } [Fact] @@ -56,19 +59,19 @@ public async Task Example2Test() Assert.Equal(ComparisonPredicateOp.Eq, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Op); Assert.Equal(2, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args.Count); Assert.IsType(cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0]); - Assert.Equal("collection", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); - Assert.Equal("landsat8_l1tp", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[1].AsChar().ToString()); + Assert.Equal("collection", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); + Assert.Equal("landsat8_l1tp", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[1].AsCharExpression().ToString()); Assert.Equal(ComparisonPredicateOp.Le, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Op); Assert.Equal(2, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args.Count); Assert.IsType(cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0]); - Assert.Equal("eo:cloud_cover", cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("eo:cloud_cover", cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); Assert.Equal(10, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[1].AsNumericExpression().AsNumber().Num); Assert.Equal(ComparisonPredicateOp.Ge, cql.AsAndOrExpression().Args[2].AsComparison().AsBinaryComparison().Op); Assert.Equal(2, cql.AsAndOrExpression().Args[2].AsComparison().AsBinaryComparison().Args.Count); Assert.IsType(cql.AsAndOrExpression().Args[2].AsComparison().AsBinaryComparison().Args[0]); - Assert.Equal("datetime", cql.AsAndOrExpression().Args[2].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("datetime", cql.AsAndOrExpression().Args[2].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); DateTimeOffset datetime = DateTimeOffset.Parse("2021-04-08T04:39:23Z"); Assert.Equal(datetime, cql.AsAndOrExpression().Args[2].AsComparison().AsBinaryComparison().Args[1].AsTemporalInstant().DateTime); @@ -95,13 +98,13 @@ public async Task Example3Test() Assert.Equal(ComparisonPredicateOp.Gt, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Op); Assert.Equal(2, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args.Count); Assert.IsType(cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0]); - Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); Assert.Equal(50, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[1].AsNumericExpression().AsNumber().Num); Assert.Equal(ComparisonPredicateOp.Lt, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Op); Assert.Equal(2, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args.Count); Assert.IsType(cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0]); - Assert.Equal("eo:cloud_cover", cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("eo:cloud_cover", cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); Assert.Equal(10, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[1].AsNumericExpression().AsNumber().Num); } @@ -122,13 +125,13 @@ public async Task Example4Test() Assert.Equal(ComparisonPredicateOp.Gt, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Op); Assert.Equal(2, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args.Count); Assert.IsType(cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0]); - Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); Assert.Equal(50, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[1].AsNumericExpression().AsNumber().Num); Assert.Equal(ComparisonPredicateOp.Lt, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Op); Assert.Equal(2, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args.Count); Assert.IsType(cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0]); - Assert.Equal("eo:cloud_cover", cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("eo:cloud_cover", cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); Assert.Equal(10, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[1].AsNumericExpression().AsNumber().Num); } @@ -144,8 +147,8 @@ public async Task Example5Test() Assert.Equal(ComparisonPredicateOp.Eq, cql.AsComparison().AsBinaryComparison().Op); Assert.Equal(2, cql.AsComparison().AsBinaryComparison().Args.Count); - Assert.Equal("prop1", cql.AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); - Assert.Equal("prop2", cql.AsComparison().AsBinaryComparison().Args[1].AsChar().AsPropertyRef().Property); + Assert.Equal("prop1", cql.AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); + Assert.Equal("prop2", cql.AsComparison().AsBinaryComparison().Args[1].AsCharExpression().AsPropertyRef().Property); } @@ -217,18 +220,18 @@ public async Task Example9Test() Assert.Equal(3, cql.AsAndOrExpression().Args.Count); Assert.Equal(ComparisonPredicateOp.Gt, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Op); - Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); Assert.Equal(50, cql.AsAndOrExpression().Args[0].AsComparison().AsBinaryComparison().Args[1].AsNumericExpression().AsNumber().Num); Assert.Equal(ComparisonPredicateOp.Lt, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Op); - Assert.Equal("landsat:coverage_percent", cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("landsat:coverage_percent", cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[0].AsCharExpression().AsPropertyRef().Property); Assert.Equal(10, cql.AsAndOrExpression().Args[1].AsComparison().AsBinaryComparison().Args[1].AsNumericExpression().AsNumber().Num); Assert.Equal(AndOrExpressionOp.And, cql.AsAndOrExpression().Args[2].AsAndOrExpression().Op); Assert.IsType(cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[0]); Assert.IsType(cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[1]); - Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[0].AsComparison().AsIsNullPredicate().Args.AsChar().AsPropertyRef().Property); - Assert.Equal("landsat:coverage_percent", cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[1].AsComparison().AsIsNullPredicate().Args.AsChar().AsPropertyRef().Property); + Assert.Equal("sentinel:data_coverage", cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[0].AsComparison().AsIsNullPredicate().Args.AsCharExpression().AsPropertyRef().Property); + Assert.Equal("landsat:coverage_percent", cql.AsAndOrExpression().Args[2].AsAndOrExpression().Args[1].AsComparison().AsIsNullPredicate().Args.AsCharExpression().AsPropertyRef().Property); } @@ -243,7 +246,7 @@ public async Task Example10Test() Assert.Equal(IsBetweenPredicateOp.Between, cql.AsComparison().AsIsBetweenPredicate().Op); Assert.Equal(3, cql.AsComparison().AsIsBetweenPredicate().Args.Count); - Assert.Equal("eo:cloud_cover", cql.AsComparison().AsIsBetweenPredicate().Args[0].AsChar().AsPropertyRef().Property); + Assert.Equal("eo:cloud_cover", cql.AsComparison().AsIsBetweenPredicate().Args[0].AsCharExpression().AsPropertyRef().Property); Assert.Equal(0.0, cql.AsComparison().AsIsBetweenPredicate().Args[1].AsNumeric().Value); Assert.Equal(50.0, cql.AsComparison().AsIsBetweenPredicate().Args[2].AsNumeric().Value); @@ -256,14 +259,30 @@ public async Task Example11Test() JObject jObject = JObject.Parse(json); var cql = JsonConvert.DeserializeObject(jObject["filter"].ToString(), _settings); Assert.IsType(cql); - Assert.NotNull(cql.AsComparison().AsIsLike()); - Assert.Equal(IsLikePredicateOp.Like, cql.AsComparison().AsIsLike().Op); - Assert.Equal(2, cql.AsComparison().AsIsLike().Args.Count); + Assert.NotNull(cql.AsComparison().AsIsLikePredicate()); + Assert.Equal(IsLikePredicateOp.Like, cql.AsComparison().AsIsLikePredicate().Op); + Assert.Equal(2, cql.AsComparison().AsIsLikePredicate().Args.Count); - Assert.Equal("mission", cql.AsComparison().AsIsLike().Args[0].AsPropertyRef().Property); - Assert.IsType(cql.AsComparison().AsIsLike().Args[1]); - Assert.Equal("sentinel%", cql.AsComparison().AsIsLike().Args[1].ToString()); + Assert.Equal("mission", cql.AsComparison().AsIsLikePredicate().Args[0].AsPropertyRef().Property); + Assert.IsType(cql.AsComparison().AsIsLikePredicate().Args[1]); + Assert.Equal("sentinel%", cql.AsComparison().AsIsLikePredicate().Args[1].ToString()); } + + [Fact] + public async Task Example12Test() + { + var json = GetJson("CQL2", "Example12"); + JObject jObject = JObject.Parse(json); + var cql = JsonConvert.DeserializeObject(jObject["filter"].ToString(), _settings); + Assert.IsType(cql); + Assert.NotNull(cql.AsComparison().AsIsInListPredicate()); + Assert.Equal(IsInListPredicateOp.In, cql.AsComparison().AsIsInListPredicate().Op); + Assert.Equal(2, cql.AsComparison().AsIsInListPredicate().Args.Count); + + Assert.Equal("keywords", cql.AsComparison().AsIsInListPredicate().Args[0].AsScalarExpression().AsCharExpression().AsPropertyRef().Property); + Assert.IsType(cql.AsComparison().AsIsInListPredicate().Args[1]); + Assert.Equal(new List(){ "fire", "forest", "wildfire" }, cql.AsComparison().AsIsInListPredicate().Args[1].AsScalarExpressionCollection().Select(x => x.AsCharExpression().ToString()).ToList()); + } } } diff --git a/src/Stac.Api.Tests/Resources/CQL2/CQL2Tests_Example12.json b/src/Stac.Api.Tests/Resources/CQL2/CQL2Tests_Example12.json new file mode 100644 index 0000000..ef0c019 --- /dev/null +++ b/src/Stac.Api.Tests/Resources/CQL2/CQL2Tests_Example12.json @@ -0,0 +1,16 @@ +{ + "filter-lang": "cql2-json", + "filter": { + "op": "in", + "args": [ + { + "property": "keywords" + }, + [ + "fire", + "forest", + "wildfire" + ] + ] + } +} \ No newline at end of file diff --git a/src/Stac.Api.WebApi/Implementations/Default/Extensions/Filter/DefaultFilterController.cs b/src/Stac.Api.WebApi/Implementations/Default/Extensions/Filter/DefaultFilterController.cs index 22bc7e6..bb7b539 100644 --- a/src/Stac.Api.WebApi/Implementations/Default/Extensions/Filter/DefaultFilterController.cs +++ b/src/Stac.Api.WebApi/Implementations/Default/Extensions/Filter/DefaultFilterController.cs @@ -145,7 +145,7 @@ public async Task> PostItemSearchAsync(Filte - private void SetQueryParametersInContext(IStacApiContext stacApiContext, ISearchFilter filter) + private void SetQueryParametersInContext(IStacApiContext stacApiContext, ISearchExpression filter) { DefaultQueryParameters queryParameters = new DefaultQueryParameters(); if (filter != null) diff --git a/src/Stac.Api.WebApi/Implementations/Default/Transaction/DefaultTransactionController.cs b/src/Stac.Api.WebApi/Implementations/Default/Transaction/DefaultTransactionController.cs index 431ffde..58ca5af 100644 --- a/src/Stac.Api.WebApi/Implementations/Default/Transaction/DefaultTransactionController.cs +++ b/src/Stac.Api.WebApi/Implementations/Default/Transaction/DefaultTransactionController.cs @@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using NJsonSchema; -using Stac.Api.Extensions.Transactions; +using Stac.Api.Models.Extensions.Transactions; using Stac.Api.Interfaces; using Stac.Api.Models; using Stac.Api.WebApi.Controllers.Collections; diff --git a/src/Stac.Api/Converters/IIsInListOperandConverter.cs b/src/Stac.Api/Converters/IIsInListOperandConverter.cs new file mode 100644 index 0000000..028b1e9 --- /dev/null +++ b/src/Stac.Api/Converters/IIsInListOperandConverter.cs @@ -0,0 +1,44 @@ +using System; +using System.Linq; +using GeoJSON.Net.Converters; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Stac.Api.Models; +using Stac.Api.Models.Cql2; + +namespace Stac.Api.Converters +{ + public class IIsInListOperandConverter : JsonConverter + { + ScalarExpressionConverter scalarExpressionConverter = new ScalarExpressionConverter(); + + public override bool CanConvert(Type objectType) + { + return objectType == typeof(IIsNullOperand); + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + reader.DateParseHandling = DateParseHandling.None; + JToken jt = JToken.Load(reader); + + if (jt.Type == JTokenType.Array) + { + var ja = (JArray)jt; + return new ScalarExpressionCollection(ja.Select(j => scalarExpressionConverter.ReadJToken(j, objectType, existingValue, serializer)).Cast().ToList()); + } + else { + return scalarExpressionConverter.ReadJToken(jt, objectType, existingValue, serializer); + } + + throw new JsonSerializationException($"Could not convert {jt.ToString()} to IIsInListOperand"); + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + serializer.Serialize(writer, value); + } + } + + +} \ No newline at end of file diff --git a/src/Stac.Api/Converters/ScalarExpressionConverter.cs b/src/Stac.Api/Converters/ScalarExpressionConverter.cs index 2d437b1..9b5ba10 100644 --- a/src/Stac.Api/Converters/ScalarExpressionConverter.cs +++ b/src/Stac.Api/Converters/ScalarExpressionConverter.cs @@ -53,7 +53,33 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist throw new JsonSerializationException($"Could not convert {reader.Value} to ScalarExpression"); } - private IScalarExpression ReadJObject(JObject jo, Type objectType, object existingValue, JsonSerializer serializer) + public object ReadJToken(JToken jt, Type objectType, object existingValue, JsonSerializer serializer) + { + if ( jt.Type == JTokenType.Object) + return ReadJObject((JObject)jt, objectType, existingValue, serializer); + + try + { + return new Number(jt.Value()); + } + catch { } + + try + { + return new BoolExpression(jt.Value()); + } + catch { } + + try + { + return new Models.Cql2.String(jt.Value()); + } + catch { } + + throw new JsonSerializationException($"Could not convert {jt.ToString()} to ScalarExpression"); + } + + public IScalarExpression ReadJObject(JObject jo, Type objectType, object existingValue, JsonSerializer serializer) { // numeric try diff --git a/src/Stac.Api/Extensions/NTSExtensions.cs b/src/Stac.Api/Extensions/NTSExtensions.cs new file mode 100644 index 0000000..d360233 --- /dev/null +++ b/src/Stac.Api/Extensions/NTSExtensions.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using NetTopologySuite.Geometries; + +namespace Stac.Api.Extensions +{ + public static class NTSExtensions + { + public static NetTopologySuite.Geometries.Geometry ToNTSGeometry(this GeoJSON.Net.Geometry.IGeometryObject geometryObject) + { + switch (geometryObject.Type) + { + case GeoJSON.Net.GeoJSONObjectType.Point: + return ((GeoJSON.Net.Geometry.Point)geometryObject).ToNTSPoint(); + case GeoJSON.Net.GeoJSONObjectType.MultiPoint: + return ((GeoJSON.Net.Geometry.MultiPoint)geometryObject).ToNTSMultiPoint(); + case GeoJSON.Net.GeoJSONObjectType.LineString: + return ((GeoJSON.Net.Geometry.LineString)geometryObject).ToNTSLineString(); + case GeoJSON.Net.GeoJSONObjectType.MultiLineString: + return ((GeoJSON.Net.Geometry.MultiLineString)geometryObject).ToNTSMultiLineString(); + case GeoJSON.Net.GeoJSONObjectType.Polygon: + return ((GeoJSON.Net.Geometry.Polygon)geometryObject).ToNTSPolygon(); + case GeoJSON.Net.GeoJSONObjectType.MultiPolygon: + return ((GeoJSON.Net.Geometry.MultiPolygon)geometryObject).ToNTSMultiPolygon(); + case GeoJSON.Net.GeoJSONObjectType.GeometryCollection: + return ((GeoJSON.Net.Geometry.GeometryCollection)geometryObject).ToNTSGeometryCollection(); + default: + throw new ArgumentOutOfRangeException(); + } + } + + public static NetTopologySuite.Geometries.Point ToNTSPoint(this GeoJSON.Net.Geometry.Point geometryPoint) + { + return new NetTopologySuite.Geometries.Point(geometryPoint.Coordinates.Longitude, geometryPoint.Coordinates.Latitude, geometryPoint.Coordinates.Altitude ?? 0); + } + + public static NetTopologySuite.Geometries.Coordinate ToNTSCoordinate(this GeoJSON.Net.Geometry.IPosition geometryPosition) + { + var coordinate = new NetTopologySuite.Geometries.Coordinate(geometryPosition.Longitude, geometryPosition.Latitude); + if (geometryPosition.Altitude.HasValue) + coordinate.Z = geometryPosition.Altitude.Value; + return coordinate; + } + + public static NetTopologySuite.Geometries.MultiPoint ToNTSMultiPoint(this GeoJSON.Net.Geometry.MultiPoint geometryMultiPoint) + { + return new NetTopologySuite.Geometries.MultiPoint(geometryMultiPoint.Coordinates.Select(c => c.ToNTSPoint()).ToArray()); + } + + public static NetTopologySuite.Geometries.LineString ToNTSLineString(this GeoJSON.Net.Geometry.LineString geometryLineString) + { + return new NetTopologySuite.Geometries.LineString(geometryLineString.Coordinates.Select(c => c.ToNTSCoordinate()).ToArray()); + } + + public static NetTopologySuite.Geometries.MultiLineString ToNTSMultiLineString(this GeoJSON.Net.Geometry.MultiLineString geometryMultiLineString) + { + return new NetTopologySuite.Geometries.MultiLineString(geometryMultiLineString.Coordinates.Select(c => c.ToNTSLineString()).ToArray()); + } + + public static NetTopologySuite.Geometries.LinearRing ToNTSLinearRing(this GeoJSON.Net.Geometry.LineString geometryLineString) + { + return new NetTopologySuite.Geometries.LinearRing(geometryLineString.Coordinates.Select(c => c.ToNTSCoordinate()).ToArray()); + } + + public static NetTopologySuite.Geometries.Polygon ToNTSPolygon(this GeoJSON.Net.Geometry.Polygon geometryPolygon) + { + return new NetTopologySuite.Geometries.Polygon(geometryPolygon.Coordinates.First().ToNTSLinearRing(), geometryPolygon.Coordinates.Skip(1).Select(c => c.ToNTSLinearRing()).ToArray()); + } + + public static NetTopologySuite.Geometries.MultiPolygon ToNTSMultiPolygon(this GeoJSON.Net.Geometry.MultiPolygon geometryMultiPolygon) + { + return new NetTopologySuite.Geometries.MultiPolygon(geometryMultiPolygon.Coordinates.Select(c => c.ToNTSPolygon()).ToArray()); + } + + public static NetTopologySuite.Geometries.GeometryCollection ToNTSGeometryCollection(this GeoJSON.Net.Geometry.GeometryCollection geometryCollection) + { + return new NetTopologySuite.Geometries.GeometryCollection(geometryCollection.Geometries.Select(g => g.ToNTSGeometry()).ToArray()); + } + } +} \ No newline at end of file diff --git a/src/Stac.Api/Interfaces/ISearchFilter.cs b/src/Stac.Api/Interfaces/ISearchExpression.cs similarity index 79% rename from src/Stac.Api/Interfaces/ISearchFilter.cs rename to src/Stac.Api/Interfaces/ISearchExpression.cs index 5db61f2..ab0b061 100644 --- a/src/Stac.Api/Interfaces/ISearchFilter.cs +++ b/src/Stac.Api/Interfaces/ISearchExpression.cs @@ -5,7 +5,7 @@ namespace Stac.Api.Interfaces { - public interface ISearchFilter + public interface ISearchExpression { } diff --git a/src/Stac.Api/Models/Cql2/CQL2.cs b/src/Stac.Api/Models/Cql2/CQL2.cs index 2b532ca..6ea2910 100644 --- a/src/Stac.Api/Models/Cql2/CQL2.cs +++ b/src/Stac.Api/Models/Cql2/CQL2.cs @@ -38,7 +38,7 @@ public System.Collections.Generic.IDictionary AdditionalProperti public abstract TemporalPredicate AsTemporalPredicate(); public abstract ArrayPredicate AsArrayPredicate(); - public CharExpression AsChar() + public CharExpression AsCharExpression() { return null; } @@ -72,6 +72,16 @@ INumericExpression IScalarExpression.AsNumericExpression() { return null; } + + public IScalarExpression AsScalarExpression() + { + return this; + } + + public ScalarExpressionCollection AsScalarExpressionCollection() + { + return null; + } } [JsonConverter(typeof(NoConverter))] @@ -85,7 +95,6 @@ public class AndOrExpression : BooleanExpression [Newtonsoft.Json.JsonProperty("args", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] [System.ComponentModel.DataAnnotations.MinLength(2)] - [System.ComponentModel.DataAnnotations.MaxLength(2)] public System.Collections.Generic.List Args { get; set; } = new System.Collections.Generic.List(); public override AndOrExpression AsAndOrExpression() @@ -167,7 +176,7 @@ public override TemporalPredicate AsTemporalPredicate() public abstract class ComparisonPredicate : BooleanExpression { public abstract BinaryComparisonPredicate AsBinaryComparison(); - public abstract IsLikePredicate AsIsLike(); + public abstract IsLikePredicate AsIsLikePredicate(); public abstract IsBetweenPredicate AsIsBetweenPredicate(); public abstract IsInListPredicate AsIsInListPredicate(); public abstract IsNullPredicate AsIsNullPredicate(); @@ -217,7 +226,7 @@ public override IsInListPredicate AsIsInListPredicate() return null; } - public override IsLikePredicate AsIsLike() + public override IsLikePredicate AsIsLikePredicate() { return null; } @@ -260,7 +269,7 @@ public abstract class CharExpression : IScalarExpression, IIsNullOperand public abstract PropertyRef AsPropertyRef(); public abstract FunctionRef AsFunctionRef(); - public CharExpression AsChar() + public CharExpression AsCharExpression() { return this; } @@ -294,6 +303,16 @@ public IGeomExpression AsGeomExpression() { return null; } + + public IScalarExpression AsScalarExpression() + { + return this; + } + + public ScalarExpressionCollection AsScalarExpressionCollection() + { + return null; + } } public class CaseiExpression : CharExpression, IPatternExpression @@ -375,6 +394,10 @@ public abstract class InstantLiteral : ITemporalInstantExpression, IScalarLitera { private System.Collections.Generic.IDictionary _additionalProperties = new System.Collections.Generic.Dictionary(); + protected InstantLiteral() + { + } + [Newtonsoft.Json.JsonExtensionData] public System.Collections.Generic.IDictionary AdditionalProperties { @@ -391,7 +414,7 @@ public BooleanExpression AsBooleanExpression() return null; } - public CharExpression AsChar() + public CharExpression AsCharExpression() { return null; } @@ -421,6 +444,16 @@ public PropertyRef AsPropertyRef() return null; } + public IScalarExpression AsScalarExpression() + { + return this; + } + + public ScalarExpressionCollection AsScalarExpressionCollection() + { + return null; + } + public ITemporalExpression AsTemporalExpression() { return this; @@ -498,7 +531,7 @@ public override IsInListPredicate AsIsInListPredicate() return null; } - public override IsLikePredicate AsIsLike() + public override IsLikePredicate AsIsLikePredicate() { return this; } @@ -578,7 +611,7 @@ public override IsInListPredicate AsIsInListPredicate() return null; } - public override IsLikePredicate AsIsLike() + public override IsLikePredicate AsIsLikePredicate() { return null; } @@ -663,7 +696,7 @@ public override IsInListPredicate AsIsInListPredicate() return this; } - public override IsLikePredicate AsIsLike() + public override IsLikePredicate AsIsLikePredicate() { return null; } @@ -691,12 +724,17 @@ public override TemporalPredicate AsTemporalPredicate() public class InListOperands : System.Collections.ObjectModel.Collection { + public IInListOperand Left => this[0]; + public IInListOperand Right => this[1]; } + [JsonConverter(typeof(IIsInListOperandConverter))] public interface IInListOperand { + IScalarExpression AsScalarExpression(); + ScalarExpressionCollection AsScalarExpressionCollection(); } [JsonConverter(typeof(NoConverter))] @@ -740,7 +778,7 @@ public override IsInListPredicate AsIsInListPredicate() return null; } - public override IsLikePredicate AsIsLike() + public override IsLikePredicate AsIsLikePredicate() { return null; } @@ -769,7 +807,7 @@ public override TemporalPredicate AsTemporalPredicate() [JsonConverter(typeof(IIsNullOperandConverter))] public interface IIsNullOperand { - public CharExpression AsChar(); + public CharExpression AsCharExpression(); public Number AsNumeric(); public ITemporalExpression AsTemporalExpression(); public BooleanExpression AsBooleanExpression(); @@ -820,7 +858,7 @@ public override IsInListPredicate AsIsInListPredicate() return null; } - public override IsLikePredicate AsIsLike() + public override IsLikePredicate AsIsLikePredicate() { return null; } @@ -902,7 +940,7 @@ public override IsInListPredicate AsIsInListPredicate() return null; } - public override IsLikePredicate AsIsLike() + public override IsLikePredicate AsIsLikePredicate() { return null; } @@ -1020,7 +1058,7 @@ public BooleanExpression AsBooleanExpression() return null; } - public CharExpression AsChar() + public CharExpression AsCharExpression() { return new String(Bool.ToString()); } @@ -1030,6 +1068,16 @@ public INumericExpression AsNumericExpression() return new Number(Bool ? 1 : 0); } + public IScalarExpression AsScalarExpression() + { + return this; + } + + public ScalarExpressionCollection AsScalarExpressionCollection() + { + return null; + } + public ITemporalInstantExpression AsTemporalInstant() { return null; @@ -1048,12 +1096,17 @@ public Number(double value) public IComparable Value => Num; + public string ToString() + { + return Num.ToString(); + } + public BooleanExpression AsBooleanExpression() { return null; } - public CharExpression AsChar() + public CharExpression AsCharExpression() { return null; } @@ -1068,6 +1121,16 @@ public INumericExpression AsNumericExpression() return this; } + public IScalarExpression AsScalarExpression() + { + return this; + } + + public ScalarExpressionCollection AsScalarExpressionCollection() + { + return null; + } + public ITemporalExpression AsTemporalExpression() { return null; @@ -1265,7 +1328,7 @@ public BooleanExpression AsBooleanExpression() return null; } - public CharExpression AsChar() + public CharExpression AsCharExpression() { return null; } @@ -1323,7 +1386,7 @@ public BooleanExpression AsBooleanExpression() return null; } - public CharExpression AsChar() + public CharExpression AsCharExpression() { return null; } @@ -1367,6 +1430,11 @@ EnvelopeLiteral ISpatialLiteral.AsEnvelopeLiteral() { return this; } + + public string ToString() + { + return $"{Bbox[0]},{Bbox[1]},{Bbox[2]},{Bbox[3]}"; + } } [JsonConverter(typeof(BboxConverter))] @@ -1515,7 +1583,7 @@ public FunctionRef AsFunctionRef() return null; } - public CharExpression AsChar() + public CharExpression AsCharExpression() { return null; } @@ -1614,13 +1682,25 @@ public enum ComparisonPredicateOp public class ScalarExpressionCollection : System.Collections.ObjectModel.Collection, IInListOperand { + public ScalarExpressionCollection(IList list) : base(list) + { + } + public IScalarExpression AsScalarExpression() + { + return null; + } + + public ScalarExpressionCollection AsScalarExpressionCollection() + { + return this; + } } [JsonConverter(typeof(ScalarExpressionConverter))] public interface IScalarExpression : IInListOperand { - public CharExpression AsChar(); + public CharExpression AsCharExpression(); public ITemporalInstantExpression AsTemporalInstant(); public INumericExpression AsNumericExpression(); public BooleanExpression AsBooleanExpression(); diff --git a/src/Stac.Api/Models/Cql2/Cql2Linq.cs b/src/Stac.Api/Models/Cql2/Cql2Linq.cs index 3493fa5..ceb1cb3 100644 --- a/src/Stac.Api/Models/Cql2/Cql2Linq.cs +++ b/src/Stac.Api/Models/Cql2/Cql2Linq.cs @@ -9,11 +9,11 @@ using GeoJSON.Net.Geometry; using Itenso.TimePeriod; using NetTopologySuite.Geometries; +using Stac.Api.Extensions; using Stac.Api.Interfaces; using Stac.Api.Models.Cql2; using Stac.Api.Services.Filtering; using Stac.Api.Services.Queryable; -using Stars.Geometry.NTS; namespace Stac.Api.Models.Cql2 { diff --git a/src/Stac.Api/Models/Extensions/Filters/CQL2expression.cs b/src/Stac.Api/Models/Extensions/Filters/CQL2expression.cs index a11b7c6..d9de2e1 100644 --- a/src/Stac.Api/Models/Extensions/Filters/CQL2expression.cs +++ b/src/Stac.Api/Models/Extensions/Filters/CQL2expression.cs @@ -6,7 +6,7 @@ namespace Stac.Api.Models.Cql2 { [JsonConverter(typeof(CQL2FilterConverter))] - public class CQL2Expression : ISearchFilter, IConvertible + public class CQL2Expression : ISearchExpression, IConvertible { public CQL2Expression(BooleanExpression expression) { diff --git a/src/Stac.Api/Models/Extensions/Filters/GeometryExtensions.cs b/src/Stac.Api/Models/Extensions/Filters/GeometryExtensions.cs index 49f236d..359419f 100644 --- a/src/Stac.Api/Models/Extensions/Filters/GeometryExtensions.cs +++ b/src/Stac.Api/Models/Extensions/Filters/GeometryExtensions.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using GeoJSON.Net.Geometry; using NetTopologySuite.Geometries; -using Stars.Geometry.NTS; namespace Stac.Api.Extensions.Filters { diff --git a/src/Stac.Api/Models/Extensions/Filters/TemporalExtensions.cs b/src/Stac.Api/Models/Extensions/Filters/TemporalExtensions.cs index a4d5649..183fea9 100644 --- a/src/Stac.Api/Models/Extensions/Filters/TemporalExtensions.cs +++ b/src/Stac.Api/Models/Extensions/Filters/TemporalExtensions.cs @@ -4,7 +4,6 @@ using System.Threading.Tasks; using GeoJSON.Net.Geometry; using NetTopologySuite.Geometries; -using Stars.Geometry.NTS; namespace Stac.Api.Extensions.Filters { diff --git a/src/Stac.Api/Extensions/Sort/Context/DefaultSortBy.cs b/src/Stac.Api/Models/Extensions/Sort/Context/DefaultSortBy.cs similarity index 87% rename from src/Stac.Api/Extensions/Sort/Context/DefaultSortBy.cs rename to src/Stac.Api/Models/Extensions/Sort/Context/DefaultSortBy.cs index 9436dc9..4a81ff0 100644 --- a/src/Stac.Api/Extensions/Sort/Context/DefaultSortBy.cs +++ b/src/Stac.Api/Models/Extensions/Sort/Context/DefaultSortBy.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace Stac.Api.Extensions.Sort.Context +namespace Stac.Api.Models.Extensions.Sort.Context { public class DefaultSortBy : List, ISortParameters { diff --git a/src/Stac.Api/Extensions/Sort/Context/DefaultSortByItem.cs b/src/Stac.Api/Models/Extensions/Sort/Context/DefaultSortByItem.cs similarity index 96% rename from src/Stac.Api/Extensions/Sort/Context/DefaultSortByItem.cs rename to src/Stac.Api/Models/Extensions/Sort/Context/DefaultSortByItem.cs index 0dac1e8..2c323f9 100644 --- a/src/Stac.Api/Extensions/Sort/Context/DefaultSortByItem.cs +++ b/src/Stac.Api/Models/Extensions/Sort/Context/DefaultSortByItem.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; using Stac.Api.Services.Queryable; -namespace Stac.Api.Extensions.Sort.Context +namespace Stac.Api.Models.Extensions.Sort.Context { public class DefaultSortByItem : ISortByItem { diff --git a/src/Stac.Api/Extensions/Sort/Context/ISortByItem.cs b/src/Stac.Api/Models/Extensions/Sort/Context/ISortByItem.cs similarity index 84% rename from src/Stac.Api/Extensions/Sort/Context/ISortByItem.cs rename to src/Stac.Api/Models/Extensions/Sort/Context/ISortByItem.cs index c5e6325..53a9bda 100644 --- a/src/Stac.Api/Extensions/Sort/Context/ISortByItem.cs +++ b/src/Stac.Api/Models/Extensions/Sort/Context/ISortByItem.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace Stac.Api.Extensions.Sort.Context +namespace Stac.Api.Models.Extensions.Sort.Context { public interface ISortByItem { diff --git a/src/Stac.Api/Extensions/Sort/Context/ISortExtension.cs b/src/Stac.Api/Models/Extensions/Sort/Context/ISortExtension.cs similarity index 87% rename from src/Stac.Api/Extensions/Sort/Context/ISortExtension.cs rename to src/Stac.Api/Models/Extensions/Sort/Context/ISortExtension.cs index e06b35d..d936e82 100644 --- a/src/Stac.Api/Extensions/Sort/Context/ISortExtension.cs +++ b/src/Stac.Api/Models/Extensions/Sort/Context/ISortExtension.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using Stac.Api.Interfaces; -namespace Stac.Api.Extensions.Sort.Context +namespace Stac.Api.Models.Extensions.Sort.Context { public interface ISortExtension { diff --git a/src/Stac.Api/Extensions/Sort/Context/ISortParameters.cs b/src/Stac.Api/Models/Extensions/Sort/Context/ISortParameters.cs similarity index 78% rename from src/Stac.Api/Extensions/Sort/Context/ISortParameters.cs rename to src/Stac.Api/Models/Extensions/Sort/Context/ISortParameters.cs index c06efb1..c3be55f 100644 --- a/src/Stac.Api/Extensions/Sort/Context/ISortParameters.cs +++ b/src/Stac.Api/Models/Extensions/Sort/Context/ISortParameters.cs @@ -3,7 +3,7 @@ using System.Linq; using System.Threading.Tasks; -namespace Stac.Api.Extensions.Sort.Context +namespace Stac.Api.Models.Extensions.Sort.Context { public interface ISortParameters : IEnumerable { diff --git a/src/Stac.Api/Extensions/Sort/Context/SortContextFilter.cs b/src/Stac.Api/Models/Extensions/Sort/Context/SortContextFilter.cs similarity index 99% rename from src/Stac.Api/Extensions/Sort/Context/SortContextFilter.cs rename to src/Stac.Api/Models/Extensions/Sort/Context/SortContextFilter.cs index 8e75ea5..31ffcda 100644 --- a/src/Stac.Api/Extensions/Sort/Context/SortContextFilter.cs +++ b/src/Stac.Api/Models/Extensions/Sort/Context/SortContextFilter.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Stac.Api.Interfaces; -namespace Stac.Api.Extensions.Sort.Context +namespace Stac.Api.Models.Extensions.Sort.Context { /// /// HTTP Paginator diff --git a/src/Stac.Api/Extensions/Sort/Context/SortDirection.cs b/src/Stac.Api/Models/Extensions/Sort/Context/SortDirection.cs similarity index 62% rename from src/Stac.Api/Extensions/Sort/Context/SortDirection.cs rename to src/Stac.Api/Models/Extensions/Sort/Context/SortDirection.cs index cdd24a8..287a951 100644 --- a/src/Stac.Api/Extensions/Sort/Context/SortDirection.cs +++ b/src/Stac.Api/Models/Extensions/Sort/Context/SortDirection.cs @@ -1,4 +1,4 @@ -namespace Stac.Api.Extensions.Sort.Context +namespace Stac.Api.Models.Extensions.Sort.Context { public enum SortDirection { diff --git a/src/Stac.Api/Extensions/Sort/Context/SortExtensions.cs b/src/Stac.Api/Models/Extensions/Sort/Context/SortExtensions.cs similarity index 97% rename from src/Stac.Api/Extensions/Sort/Context/SortExtensions.cs rename to src/Stac.Api/Models/Extensions/Sort/Context/SortExtensions.cs index 4cf95a5..83dd635 100644 --- a/src/Stac.Api/Extensions/Sort/Context/SortExtensions.cs +++ b/src/Stac.Api/Models/Extensions/Sort/Context/SortExtensions.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Primitives; -namespace Stac.Api.Extensions.Sort.Context +namespace Stac.Api.Models.Extensions.Sort.Context { public static class SortExtensions { diff --git a/src/Stac.Api/Extensions/Transactions/TransactionsExtensions.cs b/src/Stac.Api/Models/Extensions/Transactions/TransactionsExtensions.cs similarity index 96% rename from src/Stac.Api/Extensions/Transactions/TransactionsExtensions.cs rename to src/Stac.Api/Models/Extensions/Transactions/TransactionsExtensions.cs index 4fad541..2e49f70 100644 --- a/src/Stac.Api/Extensions/Transactions/TransactionsExtensions.cs +++ b/src/Stac.Api/Models/Extensions/Transactions/TransactionsExtensions.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Stac.Api.Models; -namespace Stac.Api.Extensions.Transactions +namespace Stac.Api.Models.Extensions.Transactions { public static class TransactionsExtensions { diff --git a/src/Stac.Api/Stac.Api.csproj b/src/Stac.Api/Stac.Api.csproj index 4653c42..b8b7326 100644 --- a/src/Stac.Api/Stac.Api.csproj +++ b/src/Stac.Api/Stac.Api.csproj @@ -11,7 +11,6 @@ -