-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from deveel/28-entity-key-type-in-repository-g…
…eneric-type-specification Supporting the Specification of Key Types in Repositories
- Loading branch information
Showing
48 changed files
with
2,839 additions
and
1,388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
src/Deveel.Repository.Core/Data/IFilterableRepository_T2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
// Copyright 2023 Deveel AS | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
|
||
namespace Deveel.Data { | ||
/// <summary> | ||
/// Represents a repository that can be filtered to retrieve a subset of | ||
/// the entities it contains. | ||
/// </summary> | ||
/// <typeparam name="TEntity"> | ||
/// The strongly typed entity that is stored in the repository | ||
/// </typeparam> | ||
/// <typeparam name="TKey"> | ||
/// The type of key used to identify the entity in the repository | ||
/// </typeparam> | ||
public interface IFilterableRepository<TEntity, TKey> : IRepository<TEntity, TKey> where TEntity : class { | ||
/// <summary> | ||
/// Determines if at least one item in the repository exists for the | ||
/// given filtering conditions | ||
/// </summary> | ||
/// <param name="filter">The filter used to identify the items</param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns> | ||
/// Returns <c>true</c> if at least one item in the inventory matches the given | ||
/// filter, otherwise returns <c>false</c> | ||
/// </returns> | ||
/// <exception cref="NotSupportedException"> | ||
/// Thrown if the repository does not support filtering | ||
/// </exception> | ||
/// <exception cref="ArgumentException"> | ||
/// Throw if the <paramref name="filter"/> is not supported by the repository | ||
/// </exception> | ||
Task<bool> ExistsAsync(IQueryFilter filter, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Counts the number of items in the repository matching the given | ||
/// filtering conditions | ||
/// </summary> | ||
/// <param name="filter">The filter used to identify the items</param> | ||
/// <param name="cancellationToken"></param> | ||
/// <remarks> | ||
/// Passing a <c>null</c> filter or passing <see cref="QueryFilter.Empty"/> as | ||
/// argument is equivalent to ask the repository not to use any filter, returning the | ||
/// total count of all items int the inventory. | ||
/// </remarks> | ||
/// <returns> | ||
/// Returns the total count of items matching the given filtering conditions | ||
/// </returns> | ||
/// <exception cref="NotSupportedException"> | ||
/// Thrown if the repository does not support filtering | ||
/// </exception> | ||
/// <exception cref="ArgumentException"> | ||
/// Throw if the <paramref name="filter"/> is not supported by the repository | ||
/// </exception> | ||
Task<long> CountAsync(IQueryFilter filter, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Finds the first item in the repository that matches the given query | ||
/// </summary> | ||
/// <param name="query"> | ||
/// The query definition used to identify the item to return | ||
/// and eventually sort the results. | ||
/// </param> | ||
/// <param name="cancellationToken"> | ||
/// A token used to cancel the operation | ||
/// </param> | ||
/// <returns> | ||
/// Returns the first item in the repository that matches the given filtering condition, | ||
/// or <c>null</c> if none of the items matches the condition. | ||
/// </returns> | ||
/// <exception cref="NotSupportedException"> | ||
/// Thrown if the repository does not support filtering | ||
/// </exception> | ||
/// <exception cref="ArgumentException"> | ||
/// Throw if the <paramref name="query"/> defines a filter or a sort rule | ||
/// that is not supported by the repository | ||
/// </exception> | ||
Task<TEntity?> FindAsync(IQuery query, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Finds all the items in the repository that match the given filtering condition | ||
/// </summary> | ||
/// <param name="query"> | ||
/// The query definition used to identify the item to return | ||
/// and eventually sort the results. | ||
/// </param> | ||
/// <param name="cancellationToken"> | ||
/// A token used to cancel the operation | ||
/// </param> | ||
/// <returns> | ||
/// Returns a list of items in the repository that match the given query, | ||
/// or an empty list if none of the items matches the condition. | ||
/// </returns> | ||
Task<IList<TEntity>> FindAllAsync(IQuery query, CancellationToken cancellationToken = default); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Deveel.Repository.Core/Data/IMultiTenantRepository_T.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2023 Deveel AS | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
|
||
namespace Deveel.Data { | ||
/// <summary> | ||
/// Represents a repository that is capable of segregating the | ||
/// data by the tenant that owns it. | ||
/// </summary> | ||
public interface IMultiTenantRepository<TEntity> : IMultiTenantRepository<TEntity, object> where TEntity : class { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2023 Deveel AS | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
|
||
namespace Deveel.Data { | ||
/// <summary> | ||
/// Represents a repository that is capable of returning a page of items | ||
/// of the given type contained in the underlying storage. | ||
/// </summary> | ||
/// <typeparam name="TEntity"> | ||
/// The strongly typed entity that is stored in the repository | ||
/// </typeparam> | ||
/// <typeparam name="TKey"> | ||
/// The type of the key that uniquely identifies the entity | ||
/// </typeparam> | ||
public interface IPageableRepository<TEntity, TKey> : IRepository<TEntity, TKey> where TEntity : class { | ||
/// <summary> | ||
/// Gets a page of items from the repository | ||
/// </summary> | ||
/// <param name="request">The request to obtain a given page from the repository. This | ||
/// object provides the number of the page, the size of the items to return, filters and | ||
/// sorting order.</param> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns> | ||
/// Returns an instance of <see cref="PageResult{TEntity}"/> that provides the | ||
/// page items and a count of total items. | ||
/// </returns> | ||
/// <exception cref="RepositoryException"> | ||
/// Thrown if an error occurred while retrieving the page | ||
/// </exception> | ||
/// <exception cref="NotSupportedException"> | ||
/// Thrown if the filters or the sorting capabilities are not provided by the | ||
/// implementation of the repository | ||
/// </exception> | ||
/// <seealso cref="PageResult{TEntity}"/> | ||
Task<PageResult<TEntity>> GetPageAsync(PageQuery<TEntity> request, CancellationToken cancellationToken = default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2023 Deveel AS | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
using System; | ||
|
||
namespace Deveel.Data { | ||
/// <summary> | ||
/// Represents a repository that is capable of being queried | ||
/// </summary> | ||
/// <typeparam name="TEntity"> | ||
/// The strongly typed entity that is stored in the repository | ||
/// </typeparam> | ||
/// <seealso cref="IQueryableRepository{TEntity, TKey}"/> | ||
public interface IQueryableRepository<TEntity> : IQueryableRepository<TEntity, object> where TEntity : class { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.