-
-
Notifications
You must be signed in to change notification settings - Fork 5
setup Gridify filters for entries #1524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
03d99a5
setup Gridify filters for entries
hahn-kev 7e80b5b
add some extra tests
hahn-kev 1ae2eb3
use a mapper specific to the MiniLcm implementation
hahn-kev 45a94cc
implement gridify filtering in FwData
hahn-kev 1db4259
configure mappings with a filter provider to ensure we don't miss any…
hahn-kev 7b38a05
add filtering on example sentence text
hahn-kev dee249f
Fix generated ts types
myieye 45b01f2
Expand example data to demonstrate ANY behaviour
myieye bad461a
Fix tests I broke
myieye dd063b5
Add [] as valid syntax for an empty list
myieye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
backend/FwLite/FwDataMiniLcmBridge.Tests/MiniLcmTests/QueryEntryTests.cs
This file contains hidden or 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,12 @@ | ||
| using FwDataMiniLcmBridge.Tests.Fixtures; | ||
|
|
||
| namespace FwDataMiniLcmBridge.Tests.MiniLcmTests; | ||
|
|
||
| [Collection(ProjectLoaderFixture.Name)] | ||
| public class QueryEntryTests(ProjectLoaderFixture fixture) : QueryEntryTestsBase | ||
| { | ||
| protected override Task<IMiniLcmApi> NewApi() | ||
| { | ||
| return Task.FromResult<IMiniLcmApi>(fixture.NewProjectApi("query-entry-test", "en", "en")); | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
29 changes: 29 additions & 0 deletions
29
backend/FwLite/FwDataMiniLcmBridge/LexEntryFilterMapProvider.cs
This file contains hidden or 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,29 @@ | ||
| using System.Linq.Expressions; | ||
| using FwDataMiniLcmBridge.Api; | ||
| using MiniLcm.Filtering; | ||
| using SIL.LCModel; | ||
|
|
||
| namespace FwDataMiniLcmBridge; | ||
|
|
||
| public class LexEntryFilterMapProvider : EntryFilterMapProvider<ILexEntry> | ||
| { | ||
| //used to allow comparing null to an empty list, eg Senses=null should be true when there are no senses | ||
| private static object? EmptyToNull<T>(IList<T> list) => list.Count == 0 ? null : list; | ||
| private static object? EmptyToNull<T>(IEnumerable<T> list) => !list.Any() ? null : list; | ||
| public override Expression<Func<ILexEntry, object?>> EntrySensesSemanticDomains => e => e.AllSenses.Select(s => EmptyToNull(s.SemanticDomainsRC)); | ||
| public override Expression<Func<ILexEntry, object?>> EntrySensesExampleSentences => e => EmptyToNull(e.AllSenses.SelectMany(s => s.ExamplesOS)); | ||
| public override Expression<Func<ILexEntry, string, object?>> EntrySensesExampleSentencesSentence => (entry, ws) => | ||
| entry.AllSenses.SelectMany(s => s.ExamplesOS).Select(example => example.PickText(example.Example, ws)); | ||
|
|
||
| public override Expression<Func<ILexEntry, object?>> EntrySensesPartOfSpeechId => | ||
| e => e.AllSenses.Select(s => | ||
| s.MorphoSyntaxAnalysisRA == null ? null : s.MorphoSyntaxAnalysisRA.GetPartOfSpeechId()); | ||
| public override Expression<Func<ILexEntry, object?>> EntrySenses => e => EmptyToNull(e.AllSenses); | ||
| public override Expression<Func<ILexEntry, string, object?>> EntrySensesGloss => (entry, ws) => entry.AllSenses.Select(s => s.PickText(s.Gloss, ws)); | ||
| public override Expression<Func<ILexEntry, string, object?>> EntrySensesDefinition => (entry, ws) => entry.AllSenses.Select(s => s.PickText(s.Definition, ws)); | ||
| public override Expression<Func<ILexEntry, string, object?>> EntryNote => (entry, ws) => entry.PickText(entry.Comment, ws); | ||
| public override Expression<Func<ILexEntry, string, object?>> EntryLexemeForm => (entry, ws) => entry.PickText(entry.LexemeFormOA.Form, ws); | ||
| public override Expression<Func<ILexEntry, string, object?>> EntryCitationForm => (entry, ws) => entry.PickText(entry.CitationForm, ws); | ||
| public override Expression<Func<ILexEntry, string, object?>> EntryLiteralMeaning => (entry, ws) => entry.PickText(entry.LiteralMeaning, ws); | ||
| public override Expression<Func<ILexEntry, object?>> EntryComplexFormTypes => e => EmptyToNull(e.ComplexFormEntryRefs.SelectMany(r => r.ComplexEntryTypesRS)); | ||
| } |
This file contains hidden or 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
19 changes: 19 additions & 0 deletions
19
backend/FwLite/LcmCrdt.Tests/MiniLcmTests/QueryEntryTests.cs
This file contains hidden or 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,19 @@ | ||
| namespace LcmCrdt.Tests.MiniLcmTests; | ||
|
|
||
| public class QueryEntryTests : QueryEntryTestsBase | ||
| { | ||
| private readonly MiniLcmApiFixture _fixture = new(); | ||
|
|
||
| protected override async Task<IMiniLcmApi> NewApi() | ||
| { | ||
| await _fixture.InitializeAsync(); | ||
| var api = _fixture.Api; | ||
| return api; | ||
| } | ||
|
|
||
| public override async Task DisposeAsync() | ||
| { | ||
| await base.DisposeAsync(); | ||
| await _fixture.DisposeAsync(); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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,26 @@ | ||
| using System.Linq.Expressions; | ||
| using MiniLcm.Filtering; | ||
|
|
||
| namespace LcmCrdt; | ||
|
|
||
| public class EntryFilterMapProvider : EntryFilterMapProvider<Entry> | ||
| { | ||
| public override Expression<Func<Entry, object?>> EntrySensesSemanticDomains => e => e.Senses.Select(s => s.SemanticDomains); | ||
| public override Func<string, object>? EntrySensesSemanticDomainsConverter => EntryFilter.ConvertNullToEmptyList<SemanticDomain>; | ||
| public override Expression<Func<Entry, object?>> EntrySensesExampleSentences => e => e.Senses.SelectMany(s => s.ExampleSentences); | ||
| public override Expression<Func<Entry, string, object?>> EntrySensesExampleSentencesSentence => | ||
| (e, ws)=> e.Senses.SelectMany(s => s.ExampleSentences).Select(example => Json.Value(example.Sentence, ms => ms[ws])); | ||
| public override Expression<Func<Entry, object?>> EntrySensesPartOfSpeechId => e => e.Senses.Select(s => s.PartOfSpeechId); | ||
| public override Expression<Func<Entry, object?>> EntrySenses => e => e.Senses; | ||
|
|
||
| public override Expression<Func<Entry, string, object?>> EntrySensesGloss => | ||
| (entry, ws) => entry.Senses.Select(s => Json.Value(s.Gloss, ms => ms[ws])); | ||
| public override Expression<Func<Entry, string, object?>> EntrySensesDefinition => | ||
| (entry, ws) => entry.Senses.Select(s => Json.Value(s.Definition, ms => ms[ws])); | ||
| public override Expression<Func<Entry, string, object?>> EntryNote => (entry, ws) => Json.Value(entry.Note, ms => ms[ws]); | ||
| public override Expression<Func<Entry, string, object?>> EntryLexemeForm => (entry, ws) => Json.Value(entry.LexemeForm, ms => ms[ws]); | ||
| public override Expression<Func<Entry, string, object?>> EntryCitationForm => (entry, ws) => Json.Value(entry.CitationForm, ms => ms[ws]); | ||
| public override Expression<Func<Entry, string, object?>> EntryLiteralMeaning => (entry, ws) => Json.Value(entry.LiteralMeaning, ms => ms[ws]); | ||
| public override Expression<Func<Entry, object?>> EntryComplexFormTypes => e => e.ComplexFormTypes; | ||
| public override Func<string, object>? EntryComplexFormTypesConverter => EntryFilter.ConvertNullToEmptyList<ComplexFormType>; | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,6 +1,10 @@ | ||
| namespace LcmCrdt; | ||
| using Gridify; | ||
| using MiniLcm.Filtering; | ||
|
|
||
| namespace LcmCrdt; | ||
|
|
||
| public class LcmCrdtConfig | ||
| { | ||
| public string ProjectPath { get; set; } = Path.GetFullPath("."); | ||
| public GridifyMapper<Entry> Mapper { get; set; } = EntryFilter.NewMapper(new EntryFilterMapProvider()); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.