Skip to content

Commit e904ed1

Browse files
authored
Add entry lookup util and gridify template (#1622)
* Add entry lookup util and gridify template * Fix wrong class name in commented-out code
1 parent bb825c9 commit e904ed1

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

backend/FwLite/LcmDebugger/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Refit;
1212
using SIL.Harmony;
1313
using SIL.Harmony.Core;
14+
using Microsoft.Extensions.Logging;
1415

1516
var builder = Host.CreateApplicationBuilder();
1617
//slows down import to log all sql.
@@ -45,6 +46,7 @@
4546
var fwDataFactory = app.Services.GetRequiredService<FwDataFactory>();
4647
// var miniLcmApi = fwDataFactory.GetFwDataMiniLcmApi(fwDataProject, false);
4748
// var entries = await miniLcmApi.GetEntries().ToArrayAsync();
48-
49+
// var entries = miniLcmApi.GetEntries(new(Filter: new() { GridifyFilter = "LexemeForm[sbe]=ta" })).ToArrayAsync();
50+
// var entry = Utils.GetLexEntry(app.Services, fwDataProject, new Guid("{018d71a9-12c2-4129-be8a-35fe246afda2}"));
4951

5052
fwDataFactory.Dispose();
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using FwDataMiniLcmBridge;
2+
using FwDataMiniLcmBridge.LcmUtils;
3+
using Microsoft.Extensions.DependencyInjection;
4+
using SIL.LCModel;
5+
6+
namespace LcmDebugger;
7+
8+
public static class Utils
9+
{
10+
public static LcmCache? LoadProject(this IServiceProvider services, FwDataProject project)
11+
{
12+
var projectLoader = services.GetRequiredService<IProjectLoader>();
13+
var projectService = projectLoader.LoadCache(project);
14+
return projectService;
15+
}
16+
17+
public static ILexEntry GetLexEntry(this IServiceProvider services, FwDataProject project, Guid entryId)
18+
{
19+
var cache = LoadProject(services, project) ?? throw new InvalidOperationException("Project not found.");
20+
var entryRepo = cache.ServiceLocator.GetInstance<ILexEntryRepository>() ?? throw new InvalidOperationException("Entry repository not found.");
21+
return entryRepo.GetObject(entryId) ?? throw new InvalidOperationException(message: "Entry not found.");
22+
}
23+
}

0 commit comments

Comments
 (0)