Skip to content

Commit

Permalink
change test project vernacular ws and change how ComplexFormComponent…
Browse files Browse the repository at this point in the history
… headwords get set so that they match what we get from fieldworks
  • Loading branch information
hahn-kev committed Nov 25, 2024
1 parent aab1366 commit 3bc17fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public async Task InitializeAsync()
if (Path.Exists(projectsFolder)) Directory.Delete(projectsFolder, true);
Directory.CreateDirectory(projectsFolder);
_services.ServiceProvider.GetRequiredService<IProjectLoader>()
.NewProject(new FwDataProject(_projectName, projectsFolder), "en", "fr");
.NewProject(new FwDataProject(_projectName, projectsFolder), "en", "en");
FwDataApi = _services.ServiceProvider.GetRequiredService<FwDataFactory>().GetFwDataMiniLcmApi(_projectName, false);

var crdtProjectsFolder =
Expand Down
2 changes: 0 additions & 2 deletions backend/FwLite/LcmCrdt.Tests/JsonPatchEntryRewriteTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public void ChangesFromJsonPatch_AddComponentMakesAddEntryComponentChange()
changes.Should().ContainSingle().Which.Should().BeOfType<AddEntryComponentChange>().Subject;
addEntryComponentChange.ComplexFormEntryId.Should().Be(_entry.Id);
addEntryComponentChange.ComponentEntryId.Should().Be(componentEntry.Id);
addEntryComponentChange.ComponentHeadword.Should().Be(componentEntry.Headword());
}

[Fact]
Expand Down Expand Up @@ -84,7 +83,6 @@ public void ChangesFromJsonPatch_AddComplexFormMakesAddEntryComponentChange()
changes.Should().ContainSingle().Which.Should().BeOfType<AddEntryComponentChange>().Subject;
addEntryComponentChange.ComplexFormEntryId.Should().Be(_entry.Id);
addEntryComponentChange.ComponentEntryId.Should().Be(componentEntry.Id);
addEntryComponentChange.ComponentHeadword.Should().Be(componentEntry.Headword());
}

[Fact]
Expand Down
19 changes: 10 additions & 9 deletions backend/FwLite/LcmCrdt/Changes/Entries/AddEntryComponentChange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ namespace LcmCrdt.Changes.Entries;
public class AddEntryComponentChange : CreateChange<ComplexFormComponent>, ISelfNamedType<AddEntryComponentChange>
{
public Guid ComplexFormEntryId { get; }
public string? ComplexFormHeadword { get; }
public Guid ComponentEntryId { get; }
public Guid? ComponentSenseId { get; }
public string? ComponentHeadword { get; }

[JsonConstructor]
public AddEntryComponentChange(Guid entityId,
Expand All @@ -24,9 +22,7 @@ public AddEntryComponentChange(Guid entityId,
Guid? componentSenseId = null) : base(entityId)
{
ComplexFormEntryId = complexFormEntryId;
ComplexFormHeadword = complexFormHeadword;
ComponentEntryId = componentEntryId;
ComponentHeadword = componentHeadword;
ComponentSenseId = componentSenseId;
}

Expand All @@ -41,17 +37,22 @@ public AddEntryComponentChange(Guid entityId,

public override async ValueTask<ComplexFormComponent> NewEntity(Commit commit, ChangeContext context)
{
var complexFormEntry = await context.GetCurrent<Entry>(ComplexFormEntryId);
var componentEntry = await context.GetCurrent<Entry>(ComponentEntryId);
Sense? componentSense = null;
if (ComponentSenseId is not null)
componentSense = await context.GetCurrent<Sense>(ComponentSenseId.Value);
return new ComplexFormComponent
{
Id = EntityId,
ComplexFormEntryId = ComplexFormEntryId,
ComplexFormHeadword = ComplexFormHeadword,
ComplexFormHeadword = complexFormEntry?.Headword(),
ComponentEntryId = ComponentEntryId,
ComponentHeadword = ComponentHeadword,
ComponentHeadword = componentEntry?.Headword(),
ComponentSenseId = ComponentSenseId,
DeletedAt = (await context.IsObjectDeleted(ComponentEntryId) ||
await context.IsObjectDeleted(ComplexFormEntryId) ||
ComponentSenseId.HasValue && await context.IsObjectDeleted(ComponentSenseId.Value))
DeletedAt = (complexFormEntry?.DeletedAt is not null ||
componentEntry?.DeletedAt is not null ||
(ComponentSenseId.HasValue && componentSense?.DeletedAt is not null))
? commit.DateTime
: (DateTime?)null,
};
Expand Down

0 comments on commit 3bc17fc

Please sign in to comment.